how to change the angel of the line via slider or on values submitted by user.

I want to move a line by he angles provided by a the user using slider.

Currently I’m plotting using this code taken from github repo but I’m having problem in updating it via slider .

def add_needle(speed, units):

max_speed = max_kmh if units == “kmh” else max_mph

speed = min(max(speed, 0), max_speed)

total_angle = start_angle - end_angle

angle = total_angle*float(speed)/max_speed

angle= start_angle - angle

plot.add_glyph(Ray(x=0, y=0, length=data(0.75), angle=angle, line_color=“black”, line_width=3))

``

Thank You.

Use a ColumnDataSource instead

from bokeh.models import ColumnDataSource,Slider
from bokeh.plotting import figure
from bokeh.io import curdoc

fig = figure()

slider = Slider(start=0, end=360, value=0, step=1,title=“Angle”)

source=ColumnDataSource(data={‘x’:[0],‘y’:[0],‘angle’:[0],‘length’:[0]})

fig.ray(x=‘x’,y=‘y’,length=‘length’,angle=‘angle’,angle_units=“deg”,source=source)

def change_angle(attr,old,new):

source.data['angle'] = [slider.value]

slider.on_change(‘value’,change_angle)

curdoc().add_root(slider)
curdoc().add_root(fig)

``

Thanks for the quick help.
Implementing it with my project. Thank you so much.

···

On Tuesday, January 23, 2018 at 1:21:50 AM UTC+5:30, Sébastien Roche wrote:

Use a ColumnDataSource instead

from bokeh.models import ColumnDataSource,Slider
from bokeh.plotting import figure
from bokeh.io import curdoc

fig = figure()

slider = Slider(start=0, end=360, value=0, step=1,title=“Angle”)

source=ColumnDataSource(data={‘x’:[0],‘y’:[0],‘angle’:[0],‘length’:[0]})

fig.ray(x=‘x’,y=‘y’,length=‘length’,angle=‘angle’,angle_units=“deg”,source=source)

def change_angle(attr,old,new):

source.data['angle'] = [slider.value]

slider.on_change(‘value’,change_angle)

curdoc().add_root(slider)
curdoc().add_root(fig)

``