在 Github 托管的站点中嵌入交互式 Bokeh 或 Plotly 图形

Embedding interactive Bokeh or Plotly figures in Github-hosted site

有没有人有在 Github 托管的网站中嵌入交互式图表的经验?我读到 github 不会呈现来自 Bokeh、Plotly 等的交互式图,但其他网站似乎可以?理想情况下,我想做的是上传一个包含这些图的 Jupyter notebook,并将它们显示在我的 github 博客上。但出于某种原因,当其他一切看起来都很好时,它们不会渲染。谢谢!

GitHub 从它呈现的内容中清除所有用户提供的 JavaScript。这意味着基于 JavaSript 的浏览器绘图库在 GitHub 直接呈现的页面中根本无法运行。

但是,您可以将 https://nbviewer.jupyter.org/ 指向 GitHub 存储库,该存储库中任何静态呈现的笔记本都将完全正常运行,包括绘图。看,例如

中的笔记本

https://nbviewer.jupyter.org/github/bokeh/bokeh-notebooks/blob/master/index.ipynb

另一种选择是在 MyBinder 的 GitHub 存储库中操作笔记本,它提供实时的,实际上 运行 可以与之交互的笔记本。例如。

https://mybinder.org/v2/gh/bokeh/bokeh-notebooks/master?filepath=tutorial%2F00%20-%20Introduction%20and%20Setup.ipynb

我不确定是否 bigreddot's answer was meant to apply only to github.com - if you're willing to consider GitHub Pages (github.io), simply follow these detailed instructions 来自 towardsdatascience。

在 Github 页面上托管静态 HTML 和 Javascript 内容似乎完全简单,包括 html 导出像 plotly 这样的绘图库。 您可以检查他们的 example 并说服自己 HTML body 中的 javascript 没有 被擦除。