import { type ScaleBand, type ScaleLinear, type ScaleOrdinal, ScaleQuantize, type ScaleSymLog, ScaleThreshold, type ScaleTime } from 'd3-scale'; import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units'; import type { XYAxisTypeLinear, XYAxisTypeLog } from './axis.js'; import type { XYChartAreaSeriesProps, XYChartBarSeriesProps, XYChartCategoricalAxisProps, XYChartChartLegendProps, XYChartDotSeriesProps, XYChartLineSeriesProps, XYChartLogAxisProps, XYChartNumericalAxisProps, XYChartProps, XYChartRectSeriesProps, XYChartSelectConfig, XYChartSeriesBaseProps, XYChartThresholdIndicatorProps, XYChartTimeAxisProps, XYChartToolbarConfigProps, XYChartXAxisProps, XYChartYAxisProps, XYShapeColorPaletteProp } from './xy-chart-props.js'; import type { XYChartAreaSeries, XYChartBarSeries, XYChartDotSeries, XYChartLineSeries, XYChartRectSeries, AreaDatapoint, BarDatapoint, BarSeriesVariant, BaseDatapoint, DotDatapoint, LineDatapoint, SeriesCurve, XYAccessorDataTypes, XYChartAreaSeriesActionItem, XYChartBarSeriesActionItem, XYChartColorPalette, XYChartData, XYChartDotSeriesActionItem, XYChartLineSeriesActionItem, XYChartRectSeriesActionItem, XYChartThresholdDynamicData, XYChartThresholdStaticData, XYChartXAxisPosition, XYChartYAxisPosition } from './xy-chart.js'; import type { TickLabelLayout } from '../../core/components/axes/types.js'; import { type Orientation, type PointsDisplay } from '../../core/components/canvas/types/canvas-shape.js'; import type { PointShapeType } from '../../core/components/shape/type.js'; import type { THRESHOLD_BAR_THICKNESS } from '../../core/components/threshold-bar/types/constants.js'; import { ChartUnit } from '../../core/types/chart-unit.js'; import type { ColorToken } from '../../core/types/color-palette.js'; import type { ColorRuleProps, MatchValue } from '../../core/types/color-rule.js'; import type { DataPoint } from '../../core/types/data-point.js'; import type { CategoricalFormatter, DateTimeFormatter, Formatter, FormatterWithPrecision } from '../../core/types/formatter.js'; import type { ZoomChangeHandler } from '../../core/types/interactions.js'; import type { MinMax } from '../../core/types/min-max.js'; import { SeriesActionsTemplate } from '../../core/types/series-actions-template.js'; import { XYChartAnnotationsConfigProps } from '../context/XYChartAnnotationsConfig.context.js'; import { XYChartCustomTooltipConfig } from '../context/XYChartCustomTooltip.context.js'; /** * Type for the validator function returned by buildValidator(VALUE_MATCHERS) */ export type ColorRuleValidator = (subject: T, comparator: ColorRuleProps['comparator'], value: T) => boolean; export type ChartInteractionsInternal = { zoom: boolean; pan: boolean; infinite: boolean; } & ({ initial?: [Date, Date]; current?: [Date, Date]; } | { initial?: [number, number]; current?: [number, number]; }); export interface XYChartLinearAxisInternalProps extends Omit { type: XYAxisTypeLinear; } export interface XYChartLogAxisInternalProps extends Omit { type: XYAxisTypeLog; } /** * @internal * axis slot config */ export type XYChartAxisInternal = XYChartAxisInternalProps & { tickLabelLayout: TickLabelLayout; formatter?: Formatter | FormatOptions | CategoricalFormatter; unit?: ChartUnit; isRelative: boolean; } & ({ coordinate: 'x'; position: XYChartXAxisPosition; interactions: ChartInteractionsInternal; onZoomChange: ZoomChangeHandler; } | { coordinate: 'y'; position: XYChartYAxisPosition; interactions: Record, false> & { initial?: undefined; current?: undefined; }; onZoomChange: ZoomChangeHandler; }); /** * @internal * xychart axis props */ export type XYChartAxisInternalProps = XYChartLinearAxisInternalProps | XYChartLogAxisInternalProps | XYChartCategoricalAxisProps | XYChartTimeAxisProps; export interface XYChartSeriesBaseInternal { id: SeriesId; } /** * @internal * rect series slot config */ export interface XYChartRectSeriesInternal extends XYChartRectSeriesProps, XYChartSeriesBaseInternal { type: typeof RECT_VARIANT; } /** * @internal * Dot series slot config */ export type XYChartDotSeriesInternal = XYChartDotSeriesProps & XYChartSeriesBaseInternal & { type: typeof DOT_VARIANT; }; /** * @internal * Line series slot config */ export type XYChartLineSeriesInternal = XYChartLineSeriesProps & XYChartSeriesBaseInternal & { type: typeof LINE_VARIANT; }; /** * @internal * Bar series slot config */ export type XYChartBarSeriesInternal = XYChartBarSeriesProps & XYChartSeriesBaseInternal & { type: typeof BAR_VARIANT; }; /** * @internal * xy chart orientation type for Bar and Area variants. * Extends AreaCanvasOrientation with 'both' for cases like rect series * where datapoints can have both horizontal and vertical extent. */ export type XYChartOrientation = Orientation | 'both'; /** * @internal * xy chart area variant type - determines if the area is a simple area or a band (with both y0 and y1) */ export type XYChartAreaVariant = 'area' | 'band'; /** * @internal * Area series slot config */ export type XYChartAreaSeriesInternal = XYChartAreaSeriesProps & XYChartSeriesBaseInternal & { type: typeof AREA_VARIANT; }; /** * @internal * xy chart axis direction type */ export type XYChartAxisDirection = 'x' | 'y' | undefined; /** * @internal * xy chart stacking value boundaries */ export type XYChartStackingValueBoundaries = { minBoundary: number; maxBoundary: number; }; /** * @internal * series variant type */ export type XYChartVariantsInternal = XYChartRectSeriesInternal | XYChartDotSeriesInternal | XYChartLineSeriesInternal | XYChartBarSeriesInternal | XYChartAreaSeriesInternal; export type AnyXYChartScale = ScaleSymLog | ScaleLinear | ScaleTime | ScaleBand; /** The color scale for the xy chart */ export type XYChartColorScale = ScaleQuantize | ScaleOrdinal | ScaleThreshold; /** The id for the axis */ export type AxisId = string; /** The id for the series */ export type SeriesId = string; /** * @internal * Props that represent the extracted slots of the xy chart */ export interface XYChartSlots { series: Array; yAxes: XYChartYAxisProps[]; xAxes: XYChartXAxisProps[]; legend: XYChartChartLegendProps; toolbar: XYChartToolbarConfigProps; thresholds: XYChartThresholdIndicatorProps[]; annotations?: XYChartAnnotationsConfigProps; select?: XYChartSelectConfig; colorRules?: ColorRuleProps[]; tooltip: XYChartCustomTooltipConfig | undefined; } export interface XYChartInternals { series: XYChartSlots['series']; axes: XYChartAxisInternal[]; thresholds: XYChartThresholdsInternal; } export type XYChartThresholdsInternal = { thresholds: []; none: true; offset: { left: 0; right: 0; }; yAxes: { left: Set; right: Set; }; } | { thresholds: XYChartThresholdsPropsInternal; none: false; offset: { left: typeof THRESHOLD_BAR_THICKNESS | 0; right: typeof THRESHOLD_BAR_THICKNESS | 0; }; yAxes: { left: Set; right: Set; }; }; type XYChartThresholdPropsInternal = { id: string; data: XYChartThresholdStaticData; color: string; position: XYChartYAxisPosition; label?: string; strokeOnly?: boolean; yAxisId: string; }; export type XYChartThresholdDynamicPropsInternal = { xAxisId: string; data: XYChartThresholdDynamicData[]; } & Omit; export type XYChartThresholdStaticPropsInternal = XYChartThresholdPropsInternal; export type XYChartThresholdsPropsInternal = (XYChartThresholdDynamicPropsInternal | XYChartThresholdStaticPropsInternal)[]; export interface XYChartVisibleAxesScales { top: AnyXYChartScale | undefined; bottom: AnyXYChartScale | undefined; left: AnyXYChartScale | undefined; right: AnyXYChartScale | undefined; } export interface XYChartVisibleAxesConfig { top: XYChartAxisInternal | undefined; bottom: XYChartAxisInternal | undefined; left: XYChartAxisInternal | undefined; right: XYChartAxisInternal | undefined; } /** * @internal * XYCharts that can be used in exported/imported configuration */ export type ExportableXYChartProps = Pick; /** * @internal * Category unique name */ export type CategoryName = string; /** * @internal * * min/max map by Axis Id filled in the data processing loop */ export type AxisIdToScaleDomain = Map>; /** * @internal * Maps each axis to the set of grouped categories (dimension keys) detected during data processing. */ export type AxisIdToDimension = Map>; /** * @internal * * min/max map by Axis Id with only valid axis and */ export type AxisIdToCurrentScaleDomain = Map; /** * @internal * * Formatter map by Axis Id */ export type AxisIdToFormatter = Map; /** * @internal * * min/max OR categories value by Series Id filled in the data processing loop */ export type RectSeriesIdToValueScaleDomain = Map>; export interface SeriesPropsWithAxes { seriesProps: XYChartVariantsInternal; xAxis: XYChartAxisInternal; yAxis: XYChartAxisInternal; } export type XYValueAccessorDataTypes = number | string | undefined | null; export interface RectDatapointInternal extends BaseDatapoint { x1?: XYAccessorDataTypes; y1?: XYAccessorDataTypes; value: XYValueAccessorDataTypes; } export type XYChartSeriesWithDatapoints = RectSeriesWithDatapoints | DotSeriesWithDatapoints | LineSeriesWithDatapoints | BarSeriesWithDatapoints | AreaSeriesWithDatapoints; export interface RectSeriesWithDatapoints { id: SeriesId; type: typeof RECT_VARIANT; data: RectDatapointInternal[]; filteredData: RectDatapointInternal[]; xAxisId: string; yAxisId: string; } export interface DotSeriesWithDatapoints { id: SeriesId; type: typeof DOT_VARIANT; data: DotDatapoint[]; xAxisId: string; yAxisId: string; } export interface LineSeriesWithDatapoints { id: SeriesId; type: typeof LINE_VARIANT; data: LineDatapoint[]; xAxisId: string; yAxisId: string; } export interface BarSeriesWithDatapoints { id: SeriesId; type: typeof BAR_VARIANT; data: BarDatapoint[]; xAxisId: string; yAxisId: string; } export interface AreaSeriesWithDatapoints { id: SeriesId; type: typeof AREA_VARIANT; data: AreaDatapoint[]; xAxisId: string; yAxisId: string; } export type AnyDatapoint = RectDatapointInternal | DotDatapoint | LineDatapoint | BarDatapoint | AreaDatapoint; export type BaseMetadata = { name: string; xAxis: XYChartAxisInternal; yAxis: XYChartAxisInternal; colorPalette: XYChartColorPalette; colorIsFromSlot: boolean; isVisible?: boolean; }; export interface RectMetadata extends BaseMetadata { valueMin: XYChartRectSeriesProps['valueMin']; valueMax: XYChartRectSeriesProps['valueMax']; valueAccessor: string; valueType?: LegendType; valueAccessorLabel?: XYChartRectSeriesProps['valueAccessorLabel']; valueFormatter?: Formatter | FormatOptions; valueUnit?: ChartUnit; actions?: (datapoint: XYChartRectSeriesActionItem, series?: XYChartRectSeries) => SeriesActionsTemplate; } export interface BarMetadata extends BaseMetadata { color: ColorToken; variant: BarSeriesVariant; chartOrientation?: XYChartOrientation; actions?: (datapoint: XYChartBarSeriesActionItem, series?: XYChartBarSeries) => SeriesActionsTemplate; } export interface AreaMetadata extends BaseMetadata { curve?: SeriesCurve; color: ColorToken; orientation: Orientation; isStacked: boolean; variant: XYChartAreaVariant; pointsDisplay?: PointsDisplay; actions?: (datapoint: XYChartAreaSeriesActionItem, series?: XYChartAreaSeries) => SeriesActionsTemplate; } export interface DotMetadata extends BaseMetadata { color: ColorToken; shape?: PointShapeType; actions?: (datapoint: XYChartDotSeriesActionItem, series?: XYChartDotSeries) => SeriesActionsTemplate; } export interface LineMetadata extends BaseMetadata { curve?: SeriesCurve; actions?: (datapoint: XYChartLineSeriesActionItem, series?: XYChartLineSeries) => SeriesActionsTemplate; pointsDisplay?: PointsDisplay; color: ColorToken; } export interface SeriesToMetadata extends Map { get(key: RectSeriesWithDatapoints): RectMetadata | undefined; get(key: DotSeriesWithDatapoints): DotMetadata | undefined; get(key: LineSeriesWithDatapoints): LineMetadata | undefined; get(key: BarSeriesWithDatapoints): BarMetadata | undefined; get(key: AreaSeriesWithDatapoints): AreaMetadata | undefined; get(key: unknown): any | undefined; } export type RectSeriesToMetadata = Map; export type BarSeriesToMetadata = Map; export type DotSeriesToMetadata = Map; export type LineSeriesToMetadata = Map; export type AreaSeriesToMetadata = Map; export type DatapointMetadata = { isGap: boolean; accumulator?: number; baseline?: XYChartAxisDirection; colorOverride?: string; binDomain?: number; isVisible?: boolean; }; export type MapDatapoints = Map; /** * @internal */ export type XYChartDataWithCorrespondingSeries = { data: XYChartData[]; series: SeriesPropsWithAxes[]; }; /** * @internal * The range legend type for the xy chart */ export declare const RANGE_LEGEND_TYPE = "range"; /** * @internal * The categorical legend type for the xy chart */ export declare const CATEGORICAL_LEGEND_TYPE = "categorical"; export declare const RECT_VARIANT = "rect"; export declare const DOT_VARIANT = "dot"; export declare const LINE_VARIANT = "line"; export declare const BAR_VARIANT = "bar"; export declare const AREA_VARIANT = "area"; export declare const BAND_VARIANT = "band"; export declare const AREA_HORIZONTAL: "areahorizontal"; export declare const AREA_VERTICAL: "areavertical"; export declare const BAND_HORIZONTAL: "bandhorizontal"; export declare const BAND_VERTICAL: "bandvertical"; export declare const DOT_ID = "dot_id"; export declare const LINE_ID = "line_id"; export declare const AREA_ID = "area_id"; export declare const RECT_ID = "rect_id"; export declare const BAR_ID = "bar_id"; export type LegendType = typeof RANGE_LEGEND_TYPE | typeof CATEGORICAL_LEGEND_TYPE; export type SeriesVariantType = typeof RECT_VARIANT | typeof DOT_VARIANT | typeof LINE_VARIANT | typeof BAR_VARIANT | typeof AREA_VARIANT | typeof AREA_HORIZONTAL | typeof AREA_VERTICAL | typeof BAND_HORIZONTAL | typeof BAND_VERTICAL; /** * @internal * * Series base props extended to support types coming from slots and might be incompatible between each other in the root */ export interface XYChartSeriesBasePropsExtended extends Omit { colorPalette?: XYChartColorPalette | XYShapeColorPaletteProp; x0Accessor?: string; y0Accessor?: string; } export interface HighlightedLinearPoint extends DataPoint { shape?: PointShapeType; } export type AnyLinearSeries = DotSeriesWithDatapoints | LineSeriesWithDatapoints | AreaSeriesWithDatapoints; export type AnyLinearMetadata = DotMetadata | LineMetadata | AreaMetadata; /** * @internal * Shape types compatible with gap strategies */ export type ShapeDatapointWithGapPolicy = LineDatapoint | RectDatapointInternal | AreaDatapoint; export {};