我在Uncaught TypeError: undefined is not a function
行获得date
。删除.setHours(this.getHours()-6)
它运行得很好,但我需要为时区偏移。在这种情况下CST或-6小时。我相信我误用了点符号。注释AmCharts.stringToDate(
正在返回Date
个对象。
var lineChartData = [
{
date: AmCharts.stringToDate("2014-04-18 13:44:39", "YYYY-MM-DD JJ:NN:SS").setHours(this.getHours()-6),
ambUp: 67.21,
ambDown: 62.83,
ext: 47.75,
in: 44.15,
out: 44.38,
freeze: 23.45,
fridge: 46.29,
diff: 2.14,
diff2: 0.2250
},
];
答案 0 :(得分:3)
似乎this
似乎不是你想象的那样。在这样的属性中没有特殊范围,您应该使用额外的变量来引用日期两次
var date = AmCharts.stringToDate("2014-04-18 13:44:39", "YYYY-MM-DD JJ:NN:SS");
date.setHours(date.getHours() - 6);
var lineChartData = [{
date: date,
ambUp: 67.21,
ambDown: 62.83,
ext: 47.75,
in : 44.15,
out: 44.38,
freeze: 23.45,
fridge: 46.29,
diff: 2.14,
diff2: 0.2250
}];