我試圖用autoload_static將其數據嵌入到一個簡單的html頁面中,我想在本地計算機上讀取它。根據我在文檔中所做的,我只需要將.js文件放在指定的文件夾中,並將標籤插入到html中。 但Firefox是給我下一個錯誤: 「無法加載庫http://cdn.pydata.org/bokeh-114a47707b567971f835c5877d2be44ea4e57fef.min.js」 pl.js:21散景無法加載來自CDN的散景
import numpy as np
from bokeh.plotting import *
from bokeh.objects import PanTool
N = 80
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
pantool = PanTool(dimensions=["width", "height"])
plot = line(x,y, color="#0000FF", tools=['wheel_zoom','box_zoom', pantool],
name="line_example")
from bokeh.resources import CDN
from bokeh.embed import autoload_static
js, tag = autoload_static(plot, CDN,"/Users/john/Desktop/Tests/js/pl.js")
file = open("/Users/john/Desktop/Tests/js", "w")
file.write(js)
file.close()
print(tag)
和HTML頁面:
<!DOCTYPE html>
<html>
<body>
<h1>
Hello World
</h1>
<p><script
src="/Users/john/Desktop/Tests/js/pl.js"
id="836fbd4f-68b5-4cdf-8a56-047c2a22af2a"
async="true"
data-bokeh-data="static"
data-bokeh-modelid="line_example"
data-bokeh-modeltype="Plot"
data-bokeh-loglevel="info"
></script></p>
</body>
</html>