简体   繁体   English

eCharts 水平填充区域

[英]eCharts fill area horizontally

I have a line type eCharts graph and I want to fill the area between the line and the y axis .我有一个线型eCharts图,我想填充线和y 轴之间的区域。 The default area filling behaviour happens vertically, the chart fills out the space between the line and the x axis .默认区域填充行为垂直发生,图表填充线条和x 轴之间的空间。

垂直默认区域填充 所需的水平区域填充

I know I can swap axes in other chart libraries but doesn't look like an option here in eCharts .我知道我可以在其他图表库中交换轴,但在eCharts中看起来不像一个选项。

These are the options I'm using to set up the chart:这些是我用来设置图表的选项:

const options = {
            tooltip: {
                show: false
            },
            grid: {
                show: true,
                top: 0,
                bottom: 40,
                left: 50,
                right: 10,
            },
            xAxis: {
                id: 'x',
                type: 'value',
                min: 0,
                max: 4,
            },
            yAxis: {
                id: 'y',
                type: 'value',
                inverse: true,
                min: range?.min,
                max: range?.max,
                axisLine: {
                    show: true
                },
                splitLine: {
                    show: true
                },
                axisTick: {
                    show: true
                }
            },
            series: {
                type: 'line',
                xAxisId: 'x',
                yAxisId: 'y',
                symbol: 'none',
                smooth: true,
                connectNulls: false,
                // 2d array like [[1,1000], [3, 1250], ...]
                data: filteredData.data,
                lineStyle: {
                    color: '#f00',
                },
                areaStyle: {
                    color: '#f00',
                    origin: 'auto'
                }
            }
        };

Thanks.谢谢。

Ok, looks like treating the y axis type as a category instead of value and removing the y axis boundaries did the trick.好的,看起来像将 y 轴类型视为类别而不是值并删除 y 轴边界就可以了。

yAxis: {
         id: 'y',
         type: 'category', // category and not value
         // y axis boundaries removed
         ...

Outcome after these changes:这些变化后的结果:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM