Skip to content

Commit

Permalink
Feat/export (#154)
Browse files Browse the repository at this point in the history
* fix(types): add default generic type for inheritable class

* feat: export more types and tickMethods
  • Loading branch information
pearmini authored Jun 16, 2021
1 parent cebbc5c commit fd7722d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions __tests__/unit/scales/continuous.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { identity } from '@antv/util';
import { Continuous } from '../../../src/scales/continuous';
import { ContinuousOptions } from '../../../src/types';
import { createInterpolate } from '../../../src/utils';
import { Interpolate } from '../../../src';
import { Interpolate, ContinuousOptions, Continuous } from '../../../src';

describe('Continuous', () => {
type ScaleOptions = ContinuousOptions;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/tick-methods/d3-log.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { d3Log } from '../../../src/tick-methods/d3-log';
import { d3Log } from '../../../src';

function round(x: number) {
return Math.round(x * 1e12) / 1e12;
Expand Down
3 changes: 1 addition & 2 deletions __tests__/unit/tick-methods/d3-time.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { d3Time } from '../../../src/tick-methods/d3-time';
import { DURATION_SECOND } from '../../../src';
import { DURATION_SECOND, d3Time } from '../../../src';

function UTC(
year: number,
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ export { Quantize } from './scales/quantize';
export { Quantile } from './scales/quantile';
export { Time } from './scales/time';
export { Base } from './scales/base';
export { Continuous } from './scales/continuous';

// tick-methods
export { d3Ticks } from './tick-methods/d3-ticks';
export { rPretty } from './tick-methods/r-pretty';
export { wilkinsonExtended } from './tick-methods/wilkinson-extended';
export { d3Log } from './tick-methods/d3-log';
export { d3Time } from './tick-methods/d3-time';

// scales types
export type {
BaseOptions,
BandOptions,
OrdinalOptions,
ContinuousOptions,
ConstantOptions,
IdentityOptions,
LinearOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/scales/band.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function getBandState(opt: BandStateOptions) {
*
* 性能方便较 d3 快出 8 - 9 倍
*/
export class Band<O extends BandOptions> extends Ordinal<O> {
export class Band<O extends BandOptions = BandOptions> extends Ordinal<O> {
// 步长,见上图
private step: number;

Expand Down
2 changes: 1 addition & 1 deletion src/scales/ordinal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function mapBetweenArrByMapIndex(options: MapBetweenArrOptions) {
* - 两个 map 只初始化一次,在之后的更新中复用他们,这样我们避免了重复 new Map 带来的性能问题
* 在大量调用 update 函数场景下,较 d3-scale 效率有质的提高
*/
export class Ordinal<O extends OrdinalOptions> extends Base<O> {
export class Ordinal<O extends OrdinalOptions = OrdinalOptions> extends Base<O> {
// 定义域映射表
private domainIndexMap: Map<any, number>;

Expand Down
2 changes: 1 addition & 1 deletion src/scales/pow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const transformSqrt = (x: number) => {
* 类似于 linear scale, 不同之处在于在计算输出范围值之前对输入域值应用了指数变换,.
* 即 y = x ^ k 其中 k(指数)可以是任何实数。
*/
export class Pow<O extends PowOptions> extends Continuous<O> {
export class Pow<O extends PowOptions = PowOptions> extends Continuous<O> {
protected getDefaultOptions() {
return {
domain: [0, 1],
Expand Down
2 changes: 1 addition & 1 deletion src/scales/threshold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { bisect, isValid } from '../utils';
/**
* 将连续的定义域分段,每一段所有的值对应离散的值域中一个值
*/
export class Threshold<O extends ThresholdOptions> extends Base<O> {
export class Threshold<O extends ThresholdOptions = ThresholdOptions> extends Base<O> {
/** threshold 的数量 */
protected n: number;

Expand Down

0 comments on commit fd7722d

Please sign in to comment.