1- import copy
2- from types import NoneType
31from typing import Any
42
53import altair as alt
6- import pandas as pd
74
85from chartlets import Component , Input , Output , State
9- from chartlets .components import Plot , Box , Select
6+ from chartlets .components import VegaChart , Box , Select
107from chartlets .demo .contribs import Panel
118from chartlets .demo .context import Context
129
1714@panel .layout ()
1815def render_panel (ctx : Context ) -> Component :
1916 selected_dataset : int = 0
20- plot = Plot (
21- id = "plot " , chart = make_figure (ctx , selected_dataset ), style = {"flexGrow" : 1 }
17+ chart = VegaChart (
18+ id = "chart " , chart = make_chart (ctx , selected_dataset ), style = {"flexGrow" : 1 }
2219 )
2320 select = Select (
2421 id = "selected_dataset" ,
@@ -44,15 +41,15 @@ def render_panel(ctx: Context) -> Component:
4441 "width" : "100%" ,
4542 "height" : "100%" ,
4643 },
47- children = [plot , control_group ],
44+ children = [chart , control_group ],
4845 )
4946
5047
5148@panel .callback (
5249 Input ("selected_dataset" ),
53- Output ("plot " , "chart" ),
50+ Output ("chart " , "chart" ),
5451)
55- def make_figure (ctx : Context , selected_dataset : int = 0 ) -> alt .Chart :
52+ def make_chart (ctx : Context , selected_dataset : int = 0 ) -> alt .Chart :
5653 dataset_key = tuple (ctx .datasets .keys ())[selected_dataset ]
5754 dataset = ctx .datasets [dataset_key ]
5855
@@ -88,9 +85,9 @@ def make_figure(ctx: Context, selected_dataset: int = 0) -> alt.Chart:
8885
8986
9087@panel .callback (
91- Input ("plot " , property = "points" ),
92- State ("plot " , "chart.encoding" ),
93- Output ("plot " , "chart.encoding.color" ),
88+ Input ("chart " , property = "points" ),
89+ State ("chart " , "chart.encoding" ),
90+ Output ("chart " , "chart.encoding.color" ),
9491)
9592def get_click_event_points (
9693 ctx : Context , points : dict [str , Any ], encoding : dict [str , Any ]
0 commit comments