The echarts chart solves the problem that the Y-axis scale is not an integer in some cases

1: Problem description

      When we are developing and using the echarts chart to display data, when the data is 0, the echarts chart will divide the Y-axis scale into equal parts by default. At this time, if I want to display the number of tasks and the number of types on the Y-axis, it will appear Decimals, such as: 0.2, 0.4, this is obviously unreasonable.

question:

2: Solution

  	// 解决Y轴整数刻度
	var maxCount = '5';
	var newdata = series[0].data;
	var count = Math.max(...newdata);
	if (count == 0) {
		yAxis[0].max = maxCount;
	}
    if(count <= 5){
        yAxis[0].max = maxCount;
    }

3: Effect

 

Guess you like

Origin blog.csdn.net/XikYu/article/details/131228890