Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Config not changed by callback #252

Open
@charleyferrari

Description

@charleyferrari

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dash-type-bugSomething isn't working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions