Skip to content

Commit 61c4a83

Browse files
sunburst sort attribute
- Standard (original) behavior: sort on values - new *sort* option to disable sorting
1 parent 86f5e2d commit 61c4a83

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/traces/sunburst/calc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ exports.calc = function(gd, trace) {
192192
if(failed) return;
193193

194194
// TODO add way to sort by height also?
195-
hierarchy.sort(function(a, b) { return b.value - a.value; });
195+
if ( fullLayout[ 'sort']) {
196+
hierarchy.sort(function(a, b) { return b.value - a.value; });
197+
}
196198

197199
var pullColor;
198200
var scaleColor;

src/traces/sunburst/layout_attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,15 @@ module.exports = {
3535
'Colors provided in the trace, using `marker.colors`, are never',
3636
'extended.'
3737
].join(' ')
38+
},
39+
sort: {
40+
valType: 'boolean',
41+
dflt: true,
42+
role: 'style',
43+
editType: 'calc',
44+
description: [
45+
'sort on values.',
46+
'default true'
47+
].join(' ')
3848
}
3949
};

src/traces/sunburst/layout_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
1717
}
1818
coerce('sunburstcolorway', layoutOut.colorway);
1919
coerce('extendsunburstcolors');
20+
coerce('sort');
2021
};

0 commit comments

Comments
 (0)