Live examples:
app/demo/reference-lines-and-bands.tsx
(lines, bands, badges) and
app/demo/working-orders.tsx
(draggable orders, custom tags, grouping) in the example app.Reference lines, bands, and off-axis badges
referenceLines accepts an array of ReferenceLines in three mutually-exclusive forms:
- Horizontal line at a
value - Horizontal band between
valueFromandvalueTo - Vertical time band between
fromandto(unix seconds)
intervals), and excluding their value from the axis range
(excludeFromRange). See the types reference for every field.
When the array can reorder (for example, a dynamic order book), give each line a unique id
so its rendered identity follows that line instead of its array position.
Full-width lines (fullWidth)
By default a line/band stops at the plot’s right edge. Set fullWidth: true to span it
edge to edge through the Y-axis gutter, so it connects visually to its value on the axis
(like a price tag). Only the line/band extends — any label or badge stays anchored inside
the plot. For a Form-A line with a badge, the full-width line replaces the dashed connector.
When yAxis.labelRightMargin is set, a plain non-fullWidth line stops at the same X as the grid,
honoring yAxis.gridEndGap. Badge/label anchors, fullWidth lines, and value/time bands are
unchanged.
Pill badges (working orders, alerts, targets)
For a Form-A line,badge renders the value as a pill pinned to a plot edge with a dashed
connector to the opposite side — instead of a plain gutter label that collides with the Y-axis
ticks. When the value scrolls off-screen it auto-pins to the nearest edge with a directional
chevron, so a working order or alert never disappears. It pairs naturally with the
order-ticket flow.
badge: true uses the defaults (left-pinned, the line’s label/value); pass a
ReferenceLineBadgeConfig for position ("left" /
"center" / "right" — "center" floats the pill at the value with no connector), an icon,
text: false (icon-only), and the full style/shape config — background, borderColor /
borderWidth, radius, textColor, fontSize / fontFamily / fontWeight, and
offsetX / offsetY (the same knobs as the value badge).
It supersedes the legacy offAxisBadge (still supported), which only appears once the value is
off-screen and takes no icon.
Draggable lines (draggable)
Make a Form-A line draggable along the Y-axis — grab it near its value and drag to set a new price
(a working order, alert level, or target). The line tracks the finger on the UI thread; per-line
callbacks report the value to JS:
onCommit with writing
the value back into value to make it controlled. onDragIn / onDragOut are edge-triggered and
also fire when the axis rescales under a fixed value (e.g. an order scrolling off the top), so
they’re a clean “is my order still on screen” signal even without dragging.
Dragging coexists with scrubbing: a press that lands within reach of a
draggable line grabs the line and any drag moves it (in any direction), while a press anywhere else
scrubs as usual. So you can keep scrub enabled alongside draggable orders — only the thin grab
band around each draggable line is reserved for the drag.
Custom tags (renderReferenceLine)
On both LiveChart and LiveChartSeries, replace a line’s built-in pill / gutter label with any
React Native view — the same model as renderMarker / renderTooltip. The chart floats your
element over the canvas and pins it to the
line’s value (vertically centered, horizontally at the badge / label position), tracking the
rescaling axis and any drag without JS re-renders. Called per Form-A line; return null to keep
that line’s built-in tag (works with badge: false too). Bind the ctx.value / ctx.valueStr
SharedValues to animated text for a live readout:
ctx (ReferenceLineRenderProps) also carries y, inRange,
edge ("above" / "in" / "below", for a directional chevron), and dragging as SharedValues.
For a left- or right-pinned badge, the built-in dashed connector stays in place
behind the native tag and starts after the tag’s measured edge; a center badge has
no connector by design.
For example, a multi-series market chart can use the app’s native icon and localized target copy
while leaving any other line on the built-in renderer:
Off-axis-only custom tags (renderOffAxisReferenceLine)
Use renderOffAxisReferenceLine when the regular label should remain in range but an
edge-pinned target needs custom chrome. The chart switches the two tags on the UI thread:
the built-in tag remains in range, and the custom element appears only above or below the
plot. Give the line a left- or right-pinned badge (or legacy offAxisBadge) to retain
the native dashed connector; it begins after the custom tag’s measured edge.
OffAxisTargetTag stays mounted so it can read the live edge SharedValue in an animated
style and flip its caret between "above" and "below". Return null from the callback
only to opt a static line / index out; do not branch on edge.get() while rendering the
callback itself. renderReferenceLine takes precedence if both callbacks handle one line.
Grouping near-value lines (referenceLineGrouping)
When a stack of orders or alerts sits near the same price, their tags pile up illegibly. Pass
referenceLineGrouping to collapse Form-A lines whose handles fall within radius px of each other
into a single count handle:
renderReferenceLine
or renderOffAxisReferenceLine are excluded from grouping (their custom tag draws itself), so
the count reflects only collapsed built-in tags. The count pill takes the same style/shape config as a per-line badge
(ReferenceLineBadgeConfig) via badge, plus a format fn
for the count label.
Need an overlay the built-in lines and badges can’t express — your own draggable order book or
liquidation chrome? See Overlay bridge.