如何在ColumnDataSource散景中使用dict的dic?

时间:2020-03-23 11:32:29

标签: javascript python bokeh

我想弄一些散景的仪表板。 我有字典点

      dots={'0':{1:987,3:3,7:9,0:9},
            '1':{1:3,3:4,7:8,0:9},
            '2':{3:6,1:4,5:7},
             .
             .}

我想在字典中显示每个键的条形图,所以这个想法是创建一个包含所有点号键的选择小部件,然后当我更改选择选项时,条形图更改:

from bokeh.models import HoverTool, ColumnDataSource
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.layouts import widgetbox
from bokeh.models.widgets import Select
from bokeh.layouts import column


output_file("test.html")



Curr = ColumnDataSource(
    data=dots[0]
)

p = figure(plot_width=1500, plot_height=800, title="Frames occurence per rank for voyels",
           x_range=str_keys, toolbar_location=None, tooltips=[("Rank", "@keys"),("Occurence","@values")])
p.vbar(x='keys', top='values', width=0.5, source=source)

callback = CustomJS(args=dict(source=Overall, sc=Curr), code="""

        var f = Select.value
        here I want to put new data based on selected element
        sc.change.emit();
    """)

select = Select(title="Option:", value="0", options=["1", "2", "3", "4"])
select.js_on_change('value', callback)

layout = column(select, p)
show(layout)

我想将点转换为ColumNDataSource以在CustomJS中使用它

      Overall=ColumnDataSource(dots)

它给我错误

   expected an element of ColumnData(String, Seq(Any)), got...

如何将点转换为ColumnDataSource以及如何在JavaScript中解析

谢谢

0 个答案:

没有答案