Series and levels
Spline and lollipop series, session levels, automatic Fibonacci and the comparison overlay.
This page covers the looks that were added on top of the classic series: a smoothed close line, an event lollipop, the levels of the previous sessions, the automatic Fibonacci retracement and the comparison overlay of several instruments.
What is on this page
Five panels, all rendered by the library itself with deterministic data:
- Spline - the monotone smoothed close line next to the plain line.
- Lollipop - one dot per bar with a stem down to the close of the period start.
- Session levels - the previous day and week high, low and close.
- Automatic Fibonacci - the retracement of the last significant impulse.
- Comparison - six instruments rebased to 100 on one scale.
Spline
The spline series smooths the close line with a monotone cubic interpolation.
The curve never leaves the span of its neighbouring points, so a smoothed chart
cannot show a price that was never traded - unlike the classic Catmull-Rom spline,
which overshoots on sharp moves.
import { UnifinChart } from '@unifin/chart-react/light';
<UnifinChart symbol="AAPL" timeframe="5m" bars={bars} seriesType="spline" />The smoothing itself is one function: splinePoints(points, { tension }) returns the
sampled curve. tension runs from 0 (the full monotone curve) to 1 (straight
segments), and a gap in the data breaks the curve instead of bridging it.
Lollipop
The lollipop series is the event look: a dot on every bar and a stem down to a
baseline. The baseline is the close of the first visible bar, so one glance reads the
move of the whole window; a dividend or a report series can pin its own baseline.
<UnifinChart
symbol="AAPL"
timeframe="5m"
bars={events}
seriesType="lollipop"
lollipop={{ baseline: 0 }}
/>Dots are thinned out automatically when the slot is narrower than the dot: the step follows the dot diameter, so a dense window never turns into a solid bar.
Session levels
sessionLevelsMulti(bars, { periods: ['day', 'week'], utcOffsetMs }) returns the high,
the low and the close of the previous session for every requested period. The running
session is never a "previous" one, and the session boundary is the period step plus
the host offset - the library owns no exchange calendar for every market.
const levels = sessionLevelsMulti(bars, { periods: ['day', 'week'], utcOffsetMs: 6 * 3_600_000 });
<UnifinChart symbol="AAPL" timeframe="5m" bars={bars} sessionLevels={levels} />The tag of a level turns to the warning tone when the price has broken it: a previous high is broken upwards, a previous low downwards, and the previous close either way. The levels are read-only graphics - they never enter the drawing journal.
Automatic Fibonacci
autoFibonacci(bars, { atr, atrShare, lookback }) finds the swings of the series
(a pivot needs lookback lower highs or higher lows on both sides), takes the last
impulse that covers at least atr * atrShare and returns the retracement levels
between its ends, sorted by price.
const fib = autoFibonacci(bars, { atr: 0.6 });
<UnifinChart symbol="AAPL" timeframe="5m" bars={bars} autoFib={fib} />A tiny final wobble does not hide the impulse the market is actually trading: the search walks the swing pairs from the newest one backwards. The manual Fibonacci tool of the drawing engine stays available and is not affected.
Comparison overlay
The overlay puts up to ten instruments on one scale, rebased to 100 at the first
visible point of each series, and labels every line at its last point. The colours
come from COMPARE_PALETTE, so ten lines stay distinguishable.
import { rebaseToBaseline } from '@unifin/chart-core';
const overlay = {
series: instruments.map((instrument) => ({
label: instrument.symbol,
points: rebaseToBaseline(instrument.points),
})),
};
<UnifinChart symbol="AAPL" timeframe="5m" bars={bars} compareOverlay={overlay} />The ranking table next to the chart is built by comparisonTable and
sortComparisonRows: the same change in percent the overlay draws, sorted and ranked.
See also
- Series types - the full catalogue of the 26 series types.
- Bar insight - what one bar can tell: volume-at-price, depth, delta.
- Chart and series - the painter contract behind every series type.
