@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.
- package/package.json +4 -4
- package/src/animation/CSSTransitionAnimate.tsrx +142 -0
- package/src/cartesian/Area.tsrx +1096 -0
- package/src/cartesian/Area.tsrx.d.ts +340 -0
- package/src/cartesian/AreaRevealShape.tsrx +202 -0
- package/src/cartesian/CartesianGrid.tsrx +643 -0
- package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
- package/src/cartesian/ErrorBar.tsrx +322 -0
- package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
- package/src/cartesian/Funnel.tsrx +833 -0
- package/src/cartesian/Funnel.tsrx.d.ts +274 -0
- package/src/cartesian/ReferenceLine.tsrx +452 -0
- package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
- package/src/cartesian/Scatter.tsrx +1076 -0
- package/src/cartesian/Scatter.tsrx.d.ts +351 -0
- package/src/cartesian/ZAxis.tsrx +148 -0
- package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
- package/src/chart/AreaChart.tsrx +22 -0
- package/src/chart/AreaChart.tsrx.d.ts +12 -0
- package/src/chart/ComposedChart.tsrx +22 -0
- package/src/chart/ComposedChart.tsrx.d.ts +12 -0
- package/src/chart/FunnelChart.tsrx +22 -0
- package/src/chart/FunnelChart.tsrx.d.ts +12 -0
- package/src/chart/PieChart.tsrx +31 -0
- package/src/chart/PieChart.tsrx.d.ts +31 -0
- package/src/chart/PolarChart.tsrx +121 -0
- package/src/chart/RadarChart.tsrx +53 -0
- package/src/chart/RadarChart.tsrx.d.ts +31 -0
- package/src/chart/RadialBarChart.tsrx +31 -0
- package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
- package/src/chart/Sankey.tsrx +1542 -0
- package/src/chart/Sankey.tsrx.d.ts +253 -0
- package/src/chart/ScatterChart.tsrx +22 -0
- package/src/chart/ScatterChart.tsrx.d.ts +12 -0
- package/src/chart/SunburstChart.tsrx +495 -0
- package/src/chart/SunburstChart.tsrx.d.ts +146 -0
- package/src/chart/types.ts +19 -0
- package/src/component/Cursor.tsrx +157 -0
- package/src/component/DefaultLegendContent.tsrx +288 -0
- package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
- package/src/component/DefaultTooltipContent.tsrx +215 -0
- package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
- package/src/component/Legend.tsrx +302 -0
- package/src/component/Legend.tsrx.d.ts +88 -0
- package/src/component/ResponsiveContainer.ts +1 -22
- package/src/component/ResponsiveContainer.tsrx +171 -0
- package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
- package/src/component/Tooltip.tsrx +425 -0
- package/src/component/Tooltip.tsrx.d.ts +246 -0
- package/src/component/TooltipBoundingBox.tsrx +135 -0
- package/src/context/CellsContext.ts +12 -0
- package/src/context/legendPayloadContext.tsrx +11 -0
- package/src/context/useTooltipAxis.ts +20 -0
- package/src/index.d.ts +236 -0
- package/src/index.ts +67 -0
- package/src/polar/Pie.tsrx +1224 -0
- package/src/polar/Pie.tsrx.d.ts +436 -0
- package/src/polar/PolarAngleAxis.tsrx +554 -0
- package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
- package/src/polar/PolarGrid.tsrx +317 -0
- package/src/polar/PolarGrid.tsrx.d.ts +117 -0
- package/src/polar/PolarRadiusAxis.tsrx +463 -0
- package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
- package/src/polar/Radar.tsrx +696 -0
- package/src/polar/Radar.tsrx.d.ts +215 -0
- package/src/polar/RadialBar.tsrx +887 -0
- package/src/polar/RadialBar.tsrx.d.ts +340 -0
- package/src/state/ReportPolarOptions.tsrx +11 -0
- package/src/state/selectors/areaSelectors.ts +257 -0
- package/src/state/selectors/funnelSelectors.ts +86 -0
- package/src/state/selectors/pieSelectors.ts +134 -0
- package/src/state/selectors/polarGridSelectors.ts +43 -0
- package/src/state/selectors/polarScaleSelectors.ts +159 -0
- package/src/state/selectors/polarSelectors.ts +198 -0
- package/src/state/selectors/radarSelectors.ts +228 -0
- package/src/state/selectors/radialBarSelectors.ts +511 -0
- package/src/state/selectors/scatterSelectors.ts +168 -0
- package/src/util/FunnelUtils.tsrx +19 -0
- package/src/util/RadialBarUtils.tsrx +29 -0
- package/src/util/ScatterUtils.tsrx +34 -0
- package/src/util/cursor/getCursorPoints.ts +45 -0
- package/src/util/cursor/getCursorRectangle.ts +28 -0
- package/src/util/cursor/getRadialCursorPoints.ts +31 -0
- package/src/util/payload/getUniqPayload.ts +28 -0
- package/src/util/scale/CartesianScaleHelper.ts +71 -0
- package/src/util/tooltip/translate.ts +168 -0
- package/src/util/types.ts +3 -0
- package/src/util/useElementOffset.ts +147 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'octane';
|
|
2
|
+
import { ImplicitLabelListType } from '../component/LabelList';
|
|
3
|
+
import { CurveType, Props as CurveProps } from '../shape/Curve';
|
|
4
|
+
import {
|
|
5
|
+
ActiveShape,
|
|
6
|
+
AnimationDuration,
|
|
7
|
+
EasingInput,
|
|
8
|
+
Coordinate,
|
|
9
|
+
DataConsumer,
|
|
10
|
+
DataProvider,
|
|
11
|
+
LegendType,
|
|
12
|
+
PresentationAttributesAdaptChildEvent,
|
|
13
|
+
SymbolType,
|
|
14
|
+
TickItem,
|
|
15
|
+
CartesianLayout,
|
|
16
|
+
} from '../util/types';
|
|
17
|
+
import { Formatter, TooltipType } from '../component/DefaultTooltipContent';
|
|
18
|
+
import { ScatterShapeProps } from '../util/ScatterUtils';
|
|
19
|
+
import { InnerSymbolsProp } from '../shape/Symbols';
|
|
20
|
+
import { TooltipPayload } from '../state/tooltipSlice';
|
|
21
|
+
import { AxisId } from '../state/cartesianAxisSlice';
|
|
22
|
+
import { BaseAxisWithScale, ZAxisWithScale } from '../state/selectors/axisSelectors';
|
|
23
|
+
import { ScatterSettings } from '../state/types/ScatterSettings';
|
|
24
|
+
import { AnimationInterpolateFn } from '../animation/AnimatedItems';
|
|
25
|
+
import { AnimationMatchByProp } from '../animation/matchBy';
|
|
26
|
+
import { ZIndexable } from '../zIndex/ZIndexLayer';
|
|
27
|
+
export interface ScatterPointNode {
|
|
28
|
+
x?: number | string;
|
|
29
|
+
y?: number | string;
|
|
30
|
+
z?: number | string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Scatter coordinates are nullable because sometimes the point value is out of the domain,
|
|
34
|
+
* and we can't compute a valid coordinate for it.
|
|
35
|
+
*
|
|
36
|
+
* Scatter -> Symbol ignores points with null cx or cy so those won't render if using the default shapes.
|
|
37
|
+
* However: the points are exposed via various props and can be used in custom shapes so we keep them around.
|
|
38
|
+
*/
|
|
39
|
+
export interface ScatterPointItem {
|
|
40
|
+
/**
|
|
41
|
+
* The x coordinate of the point center in pixels.
|
|
42
|
+
*/
|
|
43
|
+
cx: number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The y coordinate of the point center in pixels.
|
|
46
|
+
*/
|
|
47
|
+
cy: number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The x coordinate (in pixels) of the top-left corner of the rectangle that wraps the point.
|
|
50
|
+
*/
|
|
51
|
+
x: number | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The y coordinate (in pixels) of the top-left corner of the rectangle that wraps the point.
|
|
54
|
+
*/
|
|
55
|
+
y: number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* ScatterPointItem size is an abstract number that is used to calculate the radius of the point.
|
|
58
|
+
* It's not the radius itself, but rather a value that is used to calculate the radius.
|
|
59
|
+
* Interacts with the zAxis range.
|
|
60
|
+
*/
|
|
61
|
+
size: number;
|
|
62
|
+
/**
|
|
63
|
+
* Width of the point in pixels.
|
|
64
|
+
*/
|
|
65
|
+
width: number;
|
|
66
|
+
/**
|
|
67
|
+
* Height of the point in pixels.
|
|
68
|
+
*/
|
|
69
|
+
height: number;
|
|
70
|
+
node: ScatterPointNode;
|
|
71
|
+
payload?: any;
|
|
72
|
+
tooltipPayload?: TooltipPayload;
|
|
73
|
+
tooltipPosition: Coordinate;
|
|
74
|
+
}
|
|
75
|
+
export type ScatterCustomizedShape =
|
|
76
|
+
ActiveShape<ScatterShapeProps & InnerSymbolsProp, SVGPathElement> | SymbolType;
|
|
77
|
+
/**
|
|
78
|
+
* External props, intended for end users to fill in
|
|
79
|
+
*/
|
|
80
|
+
interface ScatterProps<DataPointType = any, DataValueType = any>
|
|
81
|
+
extends DataProvider<DataPointType>, DataConsumer<DataPointType, DataValueType>, ZIndexable {
|
|
82
|
+
/**
|
|
83
|
+
* Unique identifier of this component.
|
|
84
|
+
* Used as an HTML attribute `id`, and also to identify this element internally.
|
|
85
|
+
*
|
|
86
|
+
* If undefined, Recharts will generate a unique ID automatically.
|
|
87
|
+
*/
|
|
88
|
+
id?: string;
|
|
89
|
+
/**
|
|
90
|
+
* The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
|
|
91
|
+
* @defaultValue 0
|
|
92
|
+
*/
|
|
93
|
+
xAxisId?: AxisId;
|
|
94
|
+
/**
|
|
95
|
+
* The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
|
|
96
|
+
* @defaultValue 0
|
|
97
|
+
*/
|
|
98
|
+
yAxisId?: AxisId;
|
|
99
|
+
/**
|
|
100
|
+
* The id of ZAxis which is corresponding to the data. Required when there are multiple ZAxes.
|
|
101
|
+
*
|
|
102
|
+
* ZAxis does not render directly, has no ticks and no tick line.
|
|
103
|
+
* It is used to control the size of each scatter point.
|
|
104
|
+
*
|
|
105
|
+
* @defaultValue 0
|
|
106
|
+
* @see {@link https://recharts.github.io/en-US/examples/ThreeDimScatterChart/ Scatter chart with Z axis}
|
|
107
|
+
*/
|
|
108
|
+
zAxisId?: AxisId;
|
|
109
|
+
/**
|
|
110
|
+
* Renders line connecting individual points.
|
|
111
|
+
* Options:
|
|
112
|
+
* - `false`: no line is drawn.
|
|
113
|
+
* - `true`: a default line is drawn.
|
|
114
|
+
* - `ReactElement`: the option is the custom line element.
|
|
115
|
+
* - `function`: the function will be called to render customized line.
|
|
116
|
+
* - `object`: the option is the props of Curve element.
|
|
117
|
+
*
|
|
118
|
+
* Also see the `lineType` prop which controls how is this line calculated.
|
|
119
|
+
*
|
|
120
|
+
* @defaultValue false
|
|
121
|
+
* @example <Scatter line />
|
|
122
|
+
* @example <Scatter line={CustomizedLineComponent} />
|
|
123
|
+
* @example <Scatter line={{ strokeDasharray: '5 5' }} />
|
|
124
|
+
*
|
|
125
|
+
* @see {@link https://recharts.github.io/en-US/examples/JointLineScatterChart/ Scatter chart with joint line}
|
|
126
|
+
*/
|
|
127
|
+
line?:
|
|
128
|
+
ReactElement<SVGElement> | ((props: any) => ReactElement<SVGElement>) | CurveProps | boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Determines calculation method of the line if the `line` prop is set.
|
|
131
|
+
* Options:
|
|
132
|
+
* - `'joint'`: line will be generated by connecting all the points.
|
|
133
|
+
* - `'fitting'`: line will be generated by fitting algorithm (linear regression).
|
|
134
|
+
*
|
|
135
|
+
* Has no effect if `line` prop is not set or is false.
|
|
136
|
+
*
|
|
137
|
+
* @defaultValue joint
|
|
138
|
+
* @example <Scatter line lineType="fitting" />
|
|
139
|
+
* @see {@link https://recharts.github.io/en-US/examples/JointLineScatterChart/ Scatter chart with joint line}
|
|
140
|
+
*/
|
|
141
|
+
lineType?: 'fitting' | 'joint';
|
|
142
|
+
/**
|
|
143
|
+
* Determines the shape of joint line.
|
|
144
|
+
* Same as `type` prop on Curve, Line and Area components.
|
|
145
|
+
*
|
|
146
|
+
* Has no effect if `line` prop is not set or is false or if `lineType` is 'fitting'.
|
|
147
|
+
*
|
|
148
|
+
* @defaultValue linear
|
|
149
|
+
* @see {@link https://recharts.github.io/en-US/examples/JointLineScatterChart/ Scatter chart with joint line}
|
|
150
|
+
*/
|
|
151
|
+
lineJointType?: CurveType;
|
|
152
|
+
/**
|
|
153
|
+
* The type of icon in legend.
|
|
154
|
+
* If set to 'none', no legend item will be rendered.
|
|
155
|
+
*
|
|
156
|
+
* @defaultValue 'circle'
|
|
157
|
+
* @example <Scatter legendType="diamond" />
|
|
158
|
+
*/
|
|
159
|
+
legendType?: LegendType;
|
|
160
|
+
tooltipType?: TooltipType;
|
|
161
|
+
/**
|
|
162
|
+
* Formats the value displayed in the tooltip for this Scatter.
|
|
163
|
+
* When set, takes precedence over the `formatter` prop on the Tooltip component.
|
|
164
|
+
*/
|
|
165
|
+
formatter?: Formatter;
|
|
166
|
+
className?: string;
|
|
167
|
+
/**
|
|
168
|
+
* The name of data.
|
|
169
|
+
* This option will be used in tooltip and legend to represent this graphical item.
|
|
170
|
+
* If no value was set to this option, the value of dataKey will be used alternatively.
|
|
171
|
+
*/
|
|
172
|
+
name?: string;
|
|
173
|
+
/**
|
|
174
|
+
* This component is rendered when this graphical item is activated
|
|
175
|
+
* (could be by mouse hover, touch, keyboard, programmatically).
|
|
176
|
+
*
|
|
177
|
+
* @see {@link https://recharts.github.io/en-US/examples/SimpleScatterChart/ Scatter chart with custom active shape}
|
|
178
|
+
* @example <Scatter activeShape={{ fill: 'red' }} />
|
|
179
|
+
*/
|
|
180
|
+
activeShape?: ScatterCustomizedShape;
|
|
181
|
+
/**
|
|
182
|
+
* Determines the shape of individual data points.
|
|
183
|
+
* - Can be one of the predefined shapes as a string, which will be passed to {@link Symbols} component.
|
|
184
|
+
* - If set a ReactElement, the shape of point can be customized.
|
|
185
|
+
* - If set a function, the function will be called to render customized shape.
|
|
186
|
+
* - During animations, the function shape also receives `animationElapsedTime`, `isAnimating`, and `isEntrance`.
|
|
187
|
+
* @defaultValue circle
|
|
188
|
+
*
|
|
189
|
+
* @example <Scatter shape={CustomizedShapeComponent} />
|
|
190
|
+
* @example <Scatter shape="diamond" />
|
|
191
|
+
*
|
|
192
|
+
* @see {@link https://recharts.github.io/en-US/examples/JointLineScatterChart/ Scatter chart with custom shapes}
|
|
193
|
+
*/
|
|
194
|
+
shape?: ScatterCustomizedShape;
|
|
195
|
+
/**
|
|
196
|
+
* Hides the whole graphical element when true.
|
|
197
|
+
*
|
|
198
|
+
* Hiding an element is different from removing it from the chart:
|
|
199
|
+
* Hidden graphical elements are still visible in Legend,
|
|
200
|
+
* and can be included in axis domain calculations,
|
|
201
|
+
* depending on `includeHidden` props of your XAxis/YAxis.
|
|
202
|
+
*
|
|
203
|
+
* @defaultValue false
|
|
204
|
+
*/
|
|
205
|
+
hide?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Renders one label for each data point. Options:
|
|
208
|
+
* - `true`: renders default labels;
|
|
209
|
+
* - `false`: no labels are rendered;
|
|
210
|
+
* - `object`: the props of LabelList component;
|
|
211
|
+
* - `ReactElement`: a custom SVG label element, such as `<text>` or `<g>`.
|
|
212
|
+
* HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
|
|
213
|
+
* - `function`: a render function of custom label.
|
|
214
|
+
*
|
|
215
|
+
* @defaultValue false
|
|
216
|
+
*/
|
|
217
|
+
label?: ImplicitLabelListType;
|
|
218
|
+
/**
|
|
219
|
+
* If set false, animation of Scatter points will be disabled.
|
|
220
|
+
* If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
|
|
221
|
+
* @defaultValue 'auto'
|
|
222
|
+
*/
|
|
223
|
+
isAnimationActive?: boolean | 'auto';
|
|
224
|
+
/**
|
|
225
|
+
* Specifies when the animation should begin, the unit of this option is ms.
|
|
226
|
+
* @defaultValue 0
|
|
227
|
+
*/
|
|
228
|
+
animationBegin?: number;
|
|
229
|
+
/**
|
|
230
|
+
* Specifies the duration of animation, the unit of this option is ms.
|
|
231
|
+
* @defaultValue 400
|
|
232
|
+
*/
|
|
233
|
+
animationDuration?: AnimationDuration;
|
|
234
|
+
/**
|
|
235
|
+
* The type of easing function.
|
|
236
|
+
* @defaultValue 'linear'
|
|
237
|
+
*/
|
|
238
|
+
animationEasing?: EasingInput;
|
|
239
|
+
/**
|
|
240
|
+
* Custom animation function for interpolating data items.
|
|
241
|
+
* When provided, this replaces the default animation interpolation.
|
|
242
|
+
*
|
|
243
|
+
* @param prevItems The items from the previous animation frame, or null on first render
|
|
244
|
+
* @param nextItems The target items to animate towards
|
|
245
|
+
* @param animationElapsedTime A normalized time value (0 = start, 1 = end)
|
|
246
|
+
* @returns The interpolated items at time animationElapsedTime
|
|
247
|
+
*
|
|
248
|
+
* @since 3.9
|
|
249
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
250
|
+
*/
|
|
251
|
+
animationInterpolateFn?: AnimationInterpolateFn<ScatterPointItem, CartesianLayout>;
|
|
252
|
+
/**
|
|
253
|
+
* Strategy for matching previous items to next items during animation.
|
|
254
|
+
* Determines how Recharts pairs old data points with new data points
|
|
255
|
+
* to create smooth transitions.
|
|
256
|
+
*
|
|
257
|
+
* - `matchAppend` (default): match sequentially by index and treat newly appended items as new
|
|
258
|
+
* - `matchByIndex`: match by array position with proportional stretching
|
|
259
|
+
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
260
|
+
* - Custom function `(item, index) => key`: match by the returned key
|
|
261
|
+
*
|
|
262
|
+
* @defaultValue append
|
|
263
|
+
* @see matchByIndex
|
|
264
|
+
* @see matchByDataKey
|
|
265
|
+
* @see matchAppend
|
|
266
|
+
*
|
|
267
|
+
* @since 3.9
|
|
268
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
269
|
+
*/
|
|
270
|
+
animationMatchBy?: AnimationMatchByProp<ScatterPointItem>;
|
|
271
|
+
/**
|
|
272
|
+
* Called when the Scatter animation starts.
|
|
273
|
+
*/
|
|
274
|
+
onAnimationStart?: () => void;
|
|
275
|
+
/**
|
|
276
|
+
* Called when the Scatter animation finishes.
|
|
277
|
+
*/
|
|
278
|
+
onAnimationEnd?: () => void;
|
|
279
|
+
/**
|
|
280
|
+
* Z-Index of this component and its children. The higher the value,
|
|
281
|
+
* the more on top it will be rendered.
|
|
282
|
+
* Components with higher zIndex will appear in front of components with lower zIndex.
|
|
283
|
+
* If undefined or 0, the content is rendered in the default layer without portals.
|
|
284
|
+
*
|
|
285
|
+
* @since 3.4
|
|
286
|
+
* @defaultValue 600
|
|
287
|
+
* @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
|
|
288
|
+
*/
|
|
289
|
+
zIndex?: number;
|
|
290
|
+
children?: ReactNode;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
|
|
294
|
+
*/
|
|
295
|
+
type BaseScatterSvgProps = Omit<
|
|
296
|
+
PresentationAttributesAdaptChildEvent<ScatterPointItem, SVGGraphicsElement>,
|
|
297
|
+
'points' | 'ref' | 'children' | 'dangerouslySetInnerHTML'
|
|
298
|
+
>;
|
|
299
|
+
export type Props<DataPointType = any, ValueAxisType = any> = BaseScatterSvgProps &
|
|
300
|
+
ScatterProps<DataPointType, ValueAxisType>;
|
|
301
|
+
export declare function computeScatterPoints({
|
|
302
|
+
displayedData,
|
|
303
|
+
xAxis,
|
|
304
|
+
yAxis,
|
|
305
|
+
zAxis,
|
|
306
|
+
scatterSettings,
|
|
307
|
+
xAxisTicks,
|
|
308
|
+
yAxisTicks,
|
|
309
|
+
cells,
|
|
310
|
+
}: {
|
|
311
|
+
displayedData: ReadonlyArray<unknown>;
|
|
312
|
+
xAxis: BaseAxisWithScale;
|
|
313
|
+
yAxis: BaseAxisWithScale;
|
|
314
|
+
zAxis: ZAxisWithScale | undefined;
|
|
315
|
+
scatterSettings: ScatterSettings;
|
|
316
|
+
xAxisTicks: ReadonlyArray<TickItem> | undefined;
|
|
317
|
+
yAxisTicks: ReadonlyArray<TickItem> | undefined;
|
|
318
|
+
cells: ReadonlyArray<ReactElement> | undefined;
|
|
319
|
+
}): ReadonlyArray<ScatterPointItem>;
|
|
320
|
+
export declare const defaultScatterProps: {
|
|
321
|
+
readonly xAxisId: 0;
|
|
322
|
+
readonly yAxisId: 0;
|
|
323
|
+
readonly zAxisId: 0;
|
|
324
|
+
readonly label: false;
|
|
325
|
+
readonly line: false;
|
|
326
|
+
readonly legendType: 'circle';
|
|
327
|
+
readonly lineType: 'joint';
|
|
328
|
+
readonly lineJointType: 'linear';
|
|
329
|
+
readonly shape: 'circle';
|
|
330
|
+
readonly hide: false;
|
|
331
|
+
readonly isAnimationActive: 'auto';
|
|
332
|
+
readonly animationBegin: 0;
|
|
333
|
+
readonly animationDuration: 400;
|
|
334
|
+
readonly animationEasing: 'linear';
|
|
335
|
+
readonly animationMatchBy: 'append';
|
|
336
|
+
readonly animationInterpolateFn: AnimationInterpolateFn<ScatterPointItem, CartesianLayout>;
|
|
337
|
+
readonly zIndex: 600;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* @provides LabelListContext
|
|
341
|
+
* @provides ErrorBarContext
|
|
342
|
+
* @provides CellReader
|
|
343
|
+
* @consumes CartesianChartContext
|
|
344
|
+
*/
|
|
345
|
+
export declare const Scatter: {
|
|
346
|
+
<DataPointType = any, ValueAxisType = any>(
|
|
347
|
+
props: Props<DataPointType, ValueAxisType>,
|
|
348
|
+
): ReactElement;
|
|
349
|
+
(props: Props<any, any>): ReactElement;
|
|
350
|
+
};
|
|
351
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from 'octane';
|
|
2
|
+
import { useLayoutEffect, useRef } from 'octane';
|
|
3
|
+
import { AxisDomain, BaseAxisProps, ScaleType } from '../util/types';
|
|
4
|
+
import {
|
|
5
|
+
addZAxis,
|
|
6
|
+
AxisId,
|
|
7
|
+
removeZAxis,
|
|
8
|
+
replaceZAxis,
|
|
9
|
+
ZAxisSettings,
|
|
10
|
+
} from '../state/cartesianAxisSlice';
|
|
11
|
+
import { useAppDispatch } from '../state/hooks';
|
|
12
|
+
import { AxisRange, implicitZAxis } from '../state/selectors/axisSelectors';
|
|
13
|
+
import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
|
14
|
+
import type { CustomScaleDefinition } from '../util/scale/CustomScaleDefinition';
|
|
15
|
+
|
|
16
|
+
function SetZAxisSettings(settings: ZAxisSettings): null {
|
|
17
|
+
const dispatch = useAppDispatch();
|
|
18
|
+
const prevSettingsRef = useRef<ZAxisSettings | null>(null);
|
|
19
|
+
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
if (prevSettingsRef.current === null) {
|
|
22
|
+
dispatch(addZAxis(settings));
|
|
23
|
+
} else if (prevSettingsRef.current !== settings) {
|
|
24
|
+
dispatch(replaceZAxis({ prev: prevSettingsRef.current, next: settings }));
|
|
25
|
+
}
|
|
26
|
+
prevSettingsRef.current = settings;
|
|
27
|
+
}, [settings, dispatch]);
|
|
28
|
+
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
return () => {
|
|
31
|
+
if (prevSettingsRef.current) {
|
|
32
|
+
dispatch(removeZAxis(prevSettingsRef.current));
|
|
33
|
+
prevSettingsRef.current = null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [dispatch]);
|
|
37
|
+
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Props<DataPointType = any, DataValueType = any> extends Omit<
|
|
42
|
+
BaseAxisProps<DataPointType, DataValueType>,
|
|
43
|
+
'domain'
|
|
44
|
+
> {
|
|
45
|
+
/**
|
|
46
|
+
* The type of axis.
|
|
47
|
+
*
|
|
48
|
+
* `category`: Treats data as distinct values.
|
|
49
|
+
* Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
|
|
50
|
+
*
|
|
51
|
+
* `number`: Treats data as continuous range.
|
|
52
|
+
* Values that are numerically closer are placed closer together on the axis.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue number
|
|
55
|
+
*/
|
|
56
|
+
type?: 'number' | 'category';
|
|
57
|
+
/**
|
|
58
|
+
* The unique id of z-axis.
|
|
59
|
+
*
|
|
60
|
+
* @defaultValue 0
|
|
61
|
+
*/
|
|
62
|
+
zAxisId?: AxisId;
|
|
63
|
+
/**
|
|
64
|
+
* The range of axis.
|
|
65
|
+
* Unlike other axes, the range of z-axis is not informed by chart dimensions.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue [64,64]
|
|
68
|
+
*/
|
|
69
|
+
range?: AxisRange;
|
|
70
|
+
/**
|
|
71
|
+
* Specify the domain of axis when the axis is a number axis.
|
|
72
|
+
*
|
|
73
|
+
* If undefined, then the domain is calculated based on the data and dataKeys.
|
|
74
|
+
*
|
|
75
|
+
* The length of domain should be 2, and we will validate the values in domain.
|
|
76
|
+
*
|
|
77
|
+
* Each element in the array can be a number, 'auto', 'dataMin', 'dataMax', a string like 'dataMin - 20', 'dataMax + 100',
|
|
78
|
+
* or a function that accepts a single argument and returns a number.
|
|
79
|
+
*
|
|
80
|
+
* If any element of domain is set to be 'auto', comprehensible scale ticks will be calculated, and the final domain of axis is generated by the ticks.
|
|
81
|
+
* If a function, receives '[dataMin, dataMax]', and must return a computed domain as '[min, max]'.
|
|
82
|
+
*
|
|
83
|
+
* @example <ZAxis type="number" domain={['dataMin', 'dataMax']} />
|
|
84
|
+
* @example <ZAxis type="number" domain={[0, 'dataMax']} />
|
|
85
|
+
* @example <ZAxis type="number" domain={['auto', 'auto']} />
|
|
86
|
+
* @example <ZAxis type="number" domain={[0, 'dataMax + 1000']} />
|
|
87
|
+
* @example <ZAxis type="number" domain={['dataMin - 100', 'dataMax + 100']} />
|
|
88
|
+
* @example <ZAxis type="number" domain={[dataMin => (0 - Math.abs(dataMin)), dataMax => (dataMax * 2)]} />
|
|
89
|
+
* @example <ZAxis type="number" domain={([dataMin, dataMax]) => { const absMax = Math.max(Math.abs(dataMin), Math.abs(dataMax)); return [-absMax, absMax]; }} />
|
|
90
|
+
* @example <ZAxis type="number" domain={[0, 100]} allowDataOverflow />
|
|
91
|
+
*/
|
|
92
|
+
domain?: AxisDomain;
|
|
93
|
+
/**
|
|
94
|
+
* Scale function determines how data values are mapped to visual values.
|
|
95
|
+
* In other words, decided the mapping between data domain and coordinate range.
|
|
96
|
+
*
|
|
97
|
+
* If undefined, or 'auto', the scale function is created internally according to the type of axis and data.
|
|
98
|
+
*
|
|
99
|
+
* You can define a custom scale, either as a string shortcut to a d3 scale, or as a complete scale definition object.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue auto
|
|
102
|
+
* @example <ZAxis scale="log" />
|
|
103
|
+
* @example
|
|
104
|
+
* import { scaleLog } from 'd3-scale';
|
|
105
|
+
* const scale = scaleLog().base(Math.E);
|
|
106
|
+
* <ZAxis scale={scale} />
|
|
107
|
+
*/
|
|
108
|
+
scale?: | ScaleType
|
|
109
|
+
| CustomScaleDefinition
|
|
110
|
+
| CustomScaleDefinition<string>
|
|
111
|
+
| CustomScaleDefinition<number>
|
|
112
|
+
| CustomScaleDefinition<Date>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const zAxisDefaultProps = {
|
|
116
|
+
zAxisId: 0,
|
|
117
|
+
range: implicitZAxis.range,
|
|
118
|
+
scale: implicitZAxis.scale,
|
|
119
|
+
type: implicitZAxis.type,
|
|
120
|
+
} as const satisfies Partial<Props>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Virtual axis, does not render anything itself. Has no ticks, grid lines, or labels.
|
|
124
|
+
* Useful for dynamically setting Scatter point size, based on data.
|
|
125
|
+
*
|
|
126
|
+
* @consumes CartesianViewBoxContext
|
|
127
|
+
*/
|
|
128
|
+
export function ZAxis<DataPointType = any, DataValueType = any>(
|
|
129
|
+
outsideProps: Props<DataPointType, DataValueType>,
|
|
130
|
+
) {
|
|
131
|
+
const props = resolveDefaultProps(outsideProps, zAxisDefaultProps);
|
|
132
|
+
return <SetZAxisSettings
|
|
133
|
+
domain={props.domain}
|
|
134
|
+
id={props.zAxisId}
|
|
135
|
+
dataKey={props.dataKey}
|
|
136
|
+
name={props.name}
|
|
137
|
+
unit={props.unit}
|
|
138
|
+
range={props.range}
|
|
139
|
+
scale={props.scale}
|
|
140
|
+
type={props.type}
|
|
141
|
+
allowDuplicatedCategory={implicitZAxis.allowDuplicatedCategory}
|
|
142
|
+
allowDataOverflow={implicitZAxis.allowDataOverflow}
|
|
143
|
+
reversed={implicitZAxis.reversed}
|
|
144
|
+
includeHidden={implicitZAxis.includeHidden}
|
|
145
|
+
/>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
ZAxis.displayName = 'ZAxis';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from 'octane';
|
|
2
|
+
import { AxisDomain, BaseAxisProps, ScaleType } from '../util/types';
|
|
3
|
+
import { AxisId } from '../state/cartesianAxisSlice';
|
|
4
|
+
import { AxisRange } from '../state/selectors/axisSelectors';
|
|
5
|
+
import { CustomScaleDefinition } from '../util/scale/CustomScaleDefinition';
|
|
6
|
+
export interface Props<DataPointType = any, DataValueType = any> extends Omit<
|
|
7
|
+
BaseAxisProps<DataPointType, DataValueType>,
|
|
8
|
+
'domain'
|
|
9
|
+
> {
|
|
10
|
+
/**
|
|
11
|
+
* The type of axis.
|
|
12
|
+
*
|
|
13
|
+
* `category`: Treats data as distinct values.
|
|
14
|
+
* Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
|
|
15
|
+
*
|
|
16
|
+
* `number`: Treats data as continuous range.
|
|
17
|
+
* Values that are numerically closer are placed closer together on the axis.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue number
|
|
20
|
+
*/
|
|
21
|
+
type?: 'number' | 'category';
|
|
22
|
+
/**
|
|
23
|
+
* The unique id of z-axis.
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue 0
|
|
26
|
+
*/
|
|
27
|
+
zAxisId?: AxisId;
|
|
28
|
+
/**
|
|
29
|
+
* The range of axis.
|
|
30
|
+
* Unlike other axes, the range of z-axis is not informed by chart dimensions.
|
|
31
|
+
*
|
|
32
|
+
* @defaultValue [64,64]
|
|
33
|
+
*/
|
|
34
|
+
range?: AxisRange;
|
|
35
|
+
/**
|
|
36
|
+
* Specify the domain of axis when the axis is a number axis.
|
|
37
|
+
*
|
|
38
|
+
* If undefined, then the domain is calculated based on the data and dataKeys.
|
|
39
|
+
*
|
|
40
|
+
* The length of domain should be 2, and we will validate the values in domain.
|
|
41
|
+
*
|
|
42
|
+
* Each element in the array can be a number, 'auto', 'dataMin', 'dataMax', a string like 'dataMin - 20', 'dataMax + 100',
|
|
43
|
+
* or a function that accepts a single argument and returns a number.
|
|
44
|
+
*
|
|
45
|
+
* If any element of domain is set to be 'auto', comprehensible scale ticks will be calculated, and the final domain of axis is generated by the ticks.
|
|
46
|
+
* If a function, receives '[dataMin, dataMax]', and must return a computed domain as '[min, max]'.
|
|
47
|
+
*
|
|
48
|
+
* @example <ZAxis type="number" domain={['dataMin', 'dataMax']} />
|
|
49
|
+
* @example <ZAxis type="number" domain={[0, 'dataMax']} />
|
|
50
|
+
* @example <ZAxis type="number" domain={['auto', 'auto']} />
|
|
51
|
+
* @example <ZAxis type="number" domain={[0, 'dataMax + 1000']} />
|
|
52
|
+
* @example <ZAxis type="number" domain={['dataMin - 100', 'dataMax + 100']} />
|
|
53
|
+
* @example <ZAxis type="number" domain={[dataMin => (0 - Math.abs(dataMin)), dataMax => (dataMax * 2)]} />
|
|
54
|
+
* @example <ZAxis type="number" domain={([dataMin, dataMax]) => { const absMax = Math.max(Math.abs(dataMin), Math.abs(dataMax)); return [-absMax, absMax]; }} />
|
|
55
|
+
* @example <ZAxis type="number" domain={[0, 100]} allowDataOverflow />
|
|
56
|
+
*/
|
|
57
|
+
domain?: AxisDomain;
|
|
58
|
+
/**
|
|
59
|
+
* Scale function determines how data values are mapped to visual values.
|
|
60
|
+
* In other words, decided the mapping between data domain and coordinate range.
|
|
61
|
+
*
|
|
62
|
+
* If undefined, or 'auto', the scale function is created internally according to the type of axis and data.
|
|
63
|
+
*
|
|
64
|
+
* You can define a custom scale, either as a string shortcut to a d3 scale, or as a complete scale definition object.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue auto
|
|
67
|
+
* @example <ZAxis scale="log" />
|
|
68
|
+
* @example
|
|
69
|
+
* import { scaleLog } from 'd3-scale';
|
|
70
|
+
* const scale = scaleLog().base(Math.E);
|
|
71
|
+
* <ZAxis scale={scale} />
|
|
72
|
+
*/
|
|
73
|
+
scale?:
|
|
74
|
+
| ScaleType
|
|
75
|
+
| CustomScaleDefinition
|
|
76
|
+
| CustomScaleDefinition<string>
|
|
77
|
+
| CustomScaleDefinition<number>
|
|
78
|
+
| CustomScaleDefinition<Date>;
|
|
79
|
+
}
|
|
80
|
+
export declare const zAxisDefaultProps: {
|
|
81
|
+
readonly zAxisId: 0;
|
|
82
|
+
readonly range: AxisRange;
|
|
83
|
+
readonly scale:
|
|
84
|
+
| ScaleType
|
|
85
|
+
| CustomScaleDefinition<import('../util/types').CategoricalDomainItem>
|
|
86
|
+
| CustomScaleDefinition<string>
|
|
87
|
+
| CustomScaleDefinition<number>
|
|
88
|
+
| CustomScaleDefinition<Date>;
|
|
89
|
+
readonly type: import('../util/types').EvaluatedAxisDomainType;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Virtual axis, does not render anything itself. Has no ticks, grid lines, or labels.
|
|
93
|
+
* Useful for dynamically setting Scatter point size, based on data.
|
|
94
|
+
*
|
|
95
|
+
* @consumes CartesianViewBoxContext
|
|
96
|
+
*/
|
|
97
|
+
export declare function ZAxis<DataPointType = any, DataValueType = any>(
|
|
98
|
+
outsideProps: Props<DataPointType, DataValueType>,
|
|
99
|
+
): React.JSX.Element;
|
|
100
|
+
export declare namespace ZAxis {
|
|
101
|
+
var displayName: string;
|
|
102
|
+
}
|
|
@@ -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> = ['axis'];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @consumes ResponsiveContainerContext
|
|
9
|
+
* @provides CartesianViewBoxContext
|
|
10
|
+
* @provides CartesianChartContext
|
|
11
|
+
*/
|
|
12
|
+
export function AreaChart(props: CartesianChartProps<unknown>) {
|
|
13
|
+
const { ref, ...rest } = props;
|
|
14
|
+
return <CartesianChart
|
|
15
|
+
chartName="AreaChart"
|
|
16
|
+
defaultTooltipEventType="axis"
|
|
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 AreaChart: <DataPointType = any>(
|
|
9
|
+
props: CartesianChartProps<DataPointType> & {
|
|
10
|
+
ref?: React.Ref<SVGSVGElement>;
|
|
11
|
+
},
|
|
12
|
+
) => React.ReactElement;
|
|
@@ -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> = ['axis'];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @consumes ResponsiveContainerContext
|
|
9
|
+
* @provides CartesianViewBoxContext
|
|
10
|
+
* @provides CartesianChartContext
|
|
11
|
+
*/
|
|
12
|
+
export function ComposedChart(props: CartesianChartProps<unknown>) {
|
|
13
|
+
const { ref, ...rest } = props;
|
|
14
|
+
return <CartesianChart
|
|
15
|
+
chartName="ComposedChart"
|
|
16
|
+
defaultTooltipEventType="axis"
|
|
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 ComposedChart: <DataPointType = any>(
|
|
9
|
+
props: CartesianChartProps<DataPointType> & {
|
|
10
|
+
ref?: React.Ref<SVGSVGElement>;
|
|
11
|
+
},
|
|
12
|
+
) => React.ReactElement;
|