Skip to content

Commit 212b144

Browse files
committed
using one space character instead of a blank string to avoid jumps during treemap transition
1 parent a1a2a2b commit 212b144

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Diff for: src/traces/treemap/draw_ancestors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) {
141141
s.attr('data-notex', 1);
142142
});
143143

144-
sliceText.text(pt._text)
144+
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
145145
.classed('slicetext', true)
146146
.attr('text-anchor', 'start')
147147
.call(Drawing.font, helpers.determineTextFont(trace, pt, fullLayout.font, trace.pathdir))

Diff for: src/traces/treemap/draw_descendants.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
157157
hovered: false
158158
});
159159

160-
if(pt.x0 === pt.x1 && pt.y0 === pt.y1) {
161-
pt._text = ' '; // use one space character instead of a blank string in this case
160+
if(pt.x0 === pt.x1 || pt.y0 === pt.y1) {
161+
pt._text = '';
162162
} else {
163163
if(isHeader) {
164164
pt._text = noRoomForHeader ? '' : helpers.getPtLabel(pt) || '';
@@ -174,7 +174,7 @@ module.exports = function drawDescendants(gd, cd, entry, slices, opts) {
174174
s.attr('data-notex', 1);
175175
});
176176

177-
sliceText.text(pt._text)
177+
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition
178178
.classed('slicetext', true)
179179
.attr('text-anchor', hasRight ? 'end' : (hasLeft || isHeader) ? 'start' : 'middle')
180180
.call(Drawing.font, helpers.determineTextFont(trace, pt, fullLayout.font))

Diff for: test/jasmine/tests/treemap_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ describe('Test treemap restyle:', function() {
10661066
.then(_restyle({textinfo: 'value'}))
10671067
.then(_assert('show input values', ['Root', 'B', '1', '3']))
10681068
.then(_restyle({textinfo: 'none'}))
1069-
.then(_assert('no textinfo', ['Root', 'B', '', '']))
1069+
.then(_assert('no textinfo', ['Root', 'B', ' ', ' '])) // use one space character instead of a blank string to avoid jumps during transition
10701070
.then(_restyle({textinfo: 'label+text+value'}))
10711071
.then(_assert('show everything', ['Root', 'B', 'A\n1\nnode1', 'b\n3\nnode3']))
10721072
.then(_restyle({textinfo: null}))

0 commit comments

Comments
 (0)