Plotly Dash:在输出中显示变量值



我正在尝试使用新冠肺炎数据集制作一个带有plotly Dash的仪表板,从这里可以获得:https://github.com/RamiKrispin/coronavirus-csv

现在,我想通过下拉菜单显示所选国家的摘要。但是,我不知道如何只显示变量值。

我这样做是为了总结如下:仅使用HTML 的摘要

html.Div([html.H1('Summary'),
html.Div([html.H2('Confirmed'), 
html.H2(t_confirmed)
], style = {'width': '30%','display': 'inline-block', 'border':'2px solid black', 'text-align' : 'center', 'font-family': 'Century Gothic'}),
html.Div([html.H2('Recovered'), 
html.H2(t_recovered)
], style = {'width': '30%','display': 'inline-block', 'border':'2px solid black', 'text-align' : 'center', 'font-family': 'Century Gothic'}),
html.Div([html.H2('Deaths'), 
html.H2(t_deaths)
], style = {'width': '30%','display': 'inline-block', 'border':'2px solid black', 'text-align' : 'center', 'font-family': 'Century Gothic'}),
], style = {'width': '50%','display': 'inline-block', 'vertical-align' : 'top', 'font-family' : 'Century Gothic'})

我想要的是,价值观应该根据所选的国家而变化。我有代码和函数,可以根据国家/地区将这些值返回给我。不知道如何展示它们。任何帮助都将不胜感激!

听起来您需要的是Dash回调。这些功能允许您在与组件交互时动态更改组件的外观。向下滚动,看看"多个输出"部分——这可能与你想要做的类似。希望这会有所帮助。

您可以在app.layouthtml标记中使用类似的f字符串,并在其中放入f'Total deaths: {variable_name}'

最新更新