(updated as Ive figured otu a few things. )
I have a plot and currently it dynamically scales the y-axis based on data. However, I would like to have it with a range of (0, 100) by default, and then have a check box, and once checked, the y-axis would then dynamically scale. I think it should look something like this:
# CPU line plot cpu_plot = figure(plot_width=800, plot_height=300, title='CPU Utilization %') # cpu_plot.yaxis.axis_label = 'CPU Usage in %' cpu_ds = [0, 0, 0, 0] for i in range(len(cpu_labels)): cpu_ds[i] = (cpu_plot.line(x, cpu_data[cpu_labels[i]], line_width=2, color=color_list[i], legend_label=cpu_labels[i])).data_source cpu_plot.legend.click_policy = "hide" default_data_range = cpu_plot.y_range cpu_plot.y_range = Range1d(0, 100) # this line updates the y_range just fine # dynamic scaling: def update_scaling(attr, old, new): print(attr, old, new) if new == : cpu_plot.y_range =default_data_range #this update does nto happen cpu_plot.title.text = "name 1" #this update happens correctly else: cpu_plot.y_range = Range1d(0, 50) #this update does not happen cpu_plot.title.text = "name 2" #this update happens correctly checkbox_labels = ["Enable Dynamic Y-axis Scaling"] checkbox_group = CheckboxGroup(labels=checkbox_labels, active=, css_classes=['custom_textinput'],) checkbox_group.on_change('active', update_scaling)
for some reason, the y_range updates in the if-else statements does not happen, even though I see the title update working fine, and the y_range update outside the function works fine.