UNPKG

2.59 kBTypeScriptView Raw
1/**
2 * @fileOverview Reference Line
3 */
4import React, { ReactElement, SVGProps } from 'react';
5import { ImplicitLabelType } from '../component/Label';
6import { IfOverflow } from '../util/IfOverflowMatches';
7import { CartesianViewBox, D3Scale } from '../util/types';
8import { Props as XAxisProps } from './XAxis';
9import { Props as YAxisProps } from './YAxis';
10interface InternalReferenceLineProps {
11 viewBox?: CartesianViewBox;
12 xAxis?: Omit<XAxisProps, 'scale'> & {
13 scale: D3Scale<string | number>;
14 };
15 yAxis?: Omit<YAxisProps, 'scale'> & {
16 scale: D3Scale<string | number>;
17 };
18 clipPathId?: number | string;
19}
20export type Segment = {
21 x?: number | string;
22 y?: number | string;
23};
24export type ReferenceLinePosition = 'middle' | 'start' | 'end';
25interface ReferenceLineProps extends InternalReferenceLineProps {
26 isFront?: boolean;
27 /** @deprecated use ifOverflow="extendDomain" */
28 alwaysShow?: boolean;
29 ifOverflow?: IfOverflow;
30 x?: number | string;
31 y?: number | string;
32 segment?: ReadonlyArray<Segment>;
33 position?: ReferenceLinePosition;
34 className?: number | string;
35 yAxisId?: number | string;
36 xAxisId?: number | string;
37 shape?: ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>);
38 label?: ImplicitLabelType;
39}
40/**
41 * This excludes `viewBox` prop from svg for two reasons:
42 * 1. The components wants viewBox of object type, and svg wants string
43 * - so there's a conflict, and the component will throw if it gets string
44 * 2. Internally the component calls `filterProps` which filters the viewBox away anyway
45 */
46export type Props = Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps;
47type EndPointsPropsSubset = {
48 alwaysShow?: boolean;
49 ifOverflow?: IfOverflow;
50 segment?: ReadonlyArray<Segment>;
51 x?: number | string;
52 y?: number | string;
53};
54export declare const getEndPoints: (scales: any, isFixedX: boolean, isFixedY: boolean, isSegment: boolean, viewBox: CartesianViewBox, position: Props['position'], xAxisOrientation: XAxisProps['orientation'], yAxisOrientation: YAxisProps['orientation'], props: EndPointsPropsSubset) => any[];
55export declare class ReferenceLine extends React.Component<Props> {
56 static displayName: string;
57 static defaultProps: {
58 isFront: boolean;
59 ifOverflow: string;
60 xAxisId: number;
61 yAxisId: number;
62 fill: string;
63 stroke: string;
64 fillOpacity: number;
65 strokeWidth: number;
66 position: string;
67 };
68 render(): React.JSX.Element;
69}
70export {};