/** Name of the data series. */ export type SeriesName = string; /** Type of the data series: - 'dimension' - categorical data containing strings (dates should also be added as strings); - 'measure' - continuous data containing numbers. */ export type SeriesType = 'dimension' | 'measure'; /** Represents a categorical or data value */ export type Value = string | number; /** Represents a categorical value */ export type DimensionValue = string; /** Represents a data value */ export type MeasureValue = number | null; /** Base type for data series. */ export interface SeriesBase { /** Name of the data series. It will be the unique id of the series to reference it in various parts of the API, mainly in channel configuration and in data record filters. This name will also be used by default for Axis and Legend title. */ name: SeriesName; /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type?: SeriesType; } /** Name of a dimension data series. */ export interface BaseDimension extends SeriesBase { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type?: 'dimension'; /** The array that contains the values of the data series. The value types should match the data series' `type` property. If the data series is shorter than the longest data series defined, it will be internally extended with empty values. */ values?: DimensionValue[]; } /** Name of a dimension data series. */ export interface IndexDimension extends SeriesBase { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type?: 'dimension'; /** Distinct unique values in the series */ categories: string[]; /** The array that contains the values of the data series. The value types should match the data series' `type` property. If the data series is shorter than the longest data series defined, it will be internally extended with empty values. */ values?: number[]; } /** Name of a dimension data series. */ export interface ImplicitStringDimension extends BaseDimension { /** The array that contains the values of the data series. The value types should match the data series' `type` property. If the data series is shorter than the longest data series defined, it will be internally extended with empty values. */ values: DimensionValue[]; } /** Name of a dimension data series. */ export interface ExplicitStringDimension extends BaseDimension { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type: 'dimension'; } /** Name of a dimension data series. */ export type StringDimension = ImplicitStringDimension | ExplicitStringDimension; /** Name of a dimension data series. */ export type Dimension = IndexDimension | StringDimension; /** Name of a measure data series. */ export interface BaseMeasure extends SeriesBase { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type?: 'measure'; /** The array that contains the values of the data series. The value types should match the data series' `type` property. If the data series is shorter than the longest data series defined, it will be internally extended with empty values. */ values?: MeasureValue[]; /** Unit of the data series. */ unit?: string; } /** Name of a measure data series. */ export interface ExplicitMeasure extends BaseMeasure { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type: 'measure'; } /** Name of a measure data series. */ export interface ImplicitMeasure extends BaseMeasure { /** The array that contains the values of the data series. The value types should match the data series' `type` property. If the data series is shorter than the longest data series defined, it will be internally extended with empty values. */ values: MeasureValue[]; } /** Name of a measure data series. */ export type Measure = ImplicitMeasure | ExplicitMeasure; /** Represents a numeric interval. */ export interface Range { /** Minimal value in the series */ min: number; /** Maximal value in the series */ max: number; } /** Meta data about dimension data series */ export interface DimensionInfo extends SeriesBase { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type: 'dimension'; /** Distinct unique values in the series */ categories: string[]; /** Count of values in the series. */ length: number; } /** Meta data about measure data series */ export interface MeasureInfo extends SeriesBase { /** Type of the data series. If not set, the library will attempt to determine the type based on the type of the first value. Number type will result in measure, string type will result in dimension. */ type: 'measure'; range: Range; /** Unit of the data series. */ unit: string; /** Count of values in the series. */ length: number; } /** MetaInfo for different series types. */ export type SeriesInfo = DimensionInfo | MeasureInfo; /** Defines a data series of the data set, and contains a particular variable's values in the data set and meta info about the variable. */ export type Series = Dimension | Measure; /** A record of the data set, containing one value of each data series corresponding to the same index. */ export interface Record { /** Properties are provided for each data series, providing access to the value within the record referenced by its data series name. */ [seriesName: SeriesName]: Value; } /** A callback function receives a record */ export type FilterCallback = (record: Record) => boolean; export type SeriesMetaInfo = SeriesInfo; /** Meta data about the data set */ export interface Metainfo { series: SeriesMetaInfo[]; } /** Filter object containing a filter function */ export interface Filter { /** A filter callback is called on each record of the dataset on chart generation. If the callback returns false, the record will not be shown on the chart. */ filter?: FilterCallback | null; } /** Data table specified by series. */ export interface TableBySeries extends Filter { /** The series that make up the data set. */ series: Series[]; } /** Values of a data record in the order of the series in the dataset. */ export type ValueArray = Value[]; /** Data table specified by records. */ export interface TableByRecords extends Filter { /** The information about the data series in the records of the data set. Note: not needed if it was previously specified. */ series?: Series[]; /** The array of data records that make up the data set. */ records: (ValueArray | Record)[]; } /** Data set is a collection of related data series. Each chart works on a single data set. */ export type Set = TableBySeries | TableByRecords; /** Types of the different available data series aggregators: - sum: sum of the values (default) - count: count of the values - min: minima of the values - max: maxima of the values - mean: average/mean of the values - distinct: number of different values */ export type AggregatorType = 'sum' | 'count' | 'min' | 'max' | 'mean' | 'distinct'; /** The name of a series with an aggregator function. */ export interface SeriesDescriptor { name: SeriesName; aggregator?: AggregatorType; } /** Array or a single data series. */ export type SeriesList = SeriesDescriptor[];