JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Plotly reversed-axis WebGL reproducer</title>
</head>
<body>
<h1>Plotly reversed-axis WebGL reproducer</h1>
<p>The initial plot should show a triangle. Click Redraw: it collapses into a vertical line.</p>
<button id="redraw" disabled>Redraw</button>
<p id="status">Loading Plotly 4.3.0...</p>
<div id="plot" style="width: 900px; height: 500px"></div>
<script src="https://cdn.plot.ly/plotly-4.3.0.min.js"></script>
<script>
const status = document.getElementById('status');
const button = document.getElementById('redraw');
const plot = document.getElementById('plot');
async function initialize() {
await Plotly.newPlot(plot, [{
type: 'scattergl',
mode: 'lines',
x: [2.06488, 2.007725, 1.95057],
y: [0, 1, 0],
}], {
xaxis: { autorange: 'reversed' }
});
status.textContent = `Plotly ${Plotly.version}: initial plot`;
button.disabled = false;
}
button.addEventListener('click', async () => {
button.disabled = true;
try {
await Plotly.redraw(plot);
status.textContent = `Plotly ${Plotly.version}: after redraw`;
} catch (error) {
status.textContent = `Redraw failed: ${error.message}`;
} finally {
button.disabled = false;
}
});
initialize().catch(error => {
status.textContent = error.message;
});
</script>
</body>
</html>