【问题标题】:Bokeh Select Widget to Update Plot散景选择小部件以更新绘图
【发布时间】:2020-11-26 22:02:08
【问题描述】:

我正在尝试构建一个网格图,该网格图根据使用散景从“选择”小部件中选择的值进行更新。 图表有效,但小部件和图表之间没有交互。我不知道该怎么做。目标是使用“选择”更新 dfPlot,然后按照其余步骤操作。

这是我目前所拥有的:

output_file('layout.html')

select = Select(title="Option:", options= list(dfExpense['Ident'].unique()), value= "VALUE")

def update_plot(attr, old, new):
    dfPlot = dfExpense[dfExpense['Ident'] == select.value]

select.on_change('value', update_plot)

d = []

for x in dfPlot['Account'].unique():
    d.append(f's_{x}')

plt = []

for i, x in enumerate(dfPlot['Account'].unique()):
    dftemp = dfPlot[dfPlot['Account']==gl]
    source1 = ColumnDataSource(dftemp)
    d[i] = figure(plot_width = 250, plot_height = 250)
    d[i].circle('X', 'Amount', source = source1)
    plt.append(d[i])
    
grid= gridplot([i for i in plt], ncols = 6)
l = row(grid, select)
show(l)

curdoc().add_root(l)

谢谢!

【问题讨论】:

    标签: python pandas bokeh


    【解决方案1】:

    其他人可能会给你一个更好的答案。我只想说,我认为你做的事情可能完全错误,因为你正在尝试做的事情(我在开始使用 Bokeh 时做了同样的事情)。

    在对 Bokeh 有一些经验后,我的理解与您的问题有关,如下所示:

    我遇到了类似的问题,想要在不使用 Python Bokeh 服务器的情况下进行交互。 CustomJS 最终很好地满足了我的需求,即使我是 Javascript 的新手,它们也让它变得很容易(嗯,特别是如果你的问题与示例相似,否则它可能会变得很棘手,但仍然不是很难)。

    【讨论】:

      猜你喜欢
      • 2018-11-09
      • 1970-01-01
      • 2020-06-30
      • 1970-01-01
      • 2017-01-26
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 2018-08-05
      相关资源
      最近更新 更多