You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#35 requested support for a "sorted" extend #39 asked about updating data within a trace
Unfortunately, the plotly.js graphing library doesn't support this type of "data update". In both cases, the feature could be implemented on the callback side provided there is/was a way to replace (or just delete) an existing trace.
Make updates/modifications to the trace in question:
..
# add new values to x,y and sort by xdata_unsorted=zip(data[0]['x'].extend(new_x_values), data[0]['y'].extend(new_y_values))
data_sorted=sorted(data_unsorted, key=lambdax: x[0])
# map results to independent lists to be used in the callback outputx_new, y_new=map(list, zip(*data_sorted))
Do something like
delete the existing trace, add a new one to the figure (replace a trace)
delete the existing trace, add a new one with the same trace index (update existing trace)
In the above case, it may be better to go with update in order to support preserving the trace order for the figure (for future indexing)
Considerations
Could implement support for this within the extendData callback, and possibly rename it to a more general name e.g. updateData. Pros: It already supports specifying the trace index. In this implementation, I suppose there would be an additional input allowing the user to specify whether to extend, replace, or just delete a trace. Cons: complexity increases
Could implement separate props the explicitly implements delete, replace, and/or update functions. Pros: simpler to test, easier to implement each prop on its own. Cons: More difficult on the dash-side to perform required operations (e.g. if logic flows in such a way that some conditions require update, others require extend, and still others require delete)
While we're at it, what about implementing a prependData prop / adding it to the extendData prop? Plotly.prependTraces() exists, and this is a special case for updating a trace. I'm sure there's a use case, though no one has explicitly requested it.
To get a better sense of actual use case(s), prototype something similar within a PR made to dash-core-components
Requires
Decide on which use case(s) to support via new/existing props.
Ensure that figure.data contains the latest trace information. I'm not sure but it's possible that when using the extendData callback that figure.data isn't immediately updated.
Add functionality for Plotly.deleteTraces()
The text was updated successfully, but these errors were encountered:
@hxse, which use case do you have in mind? I have not been working on this feature as I have been loaded with work. If you can describe what you need, that would help make a decision on how to implement the above. If it's a small use case it might be easier to do a partial implementation (e.g just creating an additional prop specifically for prependData, deleteTrace or insertTrace)
Background
#35 requested support for a "sorted" extend
#39 asked about updating data within a trace
Unfortunately, the plotly.js graphing library doesn't support this type of "data update". In both cases, the feature could be implemented on the callback side provided there is/was a way to replace (or just delete) an existing trace.
Imagined use-case within a callback:
In the above case, it may be better to go with update in order to support preserving the trace order for the figure (for future indexing)
Considerations
extendData
callback, and possibly rename it to a more general name e.g.updateData
. Pros: It already supports specifying the trace index. In this implementation, I suppose there would be an additional input allowing the user to specify whether to extend, replace, or just delete a trace. Cons: complexity increasesprependData
prop / adding it to theextendData
prop?Plotly.prependTraces()
exists, and this is a special case for updating a trace. I'm sure there's a use case, though no one has explicitly requested it.Requires
The text was updated successfully, but these errors were encountered: