Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active March 26, 2021 09:42
Show Gist options
  • Save tkfm-yamaguchi/b82db0e8c96e5387a7be6242e2969746 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/b82db0e8c96e5387a7be6242e2969746 to your computer and use it in GitHub Desktop.
Plotly.react() doesn't work properly when mode is 'markers+text'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>text test</title>
</head>
<body>
<button id="btn">Toggle text</button>
<div id="app" style="width: 600px; height: 250px;"></div>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const elem = document.getElementById('app');
Plotly.newPlot(elem,
[
{
type: 'scatter',
x: [1,2,3,4,5],
y: [1,2,4,8,16],
mode: 'markers+text' // NOT WORKS
// mode: 'markers' // WORKS
}
],
{
margin: { t: 0 }
}
);
document.getElementById('btn').addEventListener('click', () => {
Plotly.react(elem,
[
{
type: 'scatter',
x: [1,2,4,8,16],
y: [1,2,4,8,16],
mode: 'markers+text',
text: ['abc','abc','abc','abc','abc']
}
],
{
margin: { t: 0 }
}
);
})
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment