From 6356363a02c672f7e6074d8106be06a6558cf6ac Mon Sep 17 00:00:00 2001 From: simaQ Date: Mon, 30 Mar 2020 10:49:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=E5=88=AB=E5=90=8D=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=203.x=EF=BC=8C=E4=BD=86=E6=98=AF=E8=BF=99?= =?UTF-8?q?=E4=BA=9B=E6=96=B9=E6=B3=95=E5=B0=86=E4=BC=9A=E5=9C=A8=204.1=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=AD=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chart/view.ts | 37 +++++++++++++++++++++++++++++ tests/unit/chart/multi-view-spec.ts | 2 +- tests/unit/chart/view/index-spec.ts | 12 ++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/chart/view.ts b/src/chart/view.ts index c6984c67d4..ed6d3dcd69 100644 --- a/src/chart/view.ts +++ b/src/chart/view.ts @@ -328,6 +328,15 @@ export class View extends Base { return this; } + /** + * @deprecated + * This method will be removed at G2 V4.1. Replaced by {@link #data(data)} + */ + public source(data: Data): View { + console.warn('This method will be removed at G2 V4.1. Please use chart.data() instead.'); + return this.data(data); + } + /** * 设置数据筛选规则。 * @@ -517,6 +526,15 @@ export class View extends Base { return this.getController('annotation') as Annotation; } + /** + * @deprecated + * This method will be removed at G2 V4.1. Replaced by {@link #guide()} + */ + public guide(): Annotation { + console.warn('This method will be removed at G2 V4.1. Please use chart.annotation() instead.'); + return this.annotation(); + } + /** * 坐标系配置。 * @@ -567,6 +585,16 @@ export class View extends Base { return this.coordinateController; } + /** + * @deprecated + * This method will be removed at G2 V4.1. Replaced by {@link #coordinate()} + */ + public coord(type: string | CoordinateOption, coordinateCfg?: CoordinateCfg): CoordinateController { + console.warn('This method will be removed at G2 V4.1. Please use chart.coordinate() instead.'); + // @ts-ignore + return this.coordinate(type, coordinateCfg); + } + /** * view 分面绘制。 * @@ -788,6 +816,15 @@ export class View extends Base { return v; } + /** + * @deprecated + * This method will be removed at G2 V4.1. Replaced by {@link #createView()} + */ + public view(cfg?: Partial) { + console.warn('This method will be removed at G2 V4.1. Please use chart.createView() instead.') + return this.createView(cfg); + } + /** * 删除一个子 view * @param view diff --git a/tests/unit/chart/multi-view-spec.ts b/tests/unit/chart/multi-view-spec.ts index 7191399280..e4392326b7 100644 --- a/tests/unit/chart/multi-view-spec.ts +++ b/tests/unit/chart/multi-view-spec.ts @@ -37,7 +37,7 @@ describe('chart multi view', () => { }, padding: 20, }); - const v2 = chart.createView({ + const v2 = chart.view({ region: { start: { x: 0.5, y: 0 }, end: { x: 1, y: 1 }, diff --git a/tests/unit/chart/view/index-spec.ts b/tests/unit/chart/view/index-spec.ts index 673c2b0f49..8e2a9536ef 100644 --- a/tests/unit/chart/view/index-spec.ts +++ b/tests/unit/chart/view/index-spec.ts @@ -78,6 +78,13 @@ describe('View', () => { expect(view.getOptions().data).toEqual(data); }); + it('source', () => { + // deperated method + view.source(data); + + expect(view.getOptions().data).toEqual(data); + }); + it('axis', () => { view.axis(false); expect(view.getOptions().axes).toBe(false); @@ -153,6 +160,11 @@ describe('View', () => { expect(view.getCoordinate().getHeight()).toEqual(590); }); + it('coord', () => { + const c = view.coord('rect'); + expect(c.getOption().type).toEqual('rect'); + }); + it('animate', () => { // @ts-ignore 默认执行动画 expect(view.options.animate).toBe(true);