From 223473de1aaf49bec610b24c65f598f342bee6dd Mon Sep 17 00:00:00 2001 From: Kasmine <736929286@qq.com> Date: Thu, 31 Dec 2020 16:18:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(open-ability):=20=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E7=9A=84=20adaptors=20=E7=BB=99=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=89=A9=E5=B1=95=E5=9B=BE=E8=A1=A8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20(#2166)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/unit/index-spec.ts | 12 +++++++++++- src/index.ts | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/__tests__/unit/index-spec.ts b/__tests__/unit/index-spec.ts index 5faecc5399..14e2467709 100644 --- a/__tests__/unit/index-spec.ts +++ b/__tests__/unit/index-spec.ts @@ -1,8 +1,18 @@ -import { version } from '../../src'; +import { version, adaptors } from '../../src'; import pkg from '../../package.json'; describe('index', () => { it('version', () => { expect(version).toBe(pkg.version); }); + + it('export common adaptors', () => { + expect(adaptors.scale).toBeDefined(); + expect(adaptors.tooltip).toBeDefined(); + expect(adaptors.legend).toBeDefined(); + expect(adaptors.animation).toBeDefined(); + expect(adaptors.interaction).toBeDefined(); + expect(adaptors.annotation).toBeDefined(); + expect(adaptors.theme).toBeDefined(); + }); }); diff --git a/src/index.ts b/src/index.ts index 16dae416bc..cd20ce214d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -106,10 +106,15 @@ export { Chord, ChordOptions } from './plots/chord'; // 以下开放自定义图表开发的能力(目前仅仅是孵化中) /** 所有开放图表都使用 G2Plot.P 作为入口开发,理论上官方的所有图表都可以走 G2Plot.P 的入口(暂时不处理) */ export { P } from './plugin'; + /** 开发 adaptor 可能会用到的方法或一些工具方法,不强制使用 */ export { flow, measureTextWidth } from './utils'; + /** 各个 geometry 的 adaptor,可以让开发者更快的构造图形 */ export { line, interval, area, point, polygon } from './adaptor/geometries'; +/** 开放一些通用的 adaptor 通道方法,实验阶段:不保证稳定性 */ +import { scale, legend, tooltip, annotation, interaction, theme, animation } from './adaptor/common'; +export const adaptors = { scale, legend, tooltip, annotation, interaction, theme, animation }; /** 对于没有开发完成的图表,可以暂时先放到 Lab 下面,先做体验,稳定后放到根 export */ export { Lab } from './lab';