Skip to content

Commit 51d7e1b

Browse files
committed
add tests for updating text positions using different inside-text-position options
1 parent beed042 commit 51d7e1b

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed

test/jasmine/tests/sunburst_test.js

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,178 @@ describe('Test sunburst tweening:', function() {
13741374
.then(done);
13751375
});
13761376
*/
1377+
1378+
it('should update text position during transition using *auto* insidetextorientation', function(done) {
1379+
Plotly.plot(gd, {
1380+
data: [{
1381+
type: 'sunburst',
1382+
textinfo: 'label',
1383+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1384+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1385+
insidetextorientation: 'auto'
1386+
}]
1387+
})
1388+
.then(_run(gd, 4))
1389+
.then(function() {
1390+
_assert('move J text to new position', 'transform', 'J', [309.3085305481173, 202.66937078300114]);
1391+
_assert('move O text to new position', 'transform', 'O', [337.158534264498, 162.57550532369754]);
1392+
_assert('move U text to new position', 'transform', 'U', [416.1153793700712, 163.4078137147134]);
1393+
_assert('move V text to new position', 'transform', 'V', [471.63745793297295, 218.00377184475153]);
1394+
_assert('move W text to new position', 'transform', 'W', [455.10235209157037, 177.717459723826]);
1395+
_assert('move X text to new position', 'transform', 'X', [431.0320488371527, 145.88885474402548]);
1396+
_assert('move Y text to new position', 'transform', 'Y', [395.12660928295867, 124.11350635624726]);
1397+
_assert('move Z text to new position', 'transform', 'Z', [354.1550374068844, 115.63596810986363]);
1398+
})
1399+
.catch(failTest)
1400+
.then(done);
1401+
});
1402+
1403+
it('should update text position during transition using *horizontal* insidetextorientation', function(done) {
1404+
Plotly.plot(gd, {
1405+
data: [{
1406+
type: 'sunburst',
1407+
textinfo: 'label',
1408+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1409+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1410+
insidetextorientation: 'horizontal'
1411+
}]
1412+
})
1413+
.then(_run(gd, 4))
1414+
.then(function() {
1415+
_assert('move J text to new position', 'transform', 'J', [350, 185.9244172266002]);
1416+
_assert('move O text to new position', 'transform', 'O', [350.1640625, 162.2952497427013]);
1417+
_assert('move U text to new position', 'transform', 'U', [416.1153793700712, 163.4078137147134]);
1418+
_assert('move V text to new position', 'transform', 'V', [471.63745793297295, 218.00377184475153]);
1419+
_assert('move W text to new position', 'transform', 'W', [457.21539566810236, 178.44157384259557]);
1420+
_assert('move X text to new position', 'transform', 'X', [431.0320488371527, 145.88885474402548]);
1421+
_assert('move Y text to new position', 'transform', 'Y', [395.12660928295867, 124.11350635624726]);
1422+
_assert('move Z text to new position', 'transform', 'Z', [354.1550374068844, 115.63596810986363]);
1423+
})
1424+
.catch(failTest)
1425+
.then(done);
1426+
});
1427+
1428+
it('should update text position during transition using *tangential* insidetextorientation', function(done) {
1429+
Plotly.plot(gd, {
1430+
data: [{
1431+
type: 'sunburst',
1432+
textinfo: 'label',
1433+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1434+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1435+
insidetextorientation: 'tangential'
1436+
}]
1437+
})
1438+
.then(_run(gd, 4))
1439+
.then(function() {
1440+
_assert('move J text to new position', 'transform', 'J', [350, 185.9244172266002]);
1441+
_assert('move O text to new position', 'transform', 'O', [350.1640625, 162.3617907020963]);
1442+
_assert('move U text to new position', 'transform', 'U', [387.0665312800944, 146.39132446549587]);
1443+
_assert('move V text to new position', 'transform', 'V', [467.5637172232141, 214.71357776223093]);
1444+
_assert('move W text to new position', 'transform', 'W', [453.6883022471187, 176.23118240799604]);
1445+
_assert('move X text to new position', 'transform', 'X', [428.32070483274055, 145.007590714263]);
1446+
_assert('move Y text to new position', 'transform', 'Y', [393.6173101979463, 123.958130483835]);
1447+
_assert('move Z text to new position', 'transform', 'Z', [359.52567880729003, 116.05583257124167]);
1448+
})
1449+
.catch(failTest)
1450+
.then(done);
1451+
});
1452+
1453+
it('should update text position during transition using *radial* insidetextorientation', function(done) {
1454+
Plotly.plot(gd, {
1455+
data: [{
1456+
type: 'sunburst',
1457+
textinfo: 'label',
1458+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1459+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1460+
insidetextorientation: 'radial'
1461+
}]
1462+
})
1463+
.then(_run(gd, 4))
1464+
.then(function() {
1465+
_assert('move J text to new position', 'transform', 'J', [298.18238454231454, 239]);
1466+
_assert('move O text to new position', 'transform', 'O', [299.00421744782363, 183.7721980352468]);
1467+
_assert('move U text to new position', 'transform', 'U', [418.6530444037927, 162.19895218157865]);
1468+
_assert('move V text to new position', 'transform', 'V', [471.8671910181962, 218.0219264868202]);
1469+
_assert('move W text to new position', 'transform', 'W', [459.0093083790858, 178.21113754411613]);
1470+
_assert('move X text to new position', 'transform', 'X', [433.74669513154777, 144.8536840385141]);
1471+
_assert('move Y text to new position', 'transform', 'Y', [398.67767996405655, 121.9940236084775]);
1472+
_assert('move Z text to new position', 'transform', 'Z', [354.00770212095256, 116.19286557341015]);
1473+
})
1474+
.catch(failTest)
1475+
.then(done);
1476+
});
1477+
1478+
it('should update text position during transition using *radial* insidetextorientation with level', function(done) {
1479+
Plotly.plot(gd, {
1480+
data: [{
1481+
type: 'sunburst',
1482+
textinfo: 'label',
1483+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1484+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1485+
insidetextorientation: 'radial',
1486+
level: 'O',
1487+
}]
1488+
})
1489+
.then(_run(gd, 2))
1490+
.then(function() {
1491+
_assert('move U text to new position', 'transform', 'U', [317.71031126211744, 202.23522389350774]);
1492+
_assert('move V text to new position', 'transform', 'V', [444.88381073744586, 191.14358863479603]);
1493+
_assert('move W text to new position', 'transform', 'W', [365.5485731154604, 134.6827081871288]);
1494+
_assert('move X text to new position', 'transform', 'X', [277.7815763779703, 162.7705278345142]);
1495+
_assert('move Y text to new position', 'transform', 'Y', [247.47466543373307, 255.288278237516]);
1496+
_assert('move Z text to new position', 'transform', 'Z', [300.75324430542196, 332.0135787956955]);
1497+
})
1498+
.catch(failTest)
1499+
.then(done);
1500+
});
1501+
1502+
it('should update text position during transition using *tangential* insidetextorientation with level', function(done) {
1503+
Plotly.plot(gd, {
1504+
data: [{
1505+
type: 'sunburst',
1506+
textinfo: 'label',
1507+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1508+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1509+
insidetextorientation: 'tangential',
1510+
level: 'O',
1511+
}]
1512+
})
1513+
.then(_run(gd, 2))
1514+
.then(function() {
1515+
_assert('move U text to new position', 'transform', 'U', [313.79288001914836, 202.45694251914836]);
1516+
_assert('move V text to new position', 'transform', 'V', [441.011030377721, 188.63633201157208]);
1517+
_assert('move W text to new position', 'transform', 'W', [382.1346244328249, 135.0126788235936]);
1518+
_assert('move X text to new position', 'transform', 'X', [277.7815763779703, 162.7705278345142]);
1519+
_assert('move Y text to new position', 'transform', 'Y', [249.73412124927503, 271.78420776316403]);
1520+
_assert('move Z text to new position', 'transform', 'Z', [305.39156336654094, 331.3597434293286]);
1521+
})
1522+
.catch(failTest)
1523+
.then(done);
1524+
});
1525+
1526+
it('should update text position during transition using *horizontal* insidetextorientation with level', function(done) {
1527+
Plotly.plot(gd, {
1528+
data: [{
1529+
type: 'sunburst',
1530+
textinfo: 'label',
1531+
labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
1532+
parents: ['', 'A', 'A', 'C', 'C', 'C', 'F', 'F', 'F', 'F', 'J', 'J', 'J', 'J', 'J', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'U'],
1533+
insidetextorientation: 'horizontal',
1534+
level: 'O',
1535+
}]
1536+
})
1537+
.then(_run(gd, 2))
1538+
.then(function() {
1539+
_assert('move U text to new position', 'transform', 'U', [313.79288001914836, 202.45694251914836]);
1540+
_assert('move V text to new position', 'transform', 'V', [445.2341347726318, 190.47976534033592]);
1541+
_assert('move W text to new position', 'transform', 'W', [366.3829959511747, 133.44080859889465]);
1542+
_assert('move X text to new position', 'transform', 'X', [274.43577526068776, 163.42796276068773]);
1543+
_assert('move Y text to new position', 'transform', 'Y', [244.44862109889465, 255.71893345117468]);
1544+
_assert('move Z text to new position', 'transform', 'Z', [301.6438278403359, 334.2263222726318]);
1545+
})
1546+
.catch(failTest)
1547+
.then(done);
1548+
});
13771549
});
13781550

13791551
describe('Test sunburst interactions edge cases', function() {

0 commit comments

Comments
 (0)