Skip to content

Commit

Permalink
feat(open-ability): 开放通用的 adaptors 给自定义扩展图表使用 (#2166)
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky authored Dec 31, 2020
1 parent 91eb109 commit 223473d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion __tests__/unit/index-spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 223473d

Please sign in to comment.