echart_documentation.py 582 B

123456789101112131415161718192021
  1. from nicegui import ui
  2. def main_demo() -> None:
  3. from random import random
  4. echart = ui.echart({
  5. 'xAxis': {'type': 'value'},
  6. 'yAxis': {'type': 'category', 'data': ['A', 'B'], 'inverse': True},
  7. 'legend': {'textStyle': {'color': 'gray'}},
  8. 'series': [
  9. {'type': 'bar', 'name': 'Alpha', 'data': [0.1, 0.2]},
  10. {'type': 'bar', 'name': 'Beta', 'data': [0.3, 0.4]},
  11. ],
  12. })
  13. def update():
  14. echart.options['series'][0]['data'][0] = random()
  15. echart.update()
  16. ui.button('Update', on_click=update)