小提琴here。
我在我的网站上设置了一个简单的谷歌图表示例,该示例已经运行了好几周。突然它不再起作用了。我已经检查了git历史记录,但我没有触及处理它的代码。在chrome中,我会收到以下错误:图表应为Cannot read property 'jI' of undefined
。在Firefox上我收到a is undefined
。这两种浏览器都没有在控制台上产生错误。
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Name', 'Amount in Dollars'],
['ALLOCATED', 5000],
['PAID-TO-DATE', 5000]]);
var ticks = [0,0];
var options = {
width: 230,
height: 400,
fontName: 'Source Sans Pro',
// If no background color is provided, defaults to white
backgroundColor: undefined,
hAxis: { baselineColor: 'white'},
vAxis: {
baselineColor: 'white',
gridlines: { color: 'black', count: 2 },
ticks: ticks
},
legend: { position: "none" }
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
我的问题是,出了什么问题,如何解决这个问题?
答案 0 :(得分:0)
首先,您在此行上的DataTable构造中存在一些语法错误:
['PAID-TO-DATE', 5000])]]);
第一个)
和第三个]
没有配对。它应该是:
['PAID-TO-DATE', 5000]]);
然后,在图表选项中,您使用vAxis.ticks
变量指定ticks
选项,但ticks
为undefined
。
如果您修复这些问题,图表应绘制:http://jsfiddle.net/asgallant/4UaA6/