Skip to content

Instantly share code, notes, and snippets.

@mafshin
Created March 16, 2024 18:28
Show Gist options
  • Save mafshin/b2b0089f1bed7cb680e2c1692b9f9910 to your computer and use it in GitHub Desktop.
Save mafshin/b2b0089f1bed7cb680e2c1692b9f9910 to your computer and use it in GitHub Desktop.
NiceGUI Highcharts Sample
from nicegui import ui
def update():
chart.options['chart']['type'] = chart_type.value
chart.update()
chart_type = ui.radio(['line', 'area', 'bar', 'column'], value='column', on_change=update).props('inline')
grades = {'Ali': [12, 16, 18, 20],
'Maryam': [19, 20, 18, 15],
'Milad': [8, 12, 19, 16],
'Rozhina': [18, 17, 13, 10]}
dates = ['1402/06', '1402/08', '1402/11', '1403/02']
data = list(map(lambda x: {'name': x, 'data': grades[x]}, grades.keys()))
chart = ui.highchart({
'title': 'Student Grades',
'chart': {'type': chart_type.value},
'xAxis': {'categories': dates},
'series': data
}).classes('w-full h-64')
ui.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment