Thanks for you work, H2O Wave is really good.
I have this code for testing
from h2o_wave import main, app, data, Q, ui
import time
from random import randrange
values_1 = []
values_2 = []
# make some data
for i in range(0,25):
values_1.append(("CH1", i, randrange(100)))
values_2.append(("CH2", i, randrange(100)))
@app('/demo')
async def serve(q: Q):
q.page['meta'] = ui.meta_card(box='', layouts=[
ui.layout(
breakpoint='xl',
width='1200px',
zones=[
ui.zone('header'),
ui.zone('control'),
ui.zone('top', direction=ui.ZoneDirection.ROW, size='385px', zones=[
ui.zone('top_left', direction=ui.ZoneDirection.ROW, size='66%'),
ui.zone('top_right'),
]),
ui.zone('middle', direction=ui.ZoneDirection.ROW, size='400px'),
ui.zone('bottom', direction=ui.ZoneDirection.ROW, size='200px'),
ui.zone('footer'),
]
)
])
q.page['stats'] = ui.form_card(
box='middle',
title="Channel Power",
items=[
ui.stats(items=[
ui.stat(label=("Man"), value=("Manuel")),
ui.stat(label=("1234"), value=("1234")),
], justify=ui.StatsJustify.BETWEEN, inset=True),
ui.visualization(
plot=ui.plot([
ui.mark(type='line', x_scale='linear', x='=date', y='=visitors', color='=site',
color_range='$orange $amber', curve=ui.MarkCurve.SMOOTH),
ui.mark(type='line', x_scale='linear', x='=date', y='=visitors', color='=site',
color_range='$orange $amber', curve=ui.MarkCurve.SMOOTH),
]),
data=data(
fields=['site', 'date', 'visitors'],
rows= values_1+ values_2,
pack=True
),
height='240px',
)
],
)
await q.page.save()
Now, i would update the stats.data, but it doesnt work and i cant find an example.
from h2o_wave import site, data
import time
from random import randrange
page = site['/demo']
quote = page['stats']
values_1 = []
values_2 = []
i = 0
while True:
if len(values_1) == 26:
values_1.pop(0)
values_2.pop(0)
values_1.append(("CH1", i, randrange(100)))
values_2.append(("CH2", i, randrange(100)))
time.sleep(0.25)
quote.data = values_1 + values_2
page.save()
i = i + 1
Hello!
Thanks for you work, H2O Wave is really good. I have this code for testing
Now, i would update the stats.data, but it doesnt work and i cant find an example.
Thanks for your help.