Merge pull request #6937 from dataease/pr@dev-v2@fix_area_gradient

fix: 面积图开启渐变后颜色随大小改变
This commit is contained in:
wisonic-s 2023-11-30 11:18:51 +08:00 committed by GitHub
commit f765203ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)