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
The visible='legendonly' doesn't work anymore in Scatermapbox.
When adding a trace with a visible value 'legendonly' , the trace is added to the legend. However the trace doesn't appear when the legend item is activated. Also when there are multiple traces added with one trace visible='legendonly' and the other traces visible=True, then you can only turn on/off the visible=True traces when the visible='legendonly' trace is de-activated.
Expected behavior
visible='legendonly' will add a trace to the legend. After that you will be able to turn on/off the trace.
Screenshots
If applicable, add screenshots or screen recording to help explain your problem.
Example
from plotly import graph_objs as go
import dash
from dash import dcc
from dash import html
lat_center = 52.1009166
lon_center = 5.6462914
zoom = 8
lat1_coord = [52.0, 52.2]
lon1_coord = [5.6, 5.7]
lat2_coord = [51.9, 52.0]
lon2_coord = [5.6, 5.7]
fig1 = go.Figure()
fig1.update_layout(
mapbox = dict(
style = "open-street-map",
zoom = zoom,
center = dict(
lat = lat_center,
lon = lon_center
)
),
showlegend = True)
#Trace visible='legendonly'
fig1.add_traces(
go.Scattermapbox(
lat = lat1_coord,
lon = lon1_coord,
mode='lines',
line = dict(
color = 'red',
width = 2),
visible ='legendonly'
)
)
#Trace visible=True
fig1.add_traces(
go.Scattermapbox(
lat = lat2_coord,
lon = lon2_coord,
mode =' lines',
line = dict(
color = 'blue',
width = 2),
visible = True
)
)
app = dash.Dash(__name__)
app.layout = html.Div(
dcc.Graph(
id = 'map_tiles',
figure = fig1
)
)
host = "127.0.0.1"
port = "8050"
DEBUG = True
if __name__ == "__main__":
app.run_server(host=host, port=port, debug = DEBUG,use_reloader=False)
The text was updated successfully, but these errors were encountered:
Hermeij
changed the title
[BUG] visible ='legendonly' doesn't work anymore in Scattermapbox
visible ='legendonly' doesn't work anymore in Scattermapbox
Feb 18, 2023
Thanks @Hermeij - this is a problem in plotly.js, I will move the issue over there. Both parts of the problem you identified are visible in this codepen: https://codepen.io/alexcjohnson/pen/BaORKpj?editors=0010: whenever the map tried to render with the blue line displayed it throws the error: Uncaught (in promise) Error: There is already a source with this ID
Describe your context
I installed a complete new Anaconda/Spyder environment on Windows 10. After that visible='legendonly' doesn't work anymore.
pip list | grep dash
belowif frontend related, tell us your Browser, Version and OS
Describe the bug
The visible='legendonly' doesn't work anymore in Scatermapbox.
When adding a trace with a visible value 'legendonly' , the trace is added to the legend. However the trace doesn't appear when the legend item is activated. Also when there are multiple traces added with one trace visible='legendonly' and the other traces visible=True, then you can only turn on/off the visible=True traces when the visible='legendonly' trace is de-activated.
Expected behavior
visible='legendonly' will add a trace to the legend. After that you will be able to turn on/off the trace.
Screenshots
If applicable, add screenshots or screen recording to help explain your problem.
Example
The text was updated successfully, but these errors were encountered: