Skip to content

Commit a79417b

Browse files
committed
add demo panel 9
1 parent be1b4af commit a79417b

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

chartlets.py/demo/my_extension/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from .my_panel_6 import panel as my_panel_6
1212
from .my_panel_7 import panel as my_panel_7
1313
from .my_panel_8 import panel as my_panel_8
14+
from .my_panel_9 import panel as my_panel_9
1415

1516

1617
ext = Extension(__name__)
@@ -22,3 +23,4 @@
2223
ext.add(my_panel_6)
2324
ext.add(my_panel_7)
2425
ext.add(my_panel_8)
26+
ext.add(my_panel_9)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (c) 2019-2026 by Brockmann Consult Development team
2+
# Permissions are hereby granted under the terms of the MIT License:
3+
# https://opensource.org/licenses/MIT.
4+
5+
6+
from chartlets import Component, State
7+
from chartlets.components import (
8+
Accordion,
9+
Typography,
10+
Box,
11+
Table
12+
)
13+
from chartlets.components.table import TableColumn, TableRow
14+
15+
16+
from server.context import Context
17+
from server.panel import Panel
18+
19+
20+
panel = Panel(__name__, title="Panel I")
21+
22+
23+
@panel.layout(State("@app", ))
24+
def render_panel(
25+
ctx: Context,
26+
) -> Component:
27+
28+
columns: list[TableColumn] = [
29+
{"id": "id", "label": "ID", "sortDirection": "desc"},
30+
{
31+
"id": "firstName",
32+
"label": "First Name",
33+
"align": "left",
34+
"sortDirection": "desc",
35+
},
36+
{"id": "lastName", "label": "Last Name", "align": "center"},
37+
{"id": "age", "label": "Age"},
38+
]
39+
40+
rows: TableRow = [
41+
["1", "John", "Doe", 30],
42+
["2", "Jane", "Smith", 25],
43+
["3", "Peter", "Jones", 40],
44+
]
45+
46+
table = Table(id="table", rows=rows, columns=columns, hover=True)
47+
48+
info_text = Typography(id="info_text", children=["This is a text."])
49+
50+
accordion1 = Accordion(
51+
id="accordion1",
52+
label="Accordion No.1",
53+
icon="arrow_drop_down",
54+
children=[info_text],
55+
)
56+
57+
accordion2 = Accordion(
58+
id="accordion2",
59+
label="Accordion No.2",
60+
icon="arrow_drop_down",
61+
# expanded=True,
62+
# disabled=True
63+
children=[table],
64+
)
65+
66+
return Box(
67+
style={
68+
"display": "flex",
69+
"flexDirection": "column",
70+
"width": "100%",
71+
"height": "100%",
72+
},
73+
children=[accordion1, accordion2],
74+
)

0 commit comments

Comments
 (0)