Combo chart
A combo chart draws bars and lines on the same categories: amounts as
bars, and a trend, a target or a rate as a line over them. Its first
series is drawn as bars and the others as lines, each series free to
choose its own display. A line can be washed, faded or dashed as on a
line chart, and read against a secondary axis on the right for a measure
of another unit. Hovering a category, or moving along them with the arrow
keys, shows every value in a tooltip.
Dependencies
When to use
Reach for a combo chart when two related measures are read together on
the same categories, one as amounts and the other as a level to compare
them to: revenue and its margin, orders and their target, visits and the
conversion rate. The bars carry the amounts, the line the trend or the
rate. With a single kind of mark, prefer a
The data follows the contract shared by every chart, see
timeCategories, which builds the categories of a period.
Install & usage
npm install @eunomia/elements @eunomia/charts
import "@eunomia/charts/combo-chart.js";
<eun-combo-chart
label="Orders and target per quarter"
integer
></eun-combo-chart>
<script type="module">
const chart = document.querySelector("eun-combo-chart");
chart.data = {
categories: [
{ key: "q1", label: "First quarter", tick: "Q1" },
{ key: "q2", label: "Second quarter", tick: "Q2" },
{ key: "q3", label: "Third quarter", tick: "Q3" },
],
series: [
{ key: "orders", label: "Orders", values: [420, 510, 380] },
{ key: "target", label: "Target", values: [450, 450, 500] },
],
};
</script>
Importing the file registers <eun-combo-chart> as a custom element,
with no further setup needed. It draws at its own width, so give it room
the way you would an image: in a card, a grid cell, a flex item with
min-width: 0. Import @eunomia/elements/skeleton.js too to show a
placeholder while loading, and @eunomia/elements/modal.js to use
details.
npm install @eunomia/elements @eunomia/charts
<script type="module">
import "@eunomia/charts/combo-chart.js";
import { timeCategories } from "@eunomia/charts/chart-utils.js";
const categories = timeCategories("2026-01", "2026-12", "month");
const chart = document.querySelector("eun-combo-chart");
chart.data = {
categories,
series: [
{
key: "revenue",
label: "Revenue",
values: categories.map(({ key }) => revenue.get(key) ?? 0),
},
{
key: "margin",
label: "Margin",
values: categories.map(({ key }) => margin.get(key) ?? null),
axis: "secondary",
},
],
};
</script>
<eun-combo-chart
label="Revenue and margin per month"
secondary-format='{"style":"percent"}'
></eun-combo-chart>
npm install @eunomia/elements @eunomia/charts
import { useMemo } from "react";
import "@eunomia/charts/combo-chart.js";
const EUROS = { style: "currency", currency: "EUR" };
const PERCENT = { style: "percent" };
function RevenueChart({ months, loading }) {
const data = useMemo(
() => ({
categories: months.map((month) => ({
key: month.key,
label: month.label,
tick: month.tick,
})),
series: [
{
key: "revenue",
label: "Revenue",
values: months.map((month) => month.revenue),
},
{
key: "margin",
label: "Margin",
values: months.map((month) => month.margin),
axis: "secondary",
},
],
}),
[months],
);
return (
<eun-combo-chart
label="Revenue and margin per month"
data={data}
format={EUROS}
secondaryFormat={PERCENT}
loading={loading}
/>
);
}
React 19 sets data, format and secondaryFormat as properties. On
React 18, set them through a ref, or with eunProps from
@eunomia/elements/react.
npm install @eunomia/elements @eunomia/charts
"use client";
import "@eunomia/charts/combo-chart.js";
const EUROS = { style: "currency", currency: "EUR" };
export function RevenueChart({ data }) {
return (
<eun-combo-chart
label="Revenue and margin per month"
data={data}
format={EUROS}
/>
);
}
Build the data on the server with timeCategories from
@eunomia/charts/chart-utils.js, which registers no component, and
import chart-ssr.css to reserve the chart's height before it upgrades
(see Server rendering below).
npm install @eunomia/elements @eunomia/charts
<script setup>
import "@eunomia/charts/combo-chart.js";
defineProps({ data: Object });
const euros = { style: "currency", currency: "EUR" };
</script>
<template>
<eun-combo-chart
label="Revenue and margin per month"
:data="data"
:format="euros"
/>
</template>
npm install @eunomia/elements @eunomia/charts
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from "@angular/core";
import type { EunomiaComboChartData } from "@eunomia/charts";
import "@eunomia/charts/combo-chart.js";
@Component({
selector: "app-revenue-chart",
template: `
<eun-combo-chart
label="Revenue and margin per month"
[data]="data"
[format]="euros"
></eun-combo-chart>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class RevenueChartComponent {
@Input() data!: EunomiaComboChartData;
euros = { style: "currency", currency: "EUR" };
}
Server rendering
Before it upgrades, a chart is an empty tag. Import chart-ssr.css with
the page's other styles to reserve its room from the first paint:
--chart-height, plus a row for the legend once legend="visible", or
100% of its parent's height with fill.
@import "@eunomia/charts/chart-ssr.css";
Without a bundler, link node_modules/@eunomia/charts/dist/ssr/chart-ssr.css
in the page's <head>. Two cases still shift the page on upgrade: a
legend left to legend="auto", which only shows with the data, and a
legend that wraps onto more than one row. See
Alternatives
| You want… | Prefers |
|---|---|
| Amounts only, compared from one category to the next | eun-bar-chart |
| A measure followed over many intervals, as lines only | eun-line-chart |
| Items compared on three measures at once, rather than along categories | eun-bubble-chart |
Guidance
- Give every chart a
label: it names the plot for assistive technology and captions its data table - Draw the amounts as bars and the level to compare them to (a target, a trend, a rate) as a line
- Read a measure of another unit, such as a rate next to amounts, against the secondary axis, with its own
secondary-format - Tell a target or a forecast apart by its style,
fadedordashed, not by its color alone
- Piling up many series of both kinds: past two or three bars and two lines, split the chart
- Two unrelated measures on two axes: the crossing of their lines means nothing, and reads as if it did
- Mutating
datain place: replace the object, the chart only redraws when it changes
Live testing
Properties
data and label are the two you'll always set. The data's own fields,
shared with the other charts, are listed on
Combo chart <eun-combo-chart>
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
| data | EunomiaChartData<S> | EMPTY_DATA | What the chart draws, as JSON: its categories and its series |
| bar-radius | number | 4 | The corner radius of a bar's outer end, in pixels. 0 draws square bars |
| bar-max-width | number | 24 | The widest a bar may be, in pixels |
| bar-gap | number | 2 | The gap between bars standing side by side in a category, in pixels |
| legend-position | EunomiaChartLegendPosition | 'start' | How the legend's entries line up under the plot |
| hide-tooltip | boolean | false | Shows no tooltip on hover or keyboard moves |
| hide-grid | boolean | false | Draws no gridlines |
| hide-value-axis | boolean | false | Hides the labels of the value axes |
| hide-category-axis | boolean | false | Hides the labels of the categories under the plot |
| empty-label | string | undefined | — | The text shown in place of the marks while there are no categories |
| hide-empty-label | boolean | false | Shows no text while there are no categories |
| hide-empty-grid | boolean | false | Draws no gridlines and no value labels while there are no categories |
| axis-min | number | undefined | — | A value the value axis reaches at least, below zero |
| axis-max | number | undefined | — | A value the value axis reaches at least, above zero, such as 100 for percentages |
| min | number | undefined | — | The exact lower end of the value axis, anything below it cut off |
| max | number | undefined | — | The exact upper end of the value axis, anything above it cut off |
| secondary-min | number | undefined | — | The exact lower end of the secondary value axis |
| secondary-max | number | undefined | — | The exact upper end of the secondary value axis |
| decimation | EunomiaChartDecimation | 'lttb' | How the series drawn as lines or points thin out their values once there are too many |
| decimation-samples | number | undefined | — | How many values a line keeps once thinned out, across the whole plot |
| format | Intl.NumberFormatOptions | undefined | — | The Intl.NumberFormat options the values are written with, as JSON |
| secondary-format | Intl.NumberFormatOptions | undefined | — | The Intl.NumberFormat options of the series on the secondary axis, as JSON |
| curve | EunomiaChartCurve | 'linear' | How the series drawn as lines join their values: straight, a smooth curve that never overshoots them, or steps |
| points | EunomiaChartPoints | 'auto' | When the values of the series drawn as lines get a point |
| point-shape | EunomiaChartPointShape | 'circle' | The shape of the points |
| point-size | number | undefined | 6 | The size of the points, in pixels across |
| select-hint | string | undefined | — | The hint at the bottom of the tooltip while categories are clickable. Defaults to the localized string when details is set (English: "Click to see the details"), to none otherwise |
| non-interactive | boolean | false | Draws the chart as a plain picture: no focus stop, no hover, no tooltip, no selection |
| stacked | boolean | false | Stacks every series without a stack of its own in a single column per category |
| integer | boolean | false | Whether values are counts: the primary value axis then never steps below 1. |
| locale | string | undefined | — | The locale used to resolve dictionary and `Intl` formatting. Defaults to the shared default set via `setDefaultLocale()`, itself defaulting to `"en"`. |
| label | string | undefined | — | The chart's accessible name, also the caption of its data table. |
| legend | EunomiaChartLegend | "auto" | When the legend is shown — see EunomiaChartLegend. |
| fill | boolean | false | Takes the whole height of the chart, rather than `--chart-height`: the plot stretches to what's left once the legend is laid out, and redraws whenever that changes. The chart takes 100% of its parent's height by default; size it like any block otherwise (`height`, `flex: 1`, a grid cell). |
| loading | boolean | false | Shows a placeholder in place of the plot while the data loads. |
| refreshing | boolean | false | Keeps the plot shown as a placeholder while new data loads, such as after a change of period: the marks faded, their colors kept, under a shimmer, the axes kept, the tooltip off. |
| animated | boolean | false | Draws the marks in once the chart is first seen. |
| selectable | boolean | false | Makes every category clickable, firing `eunchartselect`. |
| details | boolean | false | Opens a modal listing a category's values once it's clicked. Implies selectable. |
Import the exact TypeScript type behind any property above, see
Properties
JS-only — no matching HTML attribute, set these from a script or a template binding.
| Name | Type | Default | Description |
|---|---|---|---|
| valueFormatter | EunomiaChartValueFormatter | undefined | — | Writes a value in the tooltip, the details and the data table, in place of format. Property only |
| tickFormatter | EunomiaChartTickFormatter | undefined | — | Writes a value of a value axis, in place of format. Receives the value and the axis, primary or secondary. Property only |
| tooltipRenderer | EunomiaChartTooltipRenderer<S> | undefined | — | Writes the content of the tooltip in place of the values and the category's label. Receives the category, the values of every series written and colored, and the total; returns a DOM node, a string shown as text or a Lit template, null keeping the default content. Property only |
| resolvedLocale | string | — | This instance's own `locale` when set, the shared default locale otherwise. |
| dictionary | ChartDictionary | — | This instance's locale-resolved chart strings. |
Methods
| Name | Returns | Description |
|---|---|---|
| replayAnimation() | Promise<void> | Plays the entrance animation again, such as once new data is shown. Does nothing while the person asked to reduce motion. |
Slots
| Name | Description |
|---|---|
| details | Extra content shown in the details modal, below the category's values, such as the records behind them. Update it from eunchartselect. A <template slot="details"> is filled for the clicked category instead, as the tooltip's: data-field, data-each and data-bind-* attributes such as data-bind-href="/orders?day={key}" |
| tooltip | A <template> writing the content of the tooltip in plain HTML, in place of the values and the category's label: data-each="values" (or "drawn") repeats an element per series, data-field writes category, key, tick, total, and per series series, text, value or color. tooltipRenderer takes over when set. data-bind-<attr> writes an attribute, {category}, {key}, {tick} and {index} replaced |
Events
| Name | Type | Description |
|---|---|---|
| eunchartselect | ChartSelectEvent | Fired when a category is clicked, or activated with Enter or Space, while selectable or details is set. Cancelable to keep the details modal from opening |
Every event above follows the same naming convention, covered in
CSS custom properties
| Name | Description |
|---|---|
| --chart-height | Sets the height of the plot, axis labels included, ignored with fill. 220px by default |
| --chart-min-height | Sets the least height of the plot with fill. 80px by default |
| --chart-color-1 | Sets the color of the first series, and of every eighth one after it. The primary color by default |
| --chart-color-2 | Sets the color of the second series. The secondary color by default |
| --chart-color-3 | Sets the color of the third series |
| --chart-color-4 | Sets the color of the fourth series |
| --chart-color-5 | Sets the color of the fifth series |
| --chart-color-6 | Sets the color of the sixth series |
| --chart-color-7 | Sets the color of the seventh series |
| --chart-color-8 | Sets the color of the eighth series |
| --chart-surface-color | Sets the color of the surface the chart sits on, mixed into the hovered bars and ringing the markers |
| --chart-line-width | Sets the width of the lines. 2px by default |
| --chart-area-opacity | Sets the opacity of the wash under a line. 0.1 by default |
| --chart-grid-color | Sets the color of the gridlines and of the hovered category's band |
| --chart-bar-border-width | Sets the width of the bars' border. None by default |
| --chart-bar-border-color | Sets the color of the bars' border. The surface color by default, which sets the bars apart |
| --chart-axis-color | Sets the color of the axis labels and of the legend |
| --chart-axis-font-size | Sets the font size of the axis labels |
| --chart-tooltip-background | Sets the background color of the tooltip |
| --chart-tooltip-color | Sets the text color of the tooltip |
| --chart-focus-outline-color | Sets the color of the plot's focus ring |
| --chart-animation-duration | Sets the duration of the entrance animation |
| --chart-refresh-opacity | Sets the opacity the marks take while refreshing, their colors kept. 0.4 by default |
| --chart-refresh-highlight-color | Sets the color of the shimmer sweeping the plot while refreshing |
CSS shadow parts
| Name | Description |
|---|---|
| plot | The svg the chart is drawn in |
| tooltip | The tooltip |
| legend | The legend |
| legend-item | An entry of the legend, its swatch and its name |
| legend-swatch | The swatch of an entry of the legend |
| details | The details modal |
Types
import type {
EunomiaComboChartData,
EunomiaComboChartSeries,
EunomiaChartCategory,
EunomiaChartLegend,
EunomiaChartLegendPosition,
EunomiaChartAxis,
EunomiaChartDisplay,
EunomiaChartValueFormatter,
EunomiaChartTickFormatter,
EunomiaChartCurve,
EunomiaChartPoints,
EunomiaChartPointShape,
EunomiaChartTooltipRenderer,
} from "@eunomia/charts";
import { ChartSelectEvent } from "@eunomia/charts";
A series takes the fields of a bar chart series (display, stack,
axis) and of a line chart series (area, faded, dashed), the
latter applying while it's drawn as a line. ChartSelectEvent carries
the selected category, its index in data.categories, and values:
every series with its value on that category, null for none.
Series
Bars and a line
With no display of their own, the first series is drawn as bars and
the others as lines over them: here the orders of each quarter and their
target, dashed.
chart.data = {
categories: quarters,
series: [
{ key: "orders", label: "Orders", values: [420, 510, 380, 640] },
{
key: "target",
label: "Target",
values: [450, 450, 500, 550],
dashed: true,
},
],
};
Three series and more
display sets how each series is drawn: bar, line, points or
none. Bar series stand side by side, the lines and points over them.
Here two years of orders as bars, their target as a line, and the
conversion rate as points against the secondary axis.
series: [
{ key: "2025", label: "Orders, 2025", values: orders2025, display: "bar" },
{ key: "2026", label: "Orders, 2026", values: orders2026, display: "bar" },
{ key: "target", label: "Target", values: target, dashed: true },
{ key: "rate", label: "Conversion", values: rate, axis: "secondary", display: "points" },
],
Stacked bars and a line
stacked piles up every series drawn as bars into one column per
category, their total in the tooltip, the lines staying out of the
stack; stack groups only some of them. Here three channels stacked,
and last year's total faded over them.
<eun-combo-chart label="Sales per channel" stacked></eun-combo-chart>
series: [
{ key: "web", label: "Website", values: web },
{ key: "app", label: "App", values: app, display: "bar" },
{ key: "store", label: "Store", values: store, display: "bar" },
{ key: "last", label: "Total, last year", values: lastYear, faded: true },
],
Line styles
A line takes the styles of a line chart: area washes the space down to
zero, faded draws it semi-transparent and dashed dashed. A null
value leaves a gap, in the bars as in the lines, so a forecast drawn as
bars in the same stack can pick up where the actual figures stop.
curve softens the lines (smooth) or draws them in steps (step),
and points, point-shape and point-size choose when and how their
values are marked, for the whole chart or per series (curve, points,
pointShape, pointSize), as on a line chart.
series: [
{ key: "actual", label: "Actual", values: [32, 35, /* … */ 55, null, null, null], stack: "sales" },
{ key: "trend", label: "Trend", values: trend, area: true },
{ key: "forecast", label: "Forecast", values: [null, /* … */ null, 55, 60, 64, 70], display: "bar", stack: "sales" },
{ key: "target", label: "Target", values: target, faded: true, dashed: true },
],
Axes and displays
Secondary axis
A series with axis: "secondary" is read against a value axis of its
own on the right, for a measure of another unit or magnitude, here a
margin rate next to revenue. secondary-format writes its values and
its labels.
series: [
{ key: "revenue", label: "Revenue", values: revenue },
{ key: "margin", label: "Margin", values: margin, axis: "secondary" },
],
Points and hidden series
display: "points" draws a dot on each value, with no line between
them, and display: "none" leaves a series undrawn, out of the legend,
its values still in the tooltip, the details and the data table (here
the visits behind the orders).
Hiding the grid and the axes
hide-grid draws no gridlines, hide-value-axis and
hide-category-axis drop the labels on the sides and under the plot,
the marks taking their room.
Values
format takes Intl.NumberFormat options, applied in the chart's
locale: values are written in full in the tooltip, the details and the
data table, and in compact notation along the axis. secondary-format
does the same for the series on the secondary axis. The axes always
include zero and step on round values; axis-max, axis-min and
integer shape the primary one. When a format isn't enough,
valueFormatter writes the values and tickFormatter the axes, both
set as properties.
chart.format = { style: "currency", currency: "EUR" };
chart.secondaryFormat = { style: "percent" };
chart.tickFormatter = (value, axis) =>
axis === "secondary" ? `${value * 100}%` : `€${value / 1000}k`;
Legend and colors
legend="auto", the default, shows the legend from two drawn series on,
visible always and hidden never, and legend-position lines it up
from the start, in the center or against the end. Each entry's
swatch follows how its series is drawn: a square for bars, a stroke for
a line, a dot for points. Series take the palette's colors in order, and
a series' own color takes over.
The legend and the tooltip work the same on every chart: see
States
Loading and refreshing
loading shows a placeholder the height of the chart while its first
data loads. refreshing turns the current marks into a placeholder
while new data loads: they're faded, their colors kept, under a shimmer, the axes stay,
and the tooltip is off until the new data comes in.
Empty
A chart without categories keeps its axis and writes "No data".
empty-label writes your own message, hide-empty-label none, and
hide-empty-grid drops the gridlines and the value labels.
Entrance animation
By default, a chart is drawn at once, with no motion: the right choice for a dashboard refreshed often, or for one chart among many on a page.
animated grows the bars from zero and draws the lines from left to
right once the chart is first seen. replayAnimation() plays it again.
It's skipped when the person asked their system to reduce motion.
<!-- No animation, the default -->
<eun-combo-chart
label="Orders, target and conversion per quarter"
></eun-combo-chart>
<!-- Animated when first seen -->
<eun-combo-chart
label="Orders, target and conversion per quarter"
animated
></eun-combo-chart>
Selection
Selectable categories
selectable makes every category clickable, and activatable with Enter
or Space once the plot is focused, firing eunchartselect with the
category and the value of every series.
Click a quarter.
chart.addEventListener("eunchartselect", (event) => {
showOrders(event.category.key);
});
Details modal
details opens a modal on click, headed by the category's label and
listing the value of every series. It needs eun-modal to be
registered. The details slot adds content below the values, filled
from eunchartselect; canceling it keeps the modal closed.
The modal works the same on every chart: see
Non-interactive
non-interactive draws the chart as a plain picture: no focus stop, no
hover, no tooltip and no selection, even with selectable or details.
It fits a small chart in a table cell or a card, where the row or the
card already takes the click. The plot keeps its accessible name and its
data table. See
<eun-combo-chart
label="Revenue and margin per month"
non-interactive
></eun-combo-chart>
Customization
Custom appearance
The custom properties of the bar and line charts restyle the combo chart
too, and its parts (plot, tooltip, legend, details) take any
other rule.
.orders-chart {
--chart-height: 280px;
--chart-color-1: #0f766e;
--chart-color-2: #f59e0b;
--chart-line-width: 3px;
--chart-grid-color: #99f6e4;
--chart-axis-color: #115e59;
--chart-tooltip-background: #134e4a;
--chart-tooltip-color: #f0fdfa;
}
| Variable | Sets |
|---|---|
--chart-height |
Sets the height of the plot, axis labels included. 220px by default |
--chart-color-1 … -8 |
Sets the palette the series take their color from, in order |
--chart-line-width |
Sets the width of the lines. 2px by default |
--chart-area-opacity |
Sets the opacity of the wash under a line. 0.1 by default |
--chart-surface-color |
Sets the color of the surface the chart sits on, mixed into the hovered bars, ringing markers |
--chart-grid-color |
Sets the color of the gridlines and of the hovered category's band |
--chart-axis-color |
Sets the color of the axis labels and of the legend |
--chart-tooltip-background |
Sets the background color of the tooltip |
--chart-tooltip-color |
Sets the text color of the tooltip |
--chart-animation-duration |
Sets the duration of the entrance animation |
--chart-refresh-opacity |
Sets the opacity the marks take while refreshing, their colors kept. 0.4 by default |
Keyboard interactions
The plot is a single focus stop. Once focused, it shows the last category, and the arrow keys move along the others.
| Key | Action |
|---|---|
Tab / Shift+Tab |
Moves focus to or away from the plot |
ArrowLeft |
Shows the previous category |
ArrowRight |
Shows the next category |
Home / End |
Shows the first or the last category |
Enter / Space |
Selects the shown category, while selectable or details is set |
Aria attributes and rules
- The plot is an
svgwithrole="img", named bylabel. Give every chart one. - Every value stays reachable in a visually hidden table, captioned by
label, a row per category and a column per series, bars and lines alike. Screen reader users read the data there rather than through the drawing. - Moving along the categories with the keyboard announces each one through a polite live region, its label followed by its values.
- The tooltip and the legend are
aria-hidden: they repeat what the table already holds. - While
refreshing, the plot is markedaria-busy. - A missing value is written "No value", never left blank, so it can't be mistaken for a zero.
- The details modal is an
eun-modal, with its own focus trap, Escape to close and return of focus to the plot. animatedis skipped when the person asked their system to reduce motion.- With
non-interactive, the plot is no focus stop and reacts to neither the pointer nor the keyboard; its accessible name and its data table are still read by screen readers.
Color and contrast
Bars and lines are told apart by their shape, the legend's swatches
following it; series of the same kind are told apart by color, so keep
the legend shown, and give a target or a forecast a style of its own
(faded, dashed). Marks should keep a 3:1 contrast with the surface
around them (WCAG 1.4.11), a line drawn over bars with them too.
Reference links
WAI Web Accessibility Tutorials: Complex images Understanding WCAG 2.2: Non-text contrast