h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 323 forks source link

Line plot and step plot draw wrong lines in output when changed via data[-1] #2352

Open michaeltraxler opened 1 week ago

michaeltraxler commented 1 week ago

Wave SDK Version, OS

1.3.3 20240614125607 OpenSuSE Tumbleweed 20240613

Actual behavior

The plots produced by wave the wave plot_card type "line" and "step" produce in the output wrong lines from the first value to the new added value when using the online update of the data via card.data[-1] .

2024-06-17_01-55

Expected behavior

The horizontal line should be missing.

Steps To Reproduce

The code to reproduce:

from h2o_wave import main, app, Q, ui, data, run_on, on
import random
import time

@app('/')
async def serve(q: Q):
    if not q.client.initialized:

    q.page['example'] = ui.plot_card(
            box='1 1 4 4',
            title='Rate',
            data=data('time rate', -100, rows= []),
             plot=ui.plot([ui.mark(type='line', x='=time', y='=rate', y_min=0)])
    )
        q.client.initialized = True
    await q.page.save()
        await update_rates(q)

    await q.page.save()

async def update_rates(q):
    card = q.page['example']
    i=100
    while True:
    card.data[-1] = [i, random.random()*100]
    await q.page.save()
    i=i+1
    await q.sleep(0.1)

Can this be fixed somehow?

Thanks, Michael