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

How to add/del series dynamically and add data to one series dynamically #962

Open
mulgurul opened this issue Jul 1, 2024 · 1 comment

Comments

@mulgurul
Copy link

mulgurul commented Jul 1, 2024

Hi

Again thank you for a fantastic performant graph package.

I'm using uPlot with the uPlot react wrapper (skalinichev/uplot-wrappers#32)
I have a need for adding/deleting series to a graph dynamically, and in real time adding data to one of the series, and I'm wondering what the best approach would be.
I can update the data and option props on the component which seems to re-render the graph, but it also resets things like graph selection in the legend, and often i get uPlot errors "cannot read .. of undefined" which seems to be related to axis generation, see this issue . The wrapped uPlot may be very sensitive to what is added first; series og data, or maybe these errors is related to some other problem down the pipe.

I'm looking at the sample "stream-data.html". Here the series are predefined in options, and data added using u.setData. I need to avoid complete recreation of the chart so I guess this is the only option compared to updating a React data state used as property to the chart!
And same with series, here I need to call add/del series methods, and I really miss an updateSeries method or a way to connect series with data by "key" instead of indexed which makes managing a dynamic array of series/data really a pain. Or is there a better approach to these requirements?

Thanks in advance.

@mulgurul
Copy link
Author

mulgurul commented Jul 5, 2024

I added a new issues related to the exceptions I have seen. So this "issue" is now more a question about "best practice".
FYI: I struggled hard to get a implementation in place using the API methods, but it got really messy because of the indexing management, and lack of a way to update/delete by a key which can be mapped to React state values.
So I gave up on this mode, and went back to using props.

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

1 participant