diff --git a/__tests__/integration/snapshots/api/chartChangeSize.png b/__tests__/integration/snapshots/api/chartChangeSize.png index a5b71ccf52..5434dd0780 100644 Binary files a/__tests__/integration/snapshots/api/chartChangeSize.png and b/__tests__/integration/snapshots/api/chartChangeSize.png differ diff --git a/__tests__/plots/api/chart-change-size.ts b/__tests__/plots/api/chart-change-size.ts index 49293c2247..b119468e5d 100644 --- a/__tests__/plots/api/chart-change-size.ts +++ b/__tests__/plots/api/chart-change-size.ts @@ -18,6 +18,8 @@ export function chartChangeSize(context) { { genre: 'Strategy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shooter', sold: 350 }, + { genre: 'Infantry', sold: 220 }, + { genre: 'Logistics', sold: 330 }, { genre: 'Other', sold: 150 }, ]); diff --git a/src/component/legendCategory.ts b/src/component/legendCategory.ts index b084556632..c6817b0ca5 100644 --- a/src/component/legendCategory.ts +++ b/src/component/legendCategory.ts @@ -19,7 +19,7 @@ import { useMarker } from '../utils/marker'; import { adaptor, domainOf, - G2Layout, + LegendCategoryLayout, inferComponentLayout, inferComponentShape, scaleOf, @@ -244,7 +244,7 @@ export const LegendCategory: GCC = (options) => { }; const { legend: legendTheme = {} } = theme; - const layoutWrapper = new G2Layout({ + const layoutWrapper = new LegendCategoryLayout({ style: { x: bbox.x, y: bbox.y, diff --git a/src/component/utils.ts b/src/component/utils.ts index b8bec116e3..174c61fa25 100644 --- a/src/component/utils.ts +++ b/src/component/utils.ts @@ -90,6 +90,13 @@ export class G2Layout extends Layout { } } +export class LegendCategoryLayout extends Layout { + update(options: any) { + this.attr(options); + (this.children?.[0] as any)?.update(options); + } +} + export function scaleOf(scales: Scale[], type: string): Scale | undefined { return scales.filter((s) => s.getOptions().name === type)?.[0]; }