2525from xcube .core .gridmapping import GridMapping
2626from xcube .server .api import Context
2727from xcube .webapi .viewer .contrib import Panel , get_dataset
28- from xcube .webapi .viewer .contrib .helpers import get_place_name
28+ from xcube .webapi .viewer .contrib .helpers import get_place_label
2929
3030panel = Panel (__name__ , title = "2D Histogram (Demo)" , icon = "equalizer" , position = 3 )
3131
@@ -56,7 +56,7 @@ def render_panel(
5656 "paddingTop" : 6 ,
5757 # Since for dynamic resizing we use `container` as width and height for
5858 # this chart during updates, it is necessary that we provide the width
59- # and the height here. This is for its parent div.
59+ # and the height here. This is for the `container` div of VegaChart .
6060 "width" : "100%" ,
6161 "height" : 400 ,
6262 },
@@ -102,7 +102,9 @@ def render_panel(
102102 )
103103
104104 error_message = Typography (
105- id = "error_message" , style = {"color" : "red" }, children = ["Missing variable selection" ]
105+ id = "error_message" ,
106+ style = {"color" : "red" },
107+ children = ["" ],
106108 )
107109
108110 return Box (
@@ -130,7 +132,6 @@ def render_panel(
130132 Input ("@app" , "selectedPlaceGeometry" ),
131133 Input ("select_var_1" ),
132134 Input ("select_var_2" ),
133- Input ("@app" , "selectedTimeLabel" ),
134135 Input ("button" , "clicked" ),
135136 Output ("error_message" , "children" ),
136137)
@@ -140,13 +141,17 @@ def update_error_message(
140141 place_geometry : str | None = None ,
141142 var_1_name : str | None = None ,
142143 var_2_name : str | None = None ,
143- _time_label : float | None = None ,
144144 _clicked : bool | None = None ,
145145) -> str :
146146 dataset = get_dataset (ctx , dataset_id )
147- if dataset is None or not place_geometry or not var_1_name or not var_2_name :
148- return "Error: Panel disabled"
149- return ""
147+ if dataset is None :
148+ return "Missing dataset selection"
149+ elif not place_geometry :
150+ return "Missing place geometry selection"
151+ elif not var_1_name or not var_2_name :
152+ return "Missing variable selection"
153+ else :
154+ return ""
150155
151156
152157@panel .callback (
@@ -168,6 +173,7 @@ def update_plot(
168173 time_label : float | None = None ,
169174 _clicked : bool | None = None , # trigger, will always be True
170175) -> tuple [alt .Chart | None , str ]:
176+
171177 dataset = get_dataset (ctx , dataset_id )
172178
173179 if "time" in dataset .coords :
@@ -191,7 +197,7 @@ def update_plot(
191197 ):
192198 return (
193199 None ,
194- "Selected geometry must cover and area." ,
200+ "Selected geometry must cover an area." ,
195201 )
196202
197203 dataset = mask_dataset_by_geometry (dataset , place_geometry )
@@ -354,7 +360,7 @@ def update_text(
354360 time_label : str | None = None ,
355361 _clicked : bool | None = None ,
356362) -> list | None :
357- place_name = get_place_name (place_id , place_group )
363+ place_name = get_place_label (place_id , place_group )
358364 if time_label :
359365 return [f"{ dataset_title } / { time_label [0 :- 1 ]} / { place_name } " ]
360366 return [f"{ dataset_title } " ]
0 commit comments