fix: 面积图开启渐变后颜色随大小改变

This commit is contained in:
wisonic-s 2023-11-30 11:17:29 +08:00
parent 9cfdf0f9a5
commit 18a8f9ff8f

View File

@ -176,8 +176,16 @@ export class Area extends G2PlotChartView<AreaOptions, G2Area> {
const areaColors = [...colors, ...colors]
let areaStyle
if (customAttr.basicStyle.gradient) {
areaStyle = () => {
const ele = areaColors.shift()
const colorMap = new Map()
areaStyle = item => {
let ele
const key = `${item.field}-${item.category}`
if (colorMap.has(key)) {
ele = colorMap.get(key)
} else {
ele = areaColors.shift()
colorMap.set(key, ele)
}
if (ele) {
return {
fill: setGradientColor(hexColorToRGBA(ele, alpha), true, 270)