diff --git a/src/chart/__components__/mock-component.ts b/src/chart/__components__/mock-component.ts index f71f89cfba..b628c9ef8f 100644 --- a/src/chart/__components__/mock-component.ts +++ b/src/chart/__components__/mock-component.ts @@ -21,10 +21,10 @@ export class MockComponent extends Component { this.text = text; this.attributes = attributes; - this.initial(); + this.init(); } - protected initial() { + protected init() { this.container.addShape('text', { attrs: { x: 0, diff --git a/src/chart/__components__/text.ts b/src/chart/__components__/text.ts index dbb8b744c0..ea187abf0d 100644 --- a/src/chart/__components__/text.ts +++ b/src/chart/__components__/text.ts @@ -24,10 +24,10 @@ export class Text extends Component { this.isHorizontal = isHorizontal; this.attributes = attributes; - this.initial(); + this.init(); } - protected initial() { + protected init() { let attrs: LooseObject = { x: 0, y: 0, diff --git a/src/chart/view.ts b/src/chart/view.ts index 7533c20b6c..982296a970 100644 --- a/src/chart/view.ts +++ b/src/chart/view.ts @@ -147,7 +147,7 @@ export default class View extends EE { // 接受父 view 传入的参数 this.options = { ...this.options, ...options }; - this.initial(); + this.init(); } /** @@ -190,13 +190,13 @@ export default class View extends EE { /** * 初始化 */ - public initial() { + public init() { // 事件委托机制 - this.initialEvents(); + this.initEvents(); // 递归初始化子 view _.each(this.views, (view: View) => { - view.initial(); + view.init(); }); } @@ -214,7 +214,7 @@ export default class View extends EE { } /** - * 清空,之后可以再走 initial 流程,正常使用 + * 清空,之后可以再走 init 流程,正常使用 */ public clear() { this.emit(ViewLifeCircle.BEFORE_CLEAR); @@ -609,7 +609,7 @@ export default class View extends EE { this.createCoordinate(); } // 4. 初始化 Geometry - this.initialGeometries(); + this.initGeometries(); // 5. 渲染组件 component this.renderComponents(); // 6. 递归 views,进行布局 @@ -637,7 +637,7 @@ export default class View extends EE { * 当前 view 只委托自己 view 中的 Component 和 Geometry 事件,并向上冒泡 * @private */ - private initialEvents() { + private initEvents() { // 三层 group 中的 shape 事件都会通过 G 冒泡上来的 this.foregroundGroup.on('*', this.onEvents); this.middleGroup.on('*', this.onEvents); @@ -730,7 +730,7 @@ export default class View extends EE { * 初始化 Geometries * @private */ - private initialGeometries() { + private initGeometries() { // 实例化 Geometry,然后 view 将所有的 scale 管理起来 _.each(this.geometries, (geometry: Geometry) => { // 使用 coordinate 引用,可以保持 coordinate 的同步更新 @@ -741,7 +741,7 @@ export default class View extends EE { // 保持 scales 引用不要变化 geometry.scales = this.scales; - geometry.initial(); + geometry.init(); }); // Geometry 初始化之后,生成了 scale,然后进行调整 scale 配置 @@ -880,7 +880,7 @@ export default class View extends EE { private renderFacet() { if (this.facetInstance) { // 计算分面数据 - this.facetInstance.initial(); + this.facetInstance.init(); // 渲染组件和 views this.facetInstance.render(); } diff --git a/src/component/index.ts b/src/component/index.ts index a1502c3e0b..044fdcb10e 100644 --- a/src/component/index.ts +++ b/src/component/index.ts @@ -71,7 +71,7 @@ export default abstract class Component extends EE { } /** 初始化节点 */ - protected abstract initial(); + protected abstract init(); // 代理 G.shape 事件,然后自己 emit 出来 protected abstract proxyEvents(); diff --git a/src/facet/facet.ts b/src/facet/facet.ts index dd3447e94c..0e8902fbe0 100644 --- a/src/facet/facet.ts +++ b/src/facet/facet.ts @@ -12,7 +12,7 @@ import { FacetCfg, FacetComponent, FacetData } from './interface'; * * 生命周期: * - * 初始化 initial + * 初始化 init * 1. 初始化容器 * 2. 数据分面,生成分面布局信息 * @@ -52,7 +52,7 @@ export default abstract class Facet { }); it('init()', () => { - geometry.initial(); + geometry.init(); // attrs 的生成 const attrs = geometry.attributes; diff --git a/tests/unit/geometry/interval-spec.ts b/tests/unit/geometry/interval-spec.ts index 2e545be1ac..7e510b707b 100644 --- a/tests/unit/geometry/interval-spec.ts +++ b/tests/unit/geometry/interval-spec.ts @@ -34,7 +34,7 @@ describe('Interval', () => { expect(interval.visible).toBe(true); }); - test('initial()', () => { + test('init()', () => { interval = new Interval({ data, scaleDefs: { @@ -46,7 +46,7 @@ describe('Interval', () => { }); interval.position('a*b').color('a'); - interval.initial(); + interval.init(); const attributes = interval.attributes; expect(attributes).toContainKeys(['position', 'color']); @@ -101,7 +101,7 @@ describe('Interval', () => { test('interval.size(20)', () => { interval.size(20); // 指定 interval 的宽度 - interval.initial(); + interval.init(); interval.paint(); expect(interval.defaultSize).toBe(undefined); @@ -115,7 +115,7 @@ describe('Interval', () => { interval.theme.minColumnWidth = 40; interval.size(null); - interval.initial(); + interval.init(); interval.paint(); canvas.draw(); @@ -131,7 +131,7 @@ describe('Interval', () => { interval.theme.maxColumnWidth = 10; interval.theme.minColumnWidth = null; - interval.initial(); + interval.init(); interval.paint(); canvas.draw(); @@ -164,7 +164,7 @@ describe('Interval', () => { interval.position('a*b'); it('yScale min adjust when user define min', () => { - interval.initial(); + interval.init(); // 为了观察最终的绘制结果 interval.paint(); canvas.draw(); diff --git a/tests/unit/geometry/line-spec.ts b/tests/unit/geometry/line-spec.ts index 5094539df8..24db5e2d67 100644 --- a/tests/unit/geometry/line-spec.ts +++ b/tests/unit/geometry/line-spec.ts @@ -28,7 +28,7 @@ describe('Line', () => { }); line.position('x*y'); - line.initial(); + line.init(); line.paint(); canvas.draw(); diff --git a/tests/unit/geometry/path-spec.ts b/tests/unit/geometry/path-spec.ts index a142424643..86b250be07 100644 --- a/tests/unit/geometry/path-spec.ts +++ b/tests/unit/geometry/path-spec.ts @@ -38,7 +38,7 @@ describe('Path', () => { }); path.position('x*y').size(4); - path.initial(); + path.init(); path.paint(); canvas.draw(); @@ -83,7 +83,7 @@ describe('Path', () => { }); path.position('x*y').size(4); - path.initial(); + path.init(); path.paint(); canvas.draw(); diff --git a/tests/unit/geometry/util/shape-size-spec.ts b/tests/unit/geometry/util/shape-size-spec.ts index 7df5def34f..603c174439 100644 --- a/tests/unit/geometry/util/shape-size-spec.ts +++ b/tests/unit/geometry/util/shape-size-spec.ts @@ -41,7 +41,7 @@ describe('Calculate shape size', () => { }); interval.position('a*b').color('a'); - interval.initial(); + interval.init(); test('default', () => { const normalizedSize = getDefaultSize(interval); @@ -86,7 +86,7 @@ describe('Calculate shape size', () => { theme: Theme, }); interval.position('a*b'); - interval.initial(); + interval.init(); // interval.paint(); // canvas.draw(); @@ -109,7 +109,7 @@ describe('Calculate shape size', () => { theme: Theme, }); interval.position('a*b'); - interval.initial(); + interval.init(); // interval.paint(); // canvas.draw(); expect(getDefaultSize(interval)).toBe(0.125); @@ -151,7 +151,7 @@ describe('Calculate shape size', () => { type: 'dodge', }); - interval.initial(); + interval.init(); const normalizedSize = getDefaultSize(interval); expect(normalizedSize).toBe(1 / 12); @@ -164,7 +164,7 @@ describe('Calculate shape size', () => { dodgeBy: 'a', }); - interval.initial(); + interval.init(); const normalizedSize = getDefaultSize(interval); expect(normalizedSize).toBe(1 / 18); }); @@ -188,7 +188,7 @@ describe('Calculate shape size', () => { }, }); interval.position('a*b'); - interval.initial(); + interval.init(); test('polar interval', () => { const normalizedSize = getDefaultSize(interval); @@ -230,7 +230,7 @@ describe('Calculate shape size', () => { .color('a') .adjust('stack'); - interval.initial(); + interval.init(); const normalizedSize = getDefaultSize(interval); expect(normalizedSize).toBe(0.9999999); @@ -266,7 +266,7 @@ describe('Calculate shape size', () => { fields: ['c'], }); - interval.initial(); + interval.init(); const normalizedSize = getDefaultSize(interval); expect(normalizedSize).toBe((1 / 6) * Theme.roseWidthRatio); @@ -307,7 +307,7 @@ describe('Calculate shape size', () => { fields: ['c'], }); - interval.initial(); + interval.init(); // interval.paint(); // canvas.draw();