V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
waiaan
V2EX  ›  问与答

关于 echarts 中渐变的问题

  •  
  •   waiaan · Feb 4, 2020 · 1252 views
    This topic created in 2284 days ago, the information mentioned may be changed or developed.
    // 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
    
    color: {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [{
            offset: 0, color: 'red' // 0% 处的颜色
        }, {
            offset: 1, color: 'blue' // 100% 处的颜色
        }],
        global: false // 缺省为 false
    }
    

    这是官网的说明,x、y、x2、y2 代表的是什么?以及 global 为 true 时又代表什么?

    谢谢。

    3 replies    2020-02-05 22:00:54 +08:00
    bigShrimp8577
        1
    bigShrimp8577  
       Feb 4, 2020
    其实好像是 x 是右,y 是下,x2 是左,y2 是上,反正是可以这样理解的
    waiaan
        2
    waiaan  
    OP
       Feb 5, 2020
    @bigShrimp8577
    谢谢,那这又代表什么意思?
    bigShrimp8577
        3
    bigShrimp8577  
       Feb 5, 2020
    @waiaan 额,就是颜色是从哪边开始啊,像你这个就是从上到下 红色渐变到蓝色啊,offset 为 0 就是开始的颜色
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3486 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 11:44 · PVG 19:44 · LAX 04:44 · JFK 07:44
    ♥ Do have faith in what you're doing.