EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Charts·component·@astryxdesign/chartsExperimental

Chart Swatch

ChartSwatch renders the small decorative mark that pairs a chart series color with its visible label. Use a square for bar series and a short line for other series, including line, dot, and area marks.

@astryxdesign/charts

Authored source examples

Source examples recorded in the documentation for this entry.

Bar series swatch
import {ChartSwatch} from '@astryxdesign/charts';

<ChartSwatch color="#3b82f6" variant="square" />;
Series-driven swatch
import {
  ChartSwatch,
  swatchVariantForType,
} from '@astryxdesign/charts';

<ChartSwatch
  color={series.color}
  variant={swatchVariantForType(series.type)}
/>;

Usage

ChartSwatch renders the small decorative mark that pairs a chart series color with its visible label. Use a square for bar series and a short line for other series, including line, dot, and area marks.

  • Place every swatch next to visible text that names the corresponding series. ChartSwatch is decorative and stays hidden from assistive technology.
  • Use the square variant for bar series and the line variant for other mark types so legends and tooltips echo the plotted marks consistently.
  • Use ChartSwatch as the accessible name or data alternative for a series. Its surrounding legend, tooltip, or chart must provide that information.
  • Rely on arbitrary colors alone when multiple same-shaped series must be matched across a chart. Verify the complete chart and its labels together.

Typed props

PropType and behavior
colorstring · required
CSS color used to paint the swatch. The caller owns palette selection and contrast on the rendered surface.
variant'square' | 'line' · default 'square'
Mark shape: use square for bar series and line for other series types.

Anatomy

Series swatch · required

Decorative square or short line painted with a caller-owned series color.

Accessibility

Decorative mark

Semantics · 1.1.1 Non-text Content · Built in

The swatch is hidden from assistive technology. Pair it with visible series text that supplies the accessible meaning.

States: All

Series distinction

Color contrast · 1.4.1 Use of Color; 1.4.11 Non-text Contrast · Consumer verification required

Choose colors and, when necessary, additional labels or mark distinctions that remain understandable on the rendered chart surface.

States: All