Budget envelopes
One envelope for each kind of spending, filled as the money goes, with the pace of the month. Good for household budgets and team expense limits.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/themes';
const spec = {
type: 'envelopes',
format: { currency: 'EUR' },
elapsed: 0.58,
data: [
{ name: 'Groceries', budget: 450, spent: 257 },
{ name: 'Rent', budget: 900, spent: 324 },
{ name: 'Transport', budget: 120, spent: 78 },
{ name: 'Eating out', budget: 150, spent: 47 },
{ name: 'Leisure', budget: 100, spent: 31 },
{ name: 'Clothes', budget: 80, spent: 62 },
],
};
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 envelopes takes:
/** Budget envelopes: one for each kind of spending, filled as the money goes, with the pace of the month. */
interface EnvelopesSpec extends Base {
type: 'envelopes';
data: { name: string; budget: number; spent: number; color?: string }[];
/** Share of the month gone, from 0 to 1: a mark of where the spending should be. */
elapsed?: number;
onItemClick?: (name: string) => void;
}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