Skip to content

Commit 2cb5687

Browse files
committed
sunburst handle no text when using various inside-text-orientation options
1 parent d1b50b1 commit 2cb5687

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/traces/sunburst/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ function plotOne(gd, cd, element, transitionOpts) {
151151
var pathSlice = function(d) { return Lib.pathAnnulus(d.rpx0, d.rpx1, d.x0, d.x1, cx, cy); };
152152
// slice text translate x/y
153153

154-
var getTargetX = function(d) { return cx + getTextXY(d)[0] * d.transform.rCenter + (d.transform.x || 0); };
155-
var getTargetY = function(d) { return cy + getTextXY(d)[1] * d.transform.rCenter + (d.transform.y || 0); };
154+
var getTargetX = function(d) { return cx + getTextXY(d)[0] * (d.transform.rCenter || 0) + (d.transform.x || 0); };
155+
var getTargetY = function(d) { return cy + getTextXY(d)[1] * (d.transform.rCenter || 0) + (d.transform.y || 0); };
156156

157157
slices = slices.data(sliceData, helpers.getPtId);
158158

test/jasmine/tests/sunburst_test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ describe('Test sunburst restyle:', function() {
10671067
.then(done);
10681068
});
10691069

1070-
it('should be able to restyle *textinfo*', function(done) {
1070+
it('should be able to restyle *textinfo* with various *insidetextorientation*', function(done) {
10711071
var mock = {
10721072
data: [{
10731073
type: 'sunburst',
@@ -1121,6 +1121,27 @@ describe('Test sunburst restyle:', function() {
11211121
.then(_assert('show everything', ['Root\n0\nnode0', 'B\n2\nnode2', 'A\n1\nnode1', 'b\n3\nnode3']))
11221122
.then(_restyle({textinfo: null}))
11231123
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1124+
// now change insidetextorientation to 'horizontal'
1125+
.then(_restyle({insidetextorientation: 'horizontal'}))
1126+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1127+
.then(_restyle({textinfo: 'none'}))
1128+
.then(_assert('no textinfo', ['', '', '', '']))
1129+
.then(_restyle({textinfo: null}))
1130+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1131+
// now change insidetextorientation to 'tangential'
1132+
.then(_restyle({insidetextorientation: 'tangential'}))
1133+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1134+
.then(_restyle({textinfo: 'none'}))
1135+
.then(_assert('no textinfo', ['', '', '', '']))
1136+
.then(_restyle({textinfo: null}))
1137+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1138+
// now change insidetextorientation to 'radial'
1139+
.then(_restyle({insidetextorientation: 'radial'}))
1140+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
1141+
.then(_restyle({textinfo: 'none'}))
1142+
.then(_assert('no textinfo', ['', '', '', '']))
1143+
.then(_restyle({textinfo: null}))
1144+
.then(_assert('back to dflt', ['Root\nnode0', 'B\nnode2', 'A\nnode1', 'b\nnode3']))
11241145
.catch(failTest)
11251146
.then(done);
11261147
});

0 commit comments

Comments
 (0)