You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When dynamically updating a pie chart, I encountered an issue where the available space for the pie chart does not update properly after changing the plot size.
For my setup, the plot is rendered using Plotly in a React app. The plot state is managed using useState() and the layout updates are triggered via useEffect() whenever a user changes the settings object (for plot width, height, font, etc). The update is performed like this:
Used versions are "plotly.js": "^3.0.0", "plotly.js-dist-min": "^3.0.1", "react-plotly.js": "^2.6.0".
Steps to reproduce the described bug:
Render a pie chart with segments [39,61]
Set the plot size to an incorrect size, e.g. width: 40, height: 255
Correct the plot size to valid values, e.g. width: 400, height: 255
Plot, before resizing:
Plot, after resizing as described:
The visible margins are now way larger than what is defined in the layout and much larger than necessary, since the pie chart could take up more space (like before). Changing the margins or plot size has no effect on the margins; only randomly increasing or decreasing the text size causes the plot to reset and render correctly.
It seems like the issue is related to the segment ratio: It only occurs when the pie segments are similar (e.g. [39, 61]), but not when they differ a lot (e.g. [10, 90]).
None of the approaches I came across online (such as Plotly.Plots.resize() or using the revision prop) solved this problem.
The text was updated successfully, but these errors were encountered:
When dynamically updating a pie chart, I encountered an issue where the available space for the pie chart does not update properly after changing the plot size.
For my setup, the plot is rendered using Plotly in a React app. The plot state is managed using
useState()
and the layout updates are triggered viauseEffect()
whenever a user changes the settings object (for plot width, height, font, etc). The update is performed like this:Used versions are "plotly.js": "^3.0.0", "plotly.js-dist-min": "^3.0.1", "react-plotly.js": "^2.6.0".
Steps to reproduce the described bug:
Plot, before resizing:

Plot, after resizing as described:

The visible margins are now way larger than what is defined in the layout and much larger than necessary, since the pie chart could take up more space (like before). Changing the margins or plot size has no effect on the margins; only randomly increasing or decreasing the text size causes the plot to reset and render correctly.
It seems like the issue is related to the segment ratio: It only occurs when the pie segments are similar (e.g. [39, 61]), but not when they differ a lot (e.g. [10, 90]).
None of the approaches I came across online (such as Plotly.Plots.resize() or using the revision prop) solved this problem.
The text was updated successfully, but these errors were encountered: