diff --git a/src/traces/scattergl/index.js b/src/traces/scattergl/index.js index befc5e468f5..d10d12f5286 100644 --- a/src/traces/scattergl/index.js +++ b/src/traces/scattergl/index.js @@ -439,10 +439,17 @@ function plot(gd, subplot, cdata) { var pos = [], srcPos = (lineOptions && lineOptions.positions) || stash.positions; if(trace.fill === 'tozeroy') { - pos = [srcPos[0], 0]; - pos = pos.concat(srcPos); - pos.push(srcPos[srcPos.length - 2]); - pos.push(0); + var firstdef = 1; + while(isNaN(srcPos[firstdef])) { + firstdef += 2; + } + var lastdef = srcPos.length - 1; + while(isNaN(srcPos[lastdef])) { + lastdef += -2; + } + pos = [ srcPos[firstdef - 1], 0 ]; + pos = pos.concat(srcPos.slice(firstdef - 1, lastdef + 1)); + pos = pos.concat([ srcPos[lastdef - 1], 0 ]); } else if(trace.fill === 'tozerox') { pos = [0, srcPos[1]]; diff --git a/test/image/baselines/fill_trace.png b/test/image/baselines/fill_trace.png new file mode 100644 index 00000000000..5216439bd74 Binary files /dev/null and b/test/image/baselines/fill_trace.png differ diff --git a/test/image/mocks/fill_trace.json b/test/image/mocks/fill_trace.json new file mode 100644 index 00000000000..07a89ffbd3d --- /dev/null +++ b/test/image/mocks/fill_trace.json @@ -0,0 +1,52 @@ +{ + "data": [ + { + "x": [ + 1, + 2, + 3, + 4, + 5 + ], + "y": [ null + , + 100, + 100,null + ,null + ], + "type": "scattergl", + "fill": "tozeroy", + "mode": "none", + "showlegend": false, + "fillcolor": "#90ff70", + "line": { "color": "#90ff70" } + + }, + { + "x": [ + 1, + 2, + 3, + 4, + 5 + ], + "y": [null + ,null + ,null + , + 100, + 100 + ], + "type": "scattergl", + "fill": "tozeroy", + "mode": "none", + "showlegend": false, + "fillcolor": "#f02f20", + "line": { "color": "#f02f20" } + } + ], + "layout": { + "margin": {"l": 100, "r": 100, "t": 100, "b": 100}, + "yaxis": { "title": "Y axis 2 ", "type": "linear", "rangemode": "tozero", "nticks": 3 } + } +}