Skip to content

Avoid empty initial Plotly render - #637

Open
rosenrot00 wants to merge 1 commit into
dbuezas:masterfrom
rosenrot00:avoid-empty-initial-plot
Open

Avoid empty initial Plotly render#637
rosenrot00 wants to merge 1 commit into
dbuezas:masterfrom
rosenrot00:avoid-empty-initial-plot

Conversation

@rosenrot00

@rosenrot00 rosenrot00 commented Jul 30, 2026

Copy link
Copy Markdown
  • remove the empty Plotly.newPlot([], {}) call from the constructor
  • let the first real Plotly.react() initialize the plot with actual data and layout
  • defer Plotly event listeners until that first render succeeds
  • disconnect and reconnect Plotly listeners without duplicates
  • support the initial state where Plotly has not created contentEl.data yet

The constructor currently creates a complete empty Plotly graph. The first real render then runs Plotly.react() with the actual traces and layout, so initial card loading performs two Plotly render passes.

Plotly explicitly supports react() as an initial draw. When the target is not a plot div yet, it internally calls newPlot() with the supplied real data. Removing the empty render therefore keeps the same initialization path while avoiding the redundant first pass.

Listeners are attached only after the real plot exists and are guarded against duplicate registration and disconnected cards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant