@reincharts/core

Chart engine, ChartCanvas, panes, scales, hooks and themes.

npm install @reincharts/core

Everything here is also re-exported by the umbrella package reincharts.

Components

NameDescription
ChartCanvasThe chart root.
ChartOverlayAbsolutely positioned DOM layer over a pane (legends, buttons, custom HTML).
PaneA vertically stacked chart area with its own price scales.

Hooks

NameDescription
useChartThe chart engine of the closest <ChartCanvas>.
useChartEventListens to chart events (pointer events in chart coordinates, keydown, rangechange, crosshair...).
useChartStateSubscribes to chart state (layout, visible range, crosshair...).
useHitTargetRegisters an interactive object (hover, click, drag) such as a drawing or a draggable price line.
usePaneIdId of the closest <Pane> (or "main" when there is none).
useRenderableRegisters a canvas renderable with the chart.

Classes

NameDescription
ChartEngineThe chart engine: data mapping, viewport, panes, layout, render loop and events.
PriceScaleMaps prices to pixels for one scale inside a pane.
TimeFormatterTime zone aware date utilities with a per-instance cache.

Functions

NameDescription
accessorTurns an Accessor into a function.
applyStrokeSets stroke color, width and dash on a context.
clampLimits a value to [min, max].
computeTimeTicksPicks time axis ticks among visible bars: most significant boundaries first, skipping any that would sit closer than minSpacing pixels to an accepted tick.
contrastTextPicks black or white text for a given background color.
createThemeCreates a theme by deep-merging overrides into a base theme (defaults to lightTheme).
crispAligns a coordinate to the pixel grid so 1px lines are crisp.
dashArrayCanvas dash pattern for a LineDash style at a line width.
decimalsForNumber of decimals needed to display a step without losing precision.
drawLabelDraws a text label inside a filled rounded box; returns the box rect.
fontCSS font string from the theme (size and weight optional).
formatCompactCompact number formatting, e.g.
formatNumberFormats a number with a fixed number of decimals and thousands separators.
formatPercentSigned percentage, e.g.
formatPricePrice formatting with automatic precision: more decimals for small prices.
functorTurns a Functor (a static value or a function of the datum) into a function.
horizontalLineStrokes a crisp horizontal line at y from x1 to x2.
isFiniteNumberTrue for numbers that are not NaN or ±Infinity (type guard).
lowerBoundFirst index whose value is >= target (values must be ascending).
nearestIndexIndex of the value closest to target (values must be ascending, non-empty).
niceStepThe "nice" step (1, 2, 2.5, 5 × 10^n) nearest to span / count.
niceTicksEvenly spaced nice ticks covering [min, max].
resolveThemeResolves the theme prop: a preset name, a full theme, or partial overrides of the light theme.
shallowEqualShallow equality of two values or plain objects (for useChartState selectors).
upperBoundFirst index whose value is > target (values must be ascending).
verticalLineStrokes a crisp vertical line at x from y1 to y2.
withAlphaReturns a color with the given alpha.

Constants

NameDescription
darkThemeThe built-in dark theme.
lightThemeThe built-in light theme.

Types

NameDescription
AccessorA field name or a function reading a value from a datum, e.g.
AxisRegistration
ChartCanvasPropsProps of the ChartCanvas component.
ChartEventMap
ChartEventType
ChartOptions
ChartOverlayPropsProps of the ChartOverlay component.
ChartPointerEvent
ChartStateImmutable snapshot consumed by React (useChartState).
Clamp
CrosshairState
DeepPartial
DrawScopeEverything a renderable needs to draw one frame.
FunctorA static value or a function of the datum, e.g.
HitTarget
HitTargetSpec
LabelOptions
Layer
Layout
LegendItem
LegendValue
LineDashCanvas helpers shared by series, axes, coordinates and drawings.
PaneLayout
PaneOptions
PanePropsProps of the Pane component.
PriceScaleMode
PriceScaleOptions
PriceTick
Region
Renderable
RenderableSpec
StrokeStyle
ThemeVisual theme shared by every Reincharts component.
TimeFormatterOptions
TimeParts
TimeTick
VisibleRange
XMode
XType
ZoomAnchor

On this page