Simple pie chart
Three slices, each labelled with its share of the total.
src/main.ts
import 'chartist/styles.css';
import { pieChart } from 'chartist';
const data = {
series: [5, 3, 4]
};
pieChart('#chart', data, {
labelInterpolationFnc: value =>
Math.round((+value / data.series.reduce((a, b) => a + b)) * 100) + '%'
});import 'chartist/styles.css';
import { PieChart } from 'chartist';
const data = {
series: [5, 3, 4]
};
new PieChart('#chart', data, {
labelInterpolationFnc: value =>
Math.round((+value / data.series.reduce((a, b) => a + b)) * 100) + '%'
}); Live
Open in the playgroundView as MarkdownSwitch to 1.x above the code to see the same chart written with the Chartist 1.x classes.