Skip to main content
Every part of a chart you might want to style (bars, lines, grid lines, axes, the legend) has a fixed classname, and useful context like the chart type and the series index is exposed as data attributes. ARIA attributes (role, aria-label, aria-roledescription) remain in the DOM for accessibility, but they are not a styling API; selectors should use the hooks below.

Parts

Each part carries a classname; the data attributes present on a part are listed in the next section.
Tooltips render outside .graphy-chart, so don’t nest tooltip selectors under a chart selector. Write them at the top level, and note they apply to every chart on the page.

Data attributes

Prefer data-graphy-orientation over enumerating bar types when a rule only cares about direction. On grid lines, the axis side tells you the line’s direction: left/right grid lines run horizontally, top/bottom ones vertically.

Series identity

data-graphy-series-index is the 0-based position of the series in data order: the order series first appear in the data, honoring an explicit series order when one is configured. The same value is stamped on a series’ shapes (bars, lines, areas, slices, points) and on its legend item, so match them by attribute, not by visual position:
  • Combo charts move line series to the end of the legend visually; the attribute still matches the shapes.
  • Hiding a series does not shift the other series’ indices.
  • Hover highlighting reorders line z-position without touching the attribute.

Examples

Text size

Chart text is sized in em, relative to a base controlled by appearance.textScale. Your CSS can pin exact pixel sizes per element:
Use !important so your rule wins over the chart’s own styles.
The chart reserves layout space for labels based on textScale. It doesn’t know about sizes set in CSS. If labels look clipped or overlap, adjust appearance.textScale until the layout fits your CSS sizes.

Programmatic access

If you generate CSS or selectors in code, import the names instead of hardcoding strings. GRAPHY_PART_CLASSNAMES maps part keys to classnames, GRAPHY_DATA_ATTRIBUTES maps value keys to attribute names, and getChartOrientation(chartType) returns the same 'horizontal' | 'vertical' | undefined the chart stamps as data-graphy-orientation. That’s useful when you know a chart’s type and want to branch on its orientation without touching the DOM.