lxw
2020-07-11 9db52f2f2dd3665fe9da1ae5657e0167c3a34d40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//创建电池组统计分析折线图
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;
        }()
    };
    console.log(option);
    // 使用刚指定的配置项和数据显示图表。
    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);
    }
}