@octanejs/recharts 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +4 -4
  2. package/src/animation/CSSTransitionAnimate.tsrx +142 -0
  3. package/src/cartesian/Area.tsrx +1096 -0
  4. package/src/cartesian/Area.tsrx.d.ts +340 -0
  5. package/src/cartesian/AreaRevealShape.tsrx +202 -0
  6. package/src/cartesian/CartesianGrid.tsrx +643 -0
  7. package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
  8. package/src/cartesian/ErrorBar.tsrx +322 -0
  9. package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
  10. package/src/cartesian/Funnel.tsrx +833 -0
  11. package/src/cartesian/Funnel.tsrx.d.ts +274 -0
  12. package/src/cartesian/ReferenceLine.tsrx +452 -0
  13. package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
  14. package/src/cartesian/Scatter.tsrx +1076 -0
  15. package/src/cartesian/Scatter.tsrx.d.ts +351 -0
  16. package/src/cartesian/ZAxis.tsrx +148 -0
  17. package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
  18. package/src/chart/AreaChart.tsrx +22 -0
  19. package/src/chart/AreaChart.tsrx.d.ts +12 -0
  20. package/src/chart/ComposedChart.tsrx +22 -0
  21. package/src/chart/ComposedChart.tsrx.d.ts +12 -0
  22. package/src/chart/FunnelChart.tsrx +22 -0
  23. package/src/chart/FunnelChart.tsrx.d.ts +12 -0
  24. package/src/chart/PieChart.tsrx +31 -0
  25. package/src/chart/PieChart.tsrx.d.ts +31 -0
  26. package/src/chart/PolarChart.tsrx +121 -0
  27. package/src/chart/RadarChart.tsrx +53 -0
  28. package/src/chart/RadarChart.tsrx.d.ts +31 -0
  29. package/src/chart/RadialBarChart.tsrx +31 -0
  30. package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
  31. package/src/chart/Sankey.tsrx +1542 -0
  32. package/src/chart/Sankey.tsrx.d.ts +253 -0
  33. package/src/chart/ScatterChart.tsrx +22 -0
  34. package/src/chart/ScatterChart.tsrx.d.ts +12 -0
  35. package/src/chart/SunburstChart.tsrx +495 -0
  36. package/src/chart/SunburstChart.tsrx.d.ts +146 -0
  37. package/src/chart/types.ts +19 -0
  38. package/src/component/Cursor.tsrx +157 -0
  39. package/src/component/DefaultLegendContent.tsrx +288 -0
  40. package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
  41. package/src/component/DefaultTooltipContent.tsrx +215 -0
  42. package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
  43. package/src/component/Legend.tsrx +302 -0
  44. package/src/component/Legend.tsrx.d.ts +88 -0
  45. package/src/component/ResponsiveContainer.ts +1 -22
  46. package/src/component/ResponsiveContainer.tsrx +171 -0
  47. package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
  48. package/src/component/Tooltip.tsrx +425 -0
  49. package/src/component/Tooltip.tsrx.d.ts +246 -0
  50. package/src/component/TooltipBoundingBox.tsrx +135 -0
  51. package/src/context/CellsContext.ts +12 -0
  52. package/src/context/legendPayloadContext.tsrx +11 -0
  53. package/src/context/useTooltipAxis.ts +20 -0
  54. package/src/index.d.ts +236 -0
  55. package/src/index.ts +67 -0
  56. package/src/polar/Pie.tsrx +1224 -0
  57. package/src/polar/Pie.tsrx.d.ts +436 -0
  58. package/src/polar/PolarAngleAxis.tsrx +554 -0
  59. package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
  60. package/src/polar/PolarGrid.tsrx +317 -0
  61. package/src/polar/PolarGrid.tsrx.d.ts +117 -0
  62. package/src/polar/PolarRadiusAxis.tsrx +463 -0
  63. package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
  64. package/src/polar/Radar.tsrx +696 -0
  65. package/src/polar/Radar.tsrx.d.ts +215 -0
  66. package/src/polar/RadialBar.tsrx +887 -0
  67. package/src/polar/RadialBar.tsrx.d.ts +340 -0
  68. package/src/state/ReportPolarOptions.tsrx +11 -0
  69. package/src/state/selectors/areaSelectors.ts +257 -0
  70. package/src/state/selectors/funnelSelectors.ts +86 -0
  71. package/src/state/selectors/pieSelectors.ts +134 -0
  72. package/src/state/selectors/polarGridSelectors.ts +43 -0
  73. package/src/state/selectors/polarScaleSelectors.ts +159 -0
  74. package/src/state/selectors/polarSelectors.ts +198 -0
  75. package/src/state/selectors/radarSelectors.ts +228 -0
  76. package/src/state/selectors/radialBarSelectors.ts +511 -0
  77. package/src/state/selectors/scatterSelectors.ts +168 -0
  78. package/src/util/FunnelUtils.tsrx +19 -0
  79. package/src/util/RadialBarUtils.tsrx +29 -0
  80. package/src/util/ScatterUtils.tsrx +34 -0
  81. package/src/util/cursor/getCursorPoints.ts +45 -0
  82. package/src/util/cursor/getCursorRectangle.ts +28 -0
  83. package/src/util/cursor/getRadialCursorPoints.ts +31 -0
  84. package/src/util/payload/getUniqPayload.ts +28 -0
  85. package/src/util/scale/CartesianScaleHelper.ts +71 -0
  86. package/src/util/tooltip/translate.ts +168 -0
  87. package/src/util/types.ts +3 -0
  88. package/src/util/useElementOffset.ts +147 -0
