我试图在我的django应用程序中嵌入散景图.我按照Bokeh网站上的说明和另一个问题.
我在浏览器控制台上收到以下错误,没有获得任何绘图输出:
Uncaught TypeError: Bokeh.safely is not a function
at HTMLDocument.fn (localhost/:15)
Run Code Online (Sandbox Code Playgroud)
我不是一个JS人,但Bokeh.safely存在于Bokeh生成的脚本中.我附上了最后生成的脚本:
我的views.py文件:
from django.shortcuts import render
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import components
def showGraph(request):
arr = [1,4,9,16,25,36]
y = [1,2,3,4,5,6]
plot = figure()
plot.line(arr, y)
script, div = components(plot, CDN)
return render(request, "data_collection/simple_chart.html", {"script": script, "div": div})
Run Code Online (Sandbox Code Playgroud)
simplechart.html文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bokeh example</title>
<link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.css">
<link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.css">
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-0.12.0.min.js"></script>
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.0.min.js"></script>
{{ …Run Code Online (Sandbox Code Playgroud)