Hi,
I have been trying to use the chain callback’s code here with some modifications. However I cannot get it working with some small changes.
https://dash.plot.ly/getting-started-part-2
Attempting to assign a callback with
the property "value" but the component
"column-selection" doesn't have "value" as a property.
Here is a list of the available properties in "column-selection":
['id', 'options', 'values', 'className', 'style', 'inputStyle', 'inputClassName', 'labelStyle', 'labelClassName', 'loading_state']
on line 45
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
df = pd.read_pickle("hubs.p")
hubs = set(df.columns.get_level_values(0))
app.layout = html.Div([
html.Div([
html.Div([dcc.Dropdown(
id='hub-selection',
options=[{'label': i, 'value': i} for i in list(hubs)],
value='Malin'
)
],
style={'width': '48%', 'display': 'inline-block'}),
html.Div([dcc.Checklist(id='column-selection')],
style={'width': '48%', 'float': 'right', 'display': 'inline-block'})
]),
dcc.Graph(id='flow-graphic'),
])
@app.callback(
Output('column-selection', 'options'),
[Input('hub-selection', 'value')])
def set_column_options(selected_hub):
return [{'label': i, 'value': i} for i in list(df[selected_hub].columns)]
@app.callback(
Output('column-selection', 'value'),
[Input('column-selection', 'options')])
def set_column_value(available_columns):
return available_columns[0]['value']
@app.callback(
Output('flow-graphic', 'figure'),
[Input('hub-selection', 'value'),
Input('column-selection', 'value')])
def update_graph(hub_name, columns):
return {
'data': [go.Scatter(
x=df.index,
y=df[hub_name][columns],
mode='lines',
marker={
'size': 15,
'opacity': 0.5,
'line': {'width': 0.5, 'color': 'white'}
}
)]
}
if __name__ == '__main__':
app.run_server(debug=True)