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

Skip to content

Commit 82d4bcc

Browse files
committed
adapt gl2d to findExtremes
1 parent 2a745de commit 82d4bcc

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

src/plots/cartesian/autorange.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,12 @@ function concatExtremes(gd, ax, ext) {
196196

197197
var fullData = gd._fullData;
198198

199-
// should be general enough for 3d, polar etc.
200-
201199
for(i = 0; i < fullData.length; i++) {
202200
var trace = fullData[i];
203201
var extremes = trace._extremes;
204202

205203
if(trace.visible === true) {
206-
if(Registry.traceIs(trace, 'cartesian')) {
204+
if(Registry.traceIs(trace, 'cartesian') || Registry.traceIs(trace, 'gl2d')) {
207205
var axId = ax._id;
208206
if(extremes[axId]) {
209207
out = out.concat(extremes[axId][ext]);

src/plots/gl2d/scene2d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ proto.plot = function(fullData, calcData, fullLayout) {
441441
ax = this[AXES[i]];
442442
ax._length = options.viewBox[i + 2] - options.viewBox[i];
443443

444-
doAutoRange(ax);
444+
doAutoRange(this.graphDiv, ax);
445445
ax.setScale();
446446
}
447447

src/traces/contourgl/convert.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ proto.update = function(fullTrace, calcTrace) {
125125
this.contour.update(this.contourOptions);
126126
this.heatmap.update(this.heatmapOptions);
127127

128-
// expand axes
129-
Axes.expand(this.scene.xaxis, calcPt.x);
130-
Axes.expand(this.scene.yaxis, calcPt.y);
128+
var xa = this.scene.xaxis;
129+
var ya = this.scene.yaxis;
130+
fullTrace._extremes[xa._id] = Axes.findExtremes(xa, calcPt.x);
131+
fullTrace._extremes[ya._id] = Axes.findExtremes(ya, calcPt.y);
131132
};
132133

133134
proto.dispose = function() {

src/traces/heatmapgl/convert.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ proto.update = function(fullTrace, calcTrace) {
9595

9696
this.heatmap.update(this.options);
9797

98-
Axes.expand(this.scene.xaxis, calcPt.x);
99-
Axes.expand(this.scene.yaxis, calcPt.y);
98+
var xa = this.scene.xaxis;
99+
var ya = this.scene.yaxis;
100+
fullTrace._extremes[xa._id] = Axes.findExtremes(xa, calcPt.x);
101+
fullTrace._extremes[ya._id] = Axes.findExtremes(ya, calcPt.y);
100102
};
101103

102104
proto.dispose = function() {

src/traces/pointcloud/convert.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
var createPointCloudRenderer = require('gl-pointcloud2d');
1212

1313
var str2RGBArray = require('../../lib/str2rgbarray');
14-
var expandAxis = require('../../plots/cartesian/autorange').expand;
14+
var findExtremes = require('../../plots/cartesian/autorange').findExtremes;
1515
var getTraceColor = require('../scatter/get_trace_color');
1616

1717
function Pointcloud(scene, uid) {
@@ -195,14 +195,11 @@ proto.updateFast = function(options) {
195195
this.pointcloud.update(this.pointcloudOptions);
196196

197197
// add item for autorange routine
198-
this.expandAxesFast(bounds, markerSizeMax / 2); // avoid axis reexpand just because of the adaptive point size
199-
};
200-
201-
proto.expandAxesFast = function(bounds, markerSize) {
202-
var pad = markerSize || 0.5;
203-
204-
expandAxis(this.scene.xaxis, [bounds[0], bounds[2]], {ppad: pad});
205-
expandAxis(this.scene.yaxis, [bounds[1], bounds[3]], {ppad: pad});
198+
var xa = this.scene.xaxis;
199+
var ya = this.scene.yaxis;
200+
var pad = markerSizeMax / 2 || 0.5;
201+
options._extremes[xa._id] = findExtremes(xa, [bounds[0], bounds[2]], {ppad: pad});
202+
options._extremes[ya._id] = findExtremes(ya, [bounds[1], bounds[3]], {ppad: pad});
206203
};
207204

208205
proto.dispose = function() {

0 commit comments

Comments
 (0)