I’m trying to change clear_on_hover
with a BooleanSwitch
which does not work as expected.
Anyone knows why and how this could be accomplished?
from dash import Dash, dcc, html
import dash_bootstrap_components as dbc
import plotly.graph_objects as go
import numpy as np
import dash_daq as daq
from dash.dependencies import Input, Output
# figure
x, y = np.random.uniform(size=50), np.random.uniform(size=50)
fig = go.Figure(data=[go.Scattergl(x=x, y=y, mode='markers')])
# app
app = Dash()
# layout
app.layout = html.Div([
dcc.Graph(id='graph', figure=fig, clear_on_unhover=True),
daq.BooleanSwitch(id='switch-clear-on-hover', on=True)
])
@app.callback(Output('graph', 'clear_on_unhover'),
Input('switch-clear-on-hover', 'on'), prevent_initial_call=True)
def _toggle_clear_on_hover(on):
return on
if __name__ == "__main__":
app.run_server(debug=True)