TanStack
API Reference

Octane Chart

tsx
import { Chart } from '@tanstack/octane-charts'

The supplied definition infers the datum, semantic x/y values, and callbacks:

ts
function Chart<
  TDatum,
  TXValue extends ChartValue = ChartValue,
  TYValue extends ChartValue = ChartValue,
>(props: ChartProps<TDatum, TXValue, TYValue>): unknown

The definition owns focus, tooltip, animation, keyboard policy, focus distance, and spatial indexing.

Renderer entry points

The default entry uses SVG. The optional entries keep other renderer code explicit:

tsx
import { Chart as CanvasChart } from '@tanstack/octane-charts/canvas'
import { Chart as RendererChart } from '@tanstack/octane-charts/core'

const canvasChart = (
  <CanvasChart definition={definition} ariaLabel="Weekly revenue" />
)
const rendererChart = (
  <RendererChart
    definition={definition}
    renderer={myRenderer}
    ariaLabel="Weekly revenue"
  />
)

The Canvas Chart accepts the common interaction and sizing props except renderSvg. Its onRender receives ChartRendererRenderContext. The /core Chart also requires renderer: ChartRenderer. Both entries export ChartCommonProps, ChartProps, ChartTooltipBodyRenderContext, ChartDefinition, and ChartPoint.

Definition props

PropDefaultMeaning
definitionRequiredFramework-independent definition; identity is the application update boundary

See Chart Definition API.

Accessibility and sizing

PropTypeDefaultMeaning
ariaLabelstringRequiredAccessible surface name
ariaDescriptionstringNoneOptional surface description
tabIndexnumber0Surface tab index while keyboard behavior is enabled
heightnumber320 without aspect ratioFixed CSS and scene height
aspectRationumberNonePositive width-to-height ratio when height is absent
widthnumberResponsiveFixed CSS and scene width
initialWidthnumber640Initial and server width
classstringNoneExtra class on the outer ts-chart-host element
styleRecord<string, string | number | undefined>NoneOuter host styles applied after adapter sizing

See Sizing and layout.

Focus, tooltip, and callbacks

PropTypeDefaultMeaning
onFocusChange(point: ChartPoint | null) => voidNonePrimary focus callback
onFocusGroupChange(points: readonly ChartPoint[]) => voidNoneGrouped focus callback
onSelect(point: ChartPoint | null) => voidNoneClick and keyboard activation callback
onRender(context: ChartRenderContext) => voidNoneInner surface, live SVG, and scene after reconciliation
renderTooltipBody(context: ChartTooltipBodyRenderContext) => OctaneNodeNoneComposes Octane content inside the native tooltip body
tsx
<Chart
  definition={definition}
  ariaLabel="Revenue"
  renderTooltipBody={({ points, defaultBody, pinned, dismiss }) => (
    <div>
      {defaultBody}
      <SeriesDetail points={points} />
      {pinned ? <button onClick={dismiss}>Close</button> : null}
    </div>
  )}
/>

The context also exposes the resolved content. Ordering, anchoring, placement, portaling, and pinning remain in the definition. The prop is available from the default, /canvas, and /core entries.

See Focus and interaction.

Rendering and layout extensions

PropTypeDefaultMeaning
idPrefixstringGenerated from useId()Prefix for renderer-owned resource IDs
renderSvgChartSvgRenderer<TDatum, TXValue, TYValue>renderChartSvgScene-to-SVG renderer
measureTextChartTextMeasurerDOM inherited-font measurerGuide glyph measurement

See Rendering and export and Scales, guides, and color.

Exported prop types

The adapter exports ChartCommonProps, ChartProps, and ChartTooltipBodyRenderContext.

ts
interface ChartCommonProps<
  TDatum = unknown,
  TXValue extends ChartValue = ChartValue,
  TYValue extends ChartValue = ChartValue,
> {
  // every common prop listed above
}

type ChartProps<
  TDatum = unknown,
  TXValue extends ChartValue = ChartValue,
  TYValue extends ChartValue = ChartValue,
> = ChartCommonProps<TDatum, TXValue, TYValue> & {
  definition: ChartDefinition<TDatum, TXValue, TYValue>
}

The package also re-exports ChartDefinition and ChartPoint. Prefer inference at the component call site. Memoize definitions that capture component values; see Types.