xAxis: {
          type: "category",
          data: ['四美+休闲娱乐+文化场馆', '资讯', '大咖分享'],
          axisLabel: {
            show: true,
            fontSize: 10,
            interval: 0,
            color: "#CAE8EA",
            formatter: function (params) {
              var newParamsName = "";
              var paramsNameNumber = params.length;
              var provideNumber = 8; //一行显示多少个文字
              var rowNumber = Math.ceil(paramsNameNumber / provideNumber);
              if (paramsNameNumber > provideNumber) {
                for (var p = 0; p < rowNumber; p++) {
                  var tempStr = "";
                  var start = p * provideNumber;
                  var end = start + provideNumber;
                  if (p == rowNumber - 1) {
                    tempStr = params.substring(start, paramsNameNumber);
                  } else {
                    tempStr = params.substring(start, end) + "\n";
                  }
                  newParamsName += tempStr;
                }
              } else {
                newParamsName = params;
              }
              return newParamsName;
            }
          },
         
        },

echarts x轴文字过长 文字换行显示-LMLPHP

换行后

echarts x轴文字过长 文字换行显示-LMLPHP

 

 

07-15 17:28