在自己平台画折线图,一条数据时报错
配置项如下
//趋势图
var getOption = function (chart_name) {
var option = {
title : {
text: chart_name,
subtext: ''
},
tooltip : {
trigger: 'axis'
},
legend: {
data:[],
x : 'right',
padding: 25,
},
toolbox: {
show : true,
feature : {
mark : {show: false},
dataView : {show: true, readOnly: false},
magicType : {
show: false,
type: ['line', 'funnel']
},
restore : {show: false},
saveAsImage : {show: true}
}
},
calculable : false,
grid : {
x2 : 35,
x : 60
},
xAxis : [],
yAxis : [
{
type : 'value',
axisLabel : {
formatter: '{value}',
show:true
},
splitArea : {show : true}
}
],
series : [],
animation: false
}
return option
};
var makeGraph = function (option,data, elememtID) {
var xAxisObj = {
type : 'category',
boundaryGap : false
};
xAxisObj['data'] = data['date'];
option['xAxis'].push(xAxisObj);
for (var key in data) {
if (key !== 'date') {
option['legend']['data'].push(key);
var seriesObj = {
type:'line'
};
seriesObj['symbol'] = 'none';
seriesObj['name'] = key;
seriesObj['data'] = data[key];
option['series'].push(seriesObj);
}
}
var myChart = echarts.init(document.getElementById(elememtID));
myChart.setOption(option,true);
};
var flowOption = getOption('流量波动趋势');
data = {"date": ["2017-11-19", "2017-11-20", "2017-11-21", "2017-11-22", "2017-11-23", "2017-11-24", "2017-11-25", "2017-11-26", "2017-11-27"], "c8726b1d": [161992, 36255748, 29286485, 35713193, 30966991, 190651468, 47285742, 188889260, 49193835]};
makeGraph(flowOption, data,'chart-panel');