I am running an app on bokeh server (see a test code below). I have an editable datatable (x and y columns), a widget that selects the number of rows in the table and a plot of y vs x that updates with the data source.
I can edit one cell in the slickgrid data table fine and it highlights the updated x-y coordinates in the plot. However I cannot figure out how to unfocus from the cell after editing it such that the plot covers the full data source (all the rows and columns). I can manually select all the cells to get the plot to show all datapoints. Alternatively, I can click on the refresh button next to the bokeh plot. But I am asking if there is a simple way to defocus from the single edited cell.
If I cannot unfocus (or deselect) from the cell after edit, I would like to use a separate toggle button that allows the datasource to update itself and the plot to cover the whole data set. In other words I would like this button to have the same functionality as the refresh button next to the bokeh plot. How can I do it?
Thanks a lot beforehand.
'''
Use the ``bokeh serve`` command to run the example by executing:
bokeh serve test.py
at your command prompt. Then navigate to the URL
http://localhost:5006/test
in your browser.
'''
import numpy as np
from bokeh.io import curdoc
from bokeh.layouts import layout, widgetbox, column, row
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import Slider, Select, Toggle, DataTable, TableColumn
from bokeh.plotting import figure
def Steps(attrname, old, new):
n = int(Pts.value)
x=[]
y=[]
for i in range(n+1):
x.append(i)
y.append(i)
source.data = dict(x=x,y=y)
x=[]
y=[]
source = ColumnDataSource(data=dict(x=x, y=y))
# Set up plot
plot0 = figure(plot_width=350, plot_height=350, title = "plot", x_axis_label = "x", y_axis_label = "y", toolbar_location = "right", match_aspect=True, aspect_scale=1.)
plot0.min_border = 40
plot0.line('x', 'y', source=source, line_width=3, line_alpha=1, color='#b3c100')
plot0.square('x', 'y', source=source, size=8, color="red", alpha=0.5)
plot0.yaxis.axis_label_text_font_size = "12pt"
plot0.yaxis.axis_label_text_font_style = "normal"
plot0.xaxis.axis_label_text_font_size = "12pt"
plot0.title.text_font_size = "16px"
plot0.xaxis.axis_label_text_font_style = "normal"
plot0.x_range.start = 0
plot0.y_range.start = 0
columns = [
TableColumn(field="x", title="x"),
TableColumn(field="y", title="y"),
]
data_table = DataTable(source=source, columns=columns, width=250, height=400, fit_columns=True, editable=True)
Pts = Select(title="No. of steps:", value='1', options=[format(x,'d') for x in range(1,11)])
#----------------------------------------------
for w in [Pts]:
w.on_change('value', Steps)
doc_layout = layout(children=[
[column(widgetbox(Pts, data_table)), plot0]
],
sizing_mode='fixed')
curdoc().add_root(doc_layout)
curdoc().title = "test"
