Nesting DynamicMap in Holomap in Holoviews

34 Views Asked by At

I am currently having a Holomap integrated with Panel for two dropdowns. It's like this:

plots = {}
for d1 in dropdown1[0]:
    for d2 in dropdown2[0]:
        # produce some hv Layouts
        plots[(d1, d2)] = hv.Layout(year_plots).cols(2)

# create holomap
holomap = hv.HoloMap({(a,b): plots[(a, b)] for a in dropdown1[0] for b in dropdown2[0]},
                    kdims=['A', 'B'])

# define dropdown widgets
dropdown1_widget = pn.widgets.Select(name=dropdown1[2], options=dict(zip(dropdown1[1], dropdown1[0])))
dropdown2_widget = pn.widgets.Select(name=dropdown2[2], options=dict(zip(dropdown2[1], dropdown2[0])))
### I WANT A DROPDOWN/SLIDER HERE TO SLICE THE X AXIS RANGE

def update_map(event):
    selected_plot = holomap[(dropdown1_widget.value, dropdown2_widget.value)]
    plot_panel.object = selected_plot

# assign callback to dropdowns
dropdown1_widget.param.watch(update_map, "value")
dropdown2_widget.param.watch(update_map, "value")
#...

# create initial plot
init_plot = holomap[(dropdown1_widget.value, dropdown2_widget.value)]
plot_panel = pn.panel(init_plot)

# create dashboard
dashboard = pn.Row(
    plot_panel, pn.Column(dropdown1_widget, dropdown2_widget)
)

I want to add a slider or a dropdown to change the x axis value range for each of the graphs in the hv.Layout objects. I don't really want to add another of holomap since the saved object is already so heavy, so is it doable if I can add a DynamicMap inside it?

0

There are 0 best solutions below