UID setted in go.Scatter is not passed to the .js

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

Hi @Mendes,

This is a known issue (See https://github.com/plotly/plotly.py/issues/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 https://github.com/plotly/plotly.py/pull/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

Thank you for the fast answer!

@jmmease, I just upgraded my plotly to version 3.10 but my python says:

ImportError: cannot import name 'trace_uids' from '_plotly_future_' (<path>/lib/python3.7/site-packages/_plotly_future_/__init__.py)

Is the version with this flag not available in pypi?

Hmm, it should be in there.

Can you double check what you get for

import plotly
print(plotly.__version__)

If that shows 3.10, can you double check that you don’t have plotly installed using both pip and conda?

-Jon

Damn, I feel dumb now…

I was in a different python env and didn’t noticed… :sweat_smile:

1 Like

Haha, No worries. Happens all the time. I’m constantly running !which python in my notebook to remind myself which environment I’m in :slightly_smiling_face:
-Jon

Hi,

I use Chart Studio, which is becoming unusable - because it chronically locks me out of my plots,
with the error: “parseSrcTag: no valid uids to retrieve”.
I can see my plots, but I cannot edit them.

The latest plot was created just 2 days ago:

    https://chart-studio.plotly.com/create/?fid=mls31416%3A112

Now I am faced with having to re-create my work - yet again.

This problem has existed for some time. Yet it continues.
Can you advise or restore access to my work?

Thank you.