Bokeh 嵌入在 Flask 中不起作用(Bokeh 未定义)
Bokeh embed not working in Flask (Bokeh is not defined)
我正在尝试在我的 Flask 应用程序中加载散景图,但我无法在我的模板中渲染该图。我使用 bokeh.embed 组件的方式与所有示例中的方式完全相同:
script1, div1 = components(p)
cdn_js = CDN.js_files[0]
cdn_css = CDN.css_files[0]
然后我像这样将组件传递给 render_template:
return render_template("plot.html", script1=script1, div1=div1, cdn_css=cdn_css, cdn_js=cdn_js )
当 plot.html 加载时,它包含所有组件,但由于某种原因,绘图根本没有显示。以下是渲染模板中的脚本:
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cyborg/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href=https://cdn.bokeh.org/bokeh/release/bokeh-0.12.13.min.js type="text/css" />
<script type="text/javascript" src=https://cdn.bokeh.org/bokeh/release/bokeh-0.12.13.min.css></script>
脚本和 div 都在正文中并且看起来正确。但是我在 javascript:
中遇到错误
Uncaught ReferenceError: Bokeh is not defined
at HTMLDocument.fn
如果我在头部加载散景库,为什么会出现此错误?请帮忙。
您似乎混淆了 CSS 和 JS 加载。您正在 <link rel="stylesheet"...>
标签中加载 bokeh.min.js
,并在 <script>
标签中加载 bokeh.min.css
。
我正在尝试在我的 Flask 应用程序中加载散景图,但我无法在我的模板中渲染该图。我使用 bokeh.embed 组件的方式与所有示例中的方式完全相同:
script1, div1 = components(p)
cdn_js = CDN.js_files[0]
cdn_css = CDN.css_files[0]
然后我像这样将组件传递给 render_template:
return render_template("plot.html", script1=script1, div1=div1, cdn_css=cdn_css, cdn_js=cdn_js )
当 plot.html 加载时,它包含所有组件,但由于某种原因,绘图根本没有显示。以下是渲染模板中的脚本:
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cyborg/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href=https://cdn.bokeh.org/bokeh/release/bokeh-0.12.13.min.js type="text/css" />
<script type="text/javascript" src=https://cdn.bokeh.org/bokeh/release/bokeh-0.12.13.min.css></script>
脚本和 div 都在正文中并且看起来正确。但是我在 javascript:
中遇到错误Uncaught ReferenceError: Bokeh is not defined
at HTMLDocument.fn
如果我在头部加载散景库,为什么会出现此错误?请帮忙。
您似乎混淆了 CSS 和 JS 加载。您正在 <link rel="stylesheet"...>
标签中加载 bokeh.min.js
,并在 <script>
标签中加载 bokeh.min.css
。