Hello everyone.
I have computed the following code:
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
from collections import defaultdict
import pandas as pd
import sysapp = dash.Dash()
app.config.suppress_callback_exceptions=True
df = pd.read_csv(‘https://gist.githubusercontent.com/jbrav/f281e0063418dd62ad63004671cf96ec/raw/86ca0f728bdcd0a10db99d81a7949374acba7c35/coma.csv’)
print df
available_funds = df[‘FUNDS’].unique()app.layout = html.Div([
html.Div([
html.Div([
html.H1(‘Evolucion rentabilidades’),
dcc.Dropdown(
id=‘mydropdown0’,
options= [
{‘label’: ‘SCHRODER’, ‘value’: ‘SCHRODER’},
{‘label’: ‘OPM’, ‘value’: ‘OPM’},
{‘label’: ‘MSF’, ‘value’: ‘MSF’}
],
value=‘MSF’,
multi=True),
dcc.Graph(id=‘graph0’),
]),
html.Div([
html.H1(‘Evolucion volatilidades’),
dcc.Dropdown(
id=‘mydropdown2’,
options= [
{‘label’: ‘MUM’, ‘value’: ‘MUM’},
{‘label’: ‘MAM’, ‘value’: ‘MAM’},
{‘label’: ‘MOM’, ‘value’: ‘MOM’},
],
value=‘MUM’,
multi=True),
dcc.Graph(id=‘graph2’)
]),html.Div([ html.H1('Ejemplo regresion'), dcc.Dropdown( id='mydropdown3', options= [ {'label': 'CLEP', 'value': 'CLEP'}, {'label': 'CLAP', 'value': 'CLAP'}, {'label': 'CLOP', 'value': 'CLOP'}, ], value='CLEP', multi=True), dcc.Graph( id='graph3') ]), ])])
@app.callback(
Output(‘graph0’,‘figure’), [Input(‘mydropdown0’, ‘value’)])
def update_graph0(selected_values):odf = df.ix[df['FUNDS'] == selected_values] return { 'data': [{ 'x': odf.YEAR, 'y': odf.QUANTITY }] }
@app.callback(
Output(‘graph2’,‘figure’), [Input(‘mydropdown2’, ‘value’)])
def update_graph2(selected_dropdown_value):
odf = df.ix[df[‘FUNDS’] == selected_dropdown_value]
return {
‘data’: [{
‘x’: odf.YEAR,
‘y’: odf.QUANTITY
}]
}@app.callback(
Output(‘graph3’,‘figure’), [Input(‘mydropdown3’, ‘value’)])
def update_graph3(selected_dropdown_value):
odf = df.ix[df[‘FUNDS’] == selected_dropdown_value]return { 'data': [{ 'x': odf['YEAR'], 'y': odf['QUANTITY'] }] }
app.css.append_css({
“external_url”: “https://codepen.io/chriddyp/pen/bWLwgP.css”})if name == ‘main’:
app.run_server(debug=True, port= 1000)
This works, however I do want to be able for the graphs to be updated at anytime that I select a value from the dropdown. Currently this is not happening, as I am only able to select one value. I suppose there is an easy way out of this but I am stuck. Any help?
thx