Skip to content

Commit 0822bf5

Browse files
committed
drop unused treemap props and bring in relevant sunburst props for icicle
1 parent b3e1bb9 commit 0822bf5

File tree

5 files changed

+15
-143
lines changed

5 files changed

+15
-143
lines changed

src/traces/icicle/attributes.js

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,6 @@ module.exports = {
2222
maxdepth: sunburstAttrs.maxdepth,
2323

2424
tiling: {
25-
packing: {
26-
valType: 'enumerated',
27-
values: [
28-
'squarify',
29-
'binary',
30-
'dice',
31-
'slice',
32-
'slice-dice',
33-
'dice-slice'
34-
],
35-
dflt: 'squarify',
36-
editType: 'plot',
37-
description: [
38-
'Determines d3 icicle solver.',
39-
'For more info please refer to https://github.com/d3/d3-hierarchy#icicle-tiling'
40-
].join(' ')
41-
},
42-
43-
squarifyratio: {
44-
valType: 'number',
45-
min: 1,
46-
dflt: 1,
47-
editType: 'plot',
48-
description: [
49-
'When using *squarify* `packing` algorithm, according to https://github.com/d3/d3-hierarchy/blob/master/README.md#squarify_ratio',
50-
'this option specifies the desired aspect ratio of the generated rectangles.',
51-
'The ratio must be specified as a number greater than or equal to one.',
52-
'Note that the orientation of the generated rectangles (tall or wide)',
53-
'is not implied by the ratio; for example, a ratio of two will attempt',
54-
'to produce a mixture of rectangles whose width:height ratio is either 2:1 or 1:2.',
55-
'When using *squarify*, unlike d3 which uses the Golden Ratio i.e. 1.618034,',
56-
'Plotly applies 1 to increase squares in icicle layouts.'
57-
].join(' ')
58-
},
59-
6025
flip: {
6126
valType: 'flaglist',
6227
flags: [
@@ -84,61 +49,8 @@ module.exports = {
8449
},
8550

8651
marker: extendFlat({
87-
pad: {
88-
t: {
89-
valType: 'number',
90-
min: 0,
91-
editType: 'plot',
92-
description: [
93-
'Sets the padding form the top (in px).'
94-
].join(' ')
95-
},
96-
l: {
97-
valType: 'number',
98-
min: 0,
99-
editType: 'plot',
100-
description: [
101-
'Sets the padding form the left (in px).'
102-
].join(' ')
103-
},
104-
r: {
105-
valType: 'number',
106-
min: 0,
107-
editType: 'plot',
108-
description: [
109-
'Sets the padding form the right (in px).'
110-
].join(' ')
111-
},
112-
b: {
113-
valType: 'number',
114-
min: 0,
115-
editType: 'plot',
116-
description: [
117-
'Sets the padding form the bottom (in px).'
118-
].join(' ')
119-
},
120-
121-
editType: 'calc'
122-
},
123-
12452
colors: sunburstAttrs.marker.colors,
12553

126-
depthfade: {
127-
valType: 'enumerated',
128-
values: [true, false, 'reversed'],
129-
editType: 'style',
130-
description: [
131-
'Determines if the sector colors are faded towards',
132-
'the background from the leaves up to the headers.',
133-
'This option is unavailable when a `colorscale` is present,',
134-
'defaults to false when `marker.colors` is set,',
135-
'but otherwise defaults to true.',
136-
'When set to *reversed*, the fading direction is inverted,',
137-
'that is the top elements within hierarchy are drawn with fully saturated colors',
138-
'while the leaves are faded towards the background color.'
139-
].join(' ')
140-
},
141-
14254
line: sunburstAttrs.marker.line,
14355

14456
editType: 'calc'
@@ -149,6 +61,8 @@ module.exports = {
14961
})
15062
),
15163

64+
leaf: sunburstAttrs.leaf,
65+
15266
pathbar: {
15367
visible: {
15468
valType: 'boolean',

src/traces/icicle/defaults.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3434
coerce('level');
3535
coerce('maxdepth');
3636

37-
var packing = coerce('tiling.packing');
38-
if(packing === 'squarify') {
39-
coerce('tiling.squarifyratio');
40-
}
41-
4237
coerce('tiling.flip');
4338
coerce('tiling.pad');
4439

@@ -62,33 +57,25 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6257
moduleHasInsideanchor: false
6358
});
6459
coerce('textposition');
65-
var bottomText = traceOut.textposition.indexOf('bottom') !== -1;
6660

6761
var lineWidth = coerce('marker.line.width');
6862
if(lineWidth) coerce('marker.line.color', layout.paper_bgcolor);
6963

70-
var colors = coerce('marker.colors');
64+
coerce('marker.colors');
7165
var withColorscale = traceOut._hasColorscale = (
7266
hasColorscale(traceIn, 'marker', 'colors') ||
7367
(traceIn.marker || {}).coloraxis // N.B. special logic to consider "values" colorscales
7468
);
7569
if(withColorscale) {
7670
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
77-
} else {
78-
coerce('marker.depthfade', !(colors || []).length);
7971
}
8072

81-
var headerSize = traceOut.textfont.size * 2;
82-
83-
coerce('marker.pad.t', bottomText ? headerSize / 4 : headerSize);
84-
coerce('marker.pad.l', headerSize / 4);
85-
coerce('marker.pad.r', headerSize / 4);
86-
coerce('marker.pad.b', bottomText ? headerSize : headerSize / 4);
87-
8873
if(withColorscale) {
8974
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'marker.', cLetter: 'c'});
9075
}
9176

77+
coerce('leaf.opacity', withColorscale ? 1 : 0.7);
78+
9279
traceOut._hovered = {
9380
marker: {
9481
line: {

src/traces/icicle/draw_descendants.js

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
3737
var hasRight = trace.textposition.indexOf('right') !== -1;
3838
var hasBottom = trace.textposition.indexOf('bottom') !== -1;
3939

40-
var noRoomForHeader = (!hasBottom && !trace.marker.pad.t) || (hasBottom && !trace.marker.pad.b);
41-
4240
// N.B. slice data isn't the calcdata,
4341
// grab corresponding calcdata item in sliceData[i].data.data
4442
var allData = partition(entry, [width, height], {
@@ -47,11 +45,7 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
4745
flipX: trace.tiling.flip.indexOf('x') > -1,
4846
flipY: trace.tiling.flip.indexOf('y') > -1,
4947
pad: {
50-
inner: trace.tiling.pad,
51-
top: trace.marker.pad.t,
52-
left: trace.marker.pad.l,
53-
right: trace.marker.pad.r,
54-
bottom: trace.marker.pad.b,
48+
inner: trace.tiling.pad
5549
}
5650
});
5751

@@ -122,12 +116,10 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
122116
}
123117

124118
updateSlices.each(function(pt) {
125-
var isHeader = helpers.isHeader(pt, trace);
126-
127-
pt._hoverX = viewX(pt.x1 - trace.marker.pad.r),
119+
pt._hoverX = viewX(pt.x1 - trace.tiling.pad),
128120
pt._hoverY = hasBottom ?
129-
viewY(pt.y1 - trace.marker.pad.b / 2) :
130-
viewY(pt.y0 + trace.marker.pad.t / 2);
121+
viewY(pt.y1 - trace.tiling.pad / 2) :
122+
viewY(pt.y0 + trace.tiling.pad / 2);
131123

132124
var sliceTop = d3.select(this);
133125

@@ -160,11 +152,7 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
160152
if(pt.x0 === pt.x1 || pt.y0 === pt.y1) {
161153
pt._text = '';
162154
} else {
163-
if(isHeader) {
164-
pt._text = noRoomForHeader ? '' : helpers.getPtLabel(pt) || '';
165-
} else {
166-
pt._text = formatSliceLabel(pt, entry, trace, cd, fullLayout) || '';
167-
}
155+
pt._text = formatSliceLabel(pt, entry, trace, cd, fullLayout) || '';
168156
}
169157

170158
var sliceTextGroup = Lib.ensureSingle(sliceTop, 'g', 'slicetext');
@@ -178,14 +166,13 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
178166

179167
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
180168
.classed('slicetext', true)
181-
.attr('text-anchor', hasRight ? 'end' : (hasLeft || isHeader) ? 'start' : 'middle')
169+
.attr('text-anchor', hasRight ? 'end' : hasLeft ? 'start' : 'middle')
182170
.call(Drawing.font, font)
183171
.call(svgTextUtils.convertToTspans, gd);
184172

185173
pt.textBB = Drawing.bBox(sliceText.node());
186174
pt.transform = toMoveInsideSlice(pt, {
187-
fontSize: font.size,
188-
isHeader: isHeader
175+
fontSize: font.size
189176
});
190177
pt.transform.fontSize = font.size;
191178

src/traces/icicle/partition.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ var d3Hierarchy = require('d3-hierarchy');
55
module.exports = function partition(entry, size, opts) {
66
var flipX = opts.flipX;
77
var flipY = opts.flipY;
8-
var swapXY = opts.packing === 'dice-slice';
98

109
var result = d3Hierarchy
1110
.partition()
1211
.padding(opts.pad.inner)
13-
.size(
14-
swapXY ? [size[1], size[0]] : size
15-
)(entry);
12+
.size(size)(entry);
1613

17-
if(swapXY || flipX || flipY) {
14+
if(flipX || flipY) {
1815
flipTree(result, size, {
19-
swapXY: swapXY,
2016
flipX: flipX,
2117
flipY: flipY
2218
});
@@ -27,18 +23,6 @@ module.exports = function partition(entry, size, opts) {
2723
function flipTree(node, size, opts) {
2824
var tmp;
2925

30-
if(opts.swapXY) {
31-
// swap x0 and y0
32-
tmp = node.x0;
33-
node.x0 = node.y0;
34-
node.y0 = tmp;
35-
36-
// swap x1 and y1
37-
tmp = node.x1;
38-
node.x1 = node.y1;
39-
node.y1 = tmp;
40-
}
41-
4226
if(opts.flipX) {
4327
tmp = node.x0;
4428
node.x0 = size[0] - node.x1;

src/traces/icicle/plot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function plotOne(gd, cd, element, transitionOpts) {
307307
hasLeft ? -1 :
308308
hasRight ? 1 : 0;
309309

310-
var pad = trace.marker.pad;
310+
var pad = trace.tiling.pad;
311311
if(opts.isHeader) {
312312
x0 += pad.l - TEXTPAD;
313313
x1 -= pad.r - TEXTPAD;

0 commit comments

Comments
 (0)