Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 429c6fd

Browse files
committed
Simple attempt at non-scaling points
1 parent cc9c0d3 commit 429c6fd

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/lib/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,27 @@ lib.setScale = function(element, x, y) {
484484
return transform;
485485
};
486486

487+
lib.setPointScale = function(selection, x, y) {
488+
x = x || 1;
489+
y = y || 1;
490+
491+
// The same scale transform for every point:
492+
var scale = ' scale(' + x + ',' + y + ')';
493+
494+
// A regex to strip any existing scale:
495+
var re = /sc.*/;
496+
497+
selection.each(function(p) {
498+
// Get the transform:
499+
var t = this.getAttribute('transform').replace(re,'');
500+
501+
// Append the scale transform
502+
this.setAttribute('transform', t + scale);
503+
});
504+
505+
return scale;
506+
};
507+
487508
lib.isIE = function() {
488509
return typeof window.navigator.msSaveBlob !== 'undefined';
489510
};

src/plots/cartesian/dragbox.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,10 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
633633

634634
subplot.plot
635635
.call(Lib.setTranslate, plotDx, plotDy)
636-
.call(Lib.setScale, xScaleFactor, yScaleFactor);
636+
.call(Lib.setScale, xScaleFactor, yScaleFactor)
637+
.selectAll('.points').selectAll('.point')
638+
.call(Lib.setPointScale, 1 / xScaleFactor, 1 / yScaleFactor);
639+
637640
}
638641
}
639642

0 commit comments

Comments
 (0)