@apptane/react-ui-charts
Version:
Chart components in Apptane React UI framework
70 lines (69 loc) • 2.77 kB
TypeScript
/// <reference types="react" />
import { Color, PaletteHue } from "@apptane/react-ui-core";
import PropTypes from "prop-types";
/**
* One of D3 chromatic color schemes.
* See: https://github.com/d3/d3-scale-chromatic
*/
export declare type ChromaticScheme = "BrBG" | "PRGn" | "PiYG" | "PuOr" | "RdBu" | "RdGy" | "RdYlBu" | "RdYlGn" | "BuGn" | "BuPu" | "GnBu" | "OrRd" | "PuBuGn" | "PuBu" | "PuRd" | "RdPu" | "YlGnBu" | "YlGn" | "YlOrBr" | "YlOrRd" | "spectral" | "blues" | "greens" | "greys" | "oranges" | "purples" | "reds" | "turbo" | "viridis" | "inferno" | "magma" | "plasma" | "cividis" | "warm" | "cool" | "cubehelix" | "rainbow" | "sinebow";
/**
* Base interface for a visualized datum, such as metric, slice or cell.
*/
export interface Datum<Data = void> {
/**
* Unique identifier of the datum within the supplied set.
*/
id?: string;
/**
* Display label for the legend or tooltip.
*/
label?: string;
/**
* Color to use overriding the color specification at the component level.
*/
color?: Color | PaletteHue;
/**
* Arbitrary data associated with the datum.
* This field is passed through to callbacks.
*/
data?: Data;
}
/**
* Domain value types.
*/
export declare type DomainValue = number | string | Date;
export declare type DomainXValue = DomainValue;
export declare type DomainYValue = Exclude<DomainValue, Date>;
/**
* Domain types.
*/
export declare type DomainType = "time" | "numeric" | "ordinal" | "none";
export declare type MouseEventCallback<T extends Datum<Data>, Data = void> = (datum: T, event: React.MouseEvent) => void;
export declare const PropTypeDatum: {
id: PropTypes.Requireable<string>;
label: PropTypes.Requireable<string>;
color: PropTypes.Requireable<string>;
data: PropTypes.Requireable<any>;
};
export declare const PropTypeDomainValue: PropTypes.Requireable<string | number | object>;
export declare const PropTypeDomainType: PropTypes.Requireable<DomainType>;
export declare const PropTypeColorScheme: PropTypes.Requireable<ChromaticScheme | PaletteHue>;
/**
* Represents domain of values, possibly comparable.
*/
export declare class Domain<T = DomainValue> {
readonly values: T[];
private readonly __comparer?;
private readonly __ordinal;
constructor(values: T[], comparer?: (a: T, b: T) => number, ordinal?: boolean);
/**
* Tests two domain values for equality.
*/
isEqual: (a: T, b: T) => boolean;
/**
* @public
* Locates the closest value in the domain to the specified value.
* Returns both the value and its index in the domain.
*/
findNearest(v?: T): [T | undefined, number | undefined];
}