研发googlevis - 博客嵌入问题

发布于 2024-11-29 14:27:09 字数 2114 浏览 0 评论 0原文

我正在尝试将 googlevis 运动图表嵌入到博客中,但遇到了一些问题。我一直按照 takahashik.blogspot.com/2011/01/googlevis-example.html 和 将 googleVis 图表嵌入网站,但当我复制自己的代码并使用 .但是,当我从 takahashik 博客复制代码时,它就可以工作了!即使我根据该博客中使用的数据重新创建运动图表,我仍然无法将其嵌入。

我可以使用本地网络服务器和 R.rsp 包查看输出,但我真的很难进一步做到这一点,并将运动图表放在博客上。我对此很陌生,可能错过了一些非常明显的东西,所以如果有人有任何建议,我们将不胜感激,非常

感谢

这是我试图放在博客上的(缩短的)代码:

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

数据:向日葵,图表ID : MotionChart_2011-08-15-10-30-18
R版本2.11.1(2010-05-31), Google 使用条款

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




如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许你一世情深 2024-12-06 14:27:09

要在 blogger 中使用 googleVis 输出,您必须首先创建一个 Google Gadget。
这是一个例子:

库(googleVis)

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

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

您从 createGoogleGadget 看到的内容是博主所需要的。
因此,将输出复制到一个文件(例如 myMotionChart.xml)中,然后将其上传到网络上的某个位置,例如 Google Docs 或您的公共保管箱文件夹。
以下是 googleVis 包中的一个示例:
http://google-motion- Charts-with-r.googlecode.com/svn/trunk/inst/gadgets/motionchart.xml

现在您可以返回博客并导航到设计选项卡,您将在其中找到标记为小工具。点击“添加小工具”,然后点击“添加您自己的小工具”,然后将链接粘贴到您的小工具。

工作完成了。

我希望这有帮助。

问候,

马库斯

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文