fix(图表): fix(图表): 修复堆叠柱条图自定义图例顺序和自定义排序效果冲突 #17649

This commit is contained in:
wisonic
2026-01-21 19:27:14 +08:00
committed by wisonic-s
parent 26ff982a19
commit 2abc8abc6b

View File

@@ -976,10 +976,21 @@ export function setUpStackSeriesColor(
return
}
seriesSet.add(d.category)
})
const cats = [...seriesSet]
const stackAxis = extStack[0]
if (stackAxis.sort === 'custom_sort' && stackAxis.customSort?.length) {
cats.sort((a, b) => {
const aIndex = stackAxis.customSort.indexOf(a)
const bIndex = stackAxis.customSort.indexOf(b)
return aIndex - bIndex
})
}
cats.forEach((c, i) => {
result.push({
id: d.category,
name: d.category,
color: colors[(seriesSet.size - 1) % colors.length]
id: c,
name: c,
color: colors[i % colors.length]
})
})
} else {