TanStack
API Reference

Angular Chart

ts
import { Chart } from '@tanstack/angular-charts'

Chart is a standalone component with selector tanstack-chart. Its required options input accepts a chart definition. Replace the definition identity when captured application values change. The definition also owns focus, tooltip, animation, keyboard policy, focus distance, and spatial indexing.

options

OptionTypeDefaultMeaning
definitionChartDefinitionRequiredFramework-neutral chart definition
ariaLabelstringRequiredAccessible chart name
ariaDescriptionstringNoneOptional accessible description
heightnumber320 without a ratioFixed CSS and scene height
aspectRationumberNonePositive width-to-height ratio when height is absent
widthnumberResponsiveFixed CSS and scene width
initialWidthnumber640Initial and server width before responsive measurement
tabIndexnumber0Surface tab index; keyboard: false forces -1
idPrefixstringGeneratedPrefix for renderer-owned document IDs
renderSvgChartSvgRenderer<TDatum, TXValue, TYValue>renderChartSvgScene-to-SVG renderer
measureTextChartTextMeasurerHost measurerGuide text measurement
onFocusChange(point: ChartPoint | null) => voidNonePrimary focus callback
onFocusGroupChange(points: readonly ChartPoint[]) => voidNoneGrouped focus callback
onSelect(point: ChartPoint | null) => voidNonePointer or keyboard activation callback
onRender(context: ChartRenderContext) => voidNoneLive SVG, container, and scene after rendering
classstringNoneExtra class on the inner .ts-chart-host
stylestringNoneInner host declarations applied after adapter sizing
classNamestringNoneExtra class on the rendered SVG surface

Callbacks are functions inside options, not Angular outputs. Replace the complete options value when chart state changes so OnPush change detection delivers an ngOnChanges update.

Tooltip body template

Project a typed tooltip template into the chart:

html
<tanstack-chart [options]="chartOptions">
  <ng-template [tanstackChartTooltipBody]="chartOptions.definition" let-tooltip>
    <ng-container [ngTemplateOutlet]="tooltip.defaultBody" />
    <series-detail [points]="tooltip.points" />
    @if (tooltip.pinned) {
    <button type="button" (click)="tooltip.dismiss()">Close</button>
    }
  </ng-template>
</tanstack-chart>

Import ChartTooltipBodyDirective and Angular's NgTemplateOutlet beside Chart. The context exposes points, content, defaultBody, pinned, and dismiss; named template bindings are also available. Binding the same definition gives Angular's strict template checker the datum and x/y value types. Ordering, anchoring, placement, portaling, and pinning remain in the definition.

Exported types

ChartCommonOptions contains common host and presentation options. ChartOptions adds the definition. ChartPresentationOptions contains class and style. The package exports ChartTooltipBodyDirective, ChartTooltipBodyRenderContext, and ChartTooltipBodyTemplateContext. It also re-exports ChartDefinition and ChartPoint.

See the Angular adapter for lifecycle and SSR behavior, Focus and interaction for callback semantics, and Rendering and export for custom SVG renderers.