Skip to content

Commit 4ba7551

Browse files
committed
add handleAnnotations method to scene proto
- call it when ticks require a change and when user drags and scroll on plot
1 parent b29b3b2 commit 4ba7551

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/plots/gl2d/camera.js

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ function createCamera(scene) {
113113
result.lastInputTime = Date.now();
114114
unSetAutoRange();
115115
scene.cameraChanged();
116+
scene.handleAnnotations();
116117
}
117118
break;
118119
}
@@ -152,6 +153,7 @@ function createCamera(scene) {
152153
result.lastInputTime = Date.now();
153154
unSetAutoRange();
154155
scene.cameraChanged();
156+
scene.handleAnnotations();
155157
break;
156158
}
157159

src/plots/gl2d/scene2d.js

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
'use strict';
1111

12+
var Registry = require('../../registry');
1213
var Axes = require('../../plots/cartesian/axes');
1314
var Fx = require('../../plots/cartesian/graph_interact');
1415

@@ -323,10 +324,25 @@ proto.cameraChanged = function() {
323324
this.glplotOptions.ticks = nextTicks;
324325
this.glplotOptions.dataBox = camera.dataBox;
325326
this.glplot.update(this.glplotOptions);
327+
this.handleAnnotations();
328+
326329
relayoutCallback(this);
327330
}
328331
};
329332

333+
proto.handleAnnotations = function() {
334+
var gd = this.graphDiv,
335+
annotations = this.fullLayout.annotations;
336+
337+
for(var i = 0; i < annotations.length; i++) {
338+
var ann = annotations[i];
339+
340+
if(ann.xref === this.xaxis._id && ann.yref === this.yaxis._id) {
341+
Registry.getComponentMethod('annotations', 'drawOne')(gd, i);
342+
}
343+
}
344+
};
345+
330346
proto.destroy = function() {
331347
var traces = this.traces;
332348

0 commit comments

Comments
 (0)