Skip to content

Coloring pie labels and ticks by slice

This demo shows how we can use adapters to dynamically color labels and ticks using the color from their slice.

series.ticks.template.adapters.add("stroke", function(stroke, target) {
if (target.dataItem) {
return target.dataItem.get("slice").get("fill");
}
else {
return stroke;
}
});
series.labels.template.adapters.add("fill", function(fill, target) {
if (target.dataItem) {
return target.dataItem.get("slice").get("fill");
}
else {
return fill;
}
});
Open in CodePen