这不是一个错误。 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