Dash DAQ①(BooleanSwitchコンポーネント)

Dash DAQ

Dash DAQでは、データの収集・管理を行うコンポーネントを提供しています。

スイッチや計器に似た可視化ツールが用意されており、データを変化させる管理UIを作成できます。

Dash Enterprise - https://dash.plotly.com/dash-daq

BooleanSwitchコンポーネント

BooleanSwitchコンポーネントでは、オンとオフを切り替えるスイッチを表示します。

[ソースコード]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_daq as daq

app = dash.Dash(__name__)

app.layout = html.Div([
daq.BooleanSwitch(id='our-boolean-switch', on=False),
html.Div(id='boolean-switch-result')
])

@app.callback(
Output('boolean-switch-result', 'children'),
Input('our-boolean-switch', 'on')
)
def update_output(on):
return 'The switch is {}.'.format(on)

if __name__ == '__main__':
app.run_server(debug=True)

[ブラウザで表示]

スイッチを押すと、オンとオフを切り替えることができます。