Method of non-overlapping echart line chart and column chart

Define two yAxis (arrays), one for the column chart and one for the line chart.

The column chart gives a max: the maximum value of the column chart*2

The line graph gives a min: the maximum value of the line graph-((the maximum value of the line graph-the minimum value of the line graph) * 2)

The specific code is as follows:

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: [
        {
            type: 'value',
            max: (value) => value.max*2,
        },
        {
            type: 'value',
            min: (value) => value.max - ((value.max - value.min) * 2),
	    max: (value) => value.max,
        }
    ],
    series: [
        {
            data: [335, 230, 224, 218, 135, 147, 660],
            type: 'bar',
            yAxisIndex: 0
        },
        {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: 'line',
            yAxisIndex: 1
        }
    ]
};

effect:

Guess you like

Origin blog.csdn.net/joyvonlee/article/details/113757002
Recommended