Dumbbell chart
Two values joined by a line. Good for before and after, men and women, plan and result.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'dumbbell',
fromName: '2025',
toName: '2026',
data: [
{ name: 'Kairouan', from: 28, to: 47 },
{ name: 'Gabes', from: 58, to: 37 },
{ name: 'Sousse', from: 45, to: 35 },
{ name: 'Mahdia', from: 36, to: 49 },
{ name: 'Djerba', from: 30, to: 79 },
{ name: 'Sfax', from: 21, to: 61 },
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type dumbbell takes:
/** Two values joined by a line. */
interface DumbbellSpec extends Base {
type: 'dumbbell';
data: { name: string; from: number; to: number }[];
fromName?: string;
toName?: string;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More