Skip to content

Commit 61076ce

Browse files
committed
Handle multiple subplots selection properly
1 parent 8133552 commit 61076ce

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/traces/scattergl/index.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -595,15 +595,27 @@ ScatterGl.scene = function getScene(container, subplot) {
595595

596596
// make sure canvas is clear
597597
scene.clear = function clear() {
598-
var vpSize = layout._size, width = layout.width, height = layout.height;
599-
var vp = [
600-
vpSize.l,
601-
vpSize.b,
602-
(width - vpSize.r),
603-
(height - vpSize.t)
604-
];
605-
606-
var gl, regl;
598+
var vpSize = layout._size, width = layout.width, height = layout.height, vp, gl, regl;
599+
var xaxis = subplot.xaxis;
600+
var yaxis = subplot.yaxis;
601+
602+
// multisubplot case
603+
if(xaxis && xaxis.domain && yaxis && yaxis.domain) {
604+
vp = [
605+
vpSize.l + xaxis.domain[0] * vpSize.w,
606+
vpSize.b + yaxis.domain[0] * vpSize.h,
607+
(width - vpSize.r) - (1 - xaxis.domain[1]) * vpSize.w,
608+
(height - vpSize.t) - (1 - yaxis.domain[1]) * vpSize.h
609+
];
610+
}
611+
else {
612+
vp = [
613+
vpSize.l,
614+
vpSize.b,
615+
(width - vpSize.r),
616+
(height - vpSize.t)
617+
];
618+
}
607619

608620
if(scene.select2d) {
609621
regl = scene.select2d.regl;

0 commit comments

Comments
 (0)