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

Added Chart.update() functionality #14

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Added Chart.update() functionality #14

merged 3 commits into from
Jan 29, 2024

Conversation

Billy-Sheppard
Copy link
Owner

Example uses update on scatter chart.

@DDtKey
Copy link

DDtKey commented Jan 29, 2024

The API looks exactly the way I would like it to 🚀
Thank you for supporting this!

Just one question, is it possible to make to_chart(self) not self-consuming, i.e to_chart(&self)? (btw, it also corresponds to self-convertion clippy lint)

Of course, in any case, we serialize the data and send it to JS, but this makes it possible to avoid some extra allocations, for example, if I just want to add new data points, without building a new dataset and/or cloning

Not critical though, provided API in the PR is totally enough for my use-cases, thanks 🙏

@Billy-Sheppard
Copy link
Owner Author

The reason its not &self is to generally avoid having a version of the struct in rust out of sync with what was sent to the JS. E.g. in theory you should always run ChartExt::get() to get your chart every time you make a change, as things like render_mutate may or may not cause side effects after the fact. I suppose it should be into_chart() to fit with clippy.

@DDtKey
Copy link

DDtKey commented Jan 29, 2024

Makes sense to me

@Billy-Sheppard Billy-Sheppard merged commit 3b63bb9 into main Jan 29, 2024
2 checks passed
@Billy-Sheppard Billy-Sheppard deleted the update-func-v2 branch January 29, 2024 22:43
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.

2 participants