From bc3503a73b83425c5e1a1edcc2b855f6b185a0c7 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 14 Aug 2023 20:31:20 +0800 Subject: [PATCH 1/3] feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497 --- packages/vchart/src/chart/base-chart.ts | 8 ++++---- packages/vchart/src/chart/interface/chart.ts | 2 +- packages/vchart/src/core/vchart.ts | 16 +++++++++------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/vchart/src/chart/base-chart.ts b/packages/vchart/src/chart/base-chart.ts index 50f354ee79..090ffd8e5d 100644 --- a/packages/vchart/src/chart/base-chart.ts +++ b/packages/vchart/src/chart/base-chart.ts @@ -152,11 +152,11 @@ export class BaseChart extends CompilableBase implements IChart { getLayoutTag() { return this._layoutTag; } - setLayoutTag(tag: boolean, morphConfig?: IMorphConfig): boolean { + setLayoutTag(tag: boolean, morphConfig?: IMorphConfig, reLayout: boolean = true): boolean { this._layoutTag = tag; if (this.getCompiler()?.getVGrammarView()) { this.getCompiler().getVGrammarView().updateLayoutTag(); - tag && this.getCompiler().reRenderAsync(morphConfig); + tag && reLayout && this.getCompiler().reRenderAsync(morphConfig); } return this._layoutTag; } @@ -250,9 +250,9 @@ export class BaseChart extends CompilableBase implements IChart { this.setLayoutTag(true); } - updateViewBox(viewBox: IBoundsLike) { + updateViewBox(viewBox: IBoundsLike, reLayout: boolean) { this._updateLayoutRect(viewBox); - this.setLayoutTag(true); + this.setLayoutTag(true, null, reLayout); } createBackground(bg: IChartSpec['background']) { diff --git a/packages/vchart/src/chart/interface/chart.ts b/packages/vchart/src/chart/interface/chart.ts index 57cf0ed64b..50b9b8738d 100644 --- a/packages/vchart/src/chart/interface/chart.ts +++ b/packages/vchart/src/chart/interface/chart.ts @@ -143,7 +143,7 @@ export interface IChart extends ICompilable { ) => void; // 更新 viewBox - updateViewBox: (viewBox: IBoundsLike) => void; + updateViewBox: (viewBox: IBoundsLike, reLayout: boolean) => void; // 获取实际渲染的 canvas getCanvas: () => HTMLCanvasElement | undefined; diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index 7403ea340d..78fecc2ee1 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -735,18 +735,20 @@ export class VChart implements IVChart { * @param reRender 是否重新渲染,默认为 true * @returns */ - updateViewBox(viewBox: IBoundsLike, reRender: boolean = true) { + updateViewBox(viewBox: IBoundsLike, reRender: boolean = true, reLayout: boolean = true) { if (!this._chart || !this._compiler) { return this as unknown as IVChart; } this._viewBox = viewBox; // 更新 layout 参数 - this._chart.updateViewBox(viewBox); - // 重新布局 - this._compiler.renderSync(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - this._chart?.onEvaluateEnd(); + this._chart.updateViewBox(viewBox, reLayout); + if (reLayout) { + // 重新布局 + this._compiler.renderSync(); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + this._chart?.onEvaluateEnd(); + } // 获取 compiler this._compiler.updateViewBox(viewBox, reRender); return this as unknown as IVChart; From 5f6d71e2f852419907df9257f8b152aa26794668 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 14 Aug 2023 20:31:31 +0800 Subject: [PATCH 2/3] docs: update changlog of rush --- ...etviewbox-not-include-render_2023-08-14-12-31.json | 11 +++++++++++ ...etviewbox-not-include-render_2023-08-14-12-31.json | 11 +++++++++++ ...etviewbox-not-include-render_2023-08-14-12-31.json | 11 +++++++++++ ...etviewbox-not-include-render_2023-08-14-12-31.json | 11 +++++++++++ ...etviewbox-not-include-render_2023-08-14-12-31.json | 11 +++++++++++ 5 files changed, 55 insertions(+) create mode 100644 common/changes/@visactor/lark-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json create mode 100644 common/changes/@visactor/react-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json create mode 100644 common/changes/@visactor/taro-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json create mode 100644 common/changes/@visactor/vchart-schema/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json create mode 100644 common/changes/@visactor/vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json diff --git a/common/changes/@visactor/lark-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json b/common/changes/@visactor/lark-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json new file mode 100644 index 0000000000..ab598c6080 --- /dev/null +++ b/common/changes/@visactor/lark-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497\n\n", + "type": "patch", + "packageName": "@visactor/lark-vchart" + } + ], + "packageName": "@visactor/lark-vchart", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/react-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json b/common/changes/@visactor/react-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json new file mode 100644 index 0000000000..8c52f82367 --- /dev/null +++ b/common/changes/@visactor/react-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497\n\n", + "type": "patch", + "packageName": "@visactor/react-vchart" + } + ], + "packageName": "@visactor/react-vchart", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/taro-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json b/common/changes/@visactor/taro-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json new file mode 100644 index 0000000000..861a367aae --- /dev/null +++ b/common/changes/@visactor/taro-vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497\n\n", + "type": "patch", + "packageName": "@visactor/taro-vchart" + } + ], + "packageName": "@visactor/taro-vchart", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/vchart-schema/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json b/common/changes/@visactor/vchart-schema/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json new file mode 100644 index 0000000000..2522501a4a --- /dev/null +++ b/common/changes/@visactor/vchart-schema/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497\n\n", + "type": "patch", + "packageName": "@visactor/vchart-schema" + } + ], + "packageName": "@visactor/vchart-schema", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json b/common/changes/@visactor/vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json new file mode 100644 index 0000000000..a48689467b --- /dev/null +++ b/common/changes/@visactor/vchart/feat-497-feature-add-api-setviewbox-not-include-render_2023-08-14-12-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "feat: the api updateViewBox adds the relayout parameter, which supports not redrawing the chart immediately after updateViewbox, details in #497\n\n", + "type": "patch", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "lixuef1313@163.com" +} \ No newline at end of file From 1e30187e63e20902dd6fa9dc438a81176ba9f641 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Tue, 15 Aug 2023 10:22:42 +0800 Subject: [PATCH 3/3] chore: add notes about the new param of updateViewBox --- packages/vchart/src/core/vchart.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index 78fecc2ee1..47b3c568cb 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -733,6 +733,7 @@ export class VChart implements IVChart { * 更新绘制区域 * @param viewBox 绘制区域 * @param reRender 是否重新渲染,默认为 true + * @param reLayout 是否重新布局,默认为 true * @returns */ updateViewBox(viewBox: IBoundsLike, reRender: boolean = true, reLayout: boolean = true) {