Skip to content

Commit 53d2885

Browse files
committed
add panel H
1 parent 8f121bb commit 53d2885

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

chartlets.py/demo/my_extension/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .my_panel_5 import panel as my_panel_5
77
from .my_panel_6 import panel as my_panel_6
88
from .my_panel_7 import panel as my_panel_7
9+
from .my_panel_8 import panel as my_panel_8
910

1011

1112
ext = Extension(__name__)
@@ -16,3 +17,4 @@
1617
ext.add(my_panel_5)
1718
ext.add(my_panel_6)
1819
ext.add(my_panel_7)
20+
ext.add(my_panel_8)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import altair as alt
2+
import pandas as pd
3+
from chartlets import Component, Input, State, Output
4+
from chartlets.components import Tabs, Tab, Typography, Box, VegaChart
5+
6+
from server.context import Context
7+
from server.panel import Panel
8+
9+
10+
panel = Panel(__name__, title="Panel H")
11+
12+
13+
@panel.layout(State("@app", "selectedDatasetId"))
14+
def render_panel(
15+
ctx: Context,
16+
selected_dataset_id: str = "",
17+
) -> Component:
18+
dataset = ctx.datasets.get(selected_dataset_id)
19+
20+
c = (
21+
alt.Chart(dataset)
22+
.mark_bar()
23+
.encode(
24+
x=alt.X("x:N", title="x"),
25+
y=alt.Y("a:Q", title="a"))
26+
)
27+
28+
chart = VegaChart(
29+
id="chart1", chart=c, style={"flexGrow": 1}
30+
)
31+
32+
info_text = Typography(id="info_text", children=["hallo"])
33+
34+
tab1=Tab(id = "tab1",label="Plot 1", children=["Hallo"])
35+
tab2=Tab(id = "tab2",label="Plot 2", children=[info_text])
36+
tab3 = Tab(id="tab3", label="Plot 3", children=[chart])
37+
38+
select = Tabs(id = "tab", value = 0, children=[tab1,tab2,tab3])
39+
40+
41+
return Box(
42+
style={
43+
"display": "flex",
44+
"flexDirection": "column",
45+
"width": "100%",
46+
"height": "100%",
47+
},
48+
children=[chart, info_text, select,tab2],
49+
)
50+

0 commit comments

Comments
 (0)