Hello everyone,
I’m trying to update a blank datatable based on whatever point on the line graph I clicked using a python callback. I managed to get the code to execute, however the source2.change.emit() function doesn’t work. It says that ColumnDataSource has no change attribute. Does anyone know the proper/alternative way to do this in a python callback?
Here is my current code:
def bkapp(doc)
# this is kinda pseudocode, I'm not including the actual data
source = ColumnDataSource(data=data)
source2 = ColumnDataSource(data=dict(x=[], y=[]))
p = figure()
p.line(source=source, x='x_values', y='y_vlaues')
datatable = DataTable(source=source2)
def callback(event):
# the x axis is a unix timestamp value
date = datetime.datetime.fromtimestamp(event.x / 1000)
source_x = source.data['x_values']
# rounds to the nearest 3 hours
rounded_date = round_nearest_hours(date)
sected_index = int
for i in range(len(source_x)):
if rounded_date.date() == source_x[i].date():
if rounded_date.time() == source_x[i].date():
source2 = data # Calling a remote function here that returns a ColumnDataSource
source2.change.emit()
p.on_event('tap', callback)
doc.add_root(column(p, datatable))
show(bkapp)