Skip to content

Commit 4520a21

Browse files
committed
plotly_relayouting for ternary plots
1 parent 4b0a0fd commit 4520a21

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/plots/ternary/ternary.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ proto.initInteractions = function() {
644644
.duration(200);
645645
dimmed = true;
646646
}
647+
648+
gd.emit('plotly_relayouting', makeUpdate(mins));
647649
}
648650

649651
function zoomDone() {
@@ -720,6 +722,8 @@ proto.initInteractions = function() {
720722
.select('.scatterlayer').selectAll('.trace')
721723
.call(Drawing.hideOutsideRangePoints, _this);
722724
}
725+
726+
gd.emit('plotly_relayouting', makeUpdate(mins));
723727
}
724728

725729
function dragDone() {

test/jasmine/tests/ternary_test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,33 @@ describe('ternary plots', function() {
514514
.then(done);
515515
});
516516

517+
describe('plotly_relayouting', function() {
518+
['pan', 'zoom'].forEach(function(dragmode) {
519+
it('should emit plotly_relayouting events on ' + dragmode, function(done) {
520+
var events = []; var path = [[350, 250], [375, 250], [375, 225]]; var relayoutCallback;
521+
var fig = Lib.extendDeep({}, require('@mocks/ternary_simple'));
522+
fig.layout.dragmode = dragmode;
523+
524+
var gd = createGraphDiv();
525+
Plotly.plot(gd, fig)
526+
.then(function() {
527+
relayoutCallback = jasmine.createSpy('relayoutCallback');
528+
gd.on('plotly_relayout', relayoutCallback);
529+
gd.on('plotly_relayouting', function(e) {
530+
events.push(e);
531+
});
532+
return drag(path);
533+
})
534+
.then(function() {
535+
expect(events.length).toEqual(path.length - 1);
536+
// expect(relayoutCallback).toHaveBeenCalledTimes(1);
537+
})
538+
.catch(failTest)
539+
.then(done);
540+
});
541+
});
542+
});
543+
517544
function countTernarySubplot() {
518545
return d3.selectAll('.ternary').size();
519546
}

0 commit comments

Comments
 (0)