【问题标题】:Why is this Bokeh plot not showing up when embedded in Flask App?为什么嵌入 Flask 应用程序时没有显示此散景图?
【发布时间】:2015-11-11 00:01:44
【问题描述】:

我在 Python Flask 应用程序中使用 Bokeh。在test_app.py 文件中有这个代码:

See the Code, data and output in iPython notebook...

def make_figure():
     plot = figure(tools=TOOLS, width=750, height=450, title='United States Import/Exports',
              x_axis_label='date', x_axis_type='datetime')

     plot.line(dframe.index, dframe.get('Exports'), color='#A6CEE3', legend='Exports')
     return plot


@app.route('/')
def greet():
    greetings = 'Hello World, I am BOKEH'
    plot = make_figure()
    script, div = components(plot)

    return render_template('index.html', greetings=greetings, script=script, div=div)


if __name__ == '__main__':
    app.run(debug=True)

index.html 文件中,我有以下核心部分以及所需的jscss 链接:

<body>
   <h1>{{ greetings | safe }} </h1>
    {{ script | safe }}
    {{ div | safe }}
</body>

问题是,散景画布、控件等会显示,但线图本身却没有。我在这段代码中遗漏了什么?

【问题讨论】:

    标签: python flask bokeh


    【解决方案1】:

    删除 dframe = dframe.set_index('Month') 并继续使用

    【讨论】:

    • 可能值得在他们的github.com/bokeh/bokeh 上报告一个问题,设置索引名称不应该删除行恕我直言
    猜你喜欢
    • 2019-04-27
    • 1970-01-01
    • 2020-01-16
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多