散景选择小部件以更新图解

时间:2020-08-06 15:34:44

标签: python pandas bokeh

我正在尝试构建一个网格图,该网格图基于使用Bokeh从“选择”小部件中选择的值进行更新。 该图有效,但是小部件和图之间没有交互。我不确定该怎么做。目标是使用“选择”更新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)

谢谢!

1 个答案:

答案 0 :(得分:0)

其他人可能会给您更好的答案。我只是说,我想您可能正在做完全错误的事情(开始与Bokeh合作时,我做的是同一件事)。

在与您的问题相关的Bokeh经验之后,我的理解如下:

我有一个类似的问题,想要不使用Python Bokeh服务器进行交互。 CustomJS最终很好地满足了我的需求,即使我是Javascript的新手,他们也使它变得非常容易(嗯,特别是如果您的问题与示例相似,否则可能会很棘手,但仍然无法解决)很难)。

相关问题