Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Dash Interval and Callback - 60 year old noob needs help understanding

$
0
0

Once upon a time I was a fortran programmer, but I changed and became a communications tech for most of my career. Now that I’ve retired I’m looking to recapture the joy of programming but I’m having some difficulty getting going. I created a simple plot with 6 gauges and it works perfect displaying the values out of a data file that I created with python. Now I’d like to have it update by re-reading the data file once every 5 seconds and displaying the current values.
I know I need to use dcc.Interval, then trigger the update, and have callback but my old brain just isn’t getting it.

Here is a simplified segment of my current code.
Imports

app = Dash (name)

df = pd.read_csv("datafile.csv)

vext = df.at[0,‘ext’]
vint = df.at[0,‘int’]

layout **************************************

app.layout = dbc.Container([
dbc.row([
dbc.Col([
daq.Gauge(id=‘my_gauge_ext’,
label={‘label’:‘Ext’, ‘style’:{‘font-size’:‘30px’}},
showCurrentValue=True,
value=vext,
max=250,
min=100
)
daq.Gauge(id=‘my_gauge_int’,
label={‘label’:‘Int’, ‘style’:{‘font-size’:‘30px’}},
showCurrentValue=True,
value=vint,
max=250,
min=100
)
])
])
])

callbacks ************************************

@app.callback(
Output(‘my_gauge_ext’, )
Input('my_gauge_ext, )

@app.callback(
Output(‘my_gauge_int’, )
Input('my_gauge_int, )

if name == “main”:
app.run_server(debug=True)

The interval would be something like this but I’m not clear on where to put it in the layout, how do I trigger it and what variables do I put in the callbacks.

dcc.Interval(
id=‘my_interval’,
disabled=False,
interval=5*1000)

Any help you can offer will be most gratefully appreciated!
Thank you

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles