1👍
✅
You can get points on a circle with the formula
x = radius*sin(angle), y = radius*cos(angle)
So I suppose in your code you could do something like
const donutArc = {
id: 'donutArc',
afterDraw: (chart) => {
const { ctx, data: { datasets }, } = chart;
datasets.forEach((dataset, i) =>{
chart.getDatasetMeta(i).data.forEach((arc, j) => {
r1 = arc.innerRadius
r2 = arc.outerRadius
xinner = r1*Math.sin(arc.startAngle)
yinner = r1*Math.cos(arc.startAngle)
xouter = r2*Math.sin(arc.startAngle)
youter = r2*Math.cos(arc.startAngle)
// then I guess here you would draw something
})
})
}
}
This is assuming the origin of the graph is (0,0) and thatstartAngle
, outerRadius
and innerRadius
are what they would appear to be
Source:stackexchange.com