fix(echarts): prevent plain legend clipping in dashboards (#38675)

(cherry picked from commit 12aca72074)
This commit is contained in:
Richard Fogaca Nienkotter
2026-03-25 09:38:31 -03:00
committed by Michael S. Molina
parent 9619fa2156
commit 1e7d781354
16 changed files with 1514 additions and 102 deletions

View File

@@ -45,6 +45,7 @@ import {
getColtypesMapping,
getLegendProps,
} from '../utils/series';
import { resolveLegendLayout } from '../utils/legendLayout';
import { defaultGrid } from '../defaults';
import { Refs } from '../types';
import { getDefaultTooltip } from '../utils/tooltip';
@@ -313,11 +314,27 @@ export default function transformProps(
min,
};
});
const legendData = Array.from(columnsLabelMap.keys()).sort(
(a: string, b: string) => {
if (!legendSort) return 0;
return legendSort === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
},
);
const { effectiveLegendMargin, effectiveLegendType } = resolveLegendLayout({
chartHeight: height,
chartWidth: width,
legendItems: legendData,
legendMargin,
orientation: legendOrientation,
show: showLegend,
theme,
type: legendType,
});
const series: RadarSeriesOption[] = [
{
type: 'radar',
...getChartPadding(showLegend, legendOrientation, legendMargin),
...getChartPadding(showLegend, legendOrientation, effectiveLegendMargin),
animation: false,
emphasis: {
label: {
@@ -354,11 +371,13 @@ export default function transformProps(
formatter: NormalizedTooltipFormater,
},
legend: {
...getLegendProps(legendType, legendOrientation, showLegend, theme),
data: Array.from(columnsLabelMap.keys()).sort((a: string, b: string) => {
if (!legendSort) return 0;
return legendSort === 'asc' ? a.localeCompare(b) : b.localeCompare(a);
}),
...getLegendProps(
effectiveLegendType,
legendOrientation,
showLegend,
theme,
),
data: legendData,
},
series,
radar: {