You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

4 months ago
import { deepMix } from '@antv/util';
import { BaseOptions, Domain, Range, Unknown } from '../types';
export abstract class Base<O extends BaseOptions> {
/**
*
* options.unknown
* @param x
*/
abstract map(x: Domain<O>): Range<O> | Unknown<O>;
/**
*
* @param x
*/
abstract invert(x: Range<O>): Domain<O> | Domain<O>[] | Unknown<O>;
/**
*
*/
abstract clone(): Base<O>;
/**
*
*/
protected abstract getDefaultOptions(): Partial<O>;
/**
* ticks
*/
protected options: O;
/**
*
* @param options
*/
constructor(options?: O) {
this.options = deepMix({}, this.getDefaultOptions());
this.update(options);
}
/**
*
* @returns
*/
public getOptions(): O {
return this.options;
}
/**
*
* @param updateOptions
*/
public update(updateOptions: Partial<O> = {}): void {
this.options = deepMix({}, this.options, updateOptions);
this.rescale(updateOptions);
}
/**
* options options scale
* this.options options
* @param options options
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected rescale(options?: Partial<O>): void {}
}