echart sets the maximum scale of the y-axis of the histogram

start

Histogram of recently received demand and hope

  1. The maximum height of the y-axis can be slightly higher;
  2. The data of the histogram can be displayed above the histogram

Record the relevant configuration items

solution

Official document description

https://echarts.apache.org/zh/option.html#xAxis.max

Effect

insert image description here

the code

{
    
    
  key: 'business',
  title: {
    
    
    text: '业务领域分类',
    textStyle: {
    
    
      fontSize: 16
    },
    padding: [20, 32]
  },
  color: ['#A4CDEB', '#F2D378'],
  legend: {
    
    
    bottom: '10%'
  },
  tooltip: {
    
    
    trigger: 'item',
    formatter: '{b} : {a} 数量{c}'
  },
  xAxis: {
    
    
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    
    
    type: 'value',
    max: function (value) {
    
    
      return value.max + value.max * 0.2
    }
  },

  series: [
    {
    
    
      type: 'bar',
      data: [],
      itemStyle: {
    
    
        normal: {
    
    
          label: {
    
    
            show: true, // 开启显示
            position: 'top', // 在上方显示
            textStyle: {
    
    
              // 数值样式
              color: '#6E7079',
              fontSize: 14
            }
          }
        }
      }
    }
  ]
}


explain

Guess you like

Origin blog.csdn.net/wswq2505655377/article/details/131421883