我想在我的reveal.js演示文稿中导入bokeh交互式图形。
<iframe data-src="https://demo.bokeh.org/sliders"
width="445" height="355" frameborder="0" marginwidth="0" marginheight="0"
scrolling="no" style="border:3px solid #666; margin-bottom:5px; max-width:
100%;" allowfullscreen=""></iframe>
from bokeh.plotting import figure, output_file, show
output_file("/line.html")
p = figure(plot_width=400, plot_height=400)
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
show(p)
line.html
当我使用网络浏览器打开该文件时,便可以看到该文件并与之交互。
将我的line.html
文件嵌入Reveal.js中。
<iframe data-src="/Users/JohnDoe/line.html" width="945" height="555" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:3px solid #666; margin-bottom:5px; max-width: 600%;" allowfullscreen=""></iframe>
这导致该消息Cannot GET /Users/JohnDoe/line.html
显示在我的iframe中。
<iframe data-src="file:///Users/JohnDoe/line.html" width="945" height="555" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:3px solid #666; margin-bottom:5px; max-width: 600%;" allowfullscreen=""></iframe>
杂乱无章。
我希望我的.html文件在“我能做什么”部分的1.中工作时显示在iframe中。
Reveal.js输出是从某种本地服务器显示的,对吗?在这种情况下,AFAIK IFrame将不允许您从本地文件加载。通常,您无法从中进行加载file:\\
,http:\\
因为那将是一个巨大的安全漏洞。一种解决方案是运行一个基本的HTTP服务器来提供Bokeh HTML文件(例如python -m http.server
(或python -m SimpleHTTPServer
用于旧版Python 2)),然后让IFrame从简单服务器加载Bokeh页面。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句