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

This commit is contained in:
Richard Fogaca Nienkotter
2026-03-25 09:38:31 -03:00
committed by GitHub
parent 3fb903fdc6
commit 12aca72074
16 changed files with 1514 additions and 102 deletions

View File

@@ -37,7 +37,8 @@ import {
OrientationType,
EchartsTimeseriesFormData,
} from '../../src/Timeseries/types';
import { StackControlsValue } from '../../src/constants';
import { StackControlsValue, TIMESERIES_CONSTANTS } from '../../src/constants';
import { LegendOrientation, LegendType } from '../../src/types';
import { DEFAULT_FORM_DATA } from '../../src/Timeseries/constants';
import { createEchartsTimeseriesTestChartProps } from '../helpers';
import { BASE_TIMESTAMP, createTestData } from './helpers';
@@ -898,6 +899,40 @@ describe('legend sorting', () => {
'Boston',
]);
});
test('falls back to scroll for zoomable top legends when toolbox space reduces available width', () => {
const narrowLegendData = [
createTestQueryData(
createTestData(
[
{
Alpha: 1,
Beta: 2,
Gamma: 3,
},
],
{ intervalMs: 300000000 },
),
),
];
const chartProps = createTestChartProps({
width: 190 + TIMESERIES_CONSTANTS.legendTopRightOffset,
formData: {
...formData,
legendType: LegendType.Plain,
legendOrientation: LegendOrientation.Top,
showLegend: true,
zoomable: true,
},
queriesData: narrowLegendData,
});
const transformed = transformProps(chartProps);
expect((transformed.echartOptions.legend as any).type).toBe(
LegendType.Scroll,
);
});
});
const timeCompareFormData: SqlaFormData = {