Skip to content

Commit e43e8c1

Browse files
committed
remove dataCenter var so zeroline shows at 0
1 parent 183b4b9 commit e43e8c1

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

src/plots/gl3d/layout/tick_marks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function computeTickMarks(scene) {
4949
if (Math.abs(axes._length) === Infinity) {
5050
ticks[i] = [];
5151
} else {
52-
axes.range[0] = (glRange[i].lo + scene.dataCenter[i]) / scene.dataScale[i];
53-
axes.range[1] = (glRange[i].hi + scene.dataCenter[i]) / scene.dataScale[i];
52+
axes.range[0] = (glRange[i].lo) / scene.dataScale[i];
53+
axes.range[1] = (glRange[i].hi) / scene.dataScale[i];
5454
axes._m = 1.0 / (scene.dataScale[i] * glRange[i].pixelsPerDataUnit);
5555

5656
if(axes.range[0] === axes.range[1]) {
@@ -69,7 +69,7 @@ function computeTickMarks(scene) {
6969
}
7070
var dataTicks = Plotly.Axes.calcTicks(axes);
7171
for(var j=0; j<dataTicks.length; ++j) {
72-
dataTicks[j].x = dataTicks[j].x * scene.dataScale[i] - scene.dataCenter[i];
72+
dataTicks[j].x = dataTicks[j].x * scene.dataScale[i];
7373
dataTicks[j].text = convertHTML(dataTicks[j].text);
7474
}
7575
ticks[i] = dataTicks;

src/plots/gl3d/scene.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ function Scene(options, fullLayout) {
218218

219219
//Coordinate rescaling
220220
this.dataScale = [1,1,1];
221-
this.dataCenter = [0,0,0];
222221

223222
this.contourLevels = [ [], [], [] ];
224223

@@ -334,24 +333,20 @@ proto.plot = function(sceneData, fullLayout, layout) {
334333
computeTraceBounds(this, data, dataBounds);
335334
}
336335
var dataScale = [1,1,1];
337-
var dataCenter = [0,0,0];
338336
for(var j=0; j<3; ++j) {
339337
if(dataBounds[0][j] > dataBounds[1][j]) {
340338
dataScale[j] = 1.0;
341-
dataCenter[j] = 0.0;
342339
} else {
343340
if(dataBounds[1][j] === dataBounds[0][j]) {
344341
dataScale[j] = 1.0;
345342
} else {
346343
dataScale[j] = 1.0/(dataBounds[1][j] - dataBounds[0][j]);
347344
}
348-
dataCenter[j] = 0.5 * (dataBounds[0][j] + dataBounds[1][j]) * dataScale[j];
349345
}
350346
}
351347

352348
//Save scale and offset factors
353349
this.dataScale = dataScale;
354-
this.dataCenter = dataCenter;
355350

356351
//Update traces
357352
for(var i = 0; i < sceneData.length; ++i) {
@@ -422,9 +417,9 @@ trace_id_loop:
422417
for(j = 0; j < this.glplot.objects.length; ++j) {
423418
var objBounds = this.glplot.objects[j].bounds;
424419
sceneBounds[0][i] = Math.min(sceneBounds[0][i],
425-
(objBounds[0][i] + dataCenter[i]) / dataScale[i]);
420+
objBounds[0][i] / dataScale[i]);
426421
sceneBounds[1][i] = Math.max(sceneBounds[1][i],
427-
(objBounds[1][i] + dataCenter[i]) / dataScale[i]);
422+
objBounds[1][i] / dataScale[i]);
428423
}
429424
if('rangemode' in axis && axis.rangemode === 'tozero') {
430425
sceneBounds[0][i] = Math.min(sceneBounds[0][i], 0);
@@ -450,8 +445,8 @@ trace_id_loop:
450445
axisDataRange[i] = sceneBounds[1][i] - sceneBounds[0][i];
451446

452447
//Update plot bounds
453-
this.glplot.bounds[0][i] = sceneBounds[0][i] * dataScale[i] - dataCenter[i];
454-
this.glplot.bounds[1][i] = sceneBounds[1][i] * dataScale[i] - dataCenter[i];
448+
this.glplot.bounds[0][i] = sceneBounds[0][i] * dataScale[i];
449+
this.glplot.bounds[1][i] = sceneBounds[1][i] * dataScale[i];
455450
}
456451

457452
var axesScaleRatio = [1, 1, 1];

src/traces/scatter3d/convert.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ function convertPlotlyOptions(scene, data) {
169169
points = [],
170170
sceneLayout = scene.fullSceneLayout,
171171
scaleFactor = scene.dataScale,
172-
offset = scene.dataCenter,
173172
xaxis = sceneLayout.xaxis,
174173
yaxis = sceneLayout.yaxis,
175174
zaxis = sceneLayout.zaxis,
@@ -184,9 +183,9 @@ function convertPlotlyOptions(scene, data) {
184183
//Convert points
185184
for (i = 0; i < len; i++) {
186185
// sanitize numbers and apply transforms based on axes.type
187-
xc = xaxis.d2l(x[i]) * scaleFactor[0] - offset[0];
188-
yc = yaxis.d2l(y[i]) * scaleFactor[1] - offset[1];
189-
zc = zaxis.d2l(z[i]) * scaleFactor[2] - offset[2];
186+
xc = xaxis.d2l(x[i]) * scaleFactor[0];
187+
yc = yaxis.d2l(y[i]) * scaleFactor[1];
188+
zc = zaxis.d2l(z[i]) * scaleFactor[2];
190189

191190
points[i] = [xc, yc, zc];
192191
}

src/traces/surface/convert.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ proto.handlePick = function(selection) {
5252

5353
var sceneLayout = this.scene.fullSceneLayout;
5454
selection.dataCoordinate = [
55-
sceneLayout.xaxis.d2l(traceCoordinate[0])*this.scene.dataScale[0] - this.scene.dataCenter[0],
56-
sceneLayout.yaxis.d2l(traceCoordinate[1])*this.scene.dataScale[1] - this.scene.dataCenter[1],
57-
sceneLayout.zaxis.d2l(traceCoordinate[2])*this.scene.dataScale[2] - this.scene.dataCenter[2]
55+
sceneLayout.xaxis.d2l(traceCoordinate[0])*this.scene.dataScale[0],
56+
sceneLayout.yaxis.d2l(traceCoordinate[1])*this.scene.dataScale[1],
57+
sceneLayout.zaxis.d2l(traceCoordinate[2])*this.scene.dataScale[2]
5858
];
5959

6060
var text = this.data.text;
@@ -165,7 +165,6 @@ proto.update = function(data) {
165165
yaxis = sceneLayout.yaxis,
166166
zaxis = sceneLayout.zaxis,
167167
scaleFactor = scene.dataScale,
168-
offset = scene.dataCenter,
169168
xlen = z[0].length,
170169
ylen = z.length,
171170
coords = [
@@ -188,30 +187,30 @@ proto.update = function(data) {
188187
* which is the transpose of 'gl-surface-plot'.
189188
*/
190189
fill(coords[2], function(row, col) {
191-
return zaxis.d2l(z[col][row]) * scaleFactor[2] - offset[2];
190+
return zaxis.d2l(z[col][row]) * scaleFactor[2];
192191
});
193192

194193
// coords x
195194
if (Array.isArray(x[0])) {
196195
fill(xc, function(row, col) {
197-
return xaxis.d2l(x[col][row]) * scaleFactor[0] - offset[0];
196+
return xaxis.d2l(x[col][row]) * scaleFactor[0];
198197
});
199198
} else {
200199
// ticks x
201200
fill(xc, function(row) {
202-
return xaxis.d2l(x[row]) * scaleFactor[0] - offset[0];
201+
return xaxis.d2l(x[row]) * scaleFactor[0];
203202
});
204203
}
205204

206205
// coords y
207206
if (Array.isArray(y[0])) {
208207
fill(yc, function(row, col) {
209-
return yaxis.d2l(y[col][row]) * scaleFactor[1] - offset[1];
208+
return yaxis.d2l(y[col][row]) * scaleFactor[1];
210209
});
211210
} else {
212211
// ticks y
213212
fill(yc, function(row, col) {
214-
return yaxis.d2l(y[col]) * scaleFactor[1] - offset[1];
213+
return yaxis.d2l(y[col]) * scaleFactor[1];
215214
});
216215
}
217216

0 commit comments

Comments
 (0)