he wei
19 小时以前 c353554427f56eeda8a7cb75cc12bfa572dd1c85
src/components/echarts/line2.vue
@@ -16,6 +16,7 @@
   });
   const typeList = ['设备温度', '组端电流', '组端电压', '负载电流'];
  const propList = ['groupTmp', 'groupCurr', 'groupVol', 'loadCurr'];
   // 这两个数值是百分比 
   const baseTop = 10;
@@ -61,14 +62,15 @@
      return echarts.util.merge({
         top: top + '%',
         height: gridHeight + '%',
         left: '15%',
         // left: '15%',
         left: 80,
         right: 14,
      }, opt || {}, true);
   }
   function getSeries(datas) {
      let res = [];
      typeList.forEach((item, index) => {
      propList.forEach((item, index) => {
         res.push({
            type: 'line',
            smooth: true,
@@ -77,10 +79,11 @@
            showSymbol: false,
            xAxisIndex: index,
            yAxisIndex: index,
        gridIndex: index,
            lineStyle: {
               width: 1
            },
            data: datas[item] || [],
            data: datas.map(v => v[item])
         });
      });
      return res;
@@ -90,7 +93,7 @@
   function getOptions(xLabels, datas) {
      xLabels = xLabels || [];
      datas = datas || {};
      datas = datas || [];
      let series = getSeries(datas);
      const option = {
         // title: {
@@ -113,19 +116,23 @@
            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;
            
               }
@@ -197,16 +204,17 @@
         // }],
         yAxis: [
            makeYAxis(0, {
               name: typeList[0].replace(/(.{2})/g, '$1\n').replace(/\n$/, ''),
               // name: typeList[0].replace(/(.{2})/g, '$1\n').replace(/\n$/, ''),
               name: typeList[0],
            }),
            makeYAxis(1, {
               name: typeList[1].replace(/(.{2})/g, '$1\n').replace(/\n$/, ''),
               name: typeList[1],
            }),
            makeYAxis(2, {
               name: typeList[2].replace(/(.{2})/g, '$1\n').replace(/\n$/, ''),
               name: typeList[2],
            }),
            makeYAxis(3, {
               name: typeList[3].replace(/(.{2})/g, '$1\n').replace(/\n$/, ''),
               name: typeList[3],
            })
         ],
         series