I created interactive bar by rect, due to my different x_axis, I wish to change my figure’s x_range, so to change the bar’s x_axis name.
Here are some of my codes:
xis_map = {
“Current Location”:location,
#‘Current Company’:‘company’,
“Current Industry”:industry,
“Current Company”:company
}
y_map ={
“Current Location”:local_counts1,
“Current Industry”:industry_counts1
}
height_map={
“Current Location”:y_local_height,
“Current Industry”:y_indus_height,
“Current Company”:y_company_height
}
cities=TextInput(title=‘location name’)
x_axis=Select(title=‘X axis’,options=sorted(axis_map.keys()),value=‘Current Industry’)
source = ColumnDataSource(data=dict(x=,y=,height=,x_range_name=))
plot = figure(plot_height=600, plot_width=800, title="", toolbar_location=None, tools=[hover],x_range=axis_map[x_axis.value],y_range=[0,2000])
plot.rect(x=‘x’,y=‘y’,width=.8,height=‘height’,source=source)
#Callback_Age = CustomJS(args={’’})
def update():
plot.xaxis.axis_label=x_axis.value
plot.yaxis.axis_label=‘numbers’
source.data=dict(
x=axis_map[x_axis.value],
y=height_map[x_axis.value],
height=height_map[x_axis.value]*2.0,
x_range_name=axis_map[x_axis.value]
)
#bokeh.plotting.curplot().x_range=axis_map[x_axis.value]
def input_change(attrname,old,new):
update()
controls=[cities,x_axis]
for control in controls:
control.on_change('value',input_change)
inputs=HBox(VBoxForm(*controls))
input_change(None,None,None)
curdoc().add_root(HBox(inputs,plot))
in the line plot=figure,the value of x_range will be the value of my x_axis, I want to change it every time I update my data.
is there any solution?