我想用循环完成此表,但它会产生一个错误,你可以帮助我。
Morris.Area({
element: 'graph-area',
behaveLikeLine: true,
gridEnabled: false,
gridLineColor: '#dddddd',
axes: true,
fillOpacity:.7,
data: [
for( var i=1;i<10;i++)
{
{period: '2010 Q1', itouch: i},
}
],
lineColors:['#E67A77','#D9DD81','#79D1CF'],
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 0,
lineWidth: 0,
hideHover: 'auto'
});
答案 0 :(得分:0)
使用中间变量,如:
var myData = [];
for( var i=1;i<10;i++){
myData.push({period: '2010 Q1', itouch: i});
}
Morris.Area({
element: 'graph-area',
behaveLikeLine: true,
gridEnabled: false,
gridLineColor: '#dddddd',
axes: true,
fillOpacity:.7,
data: myData,
lineColors:['#E67A77','#D9DD81','#79D1CF'],
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 0,
lineWidth: 0,
hideHover: 'auto'
});