I have my data set up similar to the fruits example below. I have been trying to add a slider that controls for example the year '2015' and when I change the slider value, the stacked chart updates according to this new value.
Example:
Current value: 2015:[2, 1, 4, 3, 2, 4]
Slider value: 2
New value = Current value + slider value
---> 2015: [4,3,6,5,4,6]
Slider value:0
---> 2015:[2, 1, 4, 3, 2, 4]
(back to original value)
I hope someone can help me.
Thank you!
from bokeh.palettes import GnBu3, OrRd3
output_notebook()
years = ['2015', '2016', '2017']
exports = {'fruits' : fruits,
'2015' : [2, 1, 4, 3, 2, 4],
'2016' : [5, 3, 4, 2, 4, 6],
'2017' : [3, 2, 4, 4, 5, 3]}
p = figure(x_range=fruits, plot_height=250, y_range=(0, 16), title="Fruit import/export, by year")
p.vbar_stack(years, x='fruits', width=0.9, color=GnBu3, source=ColumnDataSource(exports))
p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
slider = Slider(start=0, end=5, value=0, step=1, title="2015 exports")
show(column(p,slider))