我最近一直在使用googleVis软件包并且我已经能够生成动态图表,但是有没有人知道可以引导某人如何将源代码发布到托管博客的教程(例如,博客,wordpress)并嵌入动态图表?
开始假设我已经获得了下面的代码块(使用googleVis中的print()函数生成):
<!-- MotionChart generated in R 2.15.2 by googleVis 0.3.3 package -->
<!-- Tue Dec 04 12:39:01 2012 -->
<!-- jsHeader -->
<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
// jsData
function gvisDataMotionChartIDb88676415c3 ()
{
var data = new google.visualization.DataTable();
var datajson =
[
[
"Apples",
2008,
"West",
98,
78,
20,
"2008-12-31"
],
[
"Apples",
2009,
"West",
111,
79,
32,
"2009-12-31"
],
[
"Apples",
2010,
"West",
89,
76,
13,
"2010-12-31"
],
[
"Oranges",
2008,
"East",
96,
81,
15,
"2008-12-31"
],
[
"Bananas",
2008,
"East",
85,
76,
9,
"2008-12-31"
],
[
"Oranges",
2009,
"East",
93,
80,
13,
"2009-12-31"
],
[
"Bananas",
2009,
"East",
94,
78,
16,
"2009-12-31"
],
[
"Oranges",
2010,
"East",
98,
91,
7,
"2010-12-31"
],
[
"Bananas",
2010,
"East",
81,
71,
10,
"2010-12-31"
]
];
data.addColumn('string','Fruit');
data.addColumn('number','Year');
data.addColumn('string','Location');
data.addColumn('number','Sales');
data.addColumn('number','Expenses');
data.addColumn('number','Profit');
data.addColumn('string','Date');
data.addRows(datajson);
return(data);
}
// jsDrawChart
function drawChartMotionChartIDb88676415c3() {
var data = gvisDataMotionChartIDb88676415c3();
var options = {};
options["width"] = 600;
options["height"] = 500;
var chart = new google.visualization.MotionChart(
document.getElementById('MotionChartIDb88676415c3')
);
chart.draw(data,options);
}
// jsDisplayChart
function displayChartMotionChartIDb88676415c3()
{
google.load("visualization", "1", { packages:["motionchart"] });
google.setOnLoadCallback(drawChartMotionChartIDb88676415c3);
}
// jsChart
displayChartMotionChartIDb88676415c3()
<!-- jsFooter -->
//-->
</script>
<!-- divChart -->
<div id="MotionChartIDb88676415c3"
style="width: 600px; height: 500px;">
</div>
将此图表实际嵌入托管博客的方法是什么?我已经尝试过striaght剪切/粘贴到HTML中无济于事。我完全没有创作html或java代码的经验,所以我想知道我是不是运气不好。