I have a pie chart that I have converted to a row chart to make it more readable.
In the label for the row chart entries, I want to be able to report on the percentage breakdown for each row (as one could with a pie chart using the start and end angles).
I'm not sure how to add the percentage to the label though. Is this possible?
I have a pie chart that I have converted to a row chart to make it more readable.
In the label for the row chart entries, I want to be able to report on the percentage breakdown for each row (as one could with a pie chart using the start and end angles).
I'm not sure how to add the percentage to the label though. Is this possible?
Share Improve this question edited May 30, 2015 at 23:09 Gordon 20.2k4 gold badges39 silver badges77 bronze badges asked May 26, 2015 at 18:12 AbhAbh 434 bronze badges 1- This should be possible. Can you post some good and we'll see if we can figure out how to make it work? – Peter Commented May 26, 2015 at 20:16
1 Answer
Reset to default 12I think this will work. In your row chart definition just add this property
.label(function(d){
return d.key + " : " + d.value + " - " +(d.value / ndx.groupAll().reduceCount().value() * 100).toFixed(2) + "%";
});
This will give you something like this on the resulting horizontal bars
Active : 267 - 50.38%
You can customize this code to suit your needs.