Hello,
Here is a short description, I need to vary an azimuth angle using a slider for a line.
My bokeh version is 0.12.4, the script below works but without update of my plot also
What is wrong?
Thanks for your help.
import numpy as np
from math import *
from bokeh.layouts import row, widgetbox
from bokeh.models.callbacks import CustomJS
from bokeh.models import Slider
from bokeh.plotting import figure, output_file, show, ColumnDataSource
========================= Set up the data
Line length d=3000, Az=30
Az = 30
d = 3000
Xp1 = 3000sin(Azpi/180)
Yp1 = 3000cos(Azpi/180)
create arrays
x = np.array([-Xp1,0,Xp1])
y = np.array([-Yp1,0,Yp1])
source = ColumnDataSource(data=dict(x=x, y=y))
======================= Setting up the plot
plot = figure(y_range=(-3000,3000),plot_width=400, plot_height=400)
plot.line(‘x’,‘y’,source=source,color="#999999", line_alpha=.8)
~~~~~~~~~~~~~~~~~~ Azimuth Slider
callback = CustomJS(args=dict(source=source), code="""
var data = source.data;
var a = cb_obj.value;
x = data[‘x’]
y = data[‘y’]
for (i=-1; i<x.length;i++) {
x[i] = 3000iMath.sin(a*pi/180);
y[i] = 3000iMath.cos(a*pi/180);
}
source.trigger(‘change’);
“”")
Azimuth_slider = Slider(start=-180, end=180, value=Az, step=.1,
title=“Projection Plan Azimuth (deg)”,callback=callback)
Azimuth_slider.js_on_change(‘value’,callback)
layout = row(plot,widgetbox(Azimuth_slider))
show(layout)