echarts标签换行

xAxis: {
      type: 'value'
    },
    yAxis: {
      type: 'category',
      axisLabel: {
        interval: 0,
        formatter: function (label) {
          // console.log(label);
          let result = '';
          const length = label.length;
          const lineLabelCnt = 4;
          const rowCnt = Math.ceil(length / lineLabelCnt);
          if (length > lineLabelCnt) {
            for (let p = 0; p < rowCnt; p++) {
              let tempStr = '';
              const start = p * lineLabelCnt;
              const end = start + lineLabelCnt;
              if (p == rowCnt - 1) {
                tempStr = label.substring(start, length);
              } else {
                tempStr = label.substring(start, end) + '\n';
              }
              result += tempStr;
            }

          } else {
            result = label;
          }
          return result;
        }
      }
    },
    ```
    

你可能感兴趣的:(H5)