11import altair as alt
2- import pandas as pd
2+
33from chartlets import Component , Input , State , Output
4- from chartlets .components import Tabs , Tab , Typography , Box , VegaChart
4+ from chartlets .components import (Tabs , Tab , Typography , Box ,
5+ VegaChart , Table )
6+ from chartlets .components .table import TableColumn , TableRow
57
68from server .context import Context
79from server .panel import Panel
@@ -17,26 +19,43 @@ def render_panel(
1719) -> Component :
1820 dataset = ctx .datasets .get (selected_dataset_id )
1921
20- c = (
22+ columns : list [TableColumn ] = [
23+ {"id" : "id" , "label" : "ID" , "sortDirection" : "desc" },
24+ {
25+ "id" : "firstName" ,
26+ "label" : "First Name" ,
27+ "align" : "left" ,
28+ "sortDirection" : "desc" ,
29+ },
30+ {"id" : "lastName" , "label" : "Last Name" , "align" : "center" },
31+ {"id" : "age" , "label" : "Age" },
32+ ]
33+
34+ rows : TableRow = [
35+ ["1" , "John" , "Doe" , 30 ],
36+ ["2" , "Jane" , "Smith" , 25 ],
37+ ["3" , "Peter" , "Jones" , 40 ],
38+ ]
39+
40+ table = Table (id = "table" , rows = rows , columns = columns , hover = True )
41+
42+ info_text = Typography (id = "info_text" , children = ["This is a text." ])
43+ chart = VegaChart (
44+ id = "chart" , chart = (
2145 alt .Chart (dataset )
2246 .mark_bar ()
2347 .encode (
2448 x = alt .X ("x:N" , title = "x" ),
2549 y = alt .Y ("a:Q" , title = "a" ))
50+ .properties (width = 290 , height = 300 , title = "Vega charts" )
51+ ), style = {"flexGrow" : 1 }
2652 )
2753
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 ])
54+ tab1 = Tab (id = "tab1" , label = "Tab 1" , children = [table ])
55+ tab2 = Tab (id = "tab2" , label = "Tab 2" , children = [info_text ])
56+ tab3 = Tab (id = "tab3" , label = "Tab 3" , children = [chart ])
3957
58+ tabs = Tabs (id = "tab" , value = 0 , children = [tab1 ,tab2 ,tab3 ])
4059
4160 return Box (
4261 style = {
@@ -45,6 +64,6 @@ def render_panel(
4564 "width" : "100%" ,
4665 "height" : "100%" ,
4766 },
48- children = [chart , info_text , select , tab2 ],
67+ children = [ tabs ],
4968 )
5069
0 commit comments