8000 Issue 0179 by archmoj · Pull Request #3299 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Issue 0179 #3299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Nov 30, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
big prepration to solve floating issues
  • Loading branch information
archmoj committed Nov 27, 2018
commit bd8caf14b323a1267ffaa2a228cd953580a56ae2
116 changes: 58 additions & 58 deletions src/traces/surface/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,36 @@ function SurfaceTrace(scene, surface, uid) {

var proto = SurfaceTrace.prototype;

proto.getXat = function(a, b) {
return (!isArrayOrTypedArray(this.data.x)) ?
a :
(isArrayOrTypedArray(this.data.x[0])) ?
this.data.x[b][a] :
this.data.x[a];
proto.getXat = function(a, b, calendar, axis) {
var v = (
(!isArrayOrTypedArray(this.data.x)) ?
a :
(isArrayOrTypedArray(this.data.x[0])) ?
this.data.x[b][a] :
this.data.x[a]
);

return (!calendar) ? v : axis.d2l(v, 0, calendar);
};

proto.getYat = function(a, b, calendar, axis) {
var v = (
(!isArrayOrTypedArray(this.data.y)) ?
b :
(isArrayOrTypedArray(this.data.y[0])) ?
this.data.y[b][a] :
this.data.y[b]
);

return (!calendar) ? v : axis.d2l(v, 0, calendar);
};

proto.getYat = function(a, b) {
return (!isArrayOrTypedArray(this.data.y)) ?
b :
(isArrayOrTypedArray(this.data.y[0])) ?
this.data.y[b][a] :
this.data.y[b];
proto.getZat = function(a, b, calendar, axis) {
var v = (
this.data.z[b][a]
);

return (!calendar) ? v : axis.d2l(v, 0, calendar);
};

proto.handlePick = function(selection) {
Expand Down Expand Up @@ -318,28 +334,17 @@ proto.setContourLevels = function() {
};

proto.update = function(data) {
var i,
scene = this.scene,
var scene = this.scene,
sceneLayout = scene.fullSceneLayout,
surface = this.surface,
alpha = data.opacity,
colormap = parseColorScale(data.colorscale, alpha),
z = data.z,
x = data.x,
y = data.y,
xaxis = sceneLayout.xaxis,
yaxis = sceneLayout.yaxis,
zaxis = sceneLayout.zaxis,
scaleFactor = scene.dataScale,
xlen = z[0].length,
ylen = data._ylength,
coords = [
ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
ndarray(new Float32Array(xlen * ylen), [xlen, ylen])
],
xc = coords[0],
yc = coords[1],
contourLevels = scene.contourLevels;

// Save data
Expand All @@ -353,43 +358,38 @@ proto.update = function(data) {
* which is the transpose of 'gl-surface-plot'.
*/

var xcalendar = data.xcalendar,
ycalendar = data.ycalendar,
zcalendar = data.zcalendar;

fill(coords[2], function(row, col) {
return zaxis.d2l(z[col][row], 0, zcalendar) * scaleFactor[2];
});
var i, j, k;
var rawCoords = [];
for(i = 0; i < 3; i++) {
rawCoords[i] = [];
for(j = 0; j < xlen; j++) {
rawCoords[i][j] = [];
/*
for(k = 0; k < ylen; k++) {
rawCoords[i][j][k] = undefined;
}
*/
}
}

// coords x
if(!isArrayOrTypedArray(x)) {
fill(xc, function(row) {
return xaxis.d2l(row, 0, xcalendar) * scaleFactor[0];
});
} else if(isArrayOrTypedArray(x[0])) {
fill(xc, function(row, col) {
return xaxis.d2l(x[col][row], 0, xcalendar) * scaleFactor[0];
});
} else {
// ticks x
fill(xc, function(row) {
return xaxis.d2l(x[row], 0, xcalendar) * scaleFactor[0];
});
// coords x, y & z
for(j = 0; j < xlen; j++) {
for(k = 0; k < ylen; k++) {
rawCoords[0][j][k] = this.getXat(j, k, data.xcalendar, sceneLayout.xaxis) * scaleFactor[0];
rawCoords[1][j][k] = this.getYat(j, k, data.ycalendar, sceneLayout.yaxis) * scaleFactor[1];
rawCoords[2][j][k] = this.getZat(j, k, data.zcalendar, sceneLayout.zaxis) * scaleFactor[2];
}
}

// coords y
if(!isArrayOrTypedArray(x)) {
fill(yc, function(row, col) {
return yaxis.d2l(col, 0, xcalendar) * scaleFactor[1];
});
} else if(isArrayOrTypedArray(y[0])) {
fill(yc, function(row, col) {
return yaxis.d2l(y[col][row], 0, ycalendar) * scaleFactor[1];
});
} else {
// ticks y
fill(yc, function(row, col) {
return yaxis.d2l(y[col], 0, ycalendar) * scaleFactor[1];
var coords = [
ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
ndarray(new Float32Array(xlen * ylen), [xlen, ylen]),
ndarray(new Float32Array(xlen * ylen), [xlen, ylen])
];

for (i = 0; i < 3; i++) {
fill(coords[i], function(row, col) {
return rawCoords[i][row][col];
});
}

Expand Down
0