@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,253 @@
1
+ import * as React from 'octane';
2
+ import { MouseEvent, ReactElement, ReactNode, SVGProps } from 'octane';
3
+ import { Props as RectangleProps } from '../shape/Rectangle';
4
+ import {
5
+ DataKey,
6
+ EventThrottlingProps,
7
+ Margin,
8
+ Percent,
9
+ SankeyLink,
10
+ SankeyNode,
11
+ } from '../util/types';
12
+ import { TooltipPayloadSearcher } from '../state/tooltipSlice';
13
+ type SankeyVerticalAlign = 'justify' | 'top';
14
+ export declare const computeData: ({
15
+ data,
16
+ width,
17
+ height,
18
+ iterations,
19
+ nodeWidth,
20
+ nodePadding,
21
+ sort,
22
+ verticalAlign,
23
+ align,
24
+ }: {
25
+ data: SankeyData;
26
+ width: number;
27
+ height: number;
28
+ iterations: number;
29
+ nodeWidth: number;
30
+ nodePadding: number;
31
+ sort: boolean;
32
+ verticalAlign: SankeyVerticalAlign;
33
+ align: 'left' | 'justify';
34
+ }) => {
35
+ nodes: ReadonlyArray<SankeyNode>;
36
+ links: ReadonlyArray<SankeyLink>;
37
+ };
38
+ export declare const sankeyPayloadSearcher: TooltipPayloadSearcher;
39
+ interface LinkDataItem {
40
+ source: number;
41
+ target: number;
42
+ value: number;
43
+ }
44
+ export interface NodeProps extends Omit<SVGProps<SVGRectElement>, 'height' | 'width'> {
45
+ height: number;
46
+ width: number;
47
+ payload: SankeyNode;
48
+ index: number;
49
+ x: number;
50
+ y: number;
51
+ }
52
+ export interface LinkProps extends SVGProps<SVGPathElement> {
53
+ sourceX: number;
54
+ targetX: number;
55
+ sourceY: number;
56
+ targetY: number;
57
+ sourceControlX: number;
58
+ targetControlX: number;
59
+ sourceRelativeY: number;
60
+ targetRelativeY: number;
61
+ linkWidth: number;
62
+ index: number;
63
+ payload: Omit<SankeyLink, 'source' | 'target'> & {
64
+ source: SankeyNode;
65
+ target: SankeyNode;
66
+ };
67
+ }
68
+ export interface SankeyData {
69
+ nodes: any[];
70
+ links: LinkDataItem[];
71
+ }
72
+ export type SankeyNodeOptions =
73
+ ReactElement<SVGProps<SVGRectElement>> | ((props: NodeProps) => ReactNode) | RectangleProps;
74
+ type SankeyLinkOptions =
75
+ | ReactElement<SVGProps<SVGPathElement>>
76
+ | ((props: LinkProps) => ReactElement<SVGProps<SVGPathElement>>)
77
+ | SVGProps<SVGPathElement>;
78
+ interface SankeyProps extends EventThrottlingProps {
79
+ /**
80
+ * Name represents each sector in the tooltip.
81
+ * This allows you to extract the name from the data:
82
+ *
83
+ * - `string`: the name of the field in the data object;
84
+ * - `number`: the index of the field in the data;
85
+ * - `function`: a function that receives the data object and returns the name.
86
+ *
87
+ * @defaultValue name
88
+ */
89
+ nameKey?: DataKey<any>;
90
+ /**
91
+ * dataKey prop in Sankey defines which key in the link objects represents the value of the link _in Tooltip only_.
92
+ *
93
+ * Unlike other charts where dataKey is used to extract values from the data array, in Sankey charts,
94
+ * the value of each link is directly taken from the 'value' property of the link objects.
95
+ *
96
+ * @default 'value'
97
+ */
98
+ dataKey?: DataKey<any>;
99
+ /**
100
+ * The width of chart container.
101
+ * Can be a number or a percent string like "100%".
102
+ *
103
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
104
+ */
105
+ width?: number | Percent;
106
+ /**
107
+ * The height of chart container.
108
+ * Can be a number or a percent string like "100%".
109
+ *
110
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
111
+ */
112
+ height?: number | Percent;
113
+ /**
114
+ * The source data, including the array of nodes, and the relationships, represented by links.
115
+ *
116
+ * Note that Sankey requires a specific data structure.
117
+ * Each node should have a unique index in the nodes array, and each link should reference these nodes by their indices.
118
+ * This is different from other chart types in Recharts, which accept arbitrary data.
119
+ *
120
+ * @example
121
+ * nodes: [
122
+ * { name: 'Visit' },
123
+ * { name: 'Direct-Favourite' },
124
+ * { name: 'Page-Click' },
125
+ * { name: 'Detail-Favourite' },
126
+ * { name: 'Lost' },
127
+ * ],
128
+ * links: [
129
+ * { source: 0, target: 1, value: 3728.3 },
130
+ * { source: 0, target: 2, value: 354170 },
131
+ * { source: 2, target: 3, value: 62429 },
132
+ * { source: 2, target: 4, value: 291741 },
133
+ * ],
134
+ */
135
+ data: SankeyData;
136
+ /**
137
+ * The padding between the nodes
138
+ * @default 10
139
+ */
140
+ nodePadding?: number;
141
+ /**
142
+ * The width of node
143
+ * @default 10
144
+ */
145
+ nodeWidth?: number;
146
+ /**
147
+ * The curvature of width
148
+ * @default 0.5
149
+ */
150
+ linkCurvature?: number;
151
+ /**
152
+ * The number of the iterations between the links
153
+ * @default 32
154
+ */
155
+ iterations?: number;
156
+ /**
157
+ * If set an object, the option is the configuration of nodes.
158
+ * If set a React element, the option is the custom react element of drawing the nodes.
159
+ *
160
+ * @example <Sankey node={MyCustomComponent} />
161
+ * @example <Sankey node={{stroke: #77c878, strokeWidth: 2}} />
162
+ */
163
+ node?: SankeyNodeOptions;
164
+ /**
165
+ * If set an object, the option is the configuration of links.
166
+ * If set a React element, the option is the custom react element of drawing the links.
167
+ *
168
+ * @example <Sankey link={MyCustomComponent} />
169
+ * @example <Sankey link={{ fill: #77c878 }} />
170
+ */
171
+ link?: SankeyLinkOptions;
172
+ style?: React.CSSProperties;
173
+ className?: string;
174
+ children?: ReactNode;
175
+ /**
176
+ * Empty space around the container.
177
+ *
178
+ * @defaultValue {"top":5,"right":5,"bottom":5,"left":5}
179
+ */
180
+ margin?: Partial<Margin>;
181
+ /**
182
+ * The customized event handler of click on the area in this group
183
+ */
184
+ onClick?: (
185
+ item: NodeProps | LinkProps,
186
+ type: SankeyElementType,
187
+ e: MouseEvent<SVGGraphicsElement>,
188
+ ) => void;
189
+ /**
190
+ * The customized event handler of mouseenter on the area in this group
191
+ */
192
+ onMouseEnter?: (
193
+ item: NodeProps | LinkProps,
194
+ type: SankeyElementType,
195
+ e: MouseEvent<SVGGraphicsElement>,
196
+ ) => void;
197
+ /**
198
+ * The customized event handler of mouseleave on the area in this group
199
+ */
200
+ onMouseLeave?: (
201
+ item: NodeProps | LinkProps,
202
+ type: SankeyElementType,
203
+ e: MouseEvent<SVGGraphicsElement>,
204
+ ) => void;
205
+ /**
206
+ * Whether to sort the nodes on the y axis, or to display them as user-defined.
207
+ * @default true
208
+ */
209
+ sort?: boolean;
210
+ /**
211
+ * Controls the vertical spacing of nodes within a depth. 'justify' distributes nodes evenly and balances link paths, while 'top' positions the group starting from the top edge of the chart.
212
+ * @default 'justify'
213
+ */
214
+ verticalAlign?: SankeyVerticalAlign;
215
+ /**
216
+ * If set to 'justify', the start nodes will be aligned to the left edge of the chart and the end nodes will be aligned to the right edge of the chart. If set to 'left', the start nodes will be aligned to the left edge of the chart.
217
+ * @default 'justify'
218
+ */
219
+ align?: 'left' | 'justify';
220
+ }
221
+ export type Props = Omit<SVGProps<SVGSVGElement>, keyof SankeyProps> & SankeyProps;
222
+ export type SankeyElementType = 'node' | 'link';
223
+ export declare const sankeyDefaultProps: {
224
+ readonly throttleDelay: number | 'raf';
225
+ readonly throttledEvents: ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all';
226
+ readonly align: 'justify';
227
+ readonly dataKey: 'value';
228
+ readonly iterations: 32;
229
+ readonly linkCurvature: 0.5;
230
+ readonly margin: {
231
+ readonly top: 5;
232
+ readonly right: 5;
233
+ readonly bottom: 5;
234
+ readonly left: 5;
235
+ };
236
+ readonly nameKey: 'name';
237
+ readonly nodePadding: 10;
238
+ readonly nodeWidth: 10;
239
+ readonly sort: true;
240
+ readonly verticalAlign: 'justify';
241
+ };
242
+ /**
243
+ * Flow diagram in which the width of the arrows is proportional to the flow rate.
244
+ * It is typically used to visualize energy or material or cost transfers between processes.
245
+ *
246
+ * @consumes ResponsiveContainerContext
247
+ * @provides TooltipEntrySettings
248
+ */
249
+ export declare function Sankey(outsideProps: Props): React.JSX.Element;
250
+ export declare namespace Sankey {
251
+ var displayName: string;
252
+ }
253
+ export {};
@@ -0,0 +1,22 @@
1
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
2
+ import { CartesianChart } from './CartesianChart.tsrx';
3
+ import { CartesianChartProps, TooltipEventType } from '../util/types';
4
+
5
+ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['item'];
6
+
7
+ /**
8
+ * @consumes ResponsiveContainerContext
9
+ * @provides CartesianViewBoxContext
10
+ * @provides CartesianChartContext
11
+ */
12
+ export function ScatterChart(props: CartesianChartProps<unknown>) {
13
+ const { ref, ...rest } = props;
14
+ return <CartesianChart
15
+ chartName="ScatterChart"
16
+ defaultTooltipEventType="item"
17
+ validateTooltipEventTypes={allowedTooltipTypes}
18
+ tooltipPayloadSearcher={arrayTooltipSearcher}
19
+ categoricalChartProps={rest}
20
+ ref={ref}
21
+ />;
22
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'octane';
2
+ import { CartesianChartProps } from '../util/types';
3
+ /**
4
+ * @consumes ResponsiveContainerContext
5
+ * @provides CartesianViewBoxContext
6
+ * @provides CartesianChartContext
7
+ */
8
+ export declare const ScatterChart: <DataPointType = any>(
9
+ props: CartesianChartProps<DataPointType> & {
10
+ ref?: React.Ref<SVGSVGElement>;
11
+ },
12
+ ) => React.ReactElement;