UNPKG

1.56 kBTypeScriptView Raw
1import { Base } from './base';
2import { ContinuousOptions, Domain, Range, NiceMethod, TickMethodOptions, Transform } from '../types';
3/**
4 * Continuous 比例尺 的输入 x 和输出 y 满足:y = a * f(x) + b
5 * 通过函数柯里化和复合函数可以在映射过程中去掉分支,提高性能。
6 * 参考:https://github.com/d3/d3-scale/blob/master/src/continuous.js
7 */
8export declare abstract class Continuous<O extends ContinuousOptions> extends Base<O> {
9 /** 实际上将 x 映射为 y 的函数 */
10 protected output: Transform;
11 /** 实际上将 y 映射为 x 的函数 */
12 protected input: Transform;
13 /**
14 * 根据比例尺 和 options 选择对应的 transform 和 untransform 函数
15 * y = a * f(x) + b
16 * x = a * f'(y) + b
17 * @returns [f(x), f'(y)]
18 */
19 protected abstract chooseTransforms(): Transform[];
20 protected getDefaultOptions(): O;
21 /**
22 * y = interpolate(normalize(clamp(transform(x))))
23 */
24 map(x: Domain<O>): any;
25 /**
26 * x = transform(clamp(interpolate(normalize(y))))
27 */
28 invert(x: Range<O>): any;
29 protected nice(): void;
30 getTicks(): (number | Date)[];
31 protected getTickMethodOptions(): TickMethodOptions;
32 protected chooseNice(): NiceMethod<number | Date>;
33 protected rescale(): void;
34 protected chooseClamp(transform: Transform): (x: number) => number;
35 protected composeOutput(transform: Transform, clamp: Transform): void;
36 protected composeInput(transform: Transform, untransform: Transform, clamp: Transform): void;
37}