title |
---|
Pie/Doughnut chart |
See the Pen chart.xkcd pie by timqian (@timqian) on CodePen.
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>const pieChart = new chartXkcd.Pie(svg, {
title: 'What Tim is made of', // optional
data: {
labels: ['a', 'b', 'e', 'f', 'g'],
datasets: [{
data: [500, 200, 80, 90, 100],
}],
},
options: { // optional
innerRadius: 0.5,
legendPosition: chartXkcd.config.positionType.upRight,
},
});
innerRadius
: specify empty pie chart radius (default:0.5
)- Want a pie chart? set
innerRadius
to0
- Want a pie chart? set
showLegend
: display legend near chart (defaulttrue
)legendPosition
: specify where you want to place the legend. (defaultchartXkcd.config.positionType.upLeft
) Possible values:- up left:
chartXkcd.config.positionType.upLeft
- up right:
chartXkcd.config.positionType.upLeft
- bottom left:
chartXkcd.config.positionType.downLeft
- bottom right:
chartXkcd.config.positionType.downRight
- up left:
dataColors
: array of colors for different datasetsfontFamily
: customize font family used in the chartunxkcdify
: disable xkcd effect (defaultfalse
)strokeColor
: stroke colors (defaultblack
)backgroundColor
: color for BG (defaultwhite
)