UNPKG

2.05 kBTypeScriptView Raw
1import React, { PureComponent, ReactNode, MouseEvent, ReactText, ReactElement } from 'react';
2import { DataKey, LegendType, LayoutType, PresentationAttributesAdaptChildEvent } from '../util/types';
3export type ContentType = ReactElement | ((props: Props) => ReactNode);
4export type IconType = Exclude<LegendType, 'none'>;
5export type HorizontalAlignmentType = 'center' | 'left' | 'right';
6export type VerticalAlignmentType = 'top' | 'bottom' | 'middle';
7export type Formatter = (value: any, entry: {
8 value: any;
9 id?: string;
10 type?: LegendType;
11 color?: string;
12 payload?: {
13 strokeDasharray: ReactText;
14 value?: any;
15 };
16}, index: number) => ReactNode;
17export interface Payload {
18 value: any;
19 id?: string;
20 type?: LegendType;
21 color?: string;
22 payload?: {
23 strokeDasharray: ReactText;
24 value?: any;
25 };
26 formatter?: Formatter;
27 inactive?: boolean;
28 legendIcon?: ReactElement<SVGElement>;
29 dataKey?: DataKey<any>;
30}
31interface InternalProps {
32 content?: ContentType;
33 iconSize?: number;
34 iconType?: IconType;
35 layout?: LayoutType;
36 align?: HorizontalAlignmentType;
37 verticalAlign?: VerticalAlignmentType;
38 payload?: Array<Payload>;
39 inactiveColor?: string;
40 formatter?: Formatter;
41 onMouseEnter?: (data: Payload, index: number, event: MouseEvent) => void;
42 onMouseLeave?: (data: Payload, index: number, event: MouseEvent) => void;
43 onClick?: (data: Payload, index: number, event: MouseEvent) => void;
44}
45export type Props = InternalProps & Omit<PresentationAttributesAdaptChildEvent<any, ReactElement>, keyof InternalProps>;
46export declare class DefaultLegendContent extends PureComponent<Props> {
47 static displayName: string;
48 static defaultProps: {
49 iconSize: number;
50 layout: string;
51 align: string;
52 verticalAlign: string;
53 inactiveColor: string;
54 };
55 renderIcon(data: Payload): React.JSX.Element;
56 renderItems(): React.JSX.Element[];
57 render(): React.JSX.Element;
58}
59export {};