echart 漸變內置生成器echarts.graphic.LinearGradient

在使用echarts繪製圖表時, 如果需要使用漸變色, 則應使用echarts內置的漸變色生成器echarts.graphic.LinearGradient

series: [{
                name: "2017",
                type: "bar",
                barWidth: 25,
                stack: "1",
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                                offset: 0,
                                color: colors[0].start
                            },
                            {
                                offset: 1,
                                color: colors[0].end
                            }
                        ]),
                    }
                },
                label: {
                    normal: {
                        show: false,
                    }
                },
                data: lastYearData,
                animationEasing: "elasticOut"
 }]

入了5個參數:

前4個參數用於配置漸變色的起止位置, 這4個參數依次對應右/下/左/上四個方位. 而0 0 0 1則代表漸變色從正上方開始.
第5個參數則是一個數組, 用於配置顏色的漸變過程. 包含offset和color兩個參數. offset的範圍是0 ~ 1, 用於表示位置, color表示顏色
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章