Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass more data to sunburst color method to allow greater customization and consistency #1677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/models/sunburst.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ nv.models.sunburst = function() {

cGE.append("path")
.attr("d", arc)
.style("fill", function (d) {
.style("fill", function (d, i) {
if (d.color) {
return d.color;
}
else if (groupColorByParent) {
return color((d.children ? d : d.parent).name);
return color((d.children ? d : d.parent), i);
}
else {
return color(d.name);
return color(d, i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default color function is nv.utils.defaultColor, which uses nv.utils.getColor which has a definition of just function(color). While it might work, it's going to hash a whole object every time, which is going to end up generating different colors if the data structure is modified.

Why would you be changing/duplicating the name attribute anyway? If you really have to do that, then I suggest putting a unique number on the end of the name and then strip it off with a custom tooltip.headerFormatter option

}
})
.style("stroke", "#FFF")
Expand Down