将googleVis图表嵌入网站 [英] Embedding googleVis charts into a web site

查看:103
本文介绍了将googleVis图表嵌入网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

googleVis 软件包中读取小插曲使用googleVis软件包用户可以使用基于R数据框的交互式图表轻松创建网页,并通过R.rsp软件包或在自己的站点中显示它们。按照说明操作,我可以使用情节方法为gvis对象。默认情况下,此方法使用对象的类型和图表id信息在googleVis包的rsp / myAnalysis文件夹中创建一个rsp文件,并使用rrsrs包的本地Web服务器显示输出(缺省端口为8074 )。

任何人都可以帮助我(或提供一些链接)关于为了将这些图表嵌入到现有网站(例如,joomla网站)?

解决方案

显然,我认为这对于@ gd047来说太冗长了,但是我提供了一种教程,对于想在自己的网站上使用googleVis的其他读者。



从CRAN安装googleVis

  install.packages('googleVis')

请留意这些讯息。

然后,创建gvis对象:

  library(googleVis)
M < - gvisMotionChart(Fruits,Fruit,Year)



<你可以通过以下方式找到M的内容:

 > M 

,您可以在浏览器中找到该图:

 > (M)

然后,生成图表的必要条件是M $ html $ chart:

 > M $ html $ chart 
[1]<! - MotionChart ... ignored ... \> \\\
< / div> \\\

将其保存到文件中:

 > cat(M $ html $ chart,file =tmp.html)

如果您打开tmp.html作为文件(即地址说文件:///***/tmp.html),则可能会发生安全警告。您需要的是通过http://访问html。 / p>

因此,如果您可以编辑任何可以使用< script>标记的网页(例如,博主),则只需复制并粘贴tmp的内容即可使用它。 html,就像这样:

http://takahashik.blogspot.com/2011/01/googlevis-example.html



这里是着名的虹膜版本的例子:



http://takahashik.blogspot.com/2011/01/googl evis-example-for-data-iris_10.html

否则,如果您有一台Web服务器,您可以通过上传tmp.html来使用它服务器。

Reading from the googleVis package vignette: "With the googleVis package users can create easily web pages with interactive charts based on R data frames and display them either via the R.rsp package or within their own sites". Following the instructions I was able to see the sample charts, using the plot method for gvis objects. This method by default creates a rsp-file in the rsp/myAnalysis folder of the googleVis package, using the type and chart id information of the object and displays the output using the local web server of the R.rsp package (port 8074 by default).

Could anybody help me (or provide some link) on the procedure someone has to follow in order to embed such charts into an existing web site (e.g. a joomla site)?

解决方案

Obviously I think that this is too verbose for @gd047, but I put a kind of tutorial since it maybe helpful for other readers who want to use googleVis on their own website.

install googleVis from CRAN

install.packages('googleVis')

pay attention to the messages.

then, create gvis object:

library(googleVis)
M <- gvisMotionChart(Fruits, "Fruit", "Year")

you can find the contents of M by:

> M

and you can find the plot on your browser:

> plot(M)

then, what is necessary to generate the chart is M$html$chart:

> M$html$chart
[1] "<!-- MotionChart ... omitted... \">\n</div>\n"

save it to a file:

> cat(M$html$chart, file="tmp.html")

if you open the "tmp.html" as a file (i.e, address says files:///***/tmp.html), then security warning may occur. What you need is to access the html via http://.

So if you can edit any web page where <script> tag is available (e.g., blogger), you can use it by simply copy and paste the contents of tmp.html, like this:

http://takahashik.blogspot.com/2011/01/googlevis-example.html

here is the famous "iris" version of example:

http://takahashik.blogspot.com/2011/01/googlevis-example-for-data-iris_10.html

Otherwise, if you have a web server, you can use it by uploading the tmp.html on the server.

这篇关于将googleVis图表嵌入网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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