dash-core-components
dash-core-components copied to clipboard
Config not changed by callback
cc @plotly/dash
This was uncovered in the dash community: https://community.plot.ly/t/remove-show-figure-modebar-programatically/12254
I can't see any reason why config wouldn't update like any other prop in dcc.Graph. This is how I've been testing it out, the dropdown should just remove the modebar by updating the config.
The only thing I can think of is the shape of config not being matched, but it works fine when you hardcode config in the dcc.Graph
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
app = dash.Dash()
app.layout = html.Div([
dcc.Dropdown(id='dropdown', options=[
{'label': 'Display Mode Bar', 'value': 'yes'},
{'label': 'Don\'t display Mode Bar', 'value': 'no'}
], value='yes'),
dcc.Graph(id='fig', figure=go.Figure(
data=[
go.Bar(x=['one', 'two', 'three'], y=[1, 2, 3])
]
))
])
@app.callback(
Output(component_id='fig', component_property='config'),
[Input(component_id='dropdown', component_property='value')]
)
def update_config(val):
if val == 'yes':
print('yes')
return {'displayModeBar': True}
else:
print('no')
return {'displayModeBar': False}
if __name__ == '__main__':
app.run_server()