echarts 横轴axisLabel长度截取

echarts yekong

wanjunshijiecom20220706HDSVvw

lodash方法

axisLabel: {
    margin: 10,
    interval: 0,
    rotate: 40,
    color: 'rgba(245, 245, 246, 1.00)',
    textStyle: {
      fontSize: 34
    },
    formatter: function (value) {
      return _.truncate(value, {
        'length': 8
      })
    }
  },

普通js方法

axisLabel: {
    margin: 10,
    interval: 0,
    rotate: 40,
    color: 'rgba(245, 245, 246, 1.00)',
    textStyle: {
      fontSize: 34
    },
    formatter: function (value) {
          if (value.length > 5) {
            return value.substring(0, 5) + '...'
          } else {
            return value
          }
        }
  },

lodash 截取指定长度的字符串

喜欢