Skip to content
本页目录

专项答疑

柱状图如何设置渐变色

柱状图可通过设置series[n].itemStyle.color来实现渐变色,具体参考如下,其中x,y的配置表示了渐变的方向,如下设置的是纵向,若要换成横向可以把y2设置成0,把x2设置成1。在此基础上调整下面的两个色值即可实现各种各样的渐变效果。

js
"itemStyle": {
        "color": {
        "type": "linear",
        "x": 0,
        "y": 0,
        "x2": 0,
        "y2": 1,
        "colorStops": [
            {
                "offset": 0,
                "color": "rgba(0,152,250, 1)"
            },
            {
                "offset": 1,
                "color": "rgba(24,30,46, 1)"
            }
        ]
    },

内部资料,请勿外传