chart_documentation.py 510 B

123456789101112131415161718192021
  1. from nicegui import ui
  2. def main_demo() -> None:
  3. from random import random
  4. chart = ui.chart({
  5. 'title': False,
  6. 'chart': {'type': 'bar'},
  7. 'xAxis': {'categories': ['A', 'B']},
  8. 'series': [
  9. {'name': 'Alpha', 'data': [0.1, 0.2]},
  10. {'name': 'Beta', 'data': [0.3, 0.4]},
  11. ],
  12. }).classes('w-full h-64')
  13. def update():
  14. chart.options['series'][0]['data'][0] = random()
  15. chart.update()
  16. ui.button('Update', on_click=update)