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

go.Figure clobbers user uids #1512

Closed
alexcjohnson opened this issue Apr 10, 2019 · 4 comments · Fixed by #1580
Closed

go.Figure clobbers user uids #1512

alexcjohnson opened this issue Apr 10, 2019 · 4 comments · Fixed by #1580

Comments

@alexcjohnson
Copy link
Collaborator

default usage of go.Figure does not allow users to enter uid for traces. That seems to be because it calls self._data_validator = DataValidator(set_uid=True) that triggers:

if self.set_uid:
for trace in v:
trace.uid = str(uuid.uuid4())

Can we override uid only if it wasn't set by the user?

Discovered while debugging https://community.plot.ly/t/preserving-ui-state-like-zoom-in-dcc-graph/15793/34

@alexcjohnson
Copy link
Collaborator Author

In fact for uirevision purposes it would be better if uid were never set (then as far as uirevision is concerned, the trace order becomes the uid). What was the purpose to include this in the first place?

@jonmmease
Copy link
Contributor

Thanks for tracking that down @alexcjohnson. The reason that the trace uid was being set on the Python side was to support the needs of FigureWidget. In this case the front end sends the default properties back to the Python side after every figure update and so plotly.py uses the uid to associate these updates with the proper trace. Trace index isn't enough because the updates are sent from JavaScript to Python asynchronously and so trace reordering could have occurred in the meantime.

But, I think we should be able to work out a way to only set the UID when traces are added to a FigureWidget instance. FigureWidget doesn't user react, so the uirevision considerations shouldn't be a factor there.

@alexcjohnson
Copy link
Collaborator Author

Ah, yes - would be great if only FigureWidget added uid, not Figure. That way Dash users wouldn't have to think about uid at all unless they want to preserve trace user interactions across reordered traces.

Even for FigureWidget I wonder if you could honor user-provided uid and only fill in missing ones, but there may not be an actual use case for that.

@jonmmease jonmmease added the V4 label Apr 10, 2019
@jonmmease
Copy link
Contributor

Alright if we take care of this for v4 (a couple of months out)? I think there is a small chance that this could be a breaking change for some applications built on top of plotly.py.

Even for FigureWidget I wonder if you could honor user-provided uid and only fill in missing ones, but there may not be an actual use case for that.

I think I was concerned that things would fail badly if a user ended up adding multiple traces with the same not-unique uid.

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 a pull request may close this issue.

2 participants