Skip to content

Commit

Permalink
fix(legend): category do not update position
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed Jul 12, 2023
1 parent 6ae86b7 commit 177f51f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Binary file modified __tests__/integration/snapshots/api/chartChangeSize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions __tests__/plots/api/chart-change-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export function chartChangeSize(context) {
const div = document.createElement('div');
container.appendChild(div);

const chart = new Chart({ theme: 'classic', container: div, canvas });
const chart = new Chart({
theme: 'classic',
container: div,
canvas,
padding: 'auto',
});

chart.data([
{ genre: 'Sports', sold: 275 },
Expand All @@ -28,7 +33,8 @@ export function chartChangeSize(context) {
.encode('x', 'genre')
.encode('y', 'sold')
.encode('color', 'genre')
.axis({ x: { animate: false }, y: { animate: false } });
.axis({ x: { animate: false }, y: { animate: false } })
.legend('color', [{}, { position: 'right' }]);

const finished = chart.render();

Expand Down
1 change: 1 addition & 0 deletions src/component/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class G2Layout extends Layout {
export class LegendCategoryLayout extends G2Layout {
update(options: any) {
const { subOptions } = options;
this.attr(options);
this.child?.update(subOptions);
}
}
Expand Down

0 comments on commit 177f51f

Please sign in to comment.