Skip to content

Commit 2686c46

Browse files
committed
Fix funnelarea, pie, sunburst and treemap tests
- also fixed parsing rotation and scale values from transform
1 parent 8784274 commit 2686c46

File tree

7 files changed

+78
-85
lines changed

7 files changed

+78
-85
lines changed

test/jasmine/tests/bar_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2817,9 +2817,9 @@ describe('bar uniformtext', function() {
28172817
var pos0 = transform.indexOf('scale(');
28182818
var scale = 1;
28192819
if(pos0 !== -1) {
2820-
pos0 += 'scale'.length;
2820+
pos0 += 'scale('.length;
28212821
var pos1 = transform.indexOf(')', pos0);
2822-
scale = +(transform.substring(pos0 + 1, pos1 - 1));
2822+
scale = +(transform.substring(pos0, pos1));
28232823
}
28242824

28252825
expect(opts.scales[i]).toBeCloseTo(scale, 1, 'scale for element ' + i, msg);

test/jasmine/tests/funnel_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,9 @@ describe('funnel uniformtext', function() {
16401640
var pos0 = transform.indexOf('scale(');
16411641
var scale = 1;
16421642
if(pos0 !== -1) {
1643-
pos0 += 'scale'.length;
1643+
pos0 += 'scale('.length;
16441644
var pos1 = transform.indexOf(')', pos0);
1645-
scale = +(transform.substring(pos0 + 1, pos1 - 1));
1645+
scale = +(transform.substring(pos0, pos1));
16461646
}
16471647

16481648
expect(opts.scales[i]).toBeCloseTo(scale, 1, 'scale for element ' + i, msg);

test/jasmine/tests/funnelarea_test.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -1741,9 +1741,9 @@ describe('funnelarea uniformtext', function() {
17411741
var pos0 = transform.indexOf('scale(');
17421742
var scale = 1;
17431743
if(pos0 !== -1) {
1744-
pos0 += 'scale'.length;
1744+
pos0 += 'scale('.length;
17451745
var pos1 = transform.indexOf(')', pos0);
1746-
scale = +(transform.substring(pos0 + 1, pos1 - 1));
1746+
scale = +(transform.substring(pos0, pos1));
17471747
}
17481748

17491749
expect(opts.scales[i]).toBeCloseTo(scale, 1, 'scale for element ' + i, msg);
@@ -1755,6 +1755,7 @@ describe('funnelarea uniformtext', function() {
17551755
var fig = {
17561756
data: [{
17571757
type: 'funnelarea',
1758+
baseratio: 1,
17581759
labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
17591760
values: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
17601761
sort: false,
@@ -1768,64 +1769,64 @@ describe('funnelarea uniformtext', function() {
17681769
'.',
17691770
'|',
17701771
'=',
1771-
'$',
1772-
'long lablel'
1772+
'longest word in German',
1773+
'Rindfleischetikettierungsueberwachungsaufgabenuebertragungsgesetz'
17731774
],
17741775

17751776
textinfo: 'text',
17761777
textangle: 0,
17771778
showlegend: false
17781779
}],
17791780
layout: {
1780-
width: 350,
1781-
height: 350
1781+
width: 450,
1782+
height: 450
17821783
}
17831784
};
17841785

17851786
Plotly.plot(gd, fig)
17861787
.then(assertTextSizes('without uniformtext', {
17871788
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
1788-
scales: [0.40, 1, 0.62, 0.70, 0.82, 0.98, 1, 0.91],
1789+
scales: [1, 1, 1, 1, 1, 1, 1, 0.69],
17891790
}))
17901791
.then(function() {
17911792
fig.layout.uniformtext = {mode: 'hide'}; // default with minsize=0
17921793
return Plotly.react(gd, fig);
17931794
})
17941795
.then(assertTextSizes('using mode: "hide"', {
17951796
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
1796-
scales: [0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4],
1797+
scales: [0.69, 0.69, 0.69, 0.69, 0.69, 0.69, 0.69, 0.69],
17971798
}))
17981799
.then(function() {
17991800
fig.layout.uniformtext.minsize = 9; // set a minsize less than trace font size
18001801
return Plotly.react(gd, fig);
18011802
})
18021803
.then(assertTextSizes('using minsize: 9', {
18031804
fontsizes: [12, 12, 12, 12, 12, 12, 12, 12],
1804-
scales: [0, 0.4, 0, 0, 0.4, 0.4, 0.4, 0.4],
1805+
scales: [0.69, 0.69, 0.69, 0.69, 0.69, 0.69, 0.69, 0],
18051806
}))
18061807
.then(function() {
18071808
fig.layout.uniformtext.minsize = 32; // set a minsize greater than trace font size
18081809
return Plotly.react(gd, fig);
18091810
})
18101811
.then(assertTextSizes('using minsize: 32', {
18111812
fontsizes: [32, 32, 32, 32, 32, 32, 32, 32],
1812-
scales: [0, 0.15, 0, 0, 0, 0, 0, 0],
1813+
scales: [0, 0.26, 0, 0, 0, 0, 0, 0],
18131814
}))
18141815
.then(function() {
1815-
fig.layout.uniformtext.minsize = 16; // set a minsize greater than trace font size
1816+
fig.layout.uniformtext.minsize = 13; // set a minsize greater than trace font size
18161817
return Plotly.react(gd, fig);
18171818
})
1818-
.then(assertTextSizes('using minsize: 16', {
1819-
fontsizes: [16, 16, 16, 16, 16, 16, 16, 16],
1820-
scales: [0, 0.3, 0, 0, 0, 0, 0.3, 0],
1819+
.then(assertTextSizes('using minsize: 13', {
1820+
fontsizes: [13, 13, 13, 13, 13, 13, 13, 13],
1821+
scales: [0.64, 0.64, 0.64, 0.64, 0.64, 0.64, 0.64, 0],
18211822
}))
18221823
.then(function() {
18231824
fig.layout.uniformtext.mode = 'show';
18241825
return Plotly.react(gd, fig);
18251826
})
18261827
.then(assertTextSizes('using mode: "show"', {
1827-
fontsizes: [16, 16, 16, 16, 16, 16, 16, 16],
1828-
scales: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3],
1828+
fontsizes: [13, 13, 13, 13, 13, 13, 13, 13],
1829+
scales: [0.64, 0.64, 0.64, 0.64, 0.64, 0.64, 0.64, 0.64],
18291830
}))
18301831
.catch(failTest)
18311832
.then(done);

test/jasmine/tests/pie_test.js

+18-21
Original file line numberDiff line numberDiff line change
@@ -1822,12 +1822,12 @@ describe('pie inside text orientation', function() {
18221822
var pos0 = transform.indexOf('rotate(');
18231823
var rotate = 0;
18241824
if(pos0 !== -1) {
1825-
pos0 += 'rotate'.length;
1825+
pos0 += 'rotate('.length;
18261826
var pos1 = transform.indexOf(')', pos0);
1827-
rotate = +(transform.substring(pos0 + 1, pos1 - 1));
1827+
rotate = +(transform.substring(pos0, pos1));
18281828
}
18291829

1830-
expect(opts.rotations[i]).toBeCloseTo(rotate, 1, 'rotation for element ' + i, msg);
1830+
expect(opts.rotations[i]).toBeCloseTo(rotate, -1, 'rotation for element ' + i, msg);
18311831
}
18321832
};
18331833
}
@@ -1836,18 +1836,15 @@ describe('pie inside text orientation', function() {
18361836
var fig = {
18371837
data: [{
18381838
type: 'pie',
1839-
labels: [1, 2, 4, 8, 16, 32, 64],
1840-
values: [1, 2, 4, 8, 16, 32, 64],
1839+
labels: [64, 32, 16, 8],
1840+
values: [64, 32, 16, 8],
18411841
sort: false,
18421842

18431843
text: [
1844-
'',
1845-
'1',
1846-
'22',
1847-
'333',
1848-
'4444',
1849-
'55555',
1850-
'666666',
1844+
'very long label',
1845+
'label',
1846+
'long label',
1847+
'+'
18511848
],
18521849

18531850
textinfo: 'text',
@@ -1862,35 +1859,35 @@ describe('pie inside text orientation', function() {
18621859

18631860
Plotly.plot(gd, fig)
18641861
.then(assertTextRotations('using default "auto"', {
1865-
rotations: [-2.83, 78.66, 61.65, 0, 0, 0]
1862+
rotations: [-84, 0, -30, 0]
18661863
}))
18671864
.then(function() {
18681865
fig.data[0].insidetextorientation = 'horizontal';
18691866
return Plotly.react(gd, fig);
18701867
})
18711868
.then(assertTextRotations('using "horizontal"', {
1872-
rotations: [0, 0, 0, 0, 0, 0]
1869+
rotations: [0, 0, 0, 0]
18731870
}))
18741871
.then(function() {
18751872
fig.data[0].insidetextorientation = 'radial';
18761873
return Plotly.react(gd, fig);
18771874
})
18781875
.then(assertTextRotations('using "radial"', {
1879-
rotations: [87.16, 78.66, 61.65, 27.64, -40.39, 0]
1876+
rotations: [0, 42, -30, -66]
18801877
}))
18811878
.then(function() {
18821879
fig.data[0].insidetextorientation = 'tangential';
18831880
return Plotly.react(gd, fig);
18841881
})
18851882
.then(assertTextRotations('using "tangential"', {
1886-
rotations: [-2.83, -11.34, -28.35, -62.36, 49.61, -86.46]
1883+
rotations: [-84, -48, 60, 24]
18871884
}))
18881885
.then(function() {
18891886
fig.data[0].insidetextorientation = 'auto';
18901887
return Plotly.react(gd, fig);
18911888
})
18921889
.then(assertTextRotations('back to "auto"', {
1893-
rotations: [-2.83, 78.66, 61.65, 0, 0, 0]
1890+
rotations: [-84, 0, -30, 0]
18941891
}))
18951892
.catch(failTest)
18961893
.then(done);
@@ -1926,9 +1923,9 @@ describe('pie uniformtext', function() {
19261923
var pos0 = transform.indexOf('scale(');
19271924
var scale = 1;
19281925
if(pos0 !== -1) {
1929-
pos0 += 'scale'.length;
1926+
pos0 += 'scale('.length;
19301927
var pos1 = transform.indexOf(')', pos0);
1931-
scale = +(transform.substring(pos0 + 1, pos1 - 1));
1928+
scale = +(transform.substring(pos0, pos1));
19321929
}
19331930

19341931
expect(opts.scales[i]).toBeCloseTo(scale, 1, 'scale for element ' + i, msg);
@@ -1951,7 +1948,7 @@ describe('pie uniformtext', function() {
19511948
'',
19521949
' ',
19531950
'.',
1954-
'|',
1951+
'+',
19551952
'=',
19561953
'$',
19571954
'very long lablel'
@@ -1994,7 +1991,7 @@ describe('pie uniformtext', function() {
19941991
})
19951992
.then(assertTextSizes('using minsize: 32', {
19961993
fontsizes: [32, 32, 32, 32, 32, 32, 32, 32],
1997-
scales: [0, 0.22, 0.22, 0.22, 0.22, 0, 0, 0],
1994+
scales: [0, 0.22, 0.22, 0.22, 0, 0, 0, 0],
19981995
}))
19991996
.then(function() {
20001997
fig.layout.uniformtext.minsize = 16; // set a minsize greater than trace font size

test/jasmine/tests/sunburst_test.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -1902,12 +1902,12 @@ describe('sunburst inside text orientation', function() {
19021902
var pos0 = transform.indexOf('rotate(');
19031903
var rotate = 0;
19041904
if(pos0 !== -1) {
1905-
pos0 += 'rotate'.length;
1905+
pos0 += 'rotate('.length;
19061906
var pos1 = transform.indexOf(')', pos0);
1907-
rotate = +(transform.substring(pos0 + 1, pos1 - 1));
1907+
rotate = +(transform.substring(pos0, pos1));
19081908
}
19091909

1910-
expect(opts.rotations[i]).toBeCloseTo(rotate, 1, 'rotation for element ' + i, msg);
1910+
expect(opts.rotations[i]).toBeCloseTo(rotate, -1, 'rotation for element ' + i, msg);
19111911
}
19121912
};
19131913
}
@@ -1916,21 +1916,21 @@ describe('sunburst inside text orientation', function() {
19161916
var fig = {
19171917
data: [{
19181918
type: 'sunburst',
1919-
parents: ['', '', '', '', '', '', ''],
1920-
labels: [64, 32, 16, 8, 4, 2, 1],
1921-
values: [64, 32, 16, 8, 4, 2, 1],
1919+
parents: ['', '', '', ''],
1920+
labels: [64, 32, 16, 8],
1921+
values: [64, 32, 16, 8],
1922+
sort: false,
19221923

19231924
text: [
1924-
'666666',
1925-
'55555',
1926-
'4444',
1927-
'333',
1928-
'22',
1929-
'1',
1930-
''
1925+
'very long label',
1926+
'label',
1927+
'long label',
1928+
'+'
19311929
],
19321930

1933-
textinfo: 'text'
1931+
textinfo: 'text',
1932+
textposition: 'inside',
1933+
showlegend: false
19341934
}],
19351935
layout: {
19361936
width: 300,
@@ -1940,35 +1940,35 @@ describe('sunburst inside text orientation', function() {
19401940

19411941
Plotly.plot(gd, fig)
19421942
.then(assertTextRotations('using default "auto"', {
1943-
rotations: [-0.71, 0, 0, 31.18, 14.17, -84.33, 0]
1943+
rotations: [-0.6, 0, 48, 0]
19441944
}))
19451945
.then(function() {
19461946
fig.data[0].insidetextorientation = 'horizontal';
19471947
return Plotly.react(gd, fig);
19481948
})
19491949
.then(assertTextRotations('using "horizontal"', {
1950-
rotations: [0, 0, 0, 0, 0, 0, 0]
1950+
rotations: [0, 0, 0, 0]
19511951
}))
19521952
.then(function() {
19531953
fig.data[0].insidetextorientation = 'radial';
19541954
return Plotly.react(gd, fig);
19551955
})
19561956
.then(assertTextRotations('using "radial"', {
1957-
rotations: [89.29, -46.77, 65.20, 31.18, 14.17, 5.67, 1.42]
1957+
rotations: [84, -60, 48, 12]
19581958
}))
19591959
.then(function() {
19601960
fig.data[0].insidetextorientation = 'tangential';
19611961
return Plotly.react(gd, fig);
19621962
})
19631963
.then(assertTextRotations('using "tangential"', {
1964-
rotations: [0, 43.23, -24.80, -58.81, -75.83, -84.33, -88.58]
1964+
rotations: [0, 0, -42, -78]
19651965
}))
19661966
.then(function() {
19671967
fig.data[0].insidetextorientation = 'auto';
19681968
return Plotly.react(gd, fig);
19691969
})
19701970
.then(assertTextRotations('back to "auto"', {
1971-
rotations: [-0.71, 0, 0, 31.18, 14.17, -84.33, 0]
1971+
rotations: [-0.6, 0, 48, 0]
19721972
}))
19731973
.catch(failTest)
19741974
.then(done);
@@ -2004,9 +2004,9 @@ describe('sunburst uniformtext', function() {
20042004
var pos0 = transform.indexOf('scale(');
20052005
var scale = 1;
20062006
if(pos0 !== -1) {
2007-
pos0 += 'scale'.length;
2007+
pos0 += 'scale('.length;
20082008
var pos1 = transform.indexOf(')', pos0);
2009-
scale = +(transform.substring(pos0 + 1, pos1 - 1));
2009+
scale = +(transform.substring(pos0, pos1));
20102010
}
20112011

20122012
expect(opts.scales[i]).toBeCloseTo(scale, 1, 'scale for element ' + i, msg);
@@ -2029,7 +2029,7 @@ describe('sunburst uniformtext', function() {
20292029
'',
20302030
' ',
20312031
'.',
2032-
'|',
2032+
'+',
20332033
'=',
20342034
'$',
20352035
'very long lablel'
@@ -2070,7 +2070,7 @@ describe('sunburst uniformtext', function() {
20702070
})
20712071
.then(assertTextSizes('using minsize: 32', {
20722072
fontsizes: [32, 32, 32, 32, 32, 32, 32, 32, 32, 32],
2073-
scales: [0, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0, 0, 0],
2073+
scales: [0, 0.22, 0.22, 0.22, 0.22, 0.22, 0, 0, 0, 0],
20742074
}))
20752075
.then(function() {
20762076
fig.layout.uniformtext.minsize = 16; // set a minsize greater than trace font size

0 commit comments

Comments
 (0)