UNPKG

2.23 kBTypeScriptView Raw
1import React, { ReactElement, SVGProps } from 'react';
2import { ChartOffset, D3Scale } from '../util/types';
3import { Props as XAxisProps } from './XAxis';
4import { Props as YAxisProps } from './YAxis';
5type XAxisWithD3Scale = Omit<XAxisProps, 'scale'> & {
6 scale: D3Scale<string | number>;
7};
8type YAxisWithD3Scale = Omit<YAxisProps, 'scale'> & {
9 scale: D3Scale<string | number>;
10};
11export type GridLineTypeFunctionProps = Omit<LineItemProps, 'key'> & {
12 key: LineItemProps['key'] | undefined;
13 offset: ChartOffset;
14 xAxis: null | XAxisWithD3Scale;
15 yAxis: null | YAxisWithD3Scale;
16};
17type GridLineType = SVGProps<SVGLineElement> | ReactElement<SVGElement> | ((props: GridLineTypeFunctionProps) => ReactElement<SVGElement>) | boolean;
18export type HorizontalCoordinatesGenerator = (props: {
19 yAxis: any;
20 width: number;
21 height: number;
22 offset: ChartOffset;
23}, syncWithTicks: boolean) => number[];
24export type VerticalCoordinatesGenerator = (props: {
25 xAxis: any;
26 width: number;
27 height: number;
28 offset: ChartOffset;
29}, syncWithTicks: boolean) => number[];
30interface InternalCartesianGridProps {
31 width?: number;
32 height?: number;
33 horizontalCoordinatesGenerator?: HorizontalCoordinatesGenerator;
34 verticalCoordinatesGenerator?: VerticalCoordinatesGenerator;
35}
36interface CartesianGridProps extends InternalCartesianGridProps {
37 x?: number;
38 y?: number;
39 horizontal?: GridLineType;
40 vertical?: GridLineType;
41 horizontalPoints?: number[];
42 verticalPoints?: number[];
43 verticalFill?: string[];
44 horizontalFill?: string[];
45 syncWithTicks?: boolean;
46 horizontalValues?: number[] | string[];
47 verticalValues?: number[] | string[];
48}
49type AcceptedSvgProps = Omit<SVGProps<SVGElement>, 'offset'>;
50export type Props = AcceptedSvgProps & CartesianGridProps;
51type LineItemProps = Props & {
52 offset: ChartOffset;
53 xAxis: null | XAxisWithD3Scale;
54 yAxis: null | YAxisWithD3Scale;
55 x1: number;
56 y1: number;
57 x2: number;
58 y2: number;
59 key: string;
60 index: number;
61};
62export declare function CartesianGrid(props: Props): React.JSX.Element;
63export declare namespace CartesianGrid {
64 var displayName: string;
65}
66export {};