Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【echarts使用】之设置柱子多个颜色(渐进色) #13

Open
yihan12 opened this issue Jul 22, 2022 · 0 comments
Open

【echarts使用】之设置柱子多个颜色(渐进色) #13

yihan12 opened this issue Jul 22, 2022 · 0 comments
Labels
【echarts使用】 echarts使用

Comments

@yihan12
Copy link
Owner

yihan12 commented Jul 22, 2022

series:[
    {
        type: 'bar',
        stack: 'Total',
        itemStyle: {
            borderRadius: [4, 4, 4, 4], // 圆柱
            color: function (params) {
                //首先定义一个数组
                const colorList = [
                    {
                        x: 0,
                        y: 1,
                        x2: 0,
                        y2: 0,
                        colorStops: [{
                            offset: 0, color: '#3BABFF' // 0% 处的颜色
                        }, {
                            offset: 1, color: '#7548FF' // 100% 处的颜色
                        }],
                        global: false // 缺省为 false
                    }, "#514FA4", "#373948"];
                if (params.data.type == "达标") {
                    return colorList[0]
                } else if (params.data.type == "未达标") {
                    return colorList[1]
                } else {
                    return colorList[2]
                }
            },
        },
    }
]
@yihan12 yihan12 added the 【echarts使用】 echarts使用 label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
【echarts使用】 echarts使用
Projects
None yet
Development

No branches or pull requests

1 participant