8000 Fix log error bars · plotly/plotly.js@9911ba8 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9911ba8

Browse files
dyetpinard
authored andcommitted
Fix log error bars
1 parent 9f9f512 commit 9911ba8

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

src/traces/scattergl/index.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi
233233
var count = positions.length / 2;
234234
var markerOpts = trace.marker;
235235
var i, ptrX = 0, ptrY = 0;
236+
var xaxis = Axes.getFromId(container, trace.xaxis);
237+
var yaxis = Axes.getFromId(container, trace.yaxis);
236238

237239
var hasLines, hasErrorX, hasErrorY, hasError, hasMarkers, hasFill;
238240

@@ -263,18 +265,26 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi
263265
errorXOptions.positions = positions;
264266
var errorsX = new Float64Array(4 * count);
265267

266-
for(i = 0; i < count; ++i) {
267-
errorsX[ptrX++] = positions[i * 2] - errorVals[i].xs || 0;
268-
errorsX[ptrX++] = errorVals[i].xh - positions[i * 2] || 0;
269-
errorsX[ptrX++] = 0;
270-
errorsX[ptrX++] = 0;
268+
if(xaxis.type === 'log') {
269+
for(i = 0; i < count; ++i) {
270+
errorsX[ptrX++] = positions[i * 2] - xaxis.d2l(errorVals[i].xs) || 0;
271+
errorsX[ptrX++] = xaxis.d2l(errorVals[i].xh) - positions[i * 2] || 0;
272+
errorsX[ptrX++] = 0;
273+
errorsX[ptrX++] = 0;
274+
}
275+
} else {
276+
for(i = 0; i < count; ++i) {
277+
errorsX[ptrX++] = positions[i * 2] - errorVals[i].xs || 0;
278+
errorsX[ptrX++] = errorVals[i].xh - positions[i * 2] || 0;
279+
errorsX[ptrX++] = 0;
280+
errorsX[ptrX++] = 0;
281+
}
271282
}
272283

273284
if(trace.error_x.copy_ystyle) {
274285
trace.error_x = trace.error_y;
275286
}
276287

277-
errorXOptions.positions = positions;
278288
errorXOptions.errors = errorsX;
279289
errorXOptions.capSize = trace.error_x.width * 2;
280290
errorXOptions.lineWidth = trace.error_x.thickness;
@@ -286,14 +296,22 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi
286296
errorYOptions.positions = positions;
287297
var errorsY = new Float64Array(4 * count);
288298

289-
for(i = 0; i < count; ++i) {
290-
errorsY[ptrY++] = 0;
291-
errorsY[ptrY++] = 0;
292-
errorsY[ptrY++] = positions[i * 2 + 1] - errorVals[i].ys || 0;
293-
errorsY[ptrY++] = errorVals[i].yh - positions[i * 2 + 1] || 0;
299+
if(yaxis.type === 'log') {
300+
for(i = 0; i < count; ++i) {
301+
errorsY[ptrY++] = 0;
302+
errorsY[ptrY++] = 0;
303+
errorsY[ptrY++] = positions[i * 2 + 1] - yaxis.d2l(errorVals[i].ys) || 0;
304+
errorsY[ptrY++] = yaxis.d2l(errorVals[i].yh) - positions[i * 2 + 1] || 0;
305+
}
306+
} else {
307+
for(i = 0; i < count; ++i) {
308+
errorsY[ptrY++] = 0;
309+
errorsY[ptrY++] = 0;
310+
errorsY[ptrY++] = positions[i * 2 + 1] - errorVals[i].ys || 0;
311+
errorsY[ptrY++] = errorVals[i].yh - positions[i * 2 + 1] || 0;
312+
}
294313
}
295314

296-
errorYOptions.positions = positions;
297315
errorYOptions.errors = errorsY;
298316
errorYOptions.capSize = trace.error_y.width * 2;
299317
errorYOptions.lineWidth = trace.error_y.thickness;
20.4 KB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"data": [{
3+
"type": "scattergl",
4+
"y": [10, 2e4, 5e6],
5+
"error_y": {"array": [5, 1e4, 4e6]}
6+
}],
7+
"layout": {
8+
"yaxis": {"type": "log"}
9+
}
10+
}

0 commit comments

Comments
 (0)
0