Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change data wont update #5002

Merged
merged 2 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified __tests__/integration/snapshots/api/chartOptionsChangeData.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/component/legendCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,27 @@ export const LegendCategory: GCC<LegendCategoryOptions> = (options) => {
};

const { legend: legendTheme = {} } = theme;

const categoryStyle = adaptor(
Object.assign({}, legendTheme, legendStyle, style),
);

const layoutWrapper = new LegendCategoryLayout({
style: {
x: bbox.x,
y: bbox.y,
width: bbox.width,
height: bbox.height,
...finalLayout,
// @ts-ignore
subOptions: categoryStyle,
},
});

layoutWrapper.appendChild(
new Category({
className: 'legend-category',
style: adaptor(Object.assign({}, legendTheme, legendStyle, style)),
style: categoryStyle,
}),
);
return layoutWrapper;
Expand Down
21 changes: 12 additions & 9 deletions src/component/legendContinuous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,6 @@ export const LegendContinuous: GCC<LegendContinuousOptions> = (options) => {
const { bbox } = value;
const { x, y, width, height } = bbox;
const finalLayout = inferComponentLayout(position, layout);
const layoutWrapper = new G2Layout({
style: {
x,
y,
width,
height,
...finalLayout,
},
});

const { continuousLegend: legendTheme = {} } = theme;
const finalStyle = adaptor(
Expand Down Expand Up @@ -252,6 +243,18 @@ export const LegendContinuous: GCC<LegendContinuousOptions> = (options) => {
),
);

const layoutWrapper = new G2Layout({
style: {
x,
y,
width,
height,
...finalLayout,
// @ts-ignore
subOptions: finalStyle,
},
});

layoutWrapper.appendChild(
new Continuous({
style: finalStyle,
Expand Down
14 changes: 9 additions & 5 deletions src/component/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ export function inferComponentLayout(
}

export class G2Layout extends Layout {
get child() {
return this.children?.[0] as any;
}

update(options: any) {
this.attr(options);
const { width, height, ...restOptions } = options;
(this.children?.[0] as any)?.update(restOptions);
const { subOptions } = options;
this.child?.update(subOptions);
}
}

export class LegendCategoryLayout extends Layout {
export class LegendCategoryLayout extends G2Layout {
update(options: any) {
this.attr(options);
(this.children?.[0] as any)?.update(options);
const { subOptions } = options;
this.child?.update(subOptions);
}
}

Expand Down