這不是一個錯誤。 Google可視化API已更改。
在http://code.google.com/apis/chart/interactive/docs/customizing_axes.html#Help他們發佈了一些解決方案來解決這個問題。使用選項:
strictFirstColumnType: false
只能用作臨時解決方案。谷歌說:
但請記住,此選項僅適用於有限的時間,並將在不久的將來被刪除。
推薦的解決方案是,您將x軸上的日期字段更改爲字符串。在將值添加到DateTable對象之前,我已經通過使用格式化程序來實現此目的。
var formatterMoney = new google.visualization.NumberFormat({suffix: ' zł', decimalSymbol: ',', groupingSymbol: ' '});
var formatterDate = new google.visualization.DateFormat({pattern: 'dd.MM.yyyy'});
var data = new google.visualization.DataTable();
data.addColumn('string', 'order date'); //used to be date field here
data.addColumn('number', 'total amount');
data.addRow([formatterDate.formatValue(new Date('2011-12-20')),971793.93]); //used to be Date object, now is Date formated as String
data.addRow([formatterDate.formatValue(new Date('2011-11-30')),1.0]);
data.addRow([formatterDate.formatValue(new Date('2011-11-17')),1.0]);
data.addRow([formatterDate.formatValue(new Date('2011-10-27')),1.72]);
data.addRow([formatterDate.formatValue(new Date('2011-10-26')),10.27]);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
formatterMoney.format(data, 1);
chart.draw(data, {width: window.width, height: 400, hAxis: {direction: -1}});
看起來它與日期字段有關。我有同樣的問題。 – 2012-01-18 20:00:03
今天他們推出了新版本:https://groups.google.com/forum/#!topic/google-visualization-api/1A-lfiFeLvc – 2012-01-18 20:26:53