소스 검색

use similar demo for both chart and echart

Falko Schindler 1 년 전
부모
커밋
e3e15d20e8
1개의 변경된 파일11개의 추가작업 그리고 6개의 파일을 삭제
  1. 11 6
      website/more_documentation/echart_documentation.py

+ 11 - 6
website/more_documentation/echart_documentation.py

@@ -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)