|
@@ -2,15 +2,20 @@ from nicegui import ui
|
|
|
|
|
|
|
|
|
def main_demo() -> None:
|
|
|
- chart = ui.echart({
|
|
|
+ from random import random
|
|
|
+
|
|
|
+ echart = ui.echart({
|
|
|
'xAxis': {'type': 'value'},
|
|
|
- 'yAxis': {'type': 'value'},
|
|
|
- 'series': [{'data': [[0, 0], [1, 1]], 'type': 'line'}],
|
|
|
+ 'yAxis': {'type': 'category', 'data': ['A', 'B'], 'inverse': True},
|
|
|
+ 'legend': {'textStyle': {'color': 'gray'}},
|
|
|
+ 'series': [
|
|
|
+ {'type': 'bar', 'name': 'Alpha', 'data': [0.1, 0.2]},
|
|
|
+ {'type': 'bar', 'name': 'Beta', 'data': [0.3, 0.4]},
|
|
|
+ ],
|
|
|
})
|
|
|
|
|
|
def update():
|
|
|
- x = len(chart.options['series'][0]['data'])
|
|
|
- chart.options['series'][0]['data'].append([x, x**2])
|
|
|
- chart.update()
|
|
|
+ echart.options['series'][0]['data'][0] = random()
|
|
|
+ echart.update()
|
|
|
|
|
|
ui.button('Update', on_click=update)
|