Skip to content

Commit

Permalink
Merge pull request #5164 from thierryVergult/sunburstSort
Browse files Browse the repository at this point in the history
Make sunburst and treemap sort optional
  • Loading branch information
archmoj authored Sep 28, 2020
2 parents 35474a1 + a66b42d commit d191ac4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/traces/sunburst/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports = {
'this option won\'t have any effect and `insidetextfont` would be used.'
].join(' ')
}),
sort: pieAttrs.sort,

domain: domainAttrs({name: 'sunburst', trace: true, editType: 'calc'})
};
4 changes: 3 additions & 1 deletion src/traces/sunburst/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ exports.calc = function(gd, trace) {
if(failed) return;

// TODO add way to sort by height also?
hierarchy.sort(function(a, b) { return b.value - a.value; });
if(trace.sort) {
hierarchy.sort(function(a, b) { return b.value - a.value; });
}

var pullColor;
var scaleColor;
Expand Down
2 changes: 2 additions & 0 deletions src/traces/sunburst/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout

coerce('insidetextorientation');

coerce('sort');

handleDomainDefaults(traceOut, layout, coerce);

// do not support transforms for now
Expand Down
1 change: 1 addition & 0 deletions src/traces/treemap/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ module.exports = {
'Sets the positions of the `text` elements.'
].join(' ')
},
sort: pieAttrs.sort,

domain: domainAttrs({name: 'treemap', trace: true, editType: 'calc'}),
};
2 changes: 2 additions & 0 deletions src/traces/treemap/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('pathbar.edgeshape');
}

coerce('sort');

handleDomainDefaults(traceOut, layout, coerce);

// do not support transforms for now
Expand Down

0 comments on commit d191ac4

Please sign in to comment.