| | |
| | | }); |
| | | |
| | | const typeList = ['设备温度', '组端电流', '组端电压', '负载电流']; |
| | | const propList = ['groupTmp', 'groupCurr', 'groupVol', 'loadCurr']; |
| | | |
| | | // 这两个数值是百分比 |
| | | const baseTop = 10; |
| | |
| | | |
| | | function getSeries(datas) { |
| | | let res = []; |
| | | typeList.forEach((item, index) => { |
| | | propList.forEach((item, index) => { |
| | | res.push({ |
| | | type: 'line', |
| | | smooth: true, |
| | |
| | | showSymbol: false, |
| | | xAxisIndex: index, |
| | | yAxisIndex: index, |
| | | gridIndex: index, |
| | | lineStyle: { |
| | | width: 1 |
| | | }, |
| | | data: datas[item] || [], |
| | | data: datas.map(v => v[item]) |
| | | }); |
| | | }); |
| | | return res; |
| | |
| | | |
| | | function getOptions(xLabels, datas) { |
| | | xLabels = xLabels || []; |
| | | datas = datas || {}; |
| | | datas = datas || []; |
| | | let series = getSeries(datas); |
| | | const option = { |
| | | // title: { |
| | |
| | | formatter: function (params) { |
| | | if (params.length) { |
| | | // params.unshift({ seriesName: 'time', value: Math.floor(params[0].value), color: '#5193f2' }) |
| | | let _label = ''; |
| | | let res = typeList.map((seriesName, idx) => { |
| | | for (var i = 0; i < params.length; i++) { |
| | | var param = params[i]; |
| | | var style = 'color: ' + param.color; |
| | | if (param.seriesIndex === idx) { |
| | | _label = param.name; |
| | | return '<span style="' + style + '">' |
| | | + seriesName |
| | | + ':</span><span style="' |
| | | + style + '">' + param.value + '</span>'; |
| | | } |
| | | } |
| | | }).join('<br>'); |
| | | console.log('res', res, '============='); |
| | | }); |
| | | res.push('<span style="color: #000">' + _label + '</span>'); |
| | | res = res.join('<br>'); |
| | | // console.log('res', res, '============='); |
| | | return res; |
| | | |
| | | } |