import type { IAdvancedBoxPlotData , IBoxPlotData , IForEachAble } from '../internal' ; import Column from './Column' ; import type { IArrayColumn } from './IArrayColumn' ; import type { IColumnDesc , IDataRow , ITypedDump , ITypeFactory } from './interfaces' ; export interface IColorMappingFunction { apply ( v ) : string ; toJSON ( ) : ITypedDump | string ; clone ( ) : IColorMappingFunction ; eq ( other ) : boolean ; } export interface IColorMappingFunctionConstructor { new ( dump , factory ) : IColorMappingFunction ; } export interface IMappingFunction { apply ( v ) : number ; toJSON ( ) : ITypedDump ; domain : number [ ] ; clone ( ) : IMappingFunction ; eq ( other ) : boolean ; getRange ( formatter ) : [ string , string ] ; } export interface IMappingFunctionConstructor { new ( dump ) : IMappingFunction ; } export interface IMapAbleDesc { /**
     * dump of mapping function
     */ map ? : ITypedDump ; /**
     * either map or domain should be available
     */ domain ? : [ number , number ] ; default range ? : [ number , number ] ; deprecated color ? : string ; /**
     * color mapping
     */ colorMapping ? : string | ( ( v : number ) => string ) | ITypedDump ; } export interface IMapAbleColumn extends INumberColumn { getOriginalMapping ( ) : IMappingFunction ; getMapping ( ) : IMappingFunction ; setMapping ( mapping ) : void ; getColorMapping ( ) : IColorMappingFunction ; setColorMapping ( mapping ) : void ; getFilter ( ) : INumberFilter ; setFilter ( value ) : void ; getRange ( ) : [ string , string ] ; } export function isMapAbleColumn ( col ) ; export function isMapAbleColumn ( col ) ; export function isMapAbleColumn ( col ) { return ( ( col instanceof Column && typeof ( col as IMapAbleColumn ) . getMapping === 'function' ) || ( ! ( col instanceof Column ) && isNumberColumn ( col ) && ( ( col as IColumnDesc ) . type . startsWith ( 'number' ) || ( col as IColumnDesc ) . type . startsWith ( 'boxplot' ) ) ) ) ; } export interface INumberColumn extends Column { getNumber ( row ) : number ; getRawNumber ( row ) : number ; iterNumber ( row ) : IForEachAble < number > ; iterRawNumber ( row ) : IForEachAble < number > ; getNumberFormat ( ) : ( v : number ) => string ; } export interface INumberDesc extends IMapAbleDesc { default numberFormat ? : string ; default filterAccuracy ? : number ; } param col returns { boolean } export function isNumberColumn ( col ) ; export function isNumberColumn ( col ) ; export function isNumberColumn ( col ) { return ( ( col instanceof Column && typeof ( col as INumberColumn ) . getNumber === 'function' ) || ( ! ( col instanceof Column ) && ( col as IColumnDesc ) . type . match ( /(number|stack|ordinal)/ ) != null ) ) ; } export enum ESortMethod { min = 'min' , max = 'max' , median = 'median' , q1 = 'q1' , q3 = 'q3' } export interface IBoxPlotColumn extends INumberColumn , IMapAbleColumn { getBoxPlotData ( row ) : IBoxPlotData | null ; getMapping ( ) : IMappingFunction ; getRawBoxPlotData ( row ) : IBoxPlotData | null ; getSortMethod ( ) : string ; setSortMethod ( sortMethod ) : void ; } export function isBoxPlotColumn ( col ) { return typeof ( col as IBoxPlotColumn ) . getBoxPlotData === 'function' ; } export enum EAdvancedSortMethod { min = 'min' , max = 'max' , median = 'median' , q1 = 'q1' , q3 = 'q3' , mean = 'mean' } export interface IAdvancedBoxPlotColumn extends IBoxPlotColumn { getBoxPlotData ( row ) : IAdvancedBoxPlotData | null ; getRawBoxPlotData ( row ) : IAdvancedBoxPlotData | null ; } export interface INumbersColumn extends IAdvancedBoxPlotColumn , IArrayColumn < number > { getNumbers ( row ) : number [ ] ; getRawNumbers ( row ) : number [ ] ; } export function isNumbersColumn ( col ) { return isBoxPlotColumn ( col ) && typeof ( col as INumbersColumn ) . getNumbers === 'function' ; } export interface INumberFilter { min : number ; max : number ; filterMissing : boolean ; }