首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过"selected.on_change()“事件更新ColumnDataSource?

如何通过"selected.on_change()“事件更新ColumnDataSource?
EN

Stack Overflow用户
提问于 2019-06-15 20:19:00
回答 1查看 918关注 0票数 0

首先,我在geogr之外创建了一个散点图。坐标。如果我单击这些圆中的一个,该散点图旁边的第二个线状图将根据我所单击的圆显示更多信息。这意味着我必须用一个新的ColumnDataSource来更新线条图中显示的当前a。但是,如果我点击其中一个圆圈,当前源代码将不会更新。线状图仍然显示了旧源的数据集。

我将尝试给您一个简短的示例,说明我到目前为止所做的工作:

代码语言:javascript
复制
def callback(attr, old, new):

    # Depending on what circle i've clicked i start a SQL request
    # to gain my dataset i want to plot and the new title of the diagram.

    # To change the title actually works:
    line_plot.title.text = 'new_title'

    # "source_new_values" is a ColumnDataSource created out of a 
    # SQL-request of my database.
    # To change the current source doesn't work. The line-plot is still
    # showing the old dataset. 
    source_current_values = source_new_values 


scatter_plot = figure(x_axis_label='lat', y_axis_label='lon')
scatter_plot.circle(x='long', y='lat', source=source_coordinates)

# I use the indices to identify what circle was clicked.
source_coordinates.selected.on_change('indices', callback)


line_plot = figure(x_axis_label='time', x_axis_type='datetime', 
                                        y_axis_label='values', title='title')

line_plot.line(x='date', y='value', source=source_current_values)
EN

回答 1

Stack Overflow用户

发布于 2019-06-16 20:07:04

tat问题的解决方案是我不能通过ColumnDataSource更新源代码,而是通过字典使用:

代码语言:javascript
复制
   source_current_values.data = Dict("some content")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56610329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档