Skip to content

Pie chart

import { PieChart } from '@arshad-shah/swift-chart';
const chart = new PieChart('#chart', { theme: 'midnight' });
chart.setData(traffic, { labelField: 'source', valueField: 'visits' });

Map a row field to a colour with colorField + colorMap. See the per-datum colours guide for the full resolution chain.

chart.setData(traffic, {
labelField: 'source',
valueField: 'visits',
colorField: 'source',
colorMap: {
'Organic Search': '#5b8cff',
Direct: '#22c55e',
Social: '#f59e0b',
},
});