dash-core-components icon indicating copy to clipboard operation
dash-core-components copied to clipboard

Config not changed by callback

Open charleyferrari opened this issue 6 years ago • 4 comments

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()

charleyferrari avatar Aug 03 '18 22:08 charleyferrari