在嵌入式绘图图表上启用滚轮缩放

Enable wheel zoom on embedded plotly chart

我想嵌入一个导出到chart studio的图表,并且可以使用鼠标滚轮放大图表(这是地图最方便的方式)。

但是,无论我在导出图表时使用哪个选项(iframe,html),一旦它被嵌入到另一个网站中,滚轮缩放就会被禁用。我使用了 jupyter-lab 并启用了它。有什么我遗漏的吗?

以下是我想要得到的结果的一些示例

https://plotly.com/python/mapbox-county-choropleth/

使用 iframe 嵌入:

<iframe width="900" height="800" frameborder="0" scrolling="no" src="//plotly.com/~hugolmn/3.embed"></iframe>

编辑了解更多详情

这是我用来将图形导出到图表工作室的代码。

# Exporting to chart_studio
py.plot(fig, filename = 'sncf-train-stations', auto_open=True)

Here is the uploaded graph and here 是嵌入的地方。

在 Chart Studio 上,鼠标滚轮缩放效果很好,但集成到其他地方时效果不佳。

感谢您的帮助!

一种解决方案是使用 write_html 在 html 中创建图形,然后将其用作 iframe 的来源。所以像:

fig.write_html("map.html")

然后是 iframe,例如:

<iframe width="900" height="800" frameborder="0" scrolling="no" src="map.html"></iframe>