API Reference

Bubble Chart API

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

Data Format

Each dataset contains a series of data points with x/y coordinates, a bubble size value, and a label.

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

Bubble

PropertyTypeDefaultDescription
bubble.minRadiusnumber3Minimum bubble radius in pixels.
bubble.maxRadiusnumber25Maximum bubble radius in pixels.
bubble.opacitynumber0.7Fill opacity of bubbles (0 to 1).
Toast Style Config

Bubble

PropertyTypeDefaultDescription
bubble.minRadiusnumber5Minimum bubble radius in pixels.
bubble.maxRadiusnumber50Maximum bubble radius in pixels.
bubble.opacitynumber0.6Fill opacity of bubbles (0 to 1).

Custom Parts

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

PartArgsDescription
bubble{ value: number; label: string; legend: string; index: number; isHovered: boolean }Individual bubble 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{ bubbles: { widget: Widget; x: number; y: number }[]; scale: BubbleChartScale }Container for all bubble widgets.
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 bubble 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: BubbleChartContext

Available in every custom builder via the second argument.

NameTypeKindDescription
dataBubbleChartDatapropertyCurrent chart data (filtered by hidden series).
legendsstring[]propertyAll legend names from the raw data.
widthnumberpropertyCurrent chart width in pixels.
heightnumberpropertyCurrent chart height in pixels.
scaleBubbleChartScale | nullpropertyComputed scale with x, y, and value ranges.
hiddenSeriesReadonlySet<string>propertySet of currently hidden series.
hoveredBubble{ index: number; legend: string } | nullpropertyCurrently hovered bubble 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.
hoverBubble(index, legend)(index: number, legend: string) => voidmethodSet hover state on a bubble.
unhoverBubble(index, legend)(index: number, legend: string) => voidmethodClear hover if the specified bubble is currently hovered.
unhoverAllBubbles()() => voidmethodClear all bubble hover state.
isBubbleHovered(index, legend)(index: number, legend: string) => booleanmethodCheck if a specific bubble is hovered.
setSize(width, height)(width: number, height: number) => voidmethodUpdate chart dimensions.

Custom Part Example

import { ToastBubbleChart } from "@/components/flitter/charts/toast-bubble-chart";

<ToastBubbleChart
  data={data}
  config={{
    bubble: { minRadius: 8, maxRadius: 40, opacity: 0.5 },
  }}
/>