//创建电池组统计分析折线图
|
var mycapacityChart;
|
function CreateLineEchart(ele,lname,xdata,sdata,battname){
|
if(arguments.length<5){
|
battname = lname;
|
}
|
mycapacityChart=echarts.init(ele);
|
mycapacityChart.clear();
|
console.info(sdata);
|
var option={
|
tooltip:{
|
show:true,
|
trigger:'axis',
|
formatter:function(params){
|
console.info(params);
|
var str = '';
|
for(var i=0;i<params.length;i++){
|
str+=params[i].seriesName+'</br>';
|
str+=params[i].marker+params[i].seriesId+':'+params[i].data[0]+','+params[i].data[1]+'AH</br>';
|
}
|
return str;
|
}
|
},
|
title : {
|
//text: tname,
|
x: "center", //标题水平方向位置
|
textStyle: {
|
fontSize:13
|
}
|
},
|
toolbox:{
|
show : true
|
},
|
calculable : true,
|
xAxis:{
|
data:xdata
|
},
|
grid: {
|
top:'10%',
|
left: '1%',
|
right: '5%',
|
bottom: '2%',
|
containLabel: true
|
},
|
yAxis:[{
|
name:"y(AH)",
|
type:'value',
|
min:function(){
|
var min = Number.POSITIVE_INFINITY; //正无穷大的数
|
var arr = new Array();
|
if(sdata.length>0){
|
for(var i=0;i<sdata.length;i++){
|
console.info(sdata[i]);
|
console.info(typeof sdata[i]);
|
for(var j=0;j<sdata[i].length;j++){
|
arr.push(sdata[i][j][1]);
|
}
|
}
|
min = Math.min.apply(null,arr);
|
}
|
return (Math.floor(min*0.8));
|
}(),
|
max:function(){
|
var max = Number.NEGATIVE_INFINITY; //负无穷大的数
|
var arr = new Array();
|
if(sdata.length>0){
|
for(var i=0;i<sdata.length;i++){
|
console.info(sdata[i]);
|
for(var j=0;j<sdata[i].length;j++){
|
arr.push(sdata[i][j][1]);
|
}
|
}
|
max = Math.max.apply(null,arr);
|
}else{
|
max = 1;
|
}
|
|
return (Math.ceil(max*1.24));
|
}(),
|
axisLabel:{
|
formatter:function(value){
|
//解决原点处带符号问题
|
if(value==0)
|
{
|
return value;
|
}else{
|
return value ;
|
}
|
}
|
}
|
}],
|
series:function(){
|
var serie=[];
|
for( var i=0;i<sdata.length;i++){
|
//console.info(lname[i]);
|
//console.info(sdata[i]);
|
var item={
|
type:'line',
|
//symbol:'none',
|
id:lname[i],
|
data:sdata[i],
|
name:battname[i]
|
}
|
serie.push(item);
|
}
|
return serie;
|
}()
|
};
|
// 使用刚指定的配置项和数据显示图表。
|
mycapacityChart.setOption(option);
|
|
}
|
|
//更新折线图中的数据
|
function reflushmycapacityChart(tname){
|
//更新数据
|
maxflag=true;
|
minflag=true;
|
var option=mycapacityChart.getOption();
|
option.title[0].text=tname;
|
//console.info(option);
|
mycapacityChart.setOption(option);
|
if(mycapacityChart!=undefined){
|
|
option=mycapacityChart.getOption();
|
option.title[0].text=tname;
|
//console.info(option);
|
mycapacityChart.setOption(option);
|
}
|
}
|