4.2.0
Core

Chart

The chrome around a recharts chart โ€” container, config, tooltip and legend โ€” so a series is named and coloured once, in the same roles as every pill on the screen.

Default

A config of three series, no colours named: each one takes the next token role, and the container publishes it as `--color-<key>` for `fill="var(--color-shipped)"` to read. The bars are a real recharts `<BarChart>` โ€” `ChartContainer` renders recharts' `ResponsiveContainer` underneath, which sizes an actual chart itself; nothing here states a width or a height.

Usage

import {
  ChartContainer,
  ChartLegend,
  ChartLegendContent,
  ChartStyle,
  ChartTooltip,
  ChartTooltipContent,
} from '@oceanic-hub/brand-system'
<ChartContainer children={โ€ฆ} config={โ€ฆ}>
  <ChartLegend>
    <ChartLegendContent>โ€ฆ</ChartLegendContent>
  </ChartLegend>
</ChartContainer>

Composition

Use the following composition to build with Chart:

ChartContainer
โ”œโ”€โ”€ ChartLegend
โ”‚   โ””โ”€โ”€ ChartLegendContent
โ””โ”€โ”€ ChartTooltip
    โ””โ”€โ”€ ChartTooltipContent

Reach for it when the shape you need is a real chart: axes, a grid, a hover, more points than a reader can count. When it is one of the fixed marks sitting beside a number โ€” a sparkline, a mini line or bar, a funnel โ€” reach for Charts instead, which draws them as inline SVG with no charting library at all. Neither is a lightweight version of the other, they ship side by side, and the export names do not collide.

Everything here is the chrome; the marks stay recharts'. <BarChart>, <Bar>, <XAxis>, <CartesianGrid> and accessibilityLayer are theirs and are documented on their side โ€” recharts is a dependency of this package rather than a peer, so importing this module is all it takes to have them. What this module adds is the one thing a charting library cannot know: what your design system calls the colour of a series.

A series takes a role, and upstream's theme is refused. Upstream's config takes theme: { light, dark } โ€” two literal colours, restated per mode, in the caller's file where no gate can see them. A role already flips, so restating it would be re-implementing the token layer somewhere nothing checks. Name neither and the container hands out the next role in a fixed rotation, so the zero-config chart is on-brand before anyone has picked anything; the rotation is exactly as long as this system has chart colours, and one more would be a second palette. color is still there for the genuine escape hatch โ€” plotting a third party's own brand โ€” and from then on it is the caller's authority: a literal follows no theme and no token rename. There are no --chart-1โ€ฆ--chart-5 variables to redefine either; the roles are the palette.

Upstream's page is a recharts tutorial, and this one deliberately is not. Your first chart, Add a grid, Add an axis and Accessibility all teach recharts' own API, which is better learned from recharts. The examples on this page stop at the boundary this module owns โ€” the config, the tooltip, the legend โ€” and every mark on it is now a genuine <BarChart>, not a hand-drawn stand-in (@OCE-1879). That used to be a hand-built SVG reading the same --color-<key> a <Bar fill> would, because the showcase's demo import allowlist forbade recharts; ChartContainer renders recharts' ResponsiveContainer, which hands anything that is not a chart a 0ร—0 box to paint out of, so every preview on this page rendered invisibly or clipped and had to hand-author a w-max plus explicit pixel dimensions to fight it โ€” advice no real consumer should follow, since a genuine chart answers that measurement itself. The allowlist now admits recharts for this module alone (charts.tsx's inline-SVG family still refuses it, on purpose), so the previews size themselves and several are literally interactive: hover a bar to see the real ChartTooltip.

RTL is not supported โ€” the same refusal Accordion and Field carry, recorded in pairings.json under direction. Nothing in this package has ever been laid out or measured right-to-left, and upstream's RTL section is not something to advertise unmeasured.

Colours are roles

Name a role per series when the series MEANS something โ€” done, working, stuck โ€” so the chart agrees with the pills and badges beside it rather than carrying a second vocabulary. Name nothing and the container hands out the next role in the rotation, which is what the default example does.

Tooltip

The hover card recharts renders through ChartTooltip content={<ChartTooltipContent />}. Hover a bar to see it โ€” this is a real <BarChart>, so the tooltip is the genuine recharts one, not a payload supplied by hand.

Indicator

The mark beside each series: a dot by default, a line when the series is drawn as a stroke rather than a fill, a dashed outline when it is a projection or a target. All three together, because the choice is a match to the mark on the chart and only reads beside its siblings. Hover any of the three to compare.

Trimming the tooltip

hideLabel drops the heading when the x value is already under the cursor on the axis; hideIndicator drops the swatches when a single series makes the colour say nothing. Shown beside the full tooltip, because what is worth noticing is what is missing โ€” hover each to compare.

Formatting

Both halves of the tooltip take a function: labelFormatter replaces the heading, formatter replaces a whole row. Reach for the first to turn a raw key into something a reader recognises, and the second when the value needs a unit the chart's axis is not carrying. Hover either chart to see its tooltip.

Legend icons

Give a series an icon in the config and both the legend and the tooltip draw it in place of the colour swatch. Reach for it when the mark on the chart is already a shape, or when two series sit close enough in tone that only a symbol tells them apart; hideIcon puts the swatch back for one legend without touching the config.

API Reference

See the Chart API page for every prop of every part, with types, defaults and the contract that pins them.

On this page