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

Dynamic Funnel Graph using React #39

Open
faizansdq opened this issue Mar 14, 2023 · 3 comments
Open

Dynamic Funnel Graph using React #39

faizansdq opened this issue Mar 14, 2023 · 3 comments

Comments

@faizansdq
Copy link

Hi greghub,

Thanks for building this amazing funnel graph library, this really helps in building funnel graphs easily.
I am experiencing the issue while drawing the graph using data from API. I can easily build the graph with static data, issue arises while using dynamic data.
I am writing FunnelGraph code within useEffect, where every time data changes the graph should be re-drawn using updated data. And the graph is re-drawn every time the data changes but it keeps overlapping on the previous graph.
Is there a method to clear previously drawn graph, so it doesn't overlap on the newly drawn graph? All the React examples that I have seen till now use only static data and only draw once.
Please help.

Thanks.

@Maximillion195
Copy link

Maximillion195 commented May 2, 2023

Add a ref the to inner div and in the useEffect before drawing the chart remove all the contents of the div

const funnel = useRef(null)

useEffect(() => {
    funnel.current.innerHTML = ''
    graph.draw
}, [update]

<div class="funnel" ref={funnel} />

@vinnie-j
Copy link

@faizansdq Do you have example code of how you integrated this library into a React component?

@DiyazY
Copy link

DiyazY commented Oct 22, 2024

@vinnie-j @faizansdq Hello! Have you made it work?

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

No branches or pull requests

4 participants