diff --git a/src/plots/ternary/ternary.js b/src/plots/ternary/ternary.js index b9895cacae5..96d7587f275 100644 --- a/src/plots/ternary/ternary.js +++ b/src/plots/ternary/ternary.js @@ -169,7 +169,9 @@ proto.makeFramework = function() { _this.plotContainer.selectAll('.backplot,.frontplot,.grids') .call(Drawing.setClipUrl, clipId); - _this.initInteractions(); + if(!_this.graphDiv._context.staticPlot) { + _this.initInteractions(); + } }; var w_over_h = Math.sqrt(4 / 3); diff --git a/test/jasmine/tests/ternary_test.js b/test/jasmine/tests/ternary_test.js index cadc1762911..bf631dfd54d 100644 --- a/test/jasmine/tests/ternary_test.js +++ b/test/jasmine/tests/ternary_test.js @@ -186,11 +186,10 @@ describe('ternary plots', function() { it('should respond zoom drag interactions', function(done) { assertRange(gd, [0.231, 0.2, 0.11]); - Plotly.relayout(gd, 'ternary.aaxis.min', 0.1).then(function() { - assertRange(gd, [0.1, 0.2, 0.11]); + drag([[390, 220], [300, 250]]); + assertRange(gd, [0.4486, 0.2480, 0.1453]); - return doubleClick(pointPos[0], pointPos[1]); - }).then(function() { + doubleClick(pointPos[0], pointPos[1]).then(function() { assertRange(gd, [0, 0, 0]); done(); @@ -198,6 +197,35 @@ describe('ternary plots', function() { }); }); + describe('static plots', function() { + var mock = require('@mocks/ternary_simple.json'); + var gd; + + beforeEach(function(done) { + gd = createGraphDiv(); + + var mockCopy = Lib.extendDeep({}, mock); + var config = { staticPlot: true }; + + Plotly.plot(gd, mockCopy.data, mockCopy.layout, config).then(done); + }); + + it('should not respond to drag', function(done) { + var range = [0.231, 0.2, 0.11]; + + assertRange(gd, range); + + drag([[390, 220], [300, 250]]); + assertRange(gd, range); + + doubleClick(390, 220).then(function() { + assertRange(gd, range); + + done(); + }); + }); + }); + function countTernarySubplot() { return d3.selectAll('.ternary').size(); } @@ -227,6 +255,19 @@ describe('ternary plots', function() { }); } + function drag(path) { + var len = path.length; + + mouseEvent('mousemove', path[0][0], path[0][1]); + mouseEvent('mousedown', path[0][0], path[0][1]); + + path.slice(1, len).forEach(function(pt) { + mouseEvent('mousemove', pt[0], pt[1]); + }); + + mouseEvent('mouseup', path[len - 1][0], path[len - 1][1]); + } + function assertRange(gd, expected) { var ternary = gd._fullLayout.ternary; var actual = [