feat(pie): add sort legend (#34323)

This commit is contained in:
SBIN2010
2025-08-29 22:19:14 +03:00
committed by GitHub
parent 54f071138c
commit dc7a8844eb
5 changed files with 128 additions and 2 deletions

View File

@@ -151,6 +151,7 @@ export default function transformProps(
legendMargin,
legendOrientation,
legendType,
legendSort,
metric = '',
numberFormat,
currencyFormat,
@@ -435,7 +436,12 @@ export default function transformProps(
},
legend: {
...getLegendProps(legendType, legendOrientation, showLegend, theme),
data: transformedData.map(datum => datum.name),
data: transformedData
.map(datum => datum.name)
.sort((a: string, b: string) => {
if (!legendSort) return 0;
return legendSort === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
}),
},
graphic: showTotal
? {