Hello Community,
I am currently writing my bachelors and one part of it is setting up an interactive dashboards where users can explore some data and build customized plots. For this I am heavily relying on Panel but I am both completly new to python and completly new to front-end development. I come from Java and R and am hopefully soon graduating in Data Science (with lots of math and using the computer as a huge calculator, not so much software development). So please be ‘soft’ haha.
One of my problems is the following: I have set up a procedure so that the user can specify certain columns from a certain database view. Given the certain columns a preview dataframe should be rendered. I’ve tried defining a callback that triggers when the column selection is changing but it does not work. The function itself works but the callback doesn’t update the actual view, only the object if that makes any sense. I’ve tried different approaches with @pn.depends and the callback but both didn’t work. Can anyone give a hint what I should try next? I am in the process of figuring out the param library but I feel that it won’t help me because my sets of parameters are not limited in the way they need to be in the moment when params parameters are initialized.
@pn.depends(var_of_int.param.value,checkboxes.param.value)
def preview_data(var_of_int,checkboxes):
if len(var_of_int.value) == 0:
empty= pd.DataFrame({}).to_html(classes=['example', 'panel-df'])
empty= pn.pane.HTML(empty+script, sizing_mode='stretch_width')
return empty
else:
preview_data = db_views.get(checkboxes.value)[var_of_int.value]
preview_data = preview_data.to_html(classes=['example', 'panel-df'])
preview_data = pn.pane.HTML(preview_data+script, sizing_mode='stretch_width')
return preview_data
def update_preview(event):
preview = preview_data(checkboxes, x_axis,y_axis,cat_selec)
return preview
preview_button = pn.widgets.Button(name='Preview Data',
disabled=True,
button_type='primary')
def toggle_prev_button(event):
if x_axis.value is None or y_axis.value is None:
preview_button.disabled = True
else:
preview_button.disabled = False
x_axis.param.watch(toggle_prev_button, 'value')
y_axis.param.watch(toggle_prev_button, 'value')
prev = pn.pane.HTML(pd.DataFrame({}).to_html(classes=['example', 'panel-df'])+script, sizing_mode='stretch_width')
def prev_button_click(event):
prev = preview_data(checkboxes, x_axis, y_axis, cat_selec)
preview_button.on_click(prev_button_click)