Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What event signals that the chart is finished rendering? #1586

Closed
kindunq opened this issue Jun 25, 2024 · 2 comments
Closed

What event signals that the chart is finished rendering? #1586

kindunq opened this issue Jun 25, 2024 · 2 comments

Comments

@kindunq
Copy link

kindunq commented Jun 25, 2024

Question

I searched for
I thought I was using "frameended", but I'm not.

If it's a word cloud chart, it's called as many times as there are words.

Am I using it wrong?

 const drawChart = useCallback(() => {
    if (id) {
      root.current = am5.Root.new(`wordCloud_${id}`);
      
      const container = root.current.container.children.push(
        am5.Container.new(root.current, {
          width: am5.percent(100),
          height: am5.percent(100),
          layout: root.current.verticalLayout,
        })
      );

      root.current.events.on("frameended", readyFunction); <===== issue

      series.data.setAll(search);
    }
  }, [id, themes, search, color, selected]);

  useEffect(() => {
    if (root.current) root.current.dispose();
    drawChart();

    return () => {
      if (root.current) {
        root.current.dispose();
        root.current = null;
      }
    };
  }, [drawChart, id]);

Environment (if applicable)

Additional context

@martynasma
Copy link
Collaborator

There is no specific event to mark completion of WordCloud rendering.

The only workaround I can think of is to use frameended event. You can debounce the handler so it does not kick in until framended events stop triggering, e.g.:

var to;
root.events.on("frameended", () => {
  if (to) {
    clearTimeout(to);
  }
  to = setTimeout(() => {
    readyFunction();
  }, 500);
});

Copy link

This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.

@github-actions github-actions bot added the stale label Jul 26, 2024
@zeroin zeroin closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants