39 lines
889 B
Python
39 lines
889 B
Python
from nicegui import ui
|
|
|
|
columns = [
|
|
{'name': 'name', 'label': 'Name', 'field': 'name', 'required': True, 'align': 'left'},
|
|
{'name': 'age', 'label': 'Age', 'field': 'age', 'sortable': True},
|
|
]
|
|
rows = [
|
|
{'name': 'Alice', 'age': 18},
|
|
{'name': 'Bob', 'age': 21},
|
|
{'name': 'Carol'},
|
|
]
|
|
ui.table(columns=columns, rows=rows, row_key='name')
|
|
|
|
# ui.run()
|
|
|
|
import pandas as pd
|
|
from nicegui import ui
|
|
|
|
df = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})
|
|
ui.aggrid.from_pandas(df).classes('max-h-40')
|
|
|
|
|
|
import plotly.graph_objects as go
|
|
from nicegui import ui
|
|
from random import random
|
|
|
|
fig = go.Figure()
|
|
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0))
|
|
plot = ui.plotly(fig).classes('w-full h-40')
|
|
|
|
def add_trace():
|
|
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[random(), random(), random()]))
|
|
plot.update()
|
|
|
|
ui.button('Add trace', on_click=add_trace)
|
|
|
|
ui.run()
|
|
|
|
ui.run() |