@@ -0,0 +1,157 @@
1
+ import * as React from 'octane';
2
+ import { cloneElement, createElement, isValidElement, ReactElement, SVGProps } from 'octane';
3
+ import { clsx } from 'clsx';
4
+ import {
5
+ ChartOffsetInternal,
6
+ Coordinate,
7
+ isPolarCoordinate,
8
+ LayoutType,
9
+ PolarCoordinate,
10
+ TooltipEventType,
11
+ } from '../util/types';
12
+ import { Curve } from '../shape/Curve';
13
+ import { Cross } from '../shape/Cross';
14
+ import { getCursorRectangle } from '../util/cursor/getCursorRectangle';
15
+ import { Rectangle } from '../shape/Rectangle';
16
+ import { getRadialCursorPoints } from '../util/cursor/getRadialCursorPoints';
17
+ import { Sector } from '../shape/Sector';
18
+ import { getCursorPoints } from '../util/cursor/getCursorPoints';
19
+ import { useChartLayout, useOffsetInternal } from '../context/chartLayoutContext';
20
+ import { useTooltipAxisBandSize } from '../context/useTooltipAxis';
21
+ import { useChartName } from '../state/selectors/selectors';
22
+ import { TooltipIndex, TooltipPayload } from '../state/tooltipSlice';
23
+ import { svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
24
+ import { ZIndexable, ZIndexLayer } from '../zIndex/ZIndexLayer';
25
+ import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
26
+
27
+ /**
28
+ * If set false, no cursor will be drawn when tooltip is active.
29
+ * If set an object, the option is the configuration of cursor.
30
+ * If set a React element, the option is the custom react element of drawing cursor
31
+ */
32
+ export type CursorDefinition = boolean | ReactElement | SVGProps<SVGElement>;
33
+
34
+ export interface CursorProps extends ZIndexable {
35
+ cursor: CursorDefinition;
36
+ tooltipEventType: TooltipEventType;
37
+ coordinate: Coordinate | PolarCoordinate | undefined;
38
+ payload: TooltipPayload;
39
+ index: TooltipIndex | undefined;
40
+ }
41
+
42
+ export type CursorConnectedProps =
43
+ CursorProps & {
44
+ tooltipAxisBandSize: number;
45
+ layout: LayoutType;
46
+ offset: ChartOffsetInternal;
47
+ chartName: string;
48
+ };
49
+
50
+ function RenderCursor({
51
+ cursor,
52
+ cursorComp,
53
+ cursorProps,
54
+ }: {
55
+ cursor: CursorDefinition;
56
+ cursorComp: React.ComponentType<any>;
57
+ cursorProps: any;
58
+ }) {
59
+ if (isValidElement(cursor)) {
60
+ return cloneElement(cursor, cursorProps);
61
+ }
62
+ return createElement(cursorComp, cursorProps);
63
+ }
64
+
65
+ export function CursorInternal(props: CursorConnectedProps) {
66
+ const {
67
+ coordinate,
68
+ payload,
69
+ index,
70
+ offset,
71
+ tooltipAxisBandSize,
72
+ layout,
73
+ cursor,
74
+ tooltipEventType,
75
+ chartName,
76
+ } = props;
77
+
78
+ // The cursor is a part of the Tooltip, and it should be shown (by default) when the Tooltip is active.
79
+ const activeCoordinate = coordinate;
80
+ const activePayload = payload;
81
+ const activeTooltipIndex = index;
82
+ if (!cursor || !activeCoordinate || chartName !== 'ScatterChart' && tooltipEventType !== 'axis') {
83
+ return null;
84
+ }
85
+ let restProps, cursorComp: React.ComponentType<any>, preferredZIndex: number;
86
+
87
+ if (chartName === 'ScatterChart') {
88
+ restProps = activeCoordinate;
89
+ cursorComp = Cross;
90
+ preferredZIndex = DefaultZIndexes.cursorLine;
91
+ } else if (chartName === 'BarChart') {
92
+ restProps = getCursorRectangle(layout, activeCoordinate, offset, tooltipAxisBandSize);
93
+ cursorComp = Rectangle;
94
+ preferredZIndex = DefaultZIndexes.cursorRectangle;
95
+ } else if (layout === 'radial' && isPolarCoordinate(activeCoordinate)) {
96
+ const { cx, cy, radius, startAngle, endAngle } = getRadialCursorPoints(activeCoordinate);
97
+ restProps = {
98
+ cx,
99
+ cy,
100
+ startAngle,
101
+ endAngle,
102
+ innerRadius: radius,
103
+ outerRadius: radius,
104
+ };
105
+ cursorComp = Sector;
106
+ preferredZIndex = DefaultZIndexes.cursorLine;
107
+ } else {
108
+ restProps = { points: getCursorPoints(layout, activeCoordinate, offset) };
109
+ cursorComp = Curve;
110
+ preferredZIndex = DefaultZIndexes.cursorLine;
111
+ }
112
+
113
+ const extraClassName: string | undefined =
114
+ typeof cursor === 'object' && 'className' in cursor ? cursor.className : undefined;
115
+
116
+ const cursorProps = {
117
+ stroke: '#ccc',
118
+ pointerEvents: 'none',
119
+ ...offset,
120
+ ...restProps,
121
+ ...svgPropertiesNoEventsFromUnknown(cursor),
122
+ payload: activePayload,
123
+ payloadIndex: activeTooltipIndex,
124
+ className: clsx('recharts-tooltip-cursor', extraClassName),
125
+ };
126
+
127
+ return <ZIndexLayer zIndex={props.zIndex ?? preferredZIndex}>
128
+ <RenderCursor cursor={cursor} cursorComp={cursorComp} cursorProps={cursorProps} />
129
+ </ZIndexLayer>;
130
+ }
131
+
132
+ /*
133
+ * Cursor is the background, or a highlight,
134
+ * that shows when user mouses over or activates
135
+ * an area.
136
+ *
137
+ * It usually shows together with a tooltip
138
+ * to emphasise which part of the chart does the tooltip refer to.
139
+ */
140
+ export function Cursor(props: CursorProps) {
141
+ const tooltipAxisBandSize = useTooltipAxisBandSize();
142
+ const offset = useOffsetInternal();
143
+ const layout = useChartLayout();
144
+ const chartName = useChartName();
145
+
146
+ if (tooltipAxisBandSize == null || offset == null || layout == null || chartName == null) {
147
+ return null;
148
+ }
149
+
150
+ return <CursorInternal
151
+ {...props}
152
+ offset={offset}
153
+ layout={layout}
154
+ tooltipAxisBandSize={tooltipAxisBandSize}
155
+ chartName={chartName}
156
+ />;
157
+ }
@@ -0,0 +1,288 @@
1
+ import * as React from 'octane';
2
+ import { ReactNode, MouseEvent, ReactElement, CSSProperties } from 'octane';
3
+
4
+ import { clsx } from 'clsx';
5
+ import { Surface } from '../container/Surface';
6
+ import { Symbols } from '../shape/Symbols';
7
+ import {
8
+ DataKey,
9
+ LegendType,
10
+ adaptEventsOfChild,
11
+ PresentationAttributesAdaptChildEvent,
12
+ CartesianLayout,
13
+ } from '../util/types';
14
+ import { RequiresDefaultProps, resolveDefaultProps } from '../util/resolveDefaultProps';
15
+
16
+ const SIZE = 32;
17
+ export type ContentType = ReactElement | ((props: Props) => ReactNode);
18
+
19
+ export type HorizontalAlignmentType = 'center' | 'left' | 'right';
20
+ export type VerticalAlignmentType = 'top' | 'bottom' | 'middle';
21
+ export type Formatter = (value: any, entry: LegendPayload, index: number) => ReactNode;
22
+
23
+ export interface LegendPayload {
24
+ /**
25
+ * This is the text that will be displayed in the legend in the DOM.
26
+ * If undefined, the text will not be displayed, so the icon will be rendered without text.
27
+ */
28
+ value: string | undefined;
29
+ type?: LegendType;
30
+ color?: string;
31
+ /**
32
+ * Different graphical items put different information in the payload object
33
+ * so double check in runtime what are you getting here.
34
+ */
35
+ payload?: object;
36
+ formatter?: Formatter;
37
+ inactive?: boolean;
38
+ legendIcon?: ReactElement<SVGElement>;
39
+ dataKey?: DataKey<any>;
40
+ }
41
+
42
+ interface DefaultLegendContentProps {
43
+ /**
44
+ * The size of icon in each legend item.
45
+ * @defaultValue 14
46
+ */
47
+ iconSize?: number;
48
+ /**
49
+ * The type of icon in each legend item.
50
+ */
51
+ iconType?: LegendType;
52
+ /**
53
+ * The layout of legend items inside the legend container.
54
+ * @defaultValue horizontal
55
+ */
56
+ layout?: CartesianLayout;
57
+ /**
58
+ * Horizontal alignment of the whole Legend container:
59
+ *
60
+ * - `left`: shows the Legend to the left of the chart, and chart width reduces automatically to make space for it.
61
+ * - `right` shows the Legend to the right of the chart, and chart width reduces automatically.
62
+ * - `center` shows the Legend in the middle of chart, and chart width remains unchanged.
63
+ *
64
+ * The exact behavior changes depending on 'verticalAlign' prop.
65
+ *
66
+ * @defaultValue center
67
+ */
68
+ align?: HorizontalAlignmentType;
69
+ /**
70
+ * Vertical alignment of the whole Legend container:
71
+ *
72
+ * - `bottom`: shows the Legend below chart, and chart height reduces automatically to make space for it.
73
+ * - `top`: shows the Legend above chart, and chart height reduces automatically.
74
+ * - `middle`: shows the Legend in the middle of chart, covering other content, and chart height remains unchanged.
75
+ * The exact behavior changes depending on `align` prop.
76
+ *
77
+ * @defaultValue middle
78
+ */
79
+ verticalAlign?: VerticalAlignmentType;
80
+ /**
81
+ * The color of the icon when the item is inactive.
82
+ * @defaultValue #ccc
83
+ */
84
+ inactiveColor?: string;
85
+ /**
86
+ * Function to customize how content is serialized before rendering.
87
+ *
88
+ * This should return HTML elements, or strings.
89
+ *
90
+ * @example (value, entry, index) => <span style={{ color: 'red' }}>{value}</span>
91
+ * @example https://codesandbox.io/s/legend-formatter-rmzp9
92
+ */
93
+ formatter?: Formatter;
94
+ /**
95
+ * The customized event handler of mouseenter on the items in this group
96
+ * @example https://recharts.github.io/examples/LegendEffectOpacity
97
+ */
98
+ onMouseEnter?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
99
+ /**
100
+ * The customized event handler of mouseleave on the items in this group
101
+ * @example https://recharts.github.io/examples/LegendEffectOpacity
102
+ */
103
+ onMouseLeave?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
104
+ /**
105
+ * The customized event handler of click on the items in this group
106
+ */
107
+ onClick?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
108
+ /**
109
+ * DefaultLegendContent.payload is omitted from Legend props.
110
+ * A custom payload can be passed here if desired, or it can be passed from the Legend "content" callback.
111
+ */
112
+ payload?: ReadonlyArray<LegendPayload>;
113
+ /**
114
+ * The style of each text label which is a span element.
115
+ * @defaultValue {}
116
+ */
117
+ labelStyle?: CSSProperties;
118
+ }
119
+
120
+ export type Props =
121
+ DefaultLegendContentProps & Omit<
122
+ PresentationAttributesAdaptChildEvent<any, ReactElement>,
123
+ keyof DefaultLegendContentProps
124
+ >;
125
+
126
+ export const defaultLegendContentDefaultProps = {
127
+ align: 'center',
128
+ iconSize: 14,
129
+ inactiveColor: '#ccc',
130
+ layout: 'horizontal',
131
+ verticalAlign: 'middle',
132
+ labelStyle: {},
133
+ } as const satisfies Partial<Props>;
134
+
135
+ type InternalProps =
136
+ RequiresDefaultProps<Props, typeof defaultLegendContentDefaultProps> & {
137
+ payload: ReadonlyArray<LegendPayload>;
138
+ };
139
+
140
+ function getStrokeDasharray(input: unknown): string | undefined {
141
+ if (typeof input === 'object' && input !== null && 'strokeDasharray' in input) {
142
+ return String(input.strokeDasharray);
143
+ }
144
+ return undefined;
145
+ }
146
+
147
+ function Icon({
148
+ data,
149
+ iconType,
150
+ inactiveColor,
151
+ }: {
152
+ data: LegendPayload;
153
+ iconType: LegendType | undefined;
154
+ inactiveColor: string;
155
+ }) {
156
+ const halfSize = SIZE / 2;
157
+ const sixthSize = SIZE / 6;
158
+ const thirdSize = SIZE / 3;
159
+ const color = data.inactive ? inactiveColor : data.color;
160
+ const preferredIcon = iconType ?? data.type;
161
+
162
+ if (preferredIcon === 'none') {
163
+ return null;
164
+ }
165
+ if (preferredIcon === 'plainline') {
166
+ return <line
167
+ strokeWidth={4}
168
+ fill="none"
169
+ stroke={color}
170
+ strokeDasharray={getStrokeDasharray(data.payload)}
171
+ x1={0}
172
+ y1={halfSize}
173
+ x2={SIZE}
174
+ y2={halfSize}
175
+ className="recharts-legend-icon"
176
+ />;
177
+ }
178
+ if (preferredIcon === 'line') {
179
+ return <path
180
+ strokeWidth={4}
181
+ fill="none"
182
+ stroke={color}
183
+ d={`M0,${halfSize}h${thirdSize}
184
+ A${sixthSize},${sixthSize},0,1,1,${
185
+ 2 * thirdSize
186
+ },${halfSize}
187
+ H${SIZE}M${
188
+ 2 * thirdSize
189
+ },${halfSize}
190
+ A${sixthSize},${sixthSize},0,1,1,${thirdSize},${halfSize}`}
191
+ className="recharts-legend-icon"
192
+ />;
193
+ }
194
+ if (preferredIcon === 'rect') {
195
+ return <path
196
+ stroke="none"
197
+ fill={color}
198
+ d={`M0,${SIZE / 8}h${SIZE}v${(SIZE * 3) / 4}h${-SIZE}z`}
199
+ className="recharts-legend-icon"
200
+ />;
201
+ }
202
+ if (React.isValidElement(data.legendIcon)) {
203
+ const iconProps: any = { ...data };
204
+ delete iconProps.legendIcon;
205
+ return React.cloneElement(data.legendIcon, iconProps);
206
+ }
207
+
208
+ return <Symbols
209
+ fill={color}
210
+ cx={halfSize}
211
+ cy={halfSize}
212
+ size={SIZE}
213
+ sizeType="diameter"
214
+ type={preferredIcon}
215
+ />;
216
+ }
217
+
218
+ function Items(props: InternalProps) {
219
+ const { payload, iconSize, layout, formatter, inactiveColor, iconType, labelStyle } = props;
220
+ const viewBox = { x: 0, y: 0, width: SIZE, height: SIZE };
221
+ const itemStyle = {
222
+ display: layout === 'horizontal' ? 'inline-block' : 'block',
223
+ marginRight: 10,
224
+ };
225
+ const svgStyle = { display: 'inline-block', verticalAlign: 'middle', marginRight: 4 };
226
+ return payload.map((entry: LegendPayload, i: number) => {
227
+ const finalFormatter = entry.formatter || formatter;
228
+ const className = clsx({
229
+ 'recharts-legend-item': true,
230
+ [`legend-item-${i}`]: true,
231
+ inactive: entry.inactive,
232
+ });
233
+
234
+ if (entry.type === 'none') {
235
+ return null;
236
+ }
237
+
238
+ const finalLabelStyle =
239
+ typeof labelStyle === 'object' ? { ...labelStyle } : {};
240
+ finalLabelStyle.color = entry.inactive ? inactiveColor : finalLabelStyle.color || entry.color;
241
+
242
+ const finalValue =
243
+ finalFormatter ? finalFormatter(entry.value, entry, i) : entry.value;
244
+
245
+ return <li
246
+ className={className}
247
+ style={itemStyle}
248
+ key={`legend-item-${i}`}
249
+ {...adaptEventsOfChild(props, entry, i)}
250
+ >
251
+ <Surface
252
+ width={iconSize}
253
+ height={iconSize}
254
+ viewBox={viewBox}
255
+ style={svgStyle}
256
+ aria-label={entry.value == null ? 'legend icon' : `${entry.value} legend icon`}
257
+ >
258
+ <Icon data={entry} iconType={iconType} inactiveColor={inactiveColor} />
259
+ </Surface>
260
+ <span className="recharts-legend-item-text" style={finalLabelStyle}>{finalValue}</span>
261
+ </li>;
262
+ });
263
+ }
264
+
265
+ /**
266
+ * This component is by default rendered inside the {@link Legend} component. You would not use it directly.
267
+ *
268
+ * You can use this component to customize the content of the legend,
269
+ * or you can provide your own completely independent content.
270
+ */
271
+ export const DefaultLegendContent = (outsideProps: Props) => {
272
+ const props = resolveDefaultProps(outsideProps, defaultLegendContentDefaultProps);
273
+ const { payload, layout, align } = props;
274
+
275
+ if (!payload || !payload.length) {
276
+ return null;
277
+ }
278
+
279
+ const finalStyle = {
280
+ padding: 0,
281
+ margin: 0,
282
+ textAlign: layout === 'horizontal' ? align : 'left',
283
+ };
284
+
285
+ return <ul className="recharts-default-legend" style={finalStyle}>
286
+ <Items {...props} payload={payload} />
287
+ </ul>;
288
+ };
@@ -0,0 +1,125 @@
1
+ import * as React from 'octane';
2
+ import { ReactNode, MouseEvent, ReactElement, CSSProperties } from 'octane';
3
+ import {
4
+ DataKey,
5
+ LegendType,
6
+ PresentationAttributesAdaptChildEvent,
7
+ CartesianLayout,
8
+ } from '../util/types';
9
+ export type ContentType = ReactElement | ((props: Props) => ReactNode);
10
+ export type HorizontalAlignmentType = 'center' | 'left' | 'right';
11
+ export type VerticalAlignmentType = 'top' | 'bottom' | 'middle';
12
+ export type Formatter = (value: any, entry: LegendPayload, index: number) => ReactNode;
13
+ export interface LegendPayload {
14
+ /**
15
+ * This is the text that will be displayed in the legend in the DOM.
16
+ * If undefined, the text will not be displayed, so the icon will be rendered without text.
17
+ */
18
+ value: string | undefined;
19
+ type?: LegendType;
20
+ color?: string;
21
+ /**
22
+ * Different graphical items put different information in the payload object
23
+ * so double check in runtime what are you getting here.
24
+ */
25
+ payload?: object;
26
+ formatter?: Formatter;
27
+ inactive?: boolean;
28
+ legendIcon?: ReactElement<SVGElement>;
29
+ dataKey?: DataKey<any>;
30
+ }
31
+ interface DefaultLegendContentProps {
32
+ /**
33
+ * The size of icon in each legend item.
34
+ * @defaultValue 14
35
+ */
36
+ iconSize?: number;
37
+ /**
38
+ * The type of icon in each legend item.
39
+ */
40
+ iconType?: LegendType;
41
+ /**
42
+ * The layout of legend items inside the legend container.
43
+ * @defaultValue horizontal
44
+ */
45
+ layout?: CartesianLayout;
46
+ /**
47
+ * Horizontal alignment of the whole Legend container:
48
+ *
49
+ * - `left`: shows the Legend to the left of the chart, and chart width reduces automatically to make space for it.
50
+ * - `right` shows the Legend to the right of the chart, and chart width reduces automatically.
51
+ * - `center` shows the Legend in the middle of chart, and chart width remains unchanged.
52
+ *
53
+ * The exact behavior changes depending on 'verticalAlign' prop.
54
+ *
55
+ * @defaultValue center
56
+ */
57
+ align?: HorizontalAlignmentType;
58
+ /**
59
+ * Vertical alignment of the whole Legend container:
60
+ *
61
+ * - `bottom`: shows the Legend below chart, and chart height reduces automatically to make space for it.
62
+ * - `top`: shows the Legend above chart, and chart height reduces automatically.
63
+ * - `middle`: shows the Legend in the middle of chart, covering other content, and chart height remains unchanged.
64
+ * The exact behavior changes depending on `align` prop.
65
+ *
66
+ * @defaultValue middle
67
+ */
68
+ verticalAlign?: VerticalAlignmentType;
69
+ /**
70
+ * The color of the icon when the item is inactive.
71
+ * @defaultValue #ccc
72
+ */
73
+ inactiveColor?: string;
74
+ /**
75
+ * Function to customize how content is serialized before rendering.
76
+ *
77
+ * This should return HTML elements, or strings.
78
+ *
79
+ * @example (value, entry, index) => <span style={{ color: 'red' }}>{value}</span>
80
+ * @example https://codesandbox.io/s/legend-formatter-rmzp9
81
+ */
82
+ formatter?: Formatter;
83
+ /**
84
+ * The customized event handler of mouseenter on the items in this group
85
+ * @example https://recharts.github.io/examples/LegendEffectOpacity
86
+ */
87
+ onMouseEnter?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
88
+ /**
89
+ * The customized event handler of mouseleave on the items in this group
90
+ * @example https://recharts.github.io/examples/LegendEffectOpacity
91
+ */
92
+ onMouseLeave?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
93
+ /**
94
+ * The customized event handler of click on the items in this group
95
+ */
96
+ onClick?: (data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void;
97
+ /**
98
+ * DefaultLegendContent.payload is omitted from Legend props.
99
+ * A custom payload can be passed here if desired, or it can be passed from the Legend "content" callback.
100
+ */
101
+ payload?: ReadonlyArray<LegendPayload>;
102
+ /**
103
+ * The style of each text label which is a span element.
104
+ * @defaultValue {}
105
+ */
106
+ labelStyle?: CSSProperties;
107
+ }
108
+ export type Props = DefaultLegendContentProps &
109
+ Omit<PresentationAttributesAdaptChildEvent<any, ReactElement>, keyof DefaultLegendContentProps>;
110
+ export declare const defaultLegendContentDefaultProps: {
111
+ readonly align: 'center';
112
+ readonly iconSize: 14;
113
+ readonly inactiveColor: '#ccc';
114
+ readonly layout: 'horizontal';
115
+ readonly verticalAlign: 'middle';
116
+ readonly labelStyle: {};
117
+ };
118
+ /**
119
+ * This component is by default rendered inside the {@link Legend} component. You would not use it directly.
120
+ *
121
+ * You can use this component to customize the content of the legend,
122
+ * or you can provide your own completely independent content.
123
+ */
124
+ export declare const DefaultLegendContent: (outsideProps: Props) => React.JSX.Element | null;
125
+ export {};