阴谋地python离线-点击访问url吗? [英] Plotly python offline - visit url on click?

查看:44
本文介绍了阴谋地python离线-点击访问url吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以配置 plotly 图,以便在用户访问特定网址时点击某个数据点?

我的预期用途是用于条形图:我希望能够单击一个条形,然后转到一个URL,每个条形都配置有不同的URL.

我正在离线使用Plotly python创建要嵌入到网站中的<div>.

在密谋的python离线模式下使用postMessage API可以做到吗?

解决方案

在这里,我为您创建了一个示例供您在此处编辑-现在,它具有定义的条形图Bar1 Bar2 Bar3 Bar4每个JavaScript代码中的URL(根据您的喜好进行编辑).为了使用PostMessage API,必须将您制作的条形图嵌入到iframe中(请参见代码笔链接HTML部分中的操作方法),并且必须包含JavaScript(在代码笔链接的右窗格中). /p>

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

嵌入式图表: https://plot.ly/~mslezak/11/y-vs-x/

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?

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.

I'm using plotly python offline to create a <div> which I'm embedding in a website.

Is this possible with the postMessage API on plotly python offline mode?

解决方案

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). 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).

Full running example: http://codepen.io/mslezak/pen/ZWxMBP

Plotly chart embedded: https://plot.ly/~mslezak/11/y-vs-x/

这篇关于阴谋地python离线-点击访问url吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