如何在一个输入框的帮助下控制2个选项卡?示例如果输入框为空,则两个选项卡都会根据总数据生成图,但是如果输入被给出,则可以说雇员ID在输入框中给出,则两个选项卡的数据都将获得子集,并且图也会更新。
在这里,我希望使用破折号/烧瓶将2个选项卡链接到输入框。
app.layout = html.Div([dashboard,
html.Div(
dcc.Input(id='AgentID', type='text')),
html.Button('Submit', id='button'),
html.Div(id='output-tab'),
dcc.Tabs(id="tabs-example", value='tab-1-example',
children=[dcc.Tab(label='Summary', value='tab-1-example'),
dcc.Tab(label='Triggers', value='tab-2-example')
],
style={'fontsize':'20px','marginBottom':'0.5em',
'width':'98%','marginLeft':'12px'}),
html.Div(id='tabs-content-example',style={'width':'100%','height':'100%'}),
html.Div(id='tabs-content-
example1',style='marginTop':'-210px','backgroundColor':
'#E7E6E5','width':'100%','height':'50%'})
],style={'backgroundColor':
'#E7E6E5','position':'absolute','width':'100%','height':'120%'})
@app.callback(
dash.dependencies.Output('tabs-example', 'children'),
[dash.dependencies.Input('button', 'n_clicks')],
[dash.dependencies.State('AgentID', 'value')])
def update(n_clicks, value):
if n_clicks == None:
df = df2.copy()
else:
df = df2[df2['AGENT_ID'] == value]