【发布时间】:2021-10-17 05:36:41
【问题描述】:
我是 Dash 的新手。我正在尝试使用daq.BooleanSwitch() 之类的输入来回调图形。我可以显示一条消息,但图表有问题。
有人有什么建议可以帮助我吗?
import dash
from dash.dependencies import Input, Output
import dash_daq as daq
import dash_html_components as html
app = dash.Dash(__name__)
app.layout = html.Div([
html.H1("Here we go"),
daq.BooleanSwitch(id='my_pb', on=False,color="red"),
html.Div(id='power-button-result-1'),
dcc.Graph(id="plot")
])
@app.callback(
Output('power-button-result-1', 'children'),
Input('my_pb', 'on')
)
def update_output(on):
x = '{}'.format(on)
if x == "True":
return "Hi Iḿ using DASH"
@app.callback(
Output('plot', 'figure'),
Input('my_pb', 'on')
)
def figura(on):
x = '{}'.format(on)
if x == "True":
# fig1 = Code to do a nice plot
return fig1
if __name__ == "__main__":
app.run_server(port = 1895)
我的 DASH 输出如下所示:
【问题讨论】:
标签: python plotly plotly-dash plotly-python