Skip to main content

Common Examples

The Chart component renders an ECharts option with Anvil2 styling. Import EChartsOption from the kit to keep chart configuration on the supported public API.
Chart defaults to appearance="light" and variant="monochrome". Set appearance to match the surrounding theme.The chart graphic is hidden from assistive technology. For supported option shapes, Chart exposes the data as a visually hidden table instead. Use accessibilityLabel for its caption; it falls back to option.title.text, then "Chart".Direct category-axis data for bar, line, and area series and direct pie or donut data are supported. Dataset transforms and other option shapes fall back to the accessible label.

Tooltips

Pass renderTooltip to provide visual tooltip content. The chart controls placement and keeps a gap from the pointer. When the plot is shorter than the tooltip, the gap wins and the tooltip extends outside the chart box. Tooltips are hidden from assistive technology because the table exposes the values.Omit renderTooltip when the chart does not need a tooltip. Format each value for its product context.

Selection

Selection is enabled by default for bars, segments, slices, line points, and area bands. A line drawn without point markers is not selectable. Clicking an area band selects its point at the nearest category. Selecting a mark changes it to the selection color and fades every other mark to 20% opacity. Select the active mark again or click an empty plot area to clear it. Keyboard and screen-reader users select the matching value in the data table.Omit selected to let Chart own selection. Use onSelectedChange to respond when the active mark changes. Pass both props to control selection from product state.A controlled selected value identifies the mark by seriesIndex and dataIndex. onSelectedChange receives ChartTooltipInfo so the product can read the selected category and value without resolving those indices again. Set selectedMode: false on a series that must not support selection.

Data point clicks

Pass onDataPointClick to handle activation of a data mark. Pointer users click the plot; keyboard and screen-reader users Tab to the data table and activate a value cell. The callback receives the same ChartTooltipInfo a tooltip does: name identifies the category, and points[0] describes the mark. Clicks on empty plot area, axis labels, legend entries, and the title are ignored. Omit the callback when the product does not need an additional click action; value cells remain interactive for selection. Dataset transforms and other unsupported option shapes produce no table; onDataPointClick is not supported for those shapes.Hold the reported mark in state to open a Dialog, reveal a detail panel, or navigate. See Stacked bar for a segment-level example.

Palette utilities

Use variant when colors follow the palette’s index order. The variant applies fills, borders, patterns, markers, corner treatments, and hover behavior.
Use chartPalette when an option needs a specific palette entry. chartStepItemStyle converts monochrome and semantic steps into ECharts itemStyle values.
Consumer-defined itemStyle values override variant styling.
Last modified on September 29, 2026