UNPKG

40.1 kBTypeScriptView Raw
1// Type definitions for Recharts 1.8
2// Project: http://recharts.org/, https://github.com/recharts/recharts
3// Definitions by: Dmitriy Serdtsev <https://github.com/in19farkt>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.8
6
7import { CurveFactory } from 'd3-shape';
8import * as React from 'react';
9
10export type Percentage = string;
11export type RechartsFunction = (...args: any[]) => void;
12export type LegendValueFormatter = (value?: LegendPayload['value'], entry?: LegendPayload, i?: number) => any;
13export type TickFormatterFunction = (value: any) => any;
14export type TickGeneratorFunction = (noTicksProps: object) => ReadonlyArray<any>;
15export type LabelFormatter = (label: string | number) => React.ReactNode;
16export type TooltipFormatter = (
17 value: string | number | Array<string | number>,
18 name: string,
19 entry: TooltipPayload,
20 index: number,
21) => React.ReactNode;
22export type ItemSorter<T> = (a: T, b: T) => number;
23export type ContentRenderer<P> = (props: P) => React.ReactNode;
24export type DataKey = string | number | ((dataObject: any) => string | number | Readonly<[number, number]> | null);
25
26export type IconType =
27 | 'plainline'
28 | 'line'
29 | 'square'
30 | 'rect'
31 | 'circle'
32 | 'cross'
33 | 'diamond'
34 | 'star'
35 | 'triangle'
36 | 'wye'
37 | 'plainline';
38export type LegendType = IconType | 'none';
39export type LayoutType = 'horizontal' | 'vertical';
40export type AnimationEasingType = 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear';
41export type ScaleType =
42 | 'auto'
43 | 'linear'
44 | 'pow'
45 | 'sqrt'
46 | 'log'
47 | 'identity'
48 | 'time'
49 | 'band'
50 | 'point'
51 | 'ordinal'
52 | 'quantile'
53 | 'quantize'
54 | 'utc'
55 | 'sequential'
56 | 'threshold';
57export type PositionType =
58 | 'top'
59 | 'left'
60 | 'right'
61 | 'bottom'
62 | 'inside'
63 | 'outside'
64 | 'insideLeft'
65 | 'insideRight'
66 | 'insideTop'
67 | 'insideBottom'
68 | 'insideTopLeft'
69 | 'insideBottomLeft'
70 | 'insideTopRight'
71 | 'insideBottomRight'
72 | 'insideStart'
73 | 'insideEnd'
74 | 'end'
75 | 'center'
76 | 'centerTop'
77 | 'centerBottom';
78export type StackOffsetType = 'sign' | 'expand' | 'none' | 'wiggle' | 'silhouette';
79export type LineType =
80 | 'basis'
81 | 'basisClosed'
82 | 'basisOpen'
83 | 'linear'
84 | 'linearClosed'
85 | 'natural'
86 | 'monotoneX'
87 | 'monotoneY'
88 | 'monotone'
89 | 'step'
90 | 'stepBefore'
91 | 'stepAfter'
92 | CurveFactory;
93export type IfOverflowType = 'hidden' | 'visible' | 'discard' | 'extendDomain';
94export type AxisInterval = number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
95export type BaseValueType = number | 'auto' | 'dataMin' | 'dataMax';
96export type ReferenceLinePosition = 'start' | 'middle' | 'end';
97
98export type PickedCSSStyleDeclarationKeys =
99 | 'alignmentBaseline'
100 | 'baselineShift'
101 | 'clip'
102 | 'clipPath'
103 | 'clipRule'
104 | 'color'
105 | 'colorInterpolationFilters'
106 | 'cursor'
107 | 'direction'
108 | 'display'
109 | 'dominantBaseline'
110 | 'fill'
111 | 'fillRule'
112 | 'filter'
113 | 'floodColor'
114 | 'floodOpacity'
115 | 'font'
116 | 'fontFamily'
117 | 'fontStretch'
118 | 'fontStyle'
119 | 'fontVariant'
120 | 'letterSpacing'
121 | 'lightingColor'
122 | 'markerEnd'
123 | 'markerMid'
124 | 'markerStart'
125 | 'mask'
126 | 'overflow'
127 | 'pointerEvents'
128 | 'stopColor'
129 | 'strokeDasharray'
130 | 'strokeLinecap'
131 | 'strokeLinejoin'
132 | 'textAnchor'
133 | 'textDecoration'
134 | 'unicodeBidi'
135 | 'visibility'
136 | 'writingMode'
137 | 'transform';
138
139export interface BoxSize {
140 boxWidth: number;
141 boxHeight: number;
142}
143
144export interface ContainerSize {
145 containerWidth: number;
146 containerHeight: number;
147}
148
149export interface Point {
150 x: number;
151 y: number;
152 value: number | ReadonlyArray<any>;
153}
154
155export interface Margin {
156 top: number;
157 right: number;
158 bottom: number;
159 left: number;
160}
161
162export interface Animatable {
163 onAnimationStart?: RechartsFunction;
164 onAnimationEnd?: RechartsFunction;
165 animationId?: number;
166 isAnimationActive?: boolean;
167 isUpdateAnimationActive?: boolean;
168 animationBegin?: number;
169 animationDuration?: number;
170 animationEasing?: AnimationEasingType;
171}
172
173export interface CategoricalChartWrapper<L = LayoutType> {
174 syncId?: string | number;
175 compact?: boolean;
176 width?: number;
177 height?: number;
178 data?: ReadonlyArray<object>;
179 layout?: L;
180 stackOffset?: StackOffsetType;
181 throttleDelay?: number;
182 margin?: Partial<Margin>;
183 barCategoryGap?: number | string;
184 barGap?: number | string;
185 barSize?: number | string;
186 baseValue?: BaseValueType;
187 maxBarSize?: number;
188 style?: object;
189 className?: string;
190 children?: React.ReactNode | React.ReactNode[];
191 onClick?: RechartsFunction;
192 onMouseLeave?: RechartsFunction;
193 onMouseEnter?: RechartsFunction;
194 onMouseMove?: RechartsFunction;
195 onMouseDown?: RechartsFunction;
196 onMouseUp?: RechartsFunction;
197 reverseStackOrder?: boolean;
198}
199
200export interface EventAttributes {
201 onClick?: RechartsFunction;
202 onMouseDown?: RechartsFunction;
203 onMouseUp?: RechartsFunction;
204 onMouseOver?: RechartsFunction;
205 onMouseMove?: RechartsFunction;
206 onMouseOut?: RechartsFunction;
207 onMouseEnter?: RechartsFunction;
208 onMouseLeave?: RechartsFunction;
209 onTouchEnd?: RechartsFunction;
210 onTouchMove?: RechartsFunction;
211 onTouchStart?: RechartsFunction;
212 onTouchCancel?: RechartsFunction;
213}
214
215export interface PresentationAttributes<X = number, Y = number>
216 extends Pick<CSSStyleDeclaration, PickedCSSStyleDeclarationKeys> {
217 angle: number;
218 colorInterpolation: string;
219 colorProfile: string;
220 colorRendering: string;
221 fill: string;
222 fillOpacity: number | string;
223 fontSize: number | string;
224 fontSizeAdjust: number | string;
225 fontWeight:
226 | 'normal'
227 | 'bold'
228 | 'bolder'
229 | 'lighter'
230 | 100
231 | 200
232 | 300
233 | 400
234 | 500
235 | 600
236 | 700
237 | 800
238 | 900
239 | 'inherit';
240 imageRendering: 'auto' | 'optimizeSpeed' | 'optimizeQuality' | 'inherit';
241 kerning: number | string;
242 opacity: number | string;
243 shapeRendering: 'auto' | 'optimizeSpeed' | 'crispEdges' | 'geometricPrecision' | 'inherit';
244 stopOpacity: number | string;
245 stroke: number | string;
246 strokeDashoffset: number | string;
247 strokeMiterlimit: number | string;
248 strokeOpacity: number | string;
249 strokeWidth: number | string;
250 textRendering: 'auto' | 'optimizeSpeed' | 'optimizeLegibility' | 'geometricPrecision' | 'inherit';
251 wordSpacing: number | string;
252 style: object;
253 width: number;
254 height: number;
255 dx: number;
256 dy: number;
257 x: X;
258 y: Y;
259 r: number;
260}
261
262export interface AreaProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
263 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
264 className?: string;
265 type?: LineType;
266 unit?: string | number;
267 name?: string | number;
268 xAxisId?: string | number;
269 yAxisId?: string | number;
270 xAxis?: object;
271 yAxis?: object;
272 stackId?: string | number;
273 legendType?: LegendType;
274 connectNulls?: boolean;
275 activeDot?: boolean | object | React.ReactElement | ContentRenderer<any>;
276 dot?: boolean | object | React.ReactElement | ContentRenderer<DotProps & { payload: any }>;
277 label?: boolean | object | ContentRenderer<any> | React.ReactElement;
278 hide?: boolean;
279 layout?: LayoutType;
280 baseLine?: number | ReadonlyArray<any>;
281 isRange?: boolean;
282 points?: ReadonlyArray<Point>;
283 id?: string;
284}
285
286export class Area extends React.Component<AreaProps> {}
287
288// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
289export type AreaChartProps = CategoricalChartWrapper & EventAttributes;
290
291export class AreaChart extends React.Component<AreaChartProps> {}
292
293export interface BarData {
294 x: number;
295 y: number;
296 width: number;
297 height: number;
298 radius: number | ReadonlyArray<any>;
299 value: number | string | ReadonlyArray<any>;
300}
301
302export interface BarProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
303 children?: React.ReactNode;
304 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
305 className?: string;
306 fill?: string;
307 radius?: number | ReadonlyArray<number>;
308 layout?: LayoutType;
309 xAxisId?: string | number;
310 yAxisId?: string | number;
311 yAxis?: object;
312 xAxis?: object;
313 stackId?: string | number;
314 barSize?: number;
315 unit?: string | number;
316 name?: string | number;
317 legendType?: LegendType;
318 minPointSize?: number;
319 maxBarSize?: number;
320 hide?: boolean;
321 shape?: React.ReactElement | ContentRenderer<RectangleProps>;
322 data?: ReadonlyArray<BarData>;
323 background?: boolean | React.ReactElement | ContentRenderer<any> | object;
324 // see label section at http://recharts.org/#/en-US/api/Bar
325 label?: boolean | Label | LabelProps | React.FC<LabelProps> | React.ReactElement<LabelProps> | ContentRenderer<any>;
326 id?: string;
327}
328
329export class Bar extends React.Component<BarProps> {}
330
331// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
332export type BarChartProps = CategoricalChartWrapper & EventAttributes;
333
334export class BarChart extends React.Component<BarChartProps> {}
335
336export interface BrushProps {
337 className?: string;
338 fill?: string;
339 stroke?: string;
340 x?: number;
341 y?: number;
342 width?: number;
343 height?: number;
344 travellerWidth?: number;
345 padding?: Partial<Margin>;
346 dataKey?: DataKey;
347 data?: ReadonlyArray<any>;
348 startIndex?: number;
349 endIndex?: number;
350 tickFormatter?: TickFormatterFunction;
351 children?: React.ReactNode;
352 onChange?: RechartsFunction;
353 updateId?: string | number;
354 gap?: number;
355 leaveTimeOut?: number;
356}
357
358export class Brush extends React.Component<BrushProps> {}
359
360export interface CartesianAxisProps extends EventAttributes, Partial<PresentationAttributes> {
361 className?: string;
362 x?: number;
363 y?: number;
364 width?: number;
365 height?: number;
366 orientation?: 'top' | 'bottom' | 'left' | 'right';
367 viewBox?: ViewBox;
368 tick?: boolean | ContentRenderer<any> | object | React.ReactElement;
369 axisLine?: boolean | object;
370 tickLine?: boolean | object;
371 mirror?: boolean;
372 minTickGap?: number;
373 ticks?: ReadonlyArray<any>;
374 tickSize?: number;
375 stroke?: string;
376 tickFormatter?: TickFormatterFunction;
377 ticksGenerator?: TickGeneratorFunction;
378 interval?: AxisInterval;
379}
380
381export class CartesianAxis extends React.Component<CartesianAxisProps> {}
382
383export type HorizontalCoordinatesGenerator = (arg: {
384 yAxis: CartesianGridProps['yAxis'];
385 width: CartesianGridProps['chartWidth'];
386 height: CartesianGridProps['chartHeight'];
387 offset: CartesianGridProps['offset'];
388}) => ReadonlyArray<number>;
389
390export type VerticalCoordinatesGenerator = (arg: {
391 xAxis: CartesianGridProps['xAxis'];
392 width: CartesianGridProps['chartWidth'];
393 height: CartesianGridProps['chartHeight'];
394 offset: CartesianGridProps['offset'];
395}) => ReadonlyArray<number>;
396
397export interface CartesianGridProps extends Partial<PresentationAttributes> {
398 y?: number;
399 width?: number;
400 height?: number;
401 horizontal?: object | React.ReactElement | ContentRenderer<LineProps & CartesianGridProps> | boolean;
402 vertical?: object | React.ReactElement | ContentRenderer<LineProps & CartesianGridProps> | boolean;
403 horizontalPoints?: ReadonlyArray<number>;
404 verticalPoints?: ReadonlyArray<number>;
405 horizontalCoordinatesGenerator?: HorizontalCoordinatesGenerator;
406 verticalCoordinatesGenerator?: VerticalCoordinatesGenerator;
407 xAxis?: XAxisProps;
408 yAxis?: YAxisProps;
409 offset?: ChartOffset;
410 chartWidth?: number;
411 chartHeight?: number;
412 horizontalFill?: ReadonlyArray<string>;
413 verticalFill?: ReadonlyArray<string>;
414}
415export class CartesianGrid extends React.Component<CartesianGridProps> {}
416
417export interface CellProps extends Partial<PresentationAttributes> {
418 className?: string;
419 onClick?: RechartsFunction;
420 onMouseEnter?: RechartsFunction;
421 onMouseLeave?: RechartsFunction;
422}
423
424export class Cell extends React.Component<CellProps> {}
425
426export interface ChartOffset {
427 top?: number;
428 bottom?: number;
429 left?: number;
430 right?: number;
431 width?: number;
432 height?: number;
433 brushBottom?: number;
434}
435
436// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
437export type ComposedChartProps = CategoricalChartWrapper & EventAttributes;
438
439export class ComposedChart extends React.Component<ComposedChartProps> {}
440
441export interface CrossProps extends Partial<PresentationAttributes> {
442 className?: string;
443 x?: number;
444 y?: number;
445 width?: number;
446 height?: number;
447 top?: number;
448 left?: number;
449}
450
451export class Cross extends React.Component<CrossProps> {}
452
453// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
454export interface CurveProps extends EventAttributes, Partial<PresentationAttributes> {
455 className?: string;
456 type?: LineType;
457 layout?: LayoutType;
458 baseLine?: number | ReadonlyArray<any>;
459 points?: ReadonlyArray<object>;
460 connectNulls?: boolean;
461 path?: string;
462 pathRef?: React.Ref<any>;
463}
464
465export class Curve extends React.Component<CurveProps> {}
466
467// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
468export interface DotProps extends EventAttributes {
469 className?: string;
470 cx?: number;
471 cy?: number;
472 r?: number;
473}
474
475export class Dot extends React.Component<DotProps> {}
476
477export type DataPointFormatter = (entry: any, dataKey: DataKey) => { x: number; y: number; value: any; errorVal: any };
478
479export interface ErrorBarProps {
480 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
481 data?: ReadonlyArray<any>;
482 xAxis?: object;
483 yAxis?: object;
484 layout?: string;
485 dataPointFormatter?: DataPointFormatter;
486 stroke?: string;
487 strokeWidth?: number;
488 width?: number;
489 offset?: number;
490}
491
492export class ErrorBar extends React.Component<ErrorBarProps> {}
493
494export interface LegendPayload {
495 value: any;
496 id: any;
497 type: LegendType;
498 color?: string;
499 payload?: {
500 strokeDasharray: string;
501 };
502}
503
504export type BBoxUpdateCallback = (box: { width: number; height: number }) => void;
505
506export interface LayerProps {
507 className?: string;
508 children?: React.ReactNode[] | React.ReactNode;
509}
510
511export class Layer extends React.Component<LayerProps> {}
512
513export interface LegendProps {
514 content?: React.ReactElement | ContentRenderer<LegendProps>;
515 wrapperStyle?: object;
516 chartWidth?: number;
517 chartHeight?: number;
518 width?: number;
519 height?: number;
520 iconSize?: number;
521 iconType?: IconType;
522 layout?: LayoutType;
523 align?: 'left' | 'center' | 'right';
524 verticalAlign?: 'top' | 'middle' | 'bottom';
525 margin?: Partial<Margin>;
526 payload?: ReadonlyArray<LegendPayload>;
527 formatter?: LegendValueFormatter;
528 onClick?: RechartsFunction;
529 onMouseEnter?: RechartsFunction;
530 onMouseLeave?: RechartsFunction;
531 onBBoxUpdate?: BBoxUpdateCallback;
532}
533
534export class Legend extends React.Component<LegendProps, BoxSize> {}
535
536export interface LineProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
537 className?: string;
538 type?: LineType;
539 unit?: string | number;
540 name?: string | number;
541 xAxisId?: string | number;
542 yAxisId?: string | number;
543 yAxis?: object;
544 xAxis?: object;
545 legendType?: LegendType;
546 layout?: LayoutType;
547 connectNulls?: boolean;
548 hide?: boolean;
549 activeDot?: object | React.ReactElement | ContentRenderer<any> | boolean;
550 dot?: object | React.ReactElement | ContentRenderer<DotProps & { payload: any }> | boolean;
551 top?: number;
552 left?: number;
553 width?: number;
554 height?: number;
555 data?: ReadonlyArray<object>;
556 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
557 label?: boolean | object | React.ReactElement | ContentRenderer<any>;
558 points?: ReadonlyArray<Point>;
559 id?: string;
560}
561
562export class Line extends React.Component<LineProps> {}
563
564// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
565export type LineChartProps = CategoricalChartWrapper & EventAttributes;
566
567export class LineChart extends React.Component<LineChartProps> {}
568
569export interface PieProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
570 children?: React.ReactNode;
571 className?: string;
572 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
573 cx?: number | string;
574 cy?: number | string;
575 startAngle?: number;
576 endAngle?: number;
577 midAngle?: number;
578 paddingAngle?: number;
579 innerRadius?: number | string;
580 outerRadius?: number | string;
581 cornerRadius?: number | string;
582 nameKey?: string | number | ((dataObject: any) => number);
583 valueKey?: string | number | ((dataObject: any) => number);
584 data?: ReadonlyArray<object>;
585 minAngle?: number;
586 legendType?: LegendType;
587 maxRadius?: number;
588 sectors?: ReadonlyArray<object>;
589 hide?: boolean;
590 labelLine?: object | ContentRenderer<LineProps & any> | React.ReactElement | boolean;
591 label?:
592 | {
593 offsetRadius: number;
594 }
595 | React.ReactElement
596 | ContentRenderer<PieLabelRenderProps>
597 | boolean;
598 activeShape?: object | ContentRenderer<any> | React.ReactElement;
599 activeIndex?: number | ReadonlyArray<number>;
600 blendStroke?: boolean;
601}
602
603export interface PieLabelRenderProps extends PieProps {
604 name: string;
605 percent?: number;
606 stroke: string;
607 index?: number;
608 textAnchor: string;
609 x: number;
610 y: number;
611 [key: string]: any;
612}
613
614export class Pie extends React.Component<PieProps> {}
615
616// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
617export interface PieChartProps extends EventAttributes, CategoricalChartWrapper<'centric'> {
618 startAngle?: number;
619 endAngle?: number;
620 cx?: number | string;
621 cy?: number | string;
622 innerRadius?: number | string;
623 outerRadius?: number | string;
624}
625
626export class PieChart extends React.Component<PieChartProps> {}
627
628export interface PolarAngleAxisTick {
629 value: any;
630 coordinate: number;
631}
632
633export interface PolarAngleAxisProps extends EventAttributes, Partial<PresentationAttributes> {
634 type?: 'number' | 'category';
635 angleAxisId?: string | number;
636 dataKey?: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
637 cx?: number;
638 cy?: number;
639 radius?: Percentage | number;
640 hide?: boolean;
641 scale?: ScaleType | RechartsFunction; // this seems not being used by the lib.
642 axisLine?: boolean | object;
643 axisLineType?: 'polygon' | 'circle';
644 tickLine?: boolean | object;
645 tick?: boolean | ContentRenderer<any> | object | React.ReactElement;
646 ticks?: ReadonlyArray<PolarAngleAxisTick>;
647 stroke?: string;
648 orientation?: 'inner' | 'outer';
649 tickFormatter?: TickFormatterFunction;
650 allowDuplicatedCategory?: boolean;
651}
652
653export class PolarAngleAxis extends React.Component<PolarAngleAxisProps> {}
654
655export interface PolarGridProps extends Partial<PresentationAttributes> {
656 cx?: number;
657 cy?: number;
658 innerRadius?: number;
659 outerRadius?: number;
660 polarAngles?: ReadonlyArray<number>;
661 polarRadius?: ReadonlyArray<number>;
662 gridType?: 'polygon' | 'circle';
663}
664
665export class PolarGrid extends React.Component<PolarGridProps> {}
666
667export interface PolarRadiusAxisTick {
668 value: any;
669 coordinate: number;
670}
671
672export type PolarRadiusAxisDomain = number | 'auto' | 'dataMin' | 'dataMax';
673
674export interface PolarRadiusAxisProps extends EventAttributes, Partial<PresentationAttributes> {
675 type?: 'number' | 'category';
676 cx?: number;
677 cy?: number;
678 hide?: boolean;
679 radiusAxisId?: string | number;
680 angle?: number;
681 tickCount?: number;
682 ticks?: ReadonlyArray<PolarRadiusAxisTick>;
683 orientation?: 'left' | 'right' | 'middle';
684 axisLine?: boolean | object;
685 tick?: boolean | object | React.ReactElement | ContentRenderer<any>;
686 stroke?: string;
687 tickFormatter?: TickFormatterFunction;
688 domain?: Readonly<[PolarRadiusAxisDomain, PolarRadiusAxisDomain]>;
689 scale?: ScaleType | RechartsFunction;
690 allowDataOverflow?: boolean;
691 allowDuplicatedCategory?: boolean;
692}
693
694export class PolarRadiusAxis extends React.Component<PolarRadiusAxisProps> {}
695
696export interface PolygonPoint {
697 x: number;
698 y: number;
699}
700
701export interface PolygonProps extends EventAttributes, Partial<PresentationAttributes> {
702 className?: string;
703 points?: ReadonlyArray<PolygonPoint>;
704}
705
706export class Polygon extends React.Component<PolygonProps> {}
707
708export interface RadarPoint {
709 x: number;
710 y: number;
711 cx: number;
712 cy: number;
713 angle: number;
714 radius: number;
715 value: number;
716 payload: object;
717}
718
719export interface RadarProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
720 className?: string;
721 name?: string;
722 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
723 points?: ReadonlyArray<RadarPoint>;
724 shape?: React.ReactElement | ContentRenderer<RadarProps>;
725 activeDot?: object | React.ReactElement | ContentRenderer<any> | boolean;
726 dot?: object | React.ReactElement | ContentRenderer<DotProps> | boolean;
727 label?: object | React.ReactElement | ContentRenderer<any> | boolean;
728 legendType?: LegendType;
729 hide?: boolean;
730}
731
732export class Radar extends React.Component<RadarProps> {}
733
734// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
735export interface RadarChartProps extends EventAttributes, CategoricalChartWrapper<'centric'> {
736 startAngle?: number;
737 endAngle?: number;
738 cx?: number | string;
739 cy?: number | string;
740 innerRadius?: number | string;
741 outerRadius?: number | string;
742}
743
744export class RadarChart extends React.Component<RadarChartProps> {}
745
746export interface RadialBarData {
747 cx: number;
748 cy: number;
749 innerRadius: number;
750 outerRadius: number;
751 value: any;
752}
753
754export interface RadialBarProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
755 className?: string;
756 dataKey: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
757 angleAxisId?: string | number;
758 radiusAxisId?: string | number;
759 shape?: ContentRenderer<any> | React.ReactElement;
760 activeShape?: object | ContentRenderer<any> | React.ReactElement;
761 cornerRadius?: number | string;
762 minPointSize?: number;
763 maxBarSize?: number;
764 data?: ReadonlyArray<RadialBarData>;
765 legendType?: LegendType;
766 label?: boolean | React.ReactElement | ContentRenderer<any> | object;
767 background?: boolean | React.ReactElement | ContentRenderer<any> | object;
768 hide?: boolean;
769}
770
771export class RadialBar extends React.Component<RadialBarProps> {}
772
773export interface RadialBarChartProps extends CategoricalChartWrapper<'radial'> {
774 startAngle?: number;
775 endAngle?: number;
776 cx?: string | number;
777 cy?: string | number;
778 innerRadius?: string | number;
779 outerRadius?: string | number;
780}
781
782export class RadialBarChart extends React.Component<RadialBarChartProps> {}
783
784export interface RectangleProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
785 className?: string;
786 x?: number;
787 y?: number;
788 width?: number;
789 height?: number;
790 radius?: number | ReadonlyArray<any>;
791}
792
793export class Rectangle extends React.Component<RectangleProps> {}
794
795export interface ReferenceAreaProps extends Partial<PresentationAttributes> {
796 className?: number | string;
797 viewBox?: ViewBox;
798 xAxis?: object;
799 yAxis?: object;
800 isFront?: boolean;
801 alwaysShow?: boolean;
802 ifOverflow?: IfOverflowType;
803 x1?: number | string;
804 x2?: number | string;
805 y1?: number | string;
806 y2?: number | string;
807 xAxisId?: string | number;
808 yAxisId?: string | number;
809 shape?: ContentRenderer<ReferenceAreaProps & RectangleProps> | React.ReactElement;
810 label?: string | number | ContentRenderer<any> | React.ReactElement;
811}
812
813export class ReferenceArea extends React.Component<ReferenceAreaProps> {}
814
815export type ScaleCalculator = (x: number | string) => number;
816export interface ReferenceDotAxisConfiguration {
817 scale: ScaleCalculator;
818}
819
820export interface ReferenceDotProps
821 extends EventAttributes,
822 Partial<PresentationAttributes<number | string, number | string>> {
823 className?: number | string;
824 r?: number;
825 xAxis?: ReferenceDotAxisConfiguration;
826 yAxis?: ReferenceDotAxisConfiguration;
827 isFront?: boolean;
828 alwaysShow?: boolean;
829 ifOverflow?: IfOverflowType;
830 x?: number | string;
831 y?: number | string;
832 xAxisId?: string | number;
833 yAxisId?: string | number;
834 shape?:
835 | ContentRenderer<
836 EventAttributes &
837 Partial<PresentationAttributes<number | string, number | string>> & { cx: number; cy: number }
838 >
839 | React.ReactElement;
840 label?: string | number | React.ReactElement | RechartsFunction;
841}
842
843export class ReferenceDot extends React.Component<ReferenceDotProps> {}
844
845export interface SegmentItem {
846 x: number | string;
847 y: number | string;
848}
849
850export interface ReferenceLineProps extends Partial<PresentationAttributes<number | string, number | string>> {
851 className?: number | string;
852 viewBox?: ViewBox;
853 xAxis?: object;
854 yAxis?: object;
855 isFront?: boolean;
856 alwaysShow?: boolean;
857 ifOverflow?: IfOverflowType;
858 x?: number | string;
859 y?: number | string;
860 segment?: Readonly<[SegmentItem, SegmentItem]>;
861 label?: string | number | ContentRenderer<any> | React.ReactElement;
862 xAxisId?: string | number;
863 yAxisId?: string | number;
864 shape?:
865 | ContentRenderer<
866 EventAttributes &
867 Partial<PresentationAttributes<number | string, number | string>> & {
868 x1: number;
869 y1: number;
870 x2: number;
871 y2: number;
872 }
873 >
874 | React.ReactElement;
875 position?: ReferenceLinePosition;
876}
877
878export class ReferenceLine extends React.Component<ReferenceLineProps> {}
879
880export interface ResponsiveContainerProps {
881 aspect?: number;
882 width?: string | number;
883 height?: string | number;
884 minHeight?: string | number;
885 minWidth?: string | number;
886 maxHeight?: string | number;
887 children: React.ReactNode;
888 debounce?: number;
889 id?: string | number;
890 className?: string | number;
891}
892
893export class ResponsiveContainer extends React.Component<ResponsiveContainerProps, ContainerSize> {}
894
895export interface SankeyProps extends EventAttributes, Partial<PresentationAttributes> {
896 data: { nodes: any[]; links: Array<{ target: number; source: number; value: number }> };
897 nameKey?: string | number | RechartsFunction;
898 dataKey?: DataKey;
899 width?: number;
900 height?: number;
901 nodePadding?: number;
902 nodeWidth?: number;
903 linkCurvature?: number;
904 iterations?: number;
905 node?: object | ContentRenderer<any> | React.ReactElement;
906 link?: object | ContentRenderer<any> | React.ReactElement;
907 style?: object;
908 className?: string;
909 children?: React.ReactNode[] | React.ReactNode;
910 margin?: Partial<Margin>;
911}
912
913export interface SankeyState {
914 activeElement?: any;
915 activeElementType?: any;
916 isTooltipActive?: boolean;
917 nodes?: any;
918 links?: any;
919}
920
921export class Sankey extends React.Component<SankeyProps, SankeyState> {}
922
923export interface ScatterPoint {
924 cx?: number;
925 cy?: number;
926 size?: number;
927 node?: {
928 x?: number | string;
929 y?: number | string;
930 z?: number | string;
931 };
932 payload?: any;
933}
934
935export interface ScatterProps extends EventAttributes, Partial<PresentationAttributes>, Animatable {
936 xAxisId?: string | number;
937 yAxisId?: string | number;
938 zAxisId?: string | number;
939 line?: boolean | object | RechartsFunction | React.ReactElement;
940 lineType?: 'joint' | 'fitting';
941 lineJointType?: LineType;
942 legendType?: LegendType;
943 activeIndex?: number;
944 activeShape?: object | RechartsFunction | React.ReactElement;
945 shape?:
946 | 'circle'
947 | 'cross'
948 | 'diamond'
949 | 'square'
950 | 'star'
951 | 'triangle'
952 | 'wye'
953 | React.ReactElement
954 | ContentRenderer<any>;
955 points?: ReadonlyArray<ScatterPoint>;
956 hide?: boolean;
957 data?: ReadonlyArray<object>;
958 dataKey?: DataKey;
959 name?: string | number;
960 id?: string;
961}
962
963export class Scatter extends React.Component<ScatterProps> {}
964
965// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
966export type ScatterChartProps = CategoricalChartWrapper & EventAttributes;
967
968export class ScatterChart extends React.Component<ScatterChartProps> {}
969
970export interface SectorProps extends EventAttributes, Partial<PresentationAttributes> {
971 className?: string;
972 cx?: number;
973 cy?: number;
974 innerRadius?: number;
975 outerRadius?: number;
976 startAngle?: number;
977 endAngle?: number;
978 cornerRadius?: number | string;
979}
980
981export class Sector extends React.Component<SectorProps> {}
982
983export interface TextProps extends Partial<PresentationAttributes> {
984 children?: React.ReactNode;
985 className?: string;
986 scaleToFit?: boolean;
987 angle?: number;
988 textAnchor?: 'start' | 'middle' | 'end' | 'inherit';
989 verticalAnchor?: 'start' | 'middle' | 'end';
990 style?: object;
991 capHeight?: string;
992 lineHeight?: string;
993}
994
995export class Text extends React.Component<TextProps> {}
996
997export interface ViewBox {
998 x?: number;
999 y?: number;
1000 width?: number;
1001 height?: number;
1002}
1003
1004export interface PolarViewBox {
1005 cx?: number;
1006 cy?: number;
1007 innerRadius?: number;
1008 outerRadius?: number;
1009 startAngle?: number;
1010 endAngle?: number;
1011}
1012
1013export interface Coordinate {
1014 x: number;
1015 y: number;
1016}
1017
1018export type AllowEscapeViewBox = { x: boolean } | { y: boolean } | { x: boolean; y: boolean };
1019
1020export interface TooltipPayload {
1021 name: string;
1022 value: string | number | ReadonlyArray<string | number>;
1023 unit?: string;
1024 color?: string;
1025 fill?: string;
1026 dataKey?: DataKey;
1027 formatter?: TooltipFormatter;
1028 payload?: any;
1029 stroke?: string | undefined;
1030 strokeDasharray?: string | number | undefined;
1031 strokeWidth?: number | string | undefined;
1032}
1033
1034export interface TooltipProps extends Animatable {
1035 content?: React.ReactElement | React.FunctionComponent<any> | ContentRenderer<TooltipProps>;
1036 viewBox?: ViewBox;
1037 allowEscapeViewBox?: AllowEscapeViewBox;
1038 active?: boolean;
1039 separator?: string;
1040 formatter?: TooltipFormatter;
1041 offset?: number;
1042 itemStyle?: object;
1043 labelStyle?: object;
1044 contentStyle?: object;
1045 wrapperStyle?: object;
1046 cursor?: boolean | object | React.ReactElement | React.FunctionComponent<any>;
1047 coordinate?: Coordinate;
1048 position?: Coordinate;
1049 label?: string | number;
1050 labelFormatter?: LabelFormatter;
1051 payload?: ReadonlyArray<TooltipPayload>;
1052 itemSorter?: ItemSorter<TooltipPayload>;
1053 filterNull?: boolean;
1054 useTranslate3d?: boolean;
1055}
1056
1057export class Tooltip extends React.Component<TooltipProps, BoxSize> {}
1058
1059export interface TreemapProps extends EventAttributes, Animatable {
1060 width?: number;
1061 height?: number;
1062 data?: ReadonlyArray<any>;
1063 style?: object;
1064 aspectRatio?: number;
1065 content?: React.ReactElement | ContentRenderer<any>;
1066 fill?: string;
1067 stroke?: string;
1068 className?: string;
1069 nameKey?: string | number | RechartsFunction;
1070 dataKey?: DataKey; // As the source code states, dataKey will replace valueKey in 1.1.0 and it'll be required (it's already required in current implementation).
1071 children?: React.ReactNode[] | React.ReactNode;
1072}
1073
1074export class Treemap extends React.Component<TreemapProps> {}
1075
1076export class Label extends React.Component<LabelProps> {}
1077
1078export interface LabelProps extends Partial<PresentationAttributes> {
1079 angle?: number;
1080 viewBox?: ViewBox | PolarViewBox;
1081 formatter?: LabelFormatter;
1082 value?: number | string;
1083 offset?: number;
1084 position?: PositionType;
1085 children?: React.ReactNode[] | React.ReactNode;
1086 className?: string;
1087 content?: React.ReactElement | ContentRenderer<any>;
1088}
1089
1090export class LabelList extends React.Component<LabelListProps> {}
1091
1092export type LabelListProps = {
1093 angle?: number;
1094 children?: React.ReactNode[] | React.ReactNode;
1095 className?: string;
1096 clockWise?: boolean;
1097 content?: React.ReactElement | ContentRenderer<LabelProps>;
1098 data?: number;
1099 formatter?: LabelFormatter;
1100 id?: string;
1101 offset?: number;
1102 position?: PositionType;
1103} & (
1104 | { dataKey: string | number | RechartsFunction; valueAccessor?: never }
1105 | { valueAccessor: RechartsFunction; dataKey?: never }
1106);
1107
1108export type AxisDomain = string | number | ContentRenderer<any> | 'auto' | 'dataMin' | 'dataMax';
1109
1110export interface XPadding {
1111 left: number;
1112 right: number;
1113}
1114
1115/**
1116 * In the current lib, there is not actual implementation for XAxis.
1117 */
1118// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
1119export interface XAxisProps extends EventAttributes {
1120 allowDecimals?: boolean;
1121 children?: React.ReactNode;
1122 hide?: boolean;
1123 // The name of data displayed in the axis
1124 name?: string | number;
1125 // The unit of data displayed in the axis
1126 unit?: string | number;
1127 // The unique id of x-axis
1128 xAxisId?: string | number;
1129 domain?: Readonly<[AxisDomain, AxisDomain]>;
1130 // The key of data displayed in the axis
1131 dataKey?: DataKey;
1132 // The width of axis which is usually calculated internally
1133 width?: number;
1134 // The height of axis, which need to be set by user
1135 height?: number;
1136 // Rotation of tick labels
1137 angle?: number;
1138 // X offset of tick label
1139 dx?: number;
1140 // Y offset of tick label
1141 dy?: number;
1142 mirror?: boolean;
1143 // The orientation of axis
1144 orientation?: 'top' | 'bottom';
1145 type?: 'number' | 'category';
1146 // Ticks can be any type when the axis is the type of category
1147 // Ticks must be numbers when the axis is the type of number
1148 ticks?: ReadonlyArray<any>;
1149 // The count of ticks
1150 tickCount?: number;
1151 // The formatter function of tick
1152 tickFormatter?: TickFormatterFunction;
1153 padding?: Partial<XPadding>;
1154 allowDataOverflow?: boolean;
1155 scale?: ScaleType | RechartsFunction;
1156 tick?: boolean | ContentRenderer<any> | object | React.ReactElement;
1157 axisLine?: boolean | object;
1158 tickLine?: boolean | object;
1159 minTickGap?: number;
1160 tickSize?: number;
1161 // The margin between tick line and the label
1162 tickMargin?: number;
1163 interval?: AxisInterval;
1164 textAnchor?: string;
1165 reversed?: boolean;
1166 // see label section at http://recharts.org/#/en-US/api/XAxis
1167 label?: string | number | Label | LabelProps;
1168 allowDuplicatedCategory?: boolean;
1169 stroke?: string;
1170}
1171
1172export class XAxis extends React.Component<XAxisProps> {}
1173
1174export interface YPadding {
1175 top: number;
1176 bottom: number;
1177}
1178
1179// NOTE: the lib's implementation doesn't inherits the event props (it's kept in this definition due to the previous typing definition has it).
1180export interface YAxisProps extends EventAttributes {
1181 allowDecimals?: boolean;
1182 children?: React.ReactNode;
1183 hide?: boolean;
1184 // The name of data displayed in the axis
1185 name?: string | number;
1186 // The unit of data displayed in the axis
1187 unit?: string | number;
1188 // The unique id of y-axis
1189 yAxisId?: string | number;
1190 domain?: Readonly<[AxisDomain, AxisDomain]>;
1191 // The key of data displayed in the axis
1192 dataKey?: DataKey;
1193 // Ticks can be any type when the axis is the type of category
1194 // Ticks must be numbers when the axis is the type of number
1195 ticks?: ReadonlyArray<any>;
1196 // The count of ticks
1197 tickCount?: number;
1198 // Rotation of tick labels
1199 angle?: number;
1200 // X offset of tick label
1201 dx?: number;
1202 // Y offset of tick label
1203 dy?: number;
1204 // The formatter function of tick
1205 tickFormatter?: TickFormatterFunction;
1206 // The width of axis, which need to be set by user
1207 width?: number;
1208 // The height of axis which is usually calculated in Chart
1209 height?: number;
1210 mirror?: boolean;
1211 // The orientation of axis
1212 orientation?: 'left' | 'right';
1213 type?: 'number' | 'category';
1214 padding?: Partial<YPadding>;
1215 allowDataOverflow?: boolean;
1216 scale?: ScaleType | RechartsFunction;
1217 tick?: boolean | ContentRenderer<any> | object | React.ReactElement;
1218 axisLine?: boolean | object;
1219 tickLine?: boolean | object;
1220 minTickGap?: number;
1221 tickSize?: number;
1222 // The margin between tick line and the label
1223 tickMargin?: number;
1224 interval?: AxisInterval;
1225 reversed?: boolean;
1226 // see label section at http://recharts.org/#/en-US/api/YAxis
1227 label?: string | number | Label | LabelProps;
1228 allowDuplicatedCategory?: boolean;
1229 stroke?: string;
1230}
1231
1232export class YAxis extends React.Component<YAxisProps> {}
1233
1234export interface ZAxisProps {
1235 type?: 'number' | 'category';
1236 // The name of data displayed in the axis
1237 name?: string | number;
1238 // The unit of data displayed in the axis
1239 unit?: string | number;
1240 // The unique id of z-axis
1241 zAxisId?: string | number;
1242 // The key of data displayed in the axis
1243 dataKey?: DataKey;
1244 // The range of axis
1245 range?: ReadonlyArray<number>;
1246 scale?: ScaleType | RechartsFunction;
1247}
1248
1249export class ZAxis extends React.Component<ZAxisProps> {}
1250
1251export interface SurfaceProps {
1252 width?: number;
1253 height?: number;
1254 viewBox?: ViewBox;
1255 className?: string;
1256 style?: object;
1257 children?: React.ReactNode[] | React.ReactNode;
1258}
1259
1260export class Surface extends React.Component<SurfaceProps> {}
1261
1262export interface SymbolsProps extends Partial<PresentationAttributes> {
1263 className?: string;
1264 type?: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
1265 cx?: number;
1266 cy?: number;
1267 size?: number;
1268 sizeType?: 'area' | 'diameter';
1269}
1270
1271export class Symbols extends React.Component<SymbolsProps> {}
1272
1273export interface CustomizedProps {
1274 component: ContentRenderer<any> | React.ReactElement;
1275}
1276
1277export class Customized extends React.Component<CustomizedProps> {}