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

Question about updateData #39

Closed
td43 opened this issue Jun 18, 2020 · 2 comments
Closed

Question about updateData #39

td43 opened this issue Jun 18, 2020 · 2 comments

Comments

@td43
Copy link

td43 commented Jun 18, 2020

Hi, I am testing your code and is working with 'extendData' which is fine if I want to add more points to the same graph, my question is if there is a way that I could use your code to update the data instead of appending new data since I have been doing an "updating" in my graph each time creating a new figure which is time-consuming, so your code looks really good for what I want to do. So, to summarize, is there a way where I could use your code to just update a graph?

@bcliang
Copy link
Owner

bcliang commented Jun 18, 2020

Hi there. Unfortunately this is not supported at the moment, and not supported within the PlotlyJS, which is what this component is a wrapper for. In this component, extending trace data is achieved by calling PlotlyJS' built-in method extendTraces. In cases where it's a new trace we use the method addTraces.

To perform a data update operation, there is no "updateTraces" method available in the library. I believe the approach that would need to be taken is:

  1. Persist selected trace data in memory
  2. Delete selected trace via deleteTraces API
  3. Add trace in the same position via addTraces API

In the case of a single trace within the figure, this is equivalent to what you are doing right now (redrawing the entire figure each time). The above approach will be faster if you are only updating a single trace, though.

I'll think about how to support it. I think the use case is something that potentially would be useful to a lot of people. It may be easier to add a feature request to Plotly for something like adding a newupdateTraceData or replaceTraceData method that can meet your use case. plotly.js repo. You could also make the feature request directly to the dash-core-components.

@td43
Copy link
Author

td43 commented Jun 19, 2020

Hi, thanks for the reply answer. I will try to follow your approach to see what happens, thanks!

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

2 participants