Skip to content

fix: apply data and layout changes made while the plot is initializing - #374

Open
RaphaelFakhri wants to merge 1 commit into
plotly:v20from
RaphaelFakhri:fix/apply-changes-during-init
Open

RaphaelFakhri wants to merge 1 commit into
plotly:v20from
RaphaelFakhri:fix/apply-changes-during-init

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

PlotlyComponent drops [data] and [layout] changes made while Plotly.newPlot is still pending, for example while plotly.js loads from a CDN. ngDoCheck consumes the differ's diff but skips updatePlot() because plotlyInstance is not set yet, so the chart keeps showing the initial input.

This change records the skipped update and applies it once the plot is created.

Fixes #373

Changes

  • ngDoCheck sets a pending flag when it detects a change before plotlyInstance exists.
  • createPlot() calls updatePlot() after initialization when the flag is set.
  • Adds a spec that changes data while newPlot is pending and expects one update after it resolves.

Testing

  • ng test plotly --watch=false --browsers ChromeHeadless: the new spec fails without the fix (1 of 50 failed) and passes with it (50 of 50).
  • npm run lint, npm test, and npm run build:demo pass.

This targets v20, the oldest affected maintained branch, as described in MAINTENANCE.md. The commit cherry-picks cleanly onto master.

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