diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index def74128c2b..a802ba0864b 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -129,6 +129,7 @@ export default function transformProps( theme, inContextMenu, emitCrossFilters, + legendState, } = chartProps; let focusedSeries: string | null = null; @@ -157,6 +158,7 @@ export default function transformProps( timeShiftColor, contributionMode, legendOrientation, + legendMargin, legendType, logAxis, logAxisSecondary, @@ -552,7 +554,7 @@ export default function transformProps( legendOrientation, addYAxisTitleOffset, zoomable, - null, + legendMargin, addXAxisTitleOffset, yAxisTitlePosition, convertInteger(yAxisTitleMargin), @@ -715,6 +717,8 @@ export default function transformProps( showLegend, theme, zoomable, + legendState, + chartPadding, ), // @ts-ignore data: series diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts index 24693494e47..dc0654c9b1c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts @@ -197,3 +197,66 @@ it('should transform chart props for viz with showQueryIdentifiers=true', () => 'sum__num (Query B), boy', ]); }); + +it('legend margin: top orientation sets grid.top correctly', () => { + const chartPropsConfigWithoutIdentifiers = { + ...chartPropsConfig, + formData: { + ...formData, + legendMargin: 250, + showLegend: true, + }, + }; + const chartProps = new ChartProps(chartPropsConfigWithoutIdentifiers); + const transformed = transformProps(chartProps as EchartsMixedTimeseriesProps); + + expect((transformed.echartOptions.grid as any).top).toEqual(270); +}); + +it('legend margin: bottom orientation sets grid.bottom correctly', () => { + const chartPropsConfigWithoutIdentifiers = { + ...chartPropsConfig, + formData: { + ...formData, + legendMargin: 250, + showLegend: true, + legendOrientation: LegendOrientation.Bottom, + }, + }; + const chartProps = new ChartProps(chartPropsConfigWithoutIdentifiers); + const transformed = transformProps(chartProps as EchartsMixedTimeseriesProps); + + expect((transformed.echartOptions.grid as any).bottom).toEqual(270); +}); + +it('legend margin: left orientation sets grid.left correctly', () => { + const chartPropsConfigWithoutIdentifiers = { + ...chartPropsConfig, + formData: { + ...formData, + legendMargin: 250, + showLegend: true, + legendOrientation: LegendOrientation.Left, + }, + }; + const chartProps = new ChartProps(chartPropsConfigWithoutIdentifiers); + const transformed = transformProps(chartProps as EchartsMixedTimeseriesProps); + + expect((transformed.echartOptions.grid as any).left).toEqual(270); +}); + +it('legend margin: right orientation sets grid.right correctly', () => { + const chartPropsConfigWithoutIdentifiers = { + ...chartPropsConfig, + formData: { + ...formData, + legendMargin: 270, + showLegend: true, + legendOrientation: LegendOrientation.Right, + }, + }; + const chartProps = new ChartProps(chartPropsConfigWithoutIdentifiers); + const transformed = transformProps(chartProps as EchartsMixedTimeseriesProps); + + expect((transformed.echartOptions.grid as any).right).toEqual(270); +});