gpt4 book ai didi

python - 为什么嵌入 Flask 应用程序时不显示此 Bokeh 图?

转载 作者:太空宇宙 更新时间:2023-11-03 17:16:46 24 4
gpt4 key购买 nike

我在 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>

问题是, Bokeh Canvas 、控件等显示出来,但线图本身没有显示。这段代码中我缺少什么?

最佳答案

删除 dframe = dframe.set_index('Month') 就可以了

关于python - 为什么嵌入 Flask 应用程序时不显示此 Bokeh 图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33592855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com