import { FunctionComponent, MouseEvent, TouchEvent, AriaAttributes } from 'react'; import { Line, Area } from 'd3-shape'; import { Dimensions, Box, MotionProps, CssMixBlendMode, ValueFormat, SvgDefsAndFill, CartesianMarkerProps, PropertyAccessor, LineCurveFactoryId, DotsItemSymbolComponent } from '@nivo/core'; import { PartialTheme } from '@nivo/theming'; import { AxisProps, CanvasAxisProps } from '@nivo/axes'; import { InheritedColorConfig, OrdinalColorScaleConfig } from '@nivo/colors'; import { ScaleSpec, TicksSpec } from '@nivo/scales'; import { LegendProps } from '@nivo/legends'; import { CrosshairType } from '@nivo/tooltip'; export type AllowedSeriesId = string | number; export type AllowedValue = string | number | Date | null; export type LineSeries = { id: AllowedSeriesId; data: readonly { x: AllowedValue; y: AllowedValue; }[]; }; export type InferSeriesId = T extends { id: infer Id; } ? Id : never; export type InferX = T extends { data: ReadonlyArray; } ? D extends { x: infer X; } ? X : never : never; export type InferY = T extends { data: ReadonlyArray; } ? D extends { y: infer Y; } ? Y : never : never; export type DefaultSeries = { id: string; data: readonly { x: string | null; y: number | null; }[]; }; export interface ComputedDatum { data: Series['data'][number]; position: { x: number; y: number; }; } export type ComputedSeries = Omit & { id: InferSeriesId; data: readonly ComputedDatum[]; color: string; }; export interface Point { id: string; indexInSeries: number; absIndex: number; seriesIndex: number; seriesId: InferSeriesId; seriesColor: string; x: number; y: number; color: string; borderColor: string; data: Series['data'][number] & { xFormatted: string; yFormatted: string; }; } export type PointColorContext = { series: ComputedSeries; point: Omit, 'color' | 'borderColor'>; }; export interface SliceData { id: string; x0: number; x: number; y0: number; y: number; width: number; height: number; points: readonly Point[]; } export type PointOrSliceData = Point | SliceData; export declare function isPoint(data: PointOrSliceData): data is Point; export declare function isSliceData(data: PointOrSliceData): data is SliceData; export interface DataProps { data: readonly Series[]; } export type LineGenerator = Line<{ x: number; y: number; }>; export type AreaGenerator = Area<{ x: number; y: number; }>; export interface PointTooltipProps { point: Point; } export type PointTooltipComponent = FunctionComponent>; export interface SliceTooltipProps { axis: 'x' | 'y'; slice: SliceData; } export type SliceTooltipComponent = FunctionComponent>; export type PointOrSliceMouseHandler = (datum: Readonly> | Readonly>, event: MouseEvent) => void; export type PointOrSliceTouchHandler = (datum: Readonly> | Readonly>, event: TouchEvent) => void; export type LineLayerId = 'grid' | 'markers' | 'axes' | 'areas' | 'crosshair' | 'lines' | 'slices' | 'points' | 'mesh' | 'legends'; export interface CommonCustomLayerProps { innerWidth: number; innerHeight: number; series: readonly ComputedSeries[]; points: readonly Point[]; xScale: (x: InferX) => number; yScale: (y: InferY) => number; lineGenerator: LineGenerator; areaGenerator: AreaGenerator; currentPoint: Point | null; setCurrentPoint: (point: Point | null) => void; } export type LineCustomSvgLayerProps = Omit, 'xScale' | 'yScale'> & CommonCustomLayerProps & { slices: readonly SliceData[]; currentSlice: SliceData | null; setCurrentSlice: (slice: SliceData | null) => void; }; export type LineCustomSvgLayer = FunctionComponent>; export type LineSvgLayer = LineLayerId | LineCustomSvgLayer; export type LineCustomCanvasLayerProps = CommonCustomLayerProps; export type LineCustomCanvasLayer = (context: CanvasRenderingContext2D, props: LineCustomCanvasLayerProps) => void; export type LineCanvasLayer = LineLayerId | LineCustomCanvasLayer; export type CommonLineProps = { xScale: ScaleSpec; xFormat?: ValueFormat>; yScale: ScaleSpec; yFormat?: ValueFormat>; margin: Box; curve: LineCurveFactoryId; theme: PartialTheme; colors: OrdinalColorScaleConfig; lineWidth: number; enablePoints: boolean; pointSymbol?: DotsItemSymbolComponent>; pointSize: number; pointColor: InheritedColorConfig>; pointBorderWidth: number; pointBorderColor: InheritedColorConfig, 'borderColor'>>; enableArea: boolean; areaBaselineValue: InferY; areaOpacity: number; enableGridX: boolean; gridXValues?: TicksSpec>; enableGridY: boolean; gridYValues?: TicksSpec>; legends: readonly LegendProps[]; isInteractive: boolean; debugMesh: boolean; onMouseEnter?: PointOrSliceMouseHandler; onMouseMove?: PointOrSliceMouseHandler; onMouseLeave?: PointOrSliceMouseHandler; onMouseDown?: PointOrSliceMouseHandler; onMouseUp?: PointOrSliceMouseHandler; onClick?: PointOrSliceMouseHandler; onDoubleClick?: PointOrSliceMouseHandler; onTouchStart?: PointOrSliceTouchHandler; onTouchMove?: PointOrSliceTouchHandler; onTouchEnd?: PointOrSliceTouchHandler; tooltip: PointTooltipComponent; sliceTooltip: SliceTooltipComponent; renderWrapper: boolean; role?: string; }; export interface LineSvgExtraProps { layers: readonly LineSvgLayer[]; enablePointLabel: boolean; pointLabel: PropertyAccessor, string>; pointLabelYOffset?: number; areaBlendMode: CssMixBlendMode; axisTop?: AxisProps | null; axisRight?: AxisProps | null; axisBottom?: AxisProps | null; axisLeft?: AxisProps | null; useMesh: boolean; enableSlices: 'x' | 'y' | false; debugSlices: boolean; enableCrosshair: boolean; crosshairType: CrosshairType; enableTouchCrosshair: boolean; markers?: readonly CartesianMarkerProps[]; initialHiddenIds: readonly InferSeriesId[]; animate: boolean; motionConfig: MotionProps['motionConfig']; ariaLabel?: AriaAttributes['aria-label']; ariaLabelledBy?: AriaAttributes['aria-labelledby']; ariaDescribedBy?: AriaAttributes['aria-describedby']; isFocusable: boolean; pointAriaLabel?: (point: Point) => AriaAttributes['aria-label']; pointAriaLabelledBy?: (point: Point) => AriaAttributes['aria-labelledby']; pointAriaDescribedBy?: (point: Point) => AriaAttributes['aria-describedby']; pointAriaHidden?: (point: Point) => AriaAttributes['aria-hidden']; pointAriaDisabled?: (point: Point) => AriaAttributes['aria-disabled']; } export type LineSvgProps = DataProps & Dimensions & Partial> & Partial> & SvgDefsAndFill; export type LineSvgPropsWithDefaults = DataProps & Dimensions & CommonLineProps & LineSvgExtraProps & SvgDefsAndFill; export interface LineCanvasExtraProps { layers: readonly LineCanvasLayer[]; pixelRatio: number; axisTop?: CanvasAxisProps | null; axisRight?: CanvasAxisProps | null; axisBottom?: CanvasAxisProps | null; axisLeft?: CanvasAxisProps | null; } export type LineCanvasProps = DataProps & Dimensions & Partial> & Partial>; export type LineCanvasPropsWithDefaults = DataProps & Dimensions & CommonLineProps & LineCanvasExtraProps; //# sourceMappingURL=types.d.ts.map