dc-js / dc.js

Multi-Dimensional charting built to work natively with crossfilter rendered with d3.js
Apache License 2.0
7.41k stars 1.81k forks source link

pie label label should use `g` element #1833

Open gordonwoodhull opened 3 years ago

gordonwoodhull commented 3 years ago

It's pretty common to want to add or change the stuff that goes into the pie slices. Right now you have to calculate the position yourself, and animations don't come out right.

We use g elements for the slices themselves, but this doesn't really help for adding images at the center where labels would go, as asked in this SO question:

https://stackoverflow.com/questions/67340109/how-to-add-icons-in-dc-js-piechart-slices-instead-texts

This has come up before. There are other charts where we put the label in a g and it is helpful.

gordonwoodhull commented 3 years ago

Btw, the answer provides a great example of why it's nice that we exposed all the private methods on upgrading to ES6 in v4. It uses both PieChart._buildArcs() and PieChart._labelPosition() and it would be a lot messier without them.