Skip to content

python Scatter uid different from the data uid in .js #1635

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

Closed
Mendes11 opened this issue Jun 21, 2019 · 1 comment
Closed

python Scatter uid different from the data uid in .js #1635

Mendes11 opened this issue Jun 21, 2019 · 1 comment

Comments

@Mendes11
Copy link

Mendes11 commented Jun 21, 2019

Hi,

I’m currently creating an app that has a graph with stream update using extendTrace function.
The app creates multiples Scatters in python and then send the plot to a HTML page.

Since this app can graph N scatters, acconding to the variables the user adds. I need to identify each one in the .JS so I can update it.

So to identify each scatter, I add an uid to it:

scatters.append(go.Scatter(
        uid=f'{equipment_uuid}',
        x=input_df['timestamp'].tolist(),
        y=input_df['value'].tolist(),
        name=f'{equipment.name} - {input_name}',
    ))

I though it was enough to identify it in the JS but when I get the element with:

document.getElementById('graph').data
it lists all the graphs, but the uid is different from the one I setted in the python Scatter class…

Am I doing something wrong or is this a bug? Is there any other way to identify each scatter (except by the name which I don’t trust to use as a unique identifier)

Thanks

@jonmmease
Copy link
Contributor

From https://community.plot.ly/t/uid-setted-in-go-scatter-is-not-passed-to-the-js/24873/2


Hi @mendes,

This is a known issue (See #1512) that will be fixed in plotly.py version 4 (to be released in a the next month or so). You can opt-in to the new behavior with plotly.py 3.10 by activating the trace_uids future flag. See #1580.

Here's how that would look

from _plotly_future_ import trace_uids
import plotly.graph_objs as go
print(go.Figure(data=[go.Scatter(y=[1, 2, 3], uid='foo123')]))
Figure({
    'data': [{'type': 'scatter', 'uid': 'foo123', 'y': [1, 2, 3]}], 'layout': {}
})

Hope that helps!
-Jon

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