Skip to content

Conversation

@elalemanyo
Copy link

This PR fixes Issue #22, where charts were being initialized multiple times on the same DOM element. This caused unexpected behavior, duplicate event listeners, and unnecessary memory usage.

✅ What’s changed

  • Added a guard using getInstanceByDom to check whether a chart instance already exists on the target DOM element.
  • Prevents duplicate initialization when the page re-renders (e.g., Turbo/Stimulus reconnect).
  • Ensures charts behave consistently across navigation events.

🧪 Why this works

ECharts recommends using lib.getInstanceByDom(chartDom) to detect existing instances. If an instance exists, we skip initialization, avoiding the “double init” problem.

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