Skip to content

Commit d3270c3

Browse files
committed
add geo dtick / tick0 jasmine test
1 parent 204a9d5 commit d3270c3

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

test/jasmine/tests/geo_test.js

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,13 @@ describe('Test event property of interactions on a geo plot:', function() {
14591459
});
14601460

14611461
describe('Test geo base layers', function() {
1462+
var gd;
1463+
1464+
beforeEach(function() { gd = createGraphDiv(); });
1465+
14621466
afterEach(destroyGraphDiv);
14631467

14641468
it('should clear obsolete features and layers on *geo.scope* relayout calls', function(done) {
1465-
var gd = createGraphDiv();
1466-
14671469
function _assert(geojson, layers) {
14681470
var cd0 = gd.calcdata[0];
14691471
var subplot = gd._fullLayout.geo._subplot;
@@ -1518,6 +1520,63 @@ describe('Test geo base layers', function() {
15181520
.catch(failTest)
15191521
.then(done);
15201522
});
1523+
1524+
it('should be able to relayout axis grid *tick0* / *dtick*', function(done) {
1525+
function findGridPath(axisName) {
1526+
return d3.select(gd).select(axisName + ' > path').attr('d');
1527+
}
1528+
1529+
function first(parts) {
1530+
return parts[1].split('L')[0].split(',').map(Number);
1531+
}
1532+
1533+
function _assert(msg, exp) {
1534+
var lonParts = findGridPath('.lonaxis').split('M');
1535+
var latParts = findGridPath('.lataxis').split('M');
1536+
1537+
expect(lonParts.length).toBe(exp.lonCnt, msg + ' - lonaxis grid segments');
1538+
expect(latParts.length).toBe(exp.latCnt, msg + ' - lataxis grid segments');
1539+
1540+
expect(first(lonParts)).toBeCloseToArray(exp.lon0, 1, msg + ' - first lonaxis grid pt');
1541+
expect(first(latParts)).toBeCloseToArray(exp.lat0, 1, msg + ' - first lataxis grid pt');
1542+
}
1543+
1544+
Plotly.plot(gd, [{type: 'scattergeo'}], {
1545+
geo: {
1546+
lonaxis: {showgrid: true},
1547+
lataxis: {showgrid: true}
1548+
}
1549+
})
1550+
.then(function() {
1551+
_assert('base', {
1552+
lonCnt: 12, lon0: [124.99, 369.99],
1553+
latCnt: 18, lat0: [80, 355]
1554+
});
1555+
})
1556+
.then(function() { return Plotly.relayout(gd, 'geo.lonaxis.tick0', 25); })
1557+
.then(function() {
1558+
_assert('w/ lonaxis.tick0:25', {
1559+
lonCnt: 12, lon0: [117.49, 369.99],
1560+
latCnt: 18, lat0: [80, 355]
1561+
});
1562+
})
1563+
.then(function() { return Plotly.relayout(gd, 'geo.lataxis.tick0', 41); })
1564+
.then(function() {
1565+
_assert('w/ lataxis.tick0:41', {
1566+
lonCnt: 12, lon0: [117.49, 369.99],
1567+
latCnt: 19, lat0: [80, 368.5]
1568+
});
1569+
})
1570+
.then(function() { return Plotly.relayout(gd, 'geo.lataxis.dtick', 45); })
1571+
.then(function() {
1572+
_assert('w/ lataxis.dtick0:45', {
1573+
lonCnt: 12, lon0: [117.49, 369.99],
1574+
latCnt: 5, lat0: [80, 308.5]
1575+
});
1576+
})
1577+
.catch(failTest)
1578+
.then(done);
1579+
});
15211580
});
15221581

15231582
describe('Test geo zoom/pan/drag interactions:', function() {

0 commit comments

Comments
 (0)