A scatter fillgradient with start or stop has four problems in plotly.js 4.1.0. All four come from the user-space branch of setFillStyle in src/components/drawing/index.js.
Case 1, before and after Plotly.relayout(gd, {'yaxis.range': [0, 10]}). The fill must be red above y = 2 in both images:
All four cases on 4.1.0, from the test case below. Case 2 and case 4 draw a black fill because the style step throws:
Copy the following code in JSFiddle or JSbin, or save it as HTML and open it in Chrome:
<script src="https://cdn.plot.ly/plotly-4.1.0.js"></script>
<div id="zoom" style="width:500px;height:350px"></div>
<div id="y2" style="width:500px;height:350px"></div>
<div id="log" style="width:500px;height:350px"></div>
<div id="radial" style="width:500px;height:350px"></div>
<script>
const cs = [[0, 'blue'], [0.5, 'blue'], [0.5, 'red'], [1, 'red']];
// 1. Expected: red above y = 2 after the relayout. Actual: no red.
Plotly.newPlot('zoom', [{
x: [0, 1, 2], y: [0, 4, 0], fill: 'tozeroy',
fillgradient: { type: 'vertical', start: 0, stop: 4, colorscale: cs }
}], { yaxis: { range: [0, 5] } })
.then(gd => Plotly.relayout(gd, { 'yaxis.range': [0, 10] }));
// 2. Expected: red above y2 = 2. Actual: TypeError (reading 'max').
Plotly.newPlot('y2', [
{ y: [1, 2] },
{ y: [1, 3, 2], yaxis: 'y2', fill: 'tozeroy',
fillgradient: { type: 'vertical', start: 1, colorscale: cs } }
], { yaxis2: { overlaying: 'y', side: 'right' } }).catch(console.error);
// 3. Expected: red above y = 10, half way between 1 and 100 on the log axis. Actual: almost all red.
Plotly.newPlot('log', [{
y: [1, 100, 10], fill: 'toself',
fillgradient: { type: 'vertical', start: 1, colorscale: cs }
}], { yaxis: { type: 'log' } });
// 4. Expected: a radial gradient. Actual: TypeError (reading 'x').
Plotly.newPlot('radial', [{
y: [1, 3, 2], fill: 'tozeroy',
fillgradient: { type: 'radial', start: 1, colorscale: cs }
}]).catch(console.error);
</script>
Description
Found while implementing #8093
A scatter fillgradient with start or stop has four problems in plotly.js 4.1.0. All four come from the user-space branch of setFillStyle in
src/components/drawing/index.js.TypeError: Cannot read properties of undefined (reading 'max'), and the plot does not draw.TypeError: Cannot read properties of undefined (reading 'x').Screenshots/Video
Case 1, before and after Plotly.relayout(gd, {'yaxis.range': [0, 10]}). The fill must be red above y = 2 in both images:
All four cases on 4.1.0, from the test case below. Case 2 and case 4 draw a black fill because the style step throws:
Steps to reproduce
Copy the following code in JSFiddle or JSbin, or save it as HTML and open it in Chrome:
Notes