Population pyramid
Two sets of bars back to back. Good for ages of men and women, imports and exports.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'population',
categories: ['0-9', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80+'],
left: { name: 'Men', data: [37, 33, 28, 31, 24, 22, 27, 23, 17] },
right: { name: 'Women', data: [34, 31, 29, 39, 22, 30, 18, 23, 18] },
};
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 population takes:
interface PopulationSpec extends Base {
type: 'population';
categories: string[];
left: { name: string; data: number[]; color?: string };
right: { name: string; data: number[]; color?: 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