Documentation / @ripl/charts
@ripl/charts ​
25 animated, interactive chart types for Ripl, rendering to Canvas, SVG, the terminal or a server from one chart definition.
Features ​
- 25 chart types, each behind a
createXChartfactory taking a CSS selector, anHTMLElementor a RiplContext. - Animated data joins —
chart.update(options)diffs the new data against the drawn elements and animates entries, updates and exits separately, at every level of a multi-series chart. Axes and legends transition rather than redraw. - Interaction — tooltips, crosshairs, hover highlighting, legend toggling, a windowing navigator strip for pan and zoom, and typed pointer events per chart (
barenter,barleave,barclick, and their equivalents). - Shared components — axes, grids, legends, tooltips, crosshairs, titles and a navigator strip are configured through the same options on every chart that has them, so a dashboard stays consistent without per-chart wiring.
- Same chart, several targets — Canvas or SVG in the browser, and braille text or raw
ImageDatafrom a headless Node script via@ripl/node. - Three built-in themes —
lightTheme,darkThemeandcolorBlindTheme, withregisterThemefor your own and per-chart or per-series overrides. - Tree-shakable — importing one factory ships one chart type.
- No third-party runtime dependencies — the only dependencies are four sibling packages in this repository (
@ripl/core,@ripl/canvas,@ripl/dom,@ripl/utilities).
Chart types ​
| Category | Charts |
|---|---|
| Cartesian | Bar, Line, Area, Scatter, Histogram, Box Plot, Trend, Stock |
| Radial & polar | Pie/Donut, Polar Area, Polar Scatter, Radial Bar, Radar, Gauge |
| Hierarchical | Sunburst, Treemap, Packed Circle |
| Network & flow | Sankey, Chord, Arc Diagram, Force-Directed, Funnel |
| Specialized | Heatmap, Gantt, Realtime |
Installation ​
bash
# npm
npm install @ripl/charts
# yarn
yarn add @ripl/charts
# pnpm
pnpm add @ripl/chartsPair it with @ripl/web when the same page also draws its own graphics; charts alone need nothing else.
Quick start ​
typescript
import {
createBarChart,
} from '@ripl/charts';
const chart = createBarChart('#chart-container', {
data: [
{
month: 'Jan',
sales: 120,
costs: 80,
},
{
month: 'Feb',
sales: 200,
costs: 110,
},
{
month: 'Mar',
sales: 150,
costs: 90,
},
],
key: 'month',
series: [
{
id: 'sales',
value: 'sales',
label: 'Sales',
},
{
id: 'costs',
value: 'costs',
label: 'Costs',
},
],
});
chart.update({
stacked: true,
});chart.update() takes any partial option, not only data — the change animates from whatever is currently drawn.
Key API ​
| Export | What it does |
|---|---|
createBarChart … createGanttChart | The 25 chart factories |
Chart | Base class to extend for a custom chart type |
createChartAnnotations | Reference lines, bands and point callouts |
createColorLegend | Legend for a continuous colour scale |
createSymbol | The scatter/legend symbol set |
registerTheme / setDefaultTheme | Light, dark and colour-blind themes, and your own |
Related packages ​
@ripl/web— the browser entry point, for drawing alongside a chart@ripl/svg— render any chart as SVG instead of Canvas@ripl/node— the same charts from a headless script, drawn through@ripl/terminal@ripl/core— the elements, scales and animation the charts are built from
Documentation ​
Guides, an options reference and a live demo per chart type are at ripl.run/charts.
License ​
Classes ​
| Class | Description |
|---|---|
| ArcDiagramChart | Arc diagram: a cartesian axis whose points are nodes, connected by semicircular arcs whose thickness encodes the link value. Nodes are laid out in order along the axis (horizontal by default, or vertical), optionally sized by their connection count. On entry the arcs draw out of each node and cascade along the axis (a ripple that fades each node in as its arcs reach it) and updates animate arcs reshaping and nodes resizing. Supports labels, tooltips, and typed node/link interaction events. |
| AreaChart | Area chart rendering filled regions beneath series lines. |
| BarChart | Bar chart supporting vertical/horizontal orientation and grouped/stacked modes. |
| BoxPlotChart | Box-plot chart: summarizes a numeric field per category with the shared boxplotStats transform and draws a box (Q1–Q3) with a median line, whiskers to the 1.5×IQR fences, and outlier points. Boxes fade/grow in on entry and animate out on exit. |
| CartesianChart | Base class providing shared cartesian component lifecycle and layout. |
| Chart | Abstract base class for all chart types, providing the scene, renderer, animation, color management, title/legend layout, and the render/update lifecycle that every concrete chart builds on. Consumers never instantiate this directly; each chart exposes a createXChart factory (e.g. createBarChart) and this class supplies the shared behavior behind it. |
| ChartAnnotations | Renders chart ChartAnnotations (reference lines, shaded bands, and point markers) into the plot area, resolving their values through the supplied axis scales. Annotations whose value cannot be mapped (e.g. an x annotation against a categorical x axis) are skipped. The overlay is redrawn each call, which is inexpensive for the handful of annotations a chart typically carries. |
| ChartLayout | Tracks the remaining free space within a chart and allows components to reserve bands from any edge. The order of reservation determines stacking: bands reserved first sit furthest from the plot area. |
| ChordChart | Chord diagram visualizing inter-relationships in a square matrix. |
| ColorLegend | A continuous-color legend: a gradient bar (approximated by solid segments so it works identically on Canvas and SVG) annotated with formatted value labels drawn from a ColorScale. Renders into a reserved region like the other chart components; formatting is supplied explicitly, keeping the scale and the formatter decoupled. |
| ForceDirectedChart | Force-directed network chart laying out nodes and links with a settling physics simulation. |
| FunnelChart | Funnel chart rendering horizontally centered bars of decreasing width. |
| GanttChart | Gantt chart rendering time-based task bars on a categorical y-axis and time x-axis. |
| GaugeChart | Gauge chart displaying a single value on a 270-degree arc. |
| HeatmapChart | Heatmap chart rendering a grid of colored cells on two categorical axes. |
| HistogramChart | Histogram chart: bins a numeric field with the shared bin transform and draws each bin as a bar on a continuous value axis against a frequency axis. Supports animated entry/update/exit, tooltips, grid, and a chart title. |
| LineChart | Line chart rendering one or more series as polylines with optional markers. |
| PackedCircleChart | Packed circle chart rendering each datum as a circle whose area encodes its value, arranged in a tight, non-overlapping cluster. Great for showing many parts of a whole without the rigid grid of a treemap. Supports labels on sufficiently large circles, tooltips, and animated transitions. |
| PieChart | Pie chart rendering proportional arc segments with optional inner radius (donut). |
| PolarAreaChart | Polar area chart rendering equal-angle segments whose radius encodes value. |
| PolarScatterChart | Polar scatter chart plotting points by angle and radius on a circular grid. |
| RadarChart | Radar (spider) chart plotting multi-axis data as filled polygonal areas. |
| RadialBarChart | Radial bar chart rendering each category as a concentric ring whose arc length encodes its value. |
| RealtimeChart | Realtime streaming chart rendering continuously updating line/area series. |
| Ribbon | A chord diagram ribbon connecting two arc segments with quadratic Bézier curves through the center. |
| SankeyChart | Sankey diagram visualizing directional flow between nodes. |
| SankeyLinkPath | A curved Sankey link shape rendered as a cubic Bézier curve between source and target points. |
| ScatterChart | Scatter chart (bubble chart) plotting data points as circles on two continuous axes. |
| StockChart | Candlestick (stock) chart rendering OHLC data with optional volume bars. |
| SunburstChart | Sunburst chart rendering hierarchical data as concentric arc rings. |
| TreemapChart | Treemap chart rendering hierarchical data as nested, space-filling rectangles. |
| TrendChart | Trend chart combining line, bar, and area series on shared categorical/value axes. |
Interfaces ​
| Interface | Description |
|---|---|
| AnnotationPlot | The plot rectangle annotations are drawn within and clipped to. |
| AnnotationScales | The x/y value scales an annotation resolves its values through. |
| ArcDiagramChartEventMap | Events emitted by an ArcDiagramChart that consumers can subscribe to via chart.on(...). |
| ArcDiagramChartOptions | Options for configuring an ArcDiagramChart. |
| ArcDiagramLink | A link between two nodes. |
| ArcDiagramLinkEvent | Payload emitted for arc diagram link interaction events. |
| ArcDiagramNode | A node in an arc diagram. |
| ArcDiagramNodeEvent | Payload emitted for arc diagram node interaction events. |
| AreaCenter | The center point and inscribed size of a rectangular ChartArea. |
| AreaChartEventMap | Events emitted by an AreaChart that consumers can subscribe to via chart.on(...). |
| AreaChartMarkerEvent | Payload emitted for area marker interaction events. |
| AreaChartOptions | Options for configuring an AreaChart. |
| AreaChartSeriesOptions | Configuration for an individual area chart series. |
| AxisTooltipRow | One row of a shared axis tooltip: a series' display label and its formatted value at the hovered category. |
| AxisTooltipSnapshot | The shared axis-tooltip content at a hovered plot position. |
| BarChartBarEvent | Payload emitted for bar interaction events. |
| BarChartEventMap | Events emitted by a BarChart that consumers can subscribe to via chart.on(...). |
| BarChartOptions | Options for configuring a BarChart. |
| BarChartSeriesOptions | Configuration for an individual bar chart series. |
| BaseChartOptions | Base options shared by all chart types. |
| Bin | A histogram bin covering the half-open interval [x0, x1) (the last bin includes x1). |
| BinOptions | Options for bin. |
| BoxPlotBoxEvent | Payload emitted for box interaction events. |
| BoxPlotChartEventMap | Events emitted by a BoxPlotChart that consumers can subscribe to via chart.on(...). |
| BoxPlotChartOptions | Options for configuring a BoxPlotChart. |
| BoxplotStats | Five-number summary plus IQR and outliers, as used by a box plot. |
| CartesianChartOptions | Options shared by all cartesian charts. |
| CartesianSetup | Declares which optional cartesian components a chart wants constructed. |
| ChartAnimationOptions | Fully resolved chart animation options. |
| ChartArea | A rectangular region expressed as a top-left origin plus dimensions. |
| ChartAxisItemOptions | Options for a single axis (x or y). |
| ChartAxisOptions | Combined x and y axis configuration. |
| ChartBandAnnotation | A shaded band spanning a value range on one axis (a threshold/target region). |
| ChartCrosshairOptions | Fully resolved chart crosshair options. |
| ChartDataLabelsOptions | Fully resolved data label options. |
| ChartGridOptions | Fully resolved chart grid options. |
| ChartLegendOptions | Fully resolved chart legend options. |
| ChartLineAnnotation | A reference line drawn across the plot at a fixed value on one axis. |
| ChartOverviewOptions | Configuration for the overview navigator strip. |
| ChartPadding | Padding with explicit top, right, bottom, and left values. |
| ChartPointAnnotation | A marker (dot + optional label) placed at a specific x/y data coordinate. |
| ChartSegmentLabelsOptions | Fully resolved segment-label options for radial charts. |
| ChartTitleOptions | Fully resolved chart title options. |
| ChartTooltipOptions | Fully resolved chart tooltip options. |
| ChartYAxisItemOptions | Y-axis specific options extending the base axis item with a left/right position. |
| ChordChartEventMap | Events emitted by a ChordChart that consumers can subscribe to via chart.on(...). |
| ChordChartLinkEvent | Payload emitted for chord ribbon interaction events. |
| ChordChartOptions | Options for configuring a ChordChart. |
| ChordChartSegmentEvent | Payload emitted for chord outer-arc interaction events. |
| ColorLegendComponentOptions | Options for constructing a ColorLegend. |
| ColorLegendOptions | Visual options for a ColorLegend. |
| DataLabelLayout | Resolved placement for a data label: the offset position and the text alignment that anchors it. |
| DataLabelSpec | Describes a single data label to render. |
| ForceDirectedChartEventMap | Events emitted by a ForceDirectedChart that consumers can subscribe to via chart.on(...). |
| ForceDirectedChartOptions | Options for configuring a ForceDirectedChart. |
| ForceDirectedLinkEvent | Payload emitted for force-directed link interaction events. |
| ForceDirectedNodeEvent | Payload emitted for force-directed node interaction events. |
| ForceNetworkLink | A link between two nodes. |
| ForceNetworkNode | A node in a force-directed network. |
| FunnelChartEventMap | Events emitted by a FunnelChart that consumers can subscribe to via chart.on(...). |
| FunnelChartOptions | Options for configuring a FunnelChart. |
| FunnelChartSegmentEvent | Payload emitted for funnel segment interaction events. |
| GanttChartEventMap | Events emitted by a GanttChart that consumers can subscribe to via chart.on(...). |
| GanttChartOptions | Options for configuring a GanttChart. |
| GanttChartTaskEvent | Payload emitted for gantt task interaction events. |
| GaugeChartEventMap | Events emitted by a GaugeChart that consumers can subscribe to via chart.on(...). |
| GaugeChartOptions | Options for configuring a GaugeChart. |
| GaugeChartValueEvent | Payload emitted for gauge value interaction events. |
| HeatmapChartCellEvent | Payload emitted for heatmap cell interaction events. |
| HeatmapChartEventMap | Events emitted by a HeatmapChart that consumers can subscribe to via chart.on(...). |
| HeatmapChartOptions | Options for configuring a HeatmapChart. |
| HistogramBinEvent | Payload emitted for histogram bin interaction events. |
| HistogramChartEventMap | Events emitted by a HistogramChart that consumers can subscribe to via chart.on(...). |
| HistogramChartOptions | Options for configuring a HistogramChart. |
| HoverHighlightOptions | Options describing how an element should respond to hover, beyond its HoverHighlightStates. |
| HoverTooltip | Minimal tooltip surface required by the hover helper (decouples it from the Tooltip class). |
| InteractionPoint | The pointer position passed to interaction callbacks. |
| KdeOptions | Options for kde. |
| LinearRegression | A fitted simple linear regression. |
| LineChartEventMap | Events emitted by a LineChart that consumers can subscribe to via chart.on(...). |
| LineChartMarkerEvent | Payload emitted for line marker interaction events. |
| LineChartOptions | Options for configuring a LineChart. |
| LineChartSeriesOptions | Configuration for an individual line chart series. |
| LineStyleSegment | A span of a series line, anchored to data keys, stroked with its own style. |
| LineStyleSegments | A segmented line style: the style of each span, plus the style used everywhere else. |
| PackedCircleChartEventMap | Events emitted by a PackedCircleChart that consumers can subscribe to via chart.on(...). |
| PackedCircleChartNodeEvent | Payload emitted for packed circle interaction events. |
| PackedCircleChartOptions | Options for configuring a PackedCircleChart. |
| PieChartEventMap | Events emitted by a PieChart that consumers can subscribe to via chart.on(...). |
| PieChartOptions | Options for configuring a PieChart. |
| PieChartSegmentEvent | Payload emitted for pie segment interaction events. |
| PolarAreaChartEventMap | Events emitted by a PolarAreaChart that consumers can subscribe to via chart.on(...). |
| PolarAreaChartOptions | Options for configuring a PolarAreaChart. |
| PolarAreaChartSegmentEvent | Payload emitted for polar-area segment interaction events. |
| PolarScatterChartEventMap | Events emitted by a PolarScatterChart that consumers can subscribe to via chart.on(...). |
| PolarScatterChartOptions | Options for configuring a PolarScatterChart. |
| PolarScatterMarkerEvent | Payload emitted for polar scatter marker interaction events. |
| PolarScatterSeriesOptions | Configuration for an individual polar scatter series. |
| RadarChartEventMap | Events emitted by a RadarChart that consumers can subscribe to via chart.on(...). |
| RadarChartMarkerEvent | Payload emitted for radar point interaction events. |
| RadarChartOptions | Options for configuring a RadarChart. |
| RadarChartSeriesOptions | Configuration for an individual radar chart series. |
| RadialBarChartBarEvent | Payload emitted for radial bar interaction events. |
| RadialBarChartEventMap | Events emitted by a RadialBarChart that consumers can subscribe to via chart.on(...). |
| RadialBarChartOptions | Options for configuring a RadialBarChart. |
| RadialLabelAnchor | A resolved anchor for a radial label, plus alignment. |
| RadialLabelInput | Input geometry for placing a label around a radial (arc-based) segment. |
| RadialLabelPlacement | Resolved inside and outside placements for a radial segment label. |
| RealtimeChartOptions | Options for configuring a RealtimeChart. |
| RealtimeChartSeriesOptions | Configuration for an individual realtime chart series. |
| ResolvedAnimation | A fully resolved animation ready to be applied to a transition. |
| ResolvedLineStyle | A LineStyleInput resolved into the polyline state that draws it. |
| RibbonState | State interface for a ribbon shape connecting two arc segments via quadratic curves. |
| SankeyChartEventMap | Events emitted by a SankeyChart that consumers can subscribe to via chart.on(...). |
| SankeyChartLinkEvent | Payload emitted for Sankey link interaction events. |
| SankeyChartNodeEvent | Payload emitted for Sankey node interaction events. |
| SankeyChartOptions | Options for configuring a SankeyChart. |
| SankeyLink | A directional flow between two nodes in a Sankey diagram. |
| SankeyLinkState | State interface for a Sankey link, defining source and target endpoint coordinates. |
| SankeyNode | A node in a Sankey diagram, with an optional typed datum carried through to node events. |
| ScatterChartEventMap | Events emitted by a ScatterChart that consumers can subscribe to via chart.on(...). |
| ScatterChartMarkerEvent | Payload emitted for scatter marker interaction events. |
| ScatterChartOptions | Options for configuring a ScatterChart. |
| ScatterChartSeriesOptions | Configuration for an individual scatter chart series. |
| SegmentInteractionOptions | How a segment reports its hover to the chart around it: the typed event it emits and the chart-wide highlight it drives. |
| SegmentLabelLayout | Fully resolved layout for a segment label: placement, content, styling, and leader-line points. |
| SegmentLabelSpec | Describes a single segment label to render. |
| StockChartCandleEvent | Payload emitted for stock candlestick interaction events. |
| StockChartEventMap | Events emitted by a StockChart that consumers can subscribe to via chart.on(...). |
| StockChartOptions | Options for configuring a StockChart. |
| SunburstChartEventMap | Events emitted by a SunburstChart that consumers can subscribe to via chart.on(...). |
| SunburstChartNodeEvent | Payload emitted for sunburst segment interaction events. |
| SunburstChartOptions | Options for configuring a SunburstChart. |
| SunburstNode | A node in a sunburst hierarchy with optional nested children and an optional typed datum. |
| Theme | The palette and furniture colors a chart renders with. |
| TreemapChartEventMap | Events emitted by a TreemapChart that consumers can subscribe to via chart.on(...). |
| TreemapChartNodeEvent | Payload emitted for treemap cell interaction events. |
| TreemapChartOptions | Options for configuring a TreemapChart. |
| TrendChartAreaSeriesOptions | Series options for an area-type series within a trend chart. |
| TrendChartBarEvent | Payload emitted for trend bar interaction events. |
| TrendChartBarSeriesOptions | Series options for a bar-type series within a trend chart. |
| TrendChartBaseSeriesOptions | Configuration shared by every trend chart series type. |
| TrendChartEventMap | Events emitted by a TrendChart that consumers can subscribe to via chart.on(...). |
| TrendChartLineSeriesOptions | Series options for a line-type series within a trend chart. |
| TrendChartMarkerEvent | Payload emitted for trend line/area marker interaction events. |
| TrendChartOptions | Options for configuring a TrendChart. |
Type Aliases ​
| Type Alias | Description |
|---|---|
| Accessor | A value accessor expressed as a property key, a constant, or a function. |
| AnnotationAxis | Which axis an annotation's value(s) are measured against. |
| ArcDiagramOrientation | How the node axis is oriented. |
| AxisFormatType | Built-in axis label format types. |
| AxisScaleType | The scale family an axis maps its domain through. Value axes accept 'linear'/'log'/'pow'/'sqrt'/'symlog'; category and time axes are selected by the chart. |
| BarChartOrientation | Whether bars are laid out vertically (default) or horizontally. |
| BorderRadiusInput | Border radius expressed as a uniform number or a per-corner tuple. |
| CartesianTarget | Re-exported for convenience to subclasses that accept a render target. |
| ChartAnimationInput | Animation input accepting a boolean toggle or partial options object. |
| ChartAnnotation | Any chart annotation: a reference line, a shaded band, or a point marker. |
| ChartAxisInput | Axis input accepting a boolean toggle or a full axis options object. |
| ChartCrosshairInput | Crosshair input accepting a boolean toggle or partial options object. |
| ChartDataLabelsInput | Data label input: a boolean toggle, a LabelAnchor string selecting where labels sit, or a partial options object. |
| ChartGridInput | Grid input accepting a boolean toggle or partial options object. |
| ChartLegendInput | Legend input accepting a boolean, position string, or partial options object. |
| ChartOptions | Alias for a chart's options type, used by factory helpers for readability and future augmentation. |
| ChartSegmentLabelsInput | Segment-label input: a boolean toggle, a SegmentLabelPosition string (which also enables labels), or a partial options object. |
| ChartSide | An edge of the layout from which a band can be reserved. |
| ChartTitleInput | Title input accepting a plain string or partial options object. |
| ChartTooltipInput | Tooltip input accepting a boolean toggle or partial options object. |
| ChartTooltipTrigger | What causes a tooltip to show. |
| ChartYAxisEntry | One y-axis in a multi-axis configuration. |
| ColorLegendOrientation | Orientation of the color legend bar. |
| CrosshairAxis | Which axis the crosshair tracks. |
| EaseName | Named easing function identifiers. |
| HoverHighlightStates | The pair of states a hover transitions between, given together or not at all: an element handed a highlight without the restore that undoes it would be stranded highlighted once the pointer left. |
| LabelAnchor | Where a data label is anchored relative to its marker/bar. |
| LegendPosition | Position of the chart legend relative to the chart area. |
| LineStyle | How a series line is stroked: a preset, or a custom canvas dash array. |
| LineStyleBound | A segment boundary: the key of a data point, or a function picking one out of the chart data. |
| LineStyleInput | How a series line is stroked: one style for the whole line, or key-anchored spans each with their own style. A bare array of segments defaults everything they do not cover to 'solid'; the object form names that fallback explicitly. |
| NumericAccessor | A strongly-typed numeric accessor: a numeric-valued property key of TData, or a function returning a number. Using this (instead of a bare keyof TData) makes the compiler reject a key that points at a non-numeric field. Fields that also accept a fixed constant (e.g. a scatter sizeBy) widen this with ` |
| NumericKey | The keys of TData whose values are number. Resolves to never for unknown/loose data. |
| Resolved padding with explicit top, right, bottom, and left values. | |
| PaddingInput | Padding, in pixels: a uniform number, a [top, right, bottom, left] tuple, or a partial per-edge object. Every option named padding accepts this same shape, on the chart and on every component. |
| SegmentLabelPosition | Where a radial segment label sits: inside the segment, or outside with a leader line. |
| SymbolElement | An element usable as a point marker: circle or regular polygon, both animated via radius. |
| SymbolType | The available marker symbol shapes. |
| TitlePosition | Position of the chart title relative to the chart area. |
| TrendChartSeriesOptions | Discriminated union of all trend chart series option types. |
| TrendSeriesType | Supported series visualization types within a trend chart. |
| ValueFormatInput | A value formatter accepted anywhere a chart renders a raw value as text (tooltips, data labels, pie segment labels, axis ticks). Either a built-in AxisFormatType, an Intl number-format options object (e.g. { style: 'currency', currency: 'USD' }), or a custom callback. |
Variables ​
| Variable | Description |
|---|---|
| ANIMATION_REFERENCE | Reference durations (in ms, at the default animation speed) for each transition kind. |
| colorBlindTheme | A colorblind-safe theme using the Okabe–Ito qualitative palette and a CVD-friendly sequential scale, for accessible categorical encoding. Pair with data labels for the strongest accessibility. |
| darkTheme | The built-in dark theme, tuned for a dark canvas background. |
| DEFAULT_CHART_PADDING | Default space, in pixels, reserved around every chart when its padding option is unset. |
| DEFAULT_SEGMENT_PAD_WIDTH | The default gap, in logical pixels, between adjacent segments of a radial chart. |
| ELEMENT_GAP | Gap, in pixels, inserted between two adjacent reserved bands (title, legend, navigator, plot). |
| lightTheme | The built-in light theme. Its colors match Ripl's historical defaults. |
| SEGMENT_LABEL_FONT | Shared segment-label style constants. Every chart routes its segment labels through these so the appearance is identical across chart types and across the Canvas and SVG contexts. The cross-context inconsistency this fixes came from labels that omitted font, leaving each backend to fall back to its own default, so always set an explicit font. |
| SEGMENT_LABEL_INSIDE_FILL | Fill for labels drawn inside a segment (on top of the filled shape). |
| SEGMENT_LABEL_OUTSIDE_FILL | Fill for labels drawn outside a segment (on the chart background). |
| SPACING | The chart spacing scale. |
Functions ​
| Function | Description |
|---|---|
| applyHoverHighlight | Wires consistent hover behavior (highlight transition + optional tooltip) onto an element. Safe to call repeatedly on the same persistent element across renders; prior listeners are disposed first so handlers never accumulate. |
| applySegmentInteraction | Wires a chart segment's full hover treatment: the tooltip and highlight transition of applyHoverHighlight, plus the typed enter/leave/click events and the chart-wide highlight every segmented chart emits alongside them. |
| arcCentroidAnchor | Anchors a tooltip at an arc's centroid, measured against the geometry the arc is animating toward rather than its current frame, so a tooltip opened mid-transition lands where the segment settles rather than where it happens to be. |
| areaCenter | Computes the center point and inscribed size (the smaller of width and height) of a rectangular area: the shared basis for laying out radial and polar charts. |
| axisTickCount | The target number of ticks (and grid lines) an axis draws, from its ticks option (default 10). |
| bin | Bins numeric values into a histogram. Without explicit thresholds, a "nice" uniform bin width is derived from the target bin count (Sturges' rule by default). Values outside the domain are dropped. |
| boxplotStats | Computes the box-plot five-number summary, splitting values beyond 1.5×IQR out as outliers. |
| computeStackOffset | Computes the stacked baseline offset for a series at a given data item. Positive and negative values stack independently so diverging stacks render correctly. Series earlier in the array sit closer to the baseline. |
| createArcDiagramChart | Factory function that creates a new ArcDiagramChart instance. |
| createAreaChart | Factory function that creates a new AreaChart instance. |
| createBarChart | Factory function that creates a new BarChart instance. |
| createBoxPlotChart | Factory function that creates a new BoxPlotChart. |
| createChartAnnotations | Factory function that creates a new ChartAnnotations component. |
| createChordChart | Factory function that creates a new ChordChart instance. |
| createColorLegend | Factory function that creates a new ColorLegend. |
| createDataLabel | Creates a data label Text element (at opacity 0) positioned by its anchor. |
| createForceDirectedChart | Factory function that creates a new ForceDirectedChart instance. |
| createFunnelChart | Factory function that creates a new FunnelChart instance. |
| createGanttChart | Factory function that creates a new GanttChart instance. |
| createGaugeChart | Factory function that creates a new GaugeChart instance. |
| createHeatmapChart | Factory function that creates a new HeatmapChart instance. |
| createHistogramChart | Factory function that creates a new HistogramChart. |
| createIndexLookup | Builds a value → index lookup with Array.prototype.indexOf semantics: the earliest occurrence wins for a duplicated value, an absent value resolves to -1, and NaN matches nothing. |
| createKeyedLookup | Builds a key → value lookup with Array.prototype.find semantics over a key comparison: the earliest match wins for a duplicated key, and an unknown key resolves to undefined. |
| createLineChart | Factory function that creates a new LineChart instance. |
| createPackedCircleChart | Factory function that creates a new PackedCircleChart instance. |
| createPieChart | Factory function that creates a new PieChart instance. |
| createPolarAreaChart | Factory function that creates a new PolarAreaChart instance. |
| createPolarScatterChart | Factory function that creates a new PolarScatterChart instance. |
| createRadarChart | Factory function that creates a new RadarChart instance. |
| createRadialBarChart | Factory function that creates a new RadialBarChart instance. |
| createRealtimeChart | Factory function that creates a new RealtimeChart instance. |
| createRibbon | Factory function that creates a new Ribbon instance. |
| createSankeyChart | Factory function that creates a new SankeyChart instance. |
| createSankeyLink | Factory function that creates a new SankeyLinkPath instance. |
| createScatterChart | Factory function that creates a new ScatterChart instance. |
| createSegmentLabel | Creates a segment label Text with all style properties set explicitly (never inheriting the context default), guaranteeing identical rendering across chart types and Canvas/SVG contexts. |
| createStockChart | Factory function that creates a new StockChart instance. |
| createSunburstChart | Factory function that creates a new SunburstChart instance. |
| createSymbol | Creates a marker element for the given symbol type. The returned element exposes cx/cy/radius, so hosts treat every symbol identically for positioning and animation. Pass the equal-area circle radius through symbolRadius when sizing non-circle symbols. |
| createTimeAxisScale | Builds a time-axis Scale from resolved axis options over a millisecond extent and pixel range. An explicit numeric min/max (epoch milliseconds) overrides the corresponding end of the data extent. Ticks are calendar-aligned Date values from the core time scale. |
| createTreemapChart | Factory function that creates a new TreemapChart instance. |
| createTrendChart | Factory function that creates a new TrendChart instance. |
| createValueScale | Builds a value-axis Scale from resolved axis options over a data extent and pixel range. |
| cumulativeExtent | Computes the value extent [min, max] of the running cumulative total across series: the span a stacked area chart covers as each series accumulates on top of the previous ones. Both bounds seed at 0, so a single-sign dataset keeps a zero baseline. |
| deviation | The population standard deviation of the values. |
| elementIsRibbon | Type guard that checks whether a value is a Ribbon instance. |
| elementIsSankeyLink | Type guard that checks whether a value is a SankeyLinkPath instance. |
| exitElement | Transitions an element to a terminal state (defaulting to fully transparent) and then destroys it, giving every chart a consistent exit animation. When animation is disabled the element is destroyed immediately. |
| formatTimeLabel | Formats a time-axis tick for display, adapting the format to the domain span; multi-year spans show the year, month-scale spans show abbreviated month and year, day-scale spans show dates, and anything shorter shows times. An explicit axis format always wins over this default. |
| getDefaultTheme | The current module-level default theme (initially lightTheme). |
| isTimeAxis | Whether the resolved axis options select the time scale family (a continuous axis over Date values with calendar-aligned ticks). |
| kde | Returns a Gaussian kernel density estimator f(x) for the values. The bandwidth defaults to Silverman's rule; pass one explicitly for tighter or smoother density curves. |
| linearRegression | Fits a simple least-squares linear regression to [x, y] points and reports its R². |
| mean | The arithmetic mean of the values (NaN when empty). |
| normalizeAnimation | Normalizes animation input into fully resolved ChartAnimationOptions. |
| normalizeAxis | Normalizes axis input into a full ChartAxisOptions object with both x and y. |
| normalizeAxisItem | Normalizes a single axis item input into fully resolved options. |
| normalizeCrosshair | Normalizes crosshair input into fully resolved ChartCrosshairOptions. |
| normalizeDataLabels | Normalizes a data label input into fully resolved ChartDataLabelsOptions. |
| normalizeGrid | Normalizes grid input into fully resolved ChartGridOptions. |
| normalizeLegend | Normalizes legend input into fully resolved ChartLegendOptions. |
| normalizePadding | Normalizes a padding input into a full ChartPadding, or returns undefined when there is no input. Unspecified edges of a partial object fall back to 0. |
| normalizeSegmentLabels | Normalizes a segment-label input into fully resolved ChartSegmentLabelsOptions. |
| normalizeTitle | Normalizes a title input into fully resolved ChartTitleOptions. |
| normalizeTooltip | Normalizes tooltip input into fully resolved ChartTooltipOptions. |
| normalizeYAxisItem | Normalizes a Y-axis item input into fully resolved options with position. |
| positionSymbol | Repositions a symbol element, keeping a rotated symbol's transform origin locked to its center (a square is a 45°-rotated regular quad, so its origin must follow cx/cy). |
| positiveNegativeExtent | Computes the value extent [min, max] of independently stacked positive and negative totals: the span a stacked bar chart covers when, per item, positive and negative values accumulate from the baseline in opposite directions. Both bounds seed at 0, so an all-positive (or all-negative) dataset keeps a zero baseline. |
| quantile | The p-quantile (0–1) of the values via linear interpolation between order statistics. |
| registerTheme | Registers a named theme so it can be selected by name via the theme option or resolveTheme. |
| resolveAccessor | Normalizes an Accessor into a function. Property keys read the field, functions are passed through, and any other value is treated as a constant. |
| resolveAnimation | Resolves chart animation options for a given reference duration, scaling by the configured speed and collapsing to 0/disabled when animation is turned off. |
| resolveChartPadding | Resolves a chart padding input into a full ChartPadding. A single number applies to all four edges; a partial object sets individual edges and leaves the rest at fallback; undefined falls back on every edge. Explicit 0 values are preserved. |
| resolveColorBy | Resolves a per-item color accessor (colorBy) into a function returning each item's color. |
| resolveDataLabelLayout | Resolves the anchored position and text alignment for a data label. |
| resolveEase | Resolves an ease name or function to an Ease function, defaulting to easeOutCubic. |
| resolveFormatLabel | Resolves a ValueFormatInput into a label formatting function. A built-in AxisFormatType maps to a preset formatter, an Intl number-format options object binds numberFormat to those options, and a function is returned as-is. |
| resolveLineDash | Resolves a LineStyle into a lineDash array ([] for a solid line). |
| resolveLineStyle | Resolves a LineStyleInput against the chart data into the dash state that draws it: the dash pattern for the line as a whole, plus the point-index spans that override it. |
| resolveRadialLabel | Computes both the inside (centroid) and outside (leader-line) label placements for a radial segment. Shared by the pie and polar-area charts so their inside/outside label behavior and the elbow leader line, stay identical. The outside textAlign flips by hemisphere so text reads away from the center. |
| resolveSegmentLabelLayout | Resolves a segment's label into a ready-to-render layout (inside centroid or outside leader line), honoring visibility, an optional minimum-angle clutter guard, and position/font/color options. Shared by the pie and polar-area charts so their label behavior is identical. |
| resolveSegmentPadWidth | Resolves the constant-width gap a radial chart separates its segments with, honoring a chart's deprecated angular padAngle option where one is still passed. |
| resolveTheme | Resolves a theme input into a concrete Theme. |
| resolveValueFormat | Resolves a value formatter into a function, always returning a usable formatter (falling back to String when no custom format is supplied). Convenience wrapper over resolveFormatLabel for the value-as-text sites that always need to print something. |
| rollup | Groups values by a key and reduces each group, returning a Map of key → reduced value. |
| setDefaultTheme | Sets the module-level default theme applied to charts that do not specify their own theme. |
| stagger | Computes a per-element stagger delay so that a collection of entering elements animate in sequence rather than all at once. Returns 0 when there is nothing to stagger. |
| symbolRadius | The circumradius a symbol element needs to match the visual area of a circle of the given radius. Hosts animating a marker's radius should animate towards this value. |
| transitionIfAny | Runs a transition over the given elements, resolving immediately when there are none. An empty renderer.transition still starts the animation loop and only settles a frame later, so the guard keeps a render with nothing to animate free. |