API Reference

Scatter Chart API

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

Data Format

Each dataset contains a series of x/y data points with labels.

type ScatterChartData = {
  datasets: {
    legend: string;
    data: { x: number; y: number; label: string }[];
  }[];
};
AG Style Config

Scatter

PropertyTypeDefaultDescription
scatter.sizenumber10Diameter of scatter point in pixels.
scatter.strokeWidthnumber2Stroke width of the scatter point border.
Toast Style Config

Scatter

PropertyTypeDefaultDescription
scatter.sizenumber10Diameter of scatter point in pixels.
scatter.fillbooleanfalseWhether scatter points are filled or outlined.
scatter.strokeWidthnumber2Stroke width of the scatter point border.

Custom Parts

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

PartArgsDescription
scatter{ label: string; legend: string; index: number; isHovered: boolean }Individual scatter point element.
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{ scatters: { widget: Widget; x: number; y: number }[]; scale: ScatterChartScale }Container for all scatter points.
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 }The plot area composing axes, data view, and grid.
legend{ name: string; index: number; isVisible: boolean }Individual legend item.
titleundefinedChart title element.
dataLabel{ x: number; y: number; value: number; label: string; legend: string }Data label at a scatter point.
grid{ xLine: Widget; yLine: Widget }Grid container.
gridXLineundefinedIndividual vertical grid line.
gridYLineundefinedIndividual horizontal grid line.
tooltip{ label: string; items: { legend: string; color: string; value: number }[] }Tooltip content widget.

Context: ScatterChartContext

Available in every custom builder via the second argument.

NameTypeKindDescription
dataScatterChartDatapropertyCurrent chart data (filtered by hidden series).
legendsstring[]propertyAll legend names from the raw data.
widthnumberpropertyCurrent chart width in pixels.
heightnumberpropertyCurrent chart height in pixels.
scaleScatterChartScale | nullpropertyComputed scale with x and y ranges.
hiddenSeriesReadonlySet<string>propertySet of currently hidden series.
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 point.
unhoverPoint(index, legend)(index: number, legend: string) => voidmethodClear hover on a point.
unhoverAllPoints()() => voidmethodClear all point hover state.
isPointHovered(index, legend)(index: number, legend: string) => booleanmethodCheck if a specific point is hovered.
setSize(width, height)(width: number, height: number) => voidmethodUpdate chart dimensions.

Custom Part Example

import { ToastScatterChart } from "@/components/flitter/charts/toast-scatter-chart";

<ToastScatterChart
  data={data}
  config={{
    scatter: { size: 14, fill: true },
  }}
/>