UNPKG

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