plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.94k stars 1.86k forks source link

Plotly does not correctly redraw text items when updated through Plotly.react() #5360

Open rtwfroody opened 3 years ago

rtwfroody commented 3 years ago
  1. Open https://codepen.io/rtwfroody/pen/OJRxdMy, and you'll see a graph with the points labeled "one", "two", and "three".
  2. Hit the toggle checkbox, and the graph contents will change. Now only the first point is labeled. This is expected.
  3. Hit the toggle checkbox again. The code returns the graph to the exact same data as it started with, but the 2nd and 3rd points have no labels.
  4. No matter how many times you hit the checkbox, the original labels are never drawn.

This is a simple example of the issue I have in https://casualhacker.net/covid19-wealth. In that link, you can see that when you change the scale (see log checkboxes), then the labels are redrawn correctly.

Using layout.datarevision doesn't make things better.

alexcjohnson commented 3 years ago

Confirmed, thanks for the very simple, clear report @rtwfroody! A couple of observations while playing with this: The problem appears when a text entry is null or an empty string "" and then the point at the same index in the same trace is changed to have non-empty text. If instead you set the blank text entries to whitespace " " there's no problem. Also if the marker wasn't present in the first case (ie a null in the y array, or the second trace has more points than the first) there's no problem.

So as a workaround you may be able to use a whitespace string instead of null or completely blank, but this is definitely a bug we need to fix.

rtwfroody commented 3 years ago

That work-around works great. I'd tried null and "" and then gave up. Thanks.

gvwilson commented 3 months ago

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson