Hi,
I am working on a “rect” plot and its entries are linked with a data table. When I click an entry in the table, the plot will highlight the corresponding area. This works fine. But I don’t know how to unselect the entry in the table. In another words, how to return to the state when nothing been highlighted.
-- coding: utf-8 --
“”"
Football chart example.
@author: qianbo01
“”"
import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.models import HoverTool, ColumnDataSource
from bokeh.models.widgets import DataTable, TableColumn
from bokeh.models.widgets.layouts import HBox
from bokeh.plotting import gridplot
hours =
for i1 in range(24):
hours.append("%02d"%(i1))
minutes =
for i1 in range(60):
minutes.append("%02d"%(i1))
xname =
yname =
values =
colors =
for i1 in range(24):
for i2 in range(60):
xname.append(minutes[i2])
yname.append(hours[i1])
values.append(np.random.rand())
colors.append("#66FFFF")
source = ColumnDataSource(data = dict(xname = xname,
yname = yname,
values = values,
colors = colors))
p = figure(title = “Football Chart Example”,
x_axis_location = “above”,
y_axis_location = “left”,
tools=“hover,save”,
x_range = minutes,
y_range = list(reversed(hours)))
p.plot_width = 1000
p.plot_height = int(p.plot_width*24/60)
p.grid.grid_line_color = None
p.axis.axis_line_color = None
p.axis.major_tick_line_color = None
p.axis.major_label_text_font_size = “9pt”
p.axis.major_label_standoff = 0
p.xaxis.major_label_orientation = np.pi/2
p.rect(‘xname’, ‘yname’, 0.9, 0.9,
source = source,
color = ‘colors’,
line_color = None)
p.select_one(HoverTool).tooltips = [(‘Time ‘,’@yname: @xname’)]
columns = [TableColumn(field=“values”, title=“Value”)]
data_table = DataTable(source=source, columns=columns, width=400, height=280)
output_file(“football.html”, title=“football chart example”)
tot = HBox(data_table, gridplot([[p]]))
show(tot)