UNPKG

@nova-ui/charts

Version:

Nova Charts is a library created to provide potential consumers with solutions for various data visualizations that conform with the Nova Design Language. It's designed to solve common patterns identified by UX designers, but also be very flexible so that

44 lines (43 loc) 1.51 kB
import { AxisScale } from "d3-axis"; import { UnitOption } from "@nova-ui/bits"; import { DomainCalculator, IFormatters, IScale } from "./types"; export declare abstract class Scale<T> implements IScale<T> { readonly id: string; domainCalculator: DomainCalculator; formatters: IFormatters<T>; isDomainFixed: boolean; scaleUnits?: UnitOption; isTimeseriesScale: boolean; private isReversed; protected _fixDomainValues: T[]; protected readonly _d3Scale: any; protected constructor(id?: string); /** * Creates a d3 scale based on the scale's type * * @returns {any} A new d3 scale appropriate to the scale type */ protected abstract createD3Scale(): any; abstract convert(value: T): number; abstract invert(coordinate: number): T | undefined; abstract isContinuous(): boolean; /** See {@link IScale#d3Scale} */ get d3Scale(): AxisScale<T>; get fixDomainValues(): T[]; /** See {@link IScale#setFixDomainValues} */ setFixDomainValues(values: T[]): void; /** See {@link IScale#range} */ range(): [number, number]; range(range: [number, number]): this; /** See {@link IScale#domain} */ domain(): T[]; domain(domain: T[]): this; /** See {@link IScale#fixDomain} */ fixDomain(domain: T[]): this; /** See {@link IScale#reverse} */ isDomainValid(): boolean; reverse(): this; /** See {@link IScale#reversed} */ reversed(): boolean; reversed(reversed: boolean): this; }