I am trying to build a dashboard, just copying one of the basic ones in Google Analytics. The aim of the game is to get a better understanding of dash.
A minimum working example.
import dash_html_components as html from dash.dependencies import Input, Output, State, Event app = dash.Dash('test setup') app.layout = html.Div([ html.Button([ html.Div([ html.Label('Users'), html.H4(10000) ], className='box')], id='userButton', className='button', value='Value 1' ), html.Button([ html.Div([ html.Label('Sessions'), html.H4(15000) ], className='box'),], id='sessionsButton', className='button', value='Value 2' ), html.Div(id='test_id') ,]) # This is very challenges occure @app.callback( Output('google_markup', 'children'), , [ State('userButton', 'value'), State('sessionsButton', 'value') ], [ Event('userButton', 'click'), Event('sessionsButton', 'click')] ) def update_id(state, state1): return 'The Values is: %s %s' % (state, state1)
So what happens is that on click it just prints out ‘Value1 Value2’. Which is not that surprising. What I would like it to do is
if userButton is clicked: output = 'Value 1' if sessionsButton is clicked: output = 'Value 2' return 'The value is: %s' % output
I hope that this makes some sense, I am trying to get data of a data frame and build a graph, what should update given the feature, and the reason I am using buttons is that I would like to have a summary on the button (if there is another approach, please let me know).
I think my confusion arises from not understanding the relations within the callback, hopefully someone can enlighten me.