![]() ![]() circle ( 'x', 'y', source = s1, alpha = 0.6 ) s2 = ColumnDataSource ( data = dict ( x =, y = )) p2 = figure ( plot_width = 400, plot_height = 400, x_range = ( 0, 1 ), y_range = ( 0, 1 ), tools = "", title = "Watch Here" ) p2. ![]() ![]() add_glyph ( source, rect, selection_glyph = rect, nonselection_glyph = rect ) show ( p )įrom random import random from bokeh.layouts import row from bokeh.models import CustomJS, ColumnDataSource from otting import figure, output_file, show output_file ( "callback.html" ) x = y = s1 = ColumnDataSource ( data = dict ( x = x, y = y )) p1 = figure ( plot_width = 400, plot_height = 400, tools = "lasso_select", title = "Select Here" ) p1. From bokeh.models import CustomJS, ColumnDataSource, BoxSelectTool, Range1d, Rect from otting import figure, output_file, show output_file ( "boxselecttool_callback.html" ) source = ColumnDataSource ( data = dict ( x =, y =, width =, height = )) callback = CustomJS ( args = dict ( source = source ), code = """ // get data source from Callback args var data = source.get('data') /// get BoxSelectTool dimensions from cb_data parameter of Callback var geometry = cb_data /// calculate Rect attributes var width = geometry - geometry var height = geometry - geometry var x = geometry + width/2 var y = geometry + height/2 /// update data source with new Rect attributes data.push(x) data.push(y) data.push(width) data.push(height) // trigger update of data source igger('change') """ ) box_select = BoxSelectTool ( callback = callback ) p = figure ( plot_width = 400, plot_height = 400, tools =, title = "Select Below", x_range = Range1d ( start = 0.0, end = 1.0 ), y_range = Range1d ( start = 0.0, end = 1.0 )) rect = Rect ( x = 'x', y = 'y', width = 'width', height = 'height', fill_alpha = 0.3, fill_color = '#009933' ) p. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |