对于大多数用户来说,这可能是一个过于简单的问题。我创建了一个 .html 文件,其中包含基于 Flash 的 Google Motion Chart 的代码。我在 Google 的 Code Playground 中编写了代码,它在那里工作,但是当我在 IE、Firefox 或 Chrome 中加载本地 .html 文件时,它就无法工作。我知道谷歌在这里建议的解决方案,但这对我不起作用。
我的代码粘贴在下面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['motionchart']});
</script>
<script type="text/javascript">
var visualization;
function drawVisualization() {
// To see the data that this visualization uses, browse to
// http://spreadsheets.google.com/ccc?key=pCQbetd-CptGXxxQIG7VFIQ
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheet/pub?key=0AjjzMkj-NxM0dEdFRWtYWTh6VDRlNGZfRThZN3BVZFE&single=true&gid=0&output=csv');
// Send the query with a callback function.
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
visualization = new google.visualization.MotionChart(document.getElementById('visualization'));
//visualization.draw(data, {'width': 800, 'height': 400});
var options = {};
options['state'] =
'{"xZoomedDataMin":631152000000,"colorOption":"3","playDuration":15000,"xZoomedIn":false, \
"sizeOption":"_UNISIZE","duration":{"timeUnit":"Y","multiplier":1}, \
"uniColorForNonSelected":false,"orderedByY":false,"yAxisOption":"3", \
"xZoomedDataMax":1230768000000,"yLambda":1,"iconType":"BUBBLE","yZoomedIn":false, \
"xLambda":1,"orderedByX":false,"yZoomedDataMin":63.16,"nonSelectedAlpha":0.3, \
"yZoomedDataMax":87.79,"xAxisOption":"_TIME","iconKeySettings":[],"time":"1990", \
"dimensions":{"iconDimensions":["dim0"]},"showTrails":true};';
options['width'] = 900;
options['height'] = 400;
visualization.draw(data, options);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="height: 400px; width: 400px;"></div>
</body>
</html>
感谢大家的帮助!
最好的,伊莱