Python 不渲染散景标题和工具栏

Python Bokeh Title and Toolbar are not rendered

我写了一篇python class that is capable of live plotting data in different graphs. It is based on python bokeh. Basically it is an abstraction of embedding bokeh server as a library and it is capable to dynamically add and remove figures and line glyphs during runtime. To make this happen in a non-blocking manner the main class extends multithreading.Thread. All codes can be found here.

我遇到的一个问题是图形并不总是正确呈现。通常图形的标题和工具栏未呈现,如下所示(单击它可在 gif 上查看大图):

在浏览器的调试控制台中抛出以下 javascript 错误 (google chrome):

Uncaught TypeError: Cannot read property 'draw_legend' of undefined

要在运行时添加图形,我使用下面的代码,其中 fig 是一个字典,其中包含我项目中的所有图形 objects 和 cds是所有对应ColumnDataSource的字典objects:

        if not fig_name in fig:
            print('add fig ' + fig_name)
            # create plot
            TOOLS="pan,wheel_zoom,box_zoom,reset, save, tap, hover"
            fig[fig_name]=figure(plot_width=900, plot_height=280, tools=TOOLS, toolbar_location='right', logo=None, title=(fig_name), name=str(fig_name))
            cds[fig_name]=ColumnDataSource(data=dict(x=np.array([])), name=(fig_name+'_cds'))
            plt_col=doc.get_model_by_name('plt_ui_col').children
            plt_col.append( fig[fig_name] )

这是散景的错误吗?

我错过了什么吗? (也许创建一些类,数字取决于?)

我正在使用 python3.6 和散景 0.12.16.

这可能是 https://github.com/bokeh/bokeh/issues/7497 我建议您在此处添加任何详细信息。