feat: add sort legend to legend section (#34911)

This commit is contained in:
SBIN2010
2025-09-05 02:41:47 +03:00
committed by GitHub
parent 031fb4b5a8
commit 9424538bb1
20 changed files with 733 additions and 238 deletions

View File

@@ -131,6 +131,7 @@ export default function transformProps(chartProps: EchartsGanttChartProps) {
legendMargin,
legendOrientation,
legendType,
legendSort,
showLegend,
yAxisTitle,
yAxisTitleMargin,
@@ -330,6 +331,18 @@ export default function transformProps(chartProps: EchartsGanttChartProps) {
},
);
const legendData = series
.map(entry => {
const { name } = entry;
if (name === null || name === undefined) return '';
return String(name);
})
.filter(name => name !== '')
.sort((a, b) => {
if (!legendSort) return 0;
return legendSort === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
});
const tooltipFormatterMap = {
[GenericDataType.Numeric]: tooltipValuesFormatter,
[GenericDataType.String]: undefined,
@@ -365,6 +378,7 @@ export default function transformProps(chartProps: EchartsGanttChartProps) {
zoomable,
legendState,
),
data: legendData,
},
grid: {
...defaultGrid,