一、legend 图例,data自动生成数组的方法;
legend: { type: 'scroll', bottom: 10, data: (function (){ var list = []; for (var i = 1; i <=28; i++) { list.push(i + 2000 + ''); } return list; })() },
最近7天日期的产生
var oneDay = 24 * 60 * 60 * 1000;//毫秒 var now = new Date(+new Date() - 6 * oneDay);//6天前 var date = []; for (var j = 1; j <= 7; j++) { now = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-'); date.push(now); now = new Date(+new Date(now) + oneDay); } //console.log(date);
随机数组的产生
function getData(shift) { var a = parseFloat(Math.random() * 600).toFixed(2); return a; } var dataList = []; for (var m = 1; m <= 7; m++) { dataList.push(getData()); } console.log(dataList);