简体   繁体   English

Plotly python 离线 - 点击访问 url?

[英]Plotly python offline - visit url on click?

Is it possible to configure a plotly plot so that the user is taken to a specific url when they click on a certain data point?是否有可能配置plotly绘制这样,当他们点击一个特定的数据点,用户被引导到一个特定的网址?

My intended usage is for bar charts: I'd like to be able to click on a bar and then be taken to a url, each bar being configured with a different url.我的预期用途是用于条形图:我希望能够点击一个条形然后被带到一个 url,每个条形都配置了一个不同的 url。

I'm using plotly python offline to create a <div> which I'm embedding in a website.我正在离线使用 plotly python 创建一个<div>并将其嵌入到网站中。

Is this possible with the postMessage API on plotly python offline mode?这可以通过 postMessage API 在 plotly python 离线模式下实现吗?

Here I have created an example for you to edit here - right now it has the bars defined Bar1 Bar2 Bar3 Bar4 which indexes a URL for each in the JavaScript code (edit to your liking).在这里,我已经创建了您编辑在这里的例子-现在它已经定义了酒吧Bar1 Bar2 Bar3 Bar4其索引中的每个JavaScript代码的URL(编辑根据自己的喜好)。 In order to use the PostMessage API the barchart you made has to be embedded in an iframe (see how to do it in the codepen link HTML section) and the JavaScript has to be included (on the right pane in the codepen link).为了使用 PostMessage API,您制作的条形图必须嵌入到 iframe 中(请参阅如何在 codepen 链接 HTML 部分中执行此操作)并且必须包含 JavaScript(在 codepen 链接的右侧窗格中)。

Full running example: http://codepen.io/mslezak/pen/ZWxMBP完整运行示例: http : //codepen.io/mslezak/pen/ZWxMBP

Plotly chart embedded: https://plot.ly/~mslezak/11/y-vs-x/嵌入的绘图图表: https ://plot.ly/~mslezak/11/y-vs-x/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM