R + googlevis - 嵌入博客的问题 [英] R + googlevis - problem embedding on blogger

查看:93
本文介绍了R + googlevis - 嵌入博客的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在博客中嵌入一个googlevis动作图表,但遇到一些问题。我一直在遵循takahashik.blogspot.com/2011/01/googlevis-example.html和将googleVis图表嵌入网站,但似乎无法在我复制我自己的代码并使用时在博客上查看图表。但是,当我从takahashik博客的代码复制它的作品!即使我从该博客中使用的数据重新创建运动图,我仍然无法将其嵌入。



我可以使用本地websever和R.rsp软件包,但是我们真的很努力地进一步研究,并且实际上将运动图表放在博客上。我很新,可能错过了一些非常明显的东西,所以如果有人有任何建议,将不胜感激



非常感谢



以下是我试图插入博客的代码(缩写):

 < script type =text / javascriptsrc =http://www.google.com/jsapi> 
< / script>
< script type =text / javascript>
google.load(visualization,1,{packages:[motionchart]});
google.setOnLoadCallback(drawChart);
函数drawChart(){
var data = new google.visualization.DataTable();
var datajson = [
[
Adam / Gemma,
new日期(2010,4,25),
0,
0,

],
[
Adam / Gemma,
新日期(2010,5,3),
1,
0 ,
0
],
[
Adam / Gemma,
new日期(2010,5,10),
2,
102,
102
],
[
Adam / Gemma,
新日期(2010,5,17),
3,
195,
93
],
[
Adam / Gemma,
新日期(2010,5,24),
5 ,
300,
105
],
[
Adam / Gemma,
new日期(2010,6,15),
7,
640,
340
],
[
Adam / Gemma,
新日期(2010,6,22),
8,
700,
60
],
[
Adam / Gemma,
新日期(2010,6,29) ,
9,
800,
100
],
[
Adam / Gemma,
new日期(2010,7, 5),
10,
null,
null
],
[
Adam / Gemma,
new日期(2010, 7,12),
11,
1200,
null
] ...............
.... ............
.............
];
data.addColumn('string','Name');
data.addColumn('date','datenew');
data.addColumn('number','Week');
data.addColumn('number','Height');
data.addColumn('数字','增长');
data.addRows(datajson);
var chart = new google.visualization.MotionChart(
document.getElementById('MotionChart_2011-08-15-10-30-18')
);
var options = {};
options [width] = 600;
options [height] = 500;
chart.draw(data,options);
}
< / script>
< div id =MotionChart_2011-08-15-10-30-18style =width:600px; height:500px;>
< / div>

数据:向日葵,图表编号:MotionChart_2011-08-15-10-30-18


R版本2.11.1(2010-05-31),

Google使用条款




解决方案

要在博客中使用googleVis输出,您必须先创建一个Google小工具。
所以这里有一个例子:


library(googleVis)



M = gvisMotionChart(水果,水果,年份)



cat(createGoogleGadget(M))#< - googleVis中的函数

$ b

您从createGoogleGadget看到的内容是博客所需的内容。
因此,将输出复制到一个文件中,比如说myMotionChart.xml,并将其上传到网络的某处,例如, Google文档或您的公共收件箱文件夹。
以下是googleVis包的一个示例:
http://google-motion-charts-with-r.googlecode.com/svn/trunk/inst/gadgets/motionchart.xml



现在您可以回到博主并导航到设计选项卡,您将在其中找到标有小工具的区域。点击'添加小工具',然后点击'添加您自己'并粘贴到您的小工具链接中。



完成任务。



我希望这会有帮助。



问候,



Markus


I am trying to embed a googlevis motion chart on to a blog, but am having some problems. I have been followin the instructions by takahashik.blogspot.com/2011/01/googlevis-example.html and Embedding googleVis charts into a web site, but cannot seem to view the chart on the blog when i copy my own code and use . However when i copy the code from the takahashik blog it works! Even if i recreate the motion chart from the data used in that blog i still can't get it to embed.

I can view the output using the local websever and the R.rsp package but am really struggling to go further with this and actually put the motion chart on the blog. I'm quite new to this and probably missing something really obvious, so if anyone has any suggestions that will be greatly appreciated

Many thanks

Here is the (shortened) code i'm trying to put on to blogger:

<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
google.load("visualization", "1", { packages:["motionchart"] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
var datajson = [
 [
 "Adam/Gemma",
new Date(2010,4,25),
0,
0,
0 
],
[
 "Adam/Gemma",
new Date(2010,5,3),
1,
0,    
0 
],
[
 "Adam/Gemma",
new Date(2010,5,10),
2,
102,
102 
],
[
 "Adam/Gemma",
new Date(2010,5,17),
3,
195,
93 
],
[
 "Adam/Gemma",
new Date(2010,5,24),
5,
300,
105 
],
[
 "Adam/Gemma",
new Date(2010,6,15),
7,
640,
340 
],
[
 "Adam/Gemma",
new Date(2010,6,22),
8,
700,
60 
],
[
 "Adam/Gemma",
new Date(2010,6,29),
9,
800,
100 
],
[
 "Adam/Gemma",
new Date(2010,7,5),
10,
null,
null 
],
[
 "Adam/Gemma",
new Date(2010,7,12),
11,
1200,
null 
]...............
................
.............
];
data.addColumn('string','Name');
data.addColumn('date','datenew');
data.addColumn('number','Week');
data.addColumn('number','Height');
data.addColumn('number','Growth');
data.addRows(datajson);
var chart = new google.visualization.MotionChart(
   document.getElementById('MotionChart_2011-08-15-10-30-18')
);
var options ={};
options["width"] =    600;
options["height"] =    500;
chart.draw(data,options);
}
</script>
<div id="MotionChart_2011-08-15-10-30-18" style="width: 600px; height: 500px;">
</div>

Data: sunflower, Chart ID: MotionChart_2011-08-15-10-30-18
R version 2.11.1 (2010-05-31), Google Terms of Use

解决方案

To use the googleVis output in blogger you have to create a Google Gadget first. So here is an example:

library(googleVis)

M=gvisMotionChart(Fruits,"Fruit", "Year")

cat(createGoogleGadget(M)) # <- function from googleVis

The content you see from createGoogleGadget is what is required for blogger. So copy the output into a file, say myMotionChart.xml, and upload it somewhere to the web, e.g. Google Docs or your public dropbox folder. Here is one example from the googleVis package: http://google-motion-charts-with-r.googlecode.com/svn/trunk/inst/gadgets/motionchart.xml

Now you can go back to blogger and navigate to the design tab, where you will find an area labelled Gadget. Click on 'Add Gadget', than 'Add your own' and paste in the link to your gadget.

Job done.

I hope this helps.

Regards,

Markus

这篇关于R + googlevis - 嵌入博客的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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