API Reference

Line Chart API

Complete API reference for the Line Chart, including data format, configuration options, custom parts, and context methods.

Data Format

Each dataset represents a line series with a legend name and an array of values corresponding to the labels.

type LineChartData = {
  labels: string[];
  datasets: { legend: string; values: number[] }[];
};
AG Style Config

Line

PropertyTypeDefaultDescription
line.strokeWidthnumber2Stroke width of the line in pixels.
line.splinebooleanfalseWhether to use spline (smooth curve) interpolation.
Toast Style Config

Line

PropertyTypeDefaultDescription
line.strokeWidthnumber2Stroke width of the line in pixels.
line.splinebooleanfalseWhether to use spline (smooth curve) interpolation.

Custom Parts

Override any visual element by providing a custom builder function: (args, context) => Widget

PartArgsDescription
line{ values: number[]; legend: string; index: number; isHovered: boolean }The line path element for a single series.
xAxis{ line: Widget; labels: Widget[]; tick: Widget }The complete x-axis assembly.
yAxis{ line: Widget; labels: Widget[]; tick: Widget }The complete y-axis assembly.
xAxisLabel{ name: string; index: number }Individual x-axis label.
yAxisLabel{ name: string; index: number }Individual y-axis label.
xAxisTickundefinedX-axis tick mark.
yAxisTickundefinedY-axis tick mark.
xAxisLineundefinedX-axis line.
yAxisLineundefinedY-axis line.
axisCornerundefinedCorner element where x and y axes meet.
dataView{ lines: Widget[] }Container for all line widgets in the data area.
layout{ title: Widget; legends: Widget[]; plot: Widget }Top-level layout composing title, legends, and the plot area.
plot{ xAxis: Widget; yAxis: Widget; dataView: Widget; grid: Widget; axisCorner: Widget; tooltipArea: Widget }The plot area composing axes, data view, grid, and tooltip.
legend{ name: string; index: number; isVisible: boolean }Individual legend item.
titleundefinedChart title element.
dataLabel{ value: number; label: string; legend: string }Data label displayed at a data point.
grid{ xLine: Widget; yLine: Widget }Grid container for horizontal and vertical grid lines.
gridXLineundefinedIndividual vertical grid line.
gridYLineundefinedIndividual horizontal grid line.
tooltip{ label: string; items: { legend: string; color: string; value: number }[] }Tooltip content widget.
tooltipArea{ tooltip: Widget | null; hoveredPoint: HoveredLinePoint | null }Tooltip positioning area that manages tooltip display.

Context: LineChartContext

Available in every custom builder via the second argument.

NameTypeKindDescription
dataLineChartDatapropertyCurrent chart data (filtered by hidden series).
legendsstring[]propertyAll legend names from the raw data.
widthnumberpropertyCurrent chart width in pixels.
heightnumberpropertyCurrent chart height in pixels.
plotWidthnumberpropertyWidth of the plot area in pixels.
plotHeightnumberpropertyHeight of the plot area in pixels.
scaleLineChartScale | nullpropertyComputed scale with min, max, and step.
hiddenSeriesReadonlySet<string>propertySet of currently hidden series legend names.
hoveredPoint{ index: number; legend: string } | nullpropertyCurrently hovered point info.
configTConfigpropertyThe resolved chart configuration object.
isSeriesVisible(legend)(legend: string) => booleanmethodCheck if a series is currently visible.
toggleSeries(legend)(legend: string) => voidmethodToggle visibility of a series.
showSeries(legend)(legend: string) => voidmethodShow a hidden series.
hideSeries(legend)(legend: string) => voidmethodHide a visible series.
showAllSeries()() => voidmethodShow all hidden series.
hoverPoint(index, legend)(index: number, legend: string) => voidmethodSet hover state on a specific point.
unhoverPoint(index, legend)(index: number, legend: string) => voidmethodClear hover if the specified point is currently hovered.
unhoverAllPoints()() => voidmethodClear all point hover state.
isPointHovered(index, legend)(index: number, legend: string) => booleanmethodCheck if a specific point is hovered.
getPointValue(index, legend)(index: number, legend: string) => number | nullmethodGet the value of a data point.
getPointPosition(index, legend)(index: number, legend: string) => { x: number; y: number } | nullmethodGet the pixel position of a data point.
setSize(width, height)(width: number, height: number) => voidmethodUpdate chart dimensions.
setPlotSize(width, height)(width: number, height: number) => voidmethodUpdate plot area dimensions.

Custom Part Example

import { ToastLineChart } from "@/components/flitter/charts/toast-line-chart";

<ToastLineChart
  data={data}
  custom={{
    line: (args, context) => {
      const color = context.config.colors[args.index % context.config.colors.length];
      return CustomPaint({
        painter: new LinePainter({
          values: args.values,
          color: args.isHovered ? color : `${color}66`,
          strokeWidth: args.isHovered ? 3 : 2,
        }),
      });
    },
  }}
/>