我正在创建图表,为此我需要 javascript 中这种形式的数据:
var currYear = [["2011-08-01",796.01], ["2011-08-02",510.5], ["2011-08-03",527.8], ["2011-08-04",308.48]]
数据来自 JSON
var total_click = JSON.parse(<%=raw @report.to_json %>);
var i=0;
var graph_type = "";
var graph_typ = new Array();
while(i < total_click.length){
graph_typ.push("['"+total_click[i].report_date+"',"+total_click[i].clicks+"]");
i++;
}
我从中得到的数据如下
['2012-03-19',48],['2012-03-20',14],['2012-03-21',934]
我如何获得这种格式
[['2012-03-19',48],['2012-03-20',14],['2012-03-21',934]]