Bar insight
What one bar can tell - volume inside the body, adaptive detail on dense history, the ghost of the previous session, the delta reading and the fold between timeframes.
Five reading aids for a single bar, all optional and all additive: a host that sets none of them gets the frame it had before. The scene below renders them with the library itself - one panel per feature, both themes.
Rendered by `@unifin/chart-core` and `@unifin/chart-react` - no iframe, no server. The rows and the deltas come from `FootprintAccumulator` over the host bars, the ghost from the public `periodGhost`, the fold from the pure `morphBars` model, so every frame is reproducible.
Volume inside the body
polish.vapInBody draws the volume-at-price profile of the bar as thin rows inside its body, built
from the cluster cells a host already has (FootprintAccumulator). Row width follows the volume of
the level, the biggest level of the bar sets the scale. polish.bodyDepth adds a volume-driven shade
inside the body, so dense bars read deeper than thin ones.
renderer.render(context, {
// frame: bars, scales, theme, sizes
polish: { vapInBody: true, bodyDepth: true },
footprint: { cells }, // FootprintCell[], the cluster data block
});Both options degrade honestly: without cells, on a body narrower than 18 px, or with a broken volume they paint nothing instead of guessing.
Adaptive detail
The adaptive series type reads the bar density and picks the representation: candles, a high-low
ribbon of the direction colour, or the close line with a direction strip. See
Series types for the thresholds and the exports.
Session ghost and trend tone
polish.trendTone fades the body colour by the ATR-normalised impulse of the bar
(|close - open| / atr) - a calm bar keeps a weak tone, a forceful one goes solid. PeriodGhost
gives the host the bars of the period before the newest one together with the index shift that puts
them behind the live bars of the same moment.
import { periodGhost } from '@unifin/chart-core';
const ghost = periodGhost(bars, 86_400_000); // previous day, or null
renderer.render(context, {
// frame: bars, scales, theme, sizes
ghost, // dashed contour plus its close line
polish: { trendTone: { atr: 0.8 } }, // atr comes from the host statistics
});The ghost is background only: it takes no part in the crosshair, the tooltip, the legend or the hit tests.
Delta in the bar
polish.deltaBars shows the sign of the bar delta on the candle itself: 'background' tints the
whole slot, 'tail' colours the lower half of the body while the upper half keeps the price
movement. The tone is the same rule as the delta candle - sign from the delta, saturation from its share in the
normaliser (the host deltaSma, otherwise the mean |delta| of the visible window).
renderer.render(context, {
// frame: bars, scales, theme, sizes
deltas: [-420, 1150, 0, 880], // one value per bar
polish: { deltaBars: 'tail' },
});Without deltas, or with a broken value, the candle stays plain.
Timeframe morph
morphBars(previous, next, progress) folds one timeframe into another without a jump: every bar of
the next series starts from the aggregation of the previous bars inside its own window - what the bar
would look like if the feed were aggregated to the new step - and walks to its own value. The model
is pure: the host owns the clock and asks for the bars of a moment.
import { morphBars, morphDurationMs, morphProgress } from '@unifin/chart-core';
const duration = morphDurationMs(prefersReducedMotion); // 0 under reduced motion
const bars = morphBars(previous, next, morphProgress(elapsedMs, duration));morphBars(previous, next, 1) returns the next array itself, so the last frame of the fold is the
real series, not an approximation of it.
