source: node_modules/recharts/lib/cartesian/Scatter.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 23.8 KB
RevLine 
[a762898]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.Scatter = void 0;
7exports.computeScatterPoints = computeScatterPoints;
8exports.defaultScatterProps = void 0;
9var _react = _interopRequireWildcard(require("react"));
10var React = _react;
11var _clsx = require("clsx");
12var _Layer = require("../container/Layer");
13var _LabelList = require("../component/LabelList");
14var _ReactUtils = require("../util/ReactUtils");
15var _Curve = require("../shape/Curve");
16var _Cell = require("../component/Cell");
17var _DataUtils = require("../util/DataUtils");
18var _ChartUtils = require("../util/ChartUtils");
19var _types = require("../util/types");
20var _ScatterUtils = require("../util/ScatterUtils");
21var _tooltipContext = require("../context/tooltipContext");
22var _SetTooltipEntrySettings = require("../state/SetTooltipEntrySettings");
23var _ErrorBarContext = require("../context/ErrorBarContext");
24var _GraphicalItemClipPath = require("./GraphicalItemClipPath");
25var _scatterSelectors = require("../state/selectors/scatterSelectors");
26var _hooks = require("../state/hooks");
27var _axisSelectors = require("../state/selectors/axisSelectors");
28var _PanoramaContext = require("../context/PanoramaContext");
29var _tooltipSelectors = require("../state/selectors/tooltipSelectors");
30var _SetLegendPayload = require("../state/SetLegendPayload");
31var _Constants = require("../util/Constants");
32var _useAnimationId = require("../util/useAnimationId");
33var _resolveDefaultProps2 = require("../util/resolveDefaultProps");
34var _RegisterGraphicalItemId = require("../context/RegisterGraphicalItemId");
35var _SetGraphicalItem = require("../state/SetGraphicalItem");
36var _svgPropertiesNoEvents = require("../util/svgPropertiesNoEvents");
37var _JavascriptAnimate = require("../animation/JavascriptAnimate");
38var _chartLayoutContext = require("../context/chartLayoutContext");
39var _ZIndexLayer = require("../zIndex/ZIndexLayer");
40var _DefaultZIndexes = require("../zIndex/DefaultZIndexes");
41var _propsAreEqual = require("../util/propsAreEqual");
42var _excluded = ["id"],
43 _excluded2 = ["onMouseEnter", "onClick", "onMouseLeave"],
44 _excluded3 = ["animationBegin", "animationDuration", "animationEasing", "hide", "isAnimationActive", "legendType", "lineJointType", "lineType", "shape", "xAxisId", "yAxisId", "zAxisId"];
45function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
46function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
47function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
48function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
49function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
50function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
51function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
52function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
53function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
54/**
55 * Scatter coordinates are nullable because sometimes the point value is out of the domain,
56 * and we can't compute a valid coordinate for it.
57 *
58 * Scatter -> Symbol ignores points with null cx or cy so those won't render if using the default shapes.
59 * However: the points are exposed via various props and can be used in custom shapes so we keep them around.
60 */
61
62/**
63 * Internal props, combination of external props + defaultProps + private Recharts state
64 */
65
66/**
67 * External props, intended for end users to fill in
68 */
69
70/**
71 * Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
72 */
73
74var computeLegendPayloadFromScatterProps = props => {
75 var {
76 dataKey,
77 name,
78 fill,
79 legendType,
80 hide
81 } = props;
82 return [{
83 inactive: hide,
84 dataKey,
85 type: legendType,
86 color: fill,
87 value: (0, _ChartUtils.getTooltipNameProp)(name, dataKey),
88 payload: props
89 }];
90};
91var SetScatterTooltipEntrySettings = /*#__PURE__*/React.memo(_ref => {
92 var {
93 dataKey,
94 points,
95 stroke,
96 strokeWidth,
97 fill,
98 name,
99 hide,
100 tooltipType,
101 id
102 } = _ref;
103 var tooltipEntrySettings = {
104 dataDefinedOnItem: points === null || points === void 0 ? void 0 : points.map(p => p.tooltipPayload),
105 getPosition: index => {
106 var _points$Number;
107 return points === null || points === void 0 || (_points$Number = points[Number(index)]) === null || _points$Number === void 0 ? void 0 : _points$Number.tooltipPosition;
108 },
109 settings: {
110 stroke,
111 strokeWidth,
112 fill,
113 nameKey: undefined,
114 dataKey,
115 name: (0, _ChartUtils.getTooltipNameProp)(name, dataKey),
116 hide,
117 type: tooltipType,
118 color: fill,
119 unit: '',
120 // why doesn't Scatter support unit?
121 graphicalItemId: id
122 }
123 };
124 return /*#__PURE__*/React.createElement(_SetTooltipEntrySettings.SetTooltipEntrySettings, {
125 tooltipEntrySettings: tooltipEntrySettings
126 });
127});
128function ScatterLine(_ref2) {
129 var {
130 points,
131 props
132 } = _ref2;
133 var {
134 line,
135 lineType,
136 lineJointType
137 } = props;
138 if (!line) {
139 return null;
140 }
141 var scatterProps = (0, _svgPropertiesNoEvents.svgPropertiesNoEvents)(props);
142 var customLineProps = (0, _svgPropertiesNoEvents.svgPropertiesNoEventsFromUnknown)(line);
143 var linePoints, lineItem;
144 if (lineType === 'joint') {
145 linePoints = points.map(entry => {
146 var _entry$cx, _entry$cy;
147 return {
148 x: (_entry$cx = entry.cx) !== null && _entry$cx !== void 0 ? _entry$cx : null,
149 y: (_entry$cy = entry.cy) !== null && _entry$cy !== void 0 ? _entry$cy : null
150 };
151 });
152 } else if (lineType === 'fitting') {
153 var {
154 xmin,
155 xmax,
156 a,
157 b
158 } = (0, _DataUtils.getLinearRegression)(points);
159 var linearExp = x => a * x + b;
160 linePoints = [{
161 x: xmin,
162 y: linearExp(xmin)
163 }, {
164 x: xmax,
165 y: linearExp(xmax)
166 }];
167 }
168 var lineProps = _objectSpread(_objectSpread(_objectSpread({}, scatterProps), {}, {
169 // @ts-expect-error customLineProps is contributing unknown props
170 fill: 'none',
171 // @ts-expect-error customLineProps is contributing unknown props
172 stroke: scatterProps && scatterProps.fill
173 }, customLineProps), {}, {
174 // @ts-expect-error linePoints is used before it is assigned (???)
175 points: linePoints
176 });
177 if (/*#__PURE__*/React.isValidElement(line)) {
178 lineItem = /*#__PURE__*/React.cloneElement(line, lineProps);
179 } else if (typeof line === 'function') {
180 lineItem = line(lineProps);
181 } else {
182 lineItem = /*#__PURE__*/React.createElement(_Curve.Curve, _extends({}, lineProps, {
183 type: lineJointType
184 }));
185 }
186 return /*#__PURE__*/React.createElement(_Layer.Layer, {
187 className: "recharts-scatter-line",
188 key: "recharts-scatter-line"
189 }, lineItem);
190}
191function ScatterLabelListProvider(_ref3) {
192 var {
193 showLabels,
194 points,
195 children
196 } = _ref3;
197 var chartViewBox = (0, _chartLayoutContext.useViewBox)();
198 var labelListEntries = (0, _react.useMemo)(() => {
199 return points === null || points === void 0 ? void 0 : points.map(point => {
200 var _point$x, _point$y;
201 var viewBox = {
202 /*
203 * Scatter label uses x and y as the reference point for the label,
204 * not cx and cy.
205 */
206 x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
207 /*
208 * Scatter label uses x and y as the reference point for the label,
209 * not cx and cy.
210 */
211 y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
212 width: point.width,
213 height: point.height,
214 lowerWidth: point.width,
215 upperWidth: point.width
216 };
217 return _objectSpread(_objectSpread({}, viewBox), {}, {
218 /*
219 * Here we put undefined because Scatter shows two values usually, one for X and one for Y.
220 * LabelList will see this undefined and will use its own `dataKey` prop to determine which value to show,
221 * using the payload below.
222 */
223 value: undefined,
224 payload: point.payload,
225 viewBox,
226 parentViewBox: chartViewBox,
227 fill: undefined
228 });
229 });
230 }, [chartViewBox, points]);
231 return /*#__PURE__*/React.createElement(_LabelList.CartesianLabelListContextProvider, {
232 value: showLabels ? labelListEntries : undefined
233 }, children);
234}
235function ScatterSymbols(props) {
236 var {
237 points,
238 allOtherScatterProps
239 } = props;
240 var {
241 shape,
242 activeShape,
243 dataKey
244 } = allOtherScatterProps;
245 var {
246 id
247 } = allOtherScatterProps,
248 allOtherPropsWithoutId = _objectWithoutProperties(allOtherScatterProps, _excluded);
249 var activeIndex = (0, _hooks.useAppSelector)(_tooltipSelectors.selectActiveTooltipIndex);
250 var {
251 onMouseEnter: onMouseEnterFromProps,
252 onClick: onItemClickFromProps,
253 onMouseLeave: onMouseLeaveFromProps
254 } = allOtherScatterProps,
255 restOfAllOtherProps = _objectWithoutProperties(allOtherScatterProps, _excluded2);
256 var onMouseEnterFromContext = (0, _tooltipContext.useMouseEnterItemDispatch)(onMouseEnterFromProps, dataKey, id);
257 var onMouseLeaveFromContext = (0, _tooltipContext.useMouseLeaveItemDispatch)(onMouseLeaveFromProps);
258 var onClickFromContext = (0, _tooltipContext.useMouseClickItemDispatch)(onItemClickFromProps, dataKey, id);
259 if (!(0, _types.isNonEmptyArray)(points)) {
260 return null;
261 }
262 var baseProps = (0, _svgPropertiesNoEvents.svgPropertiesNoEvents)(allOtherPropsWithoutId);
263 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScatterLine, {
264 points: points,
265 props: allOtherPropsWithoutId
266 }), points.map((entry, i) => {
267 var hasActiveShape = activeShape != null && activeShape !== false;
268 var isActive = hasActiveShape && activeIndex === String(i);
269 var option = hasActiveShape && isActive ? activeShape : shape;
270 var symbolProps = _objectSpread(_objectSpread(_objectSpread({}, baseProps), entry), {}, {
271 index: i,
272 [_Constants.DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME]: String(id)
273 });
274 return /*#__PURE__*/React.createElement(_ZIndexLayer.ZIndexLayer, {
275 key: "symbol-".concat(entry === null || entry === void 0 ? void 0 : entry.cx, "-").concat(entry === null || entry === void 0 ? void 0 : entry.cy, "-").concat(entry === null || entry === void 0 ? void 0 : entry.size, "-").concat(i)
276 /*
277 * inactive Scatters use the parent zIndex, which is represented by undefined here.
278 * ZIndexLayer will render undefined zIndex as-is, as regular children, without portals.
279 * Active Scatters use the activeDot zIndex so they render above other elements.
280 */,
281 zIndex: isActive ? _DefaultZIndexes.DefaultZIndexes.activeDot : undefined
282 }, /*#__PURE__*/React.createElement(_Layer.Layer, _extends({
283 className: "recharts-scatter-symbol"
284 }, (0, _types.adaptEventsOfChild)(restOfAllOtherProps, entry, i), {
285 // @ts-expect-error the types need a bit of attention
286 onMouseEnter: onMouseEnterFromContext(entry, i)
287 // @ts-expect-error the types need a bit of attention
288 ,
289 onMouseLeave: onMouseLeaveFromContext(entry, i)
290 // @ts-expect-error the types need a bit of attention
291 ,
292 onClick: onClickFromContext(entry, i)
293 }), /*#__PURE__*/React.createElement(_ScatterUtils.ScatterSymbol, _extends({
294 option: option,
295 isActive: isActive
296 }, symbolProps))));
297 }));
298}
299function SymbolsWithAnimation(_ref4) {
300 var {
301 previousPointsRef,
302 props
303 } = _ref4;
304 var {
305 points,
306 isAnimationActive,
307 animationBegin,
308 animationDuration,
309 animationEasing
310 } = props;
311 var prevPoints = previousPointsRef.current;
312 var animationId = (0, _useAnimationId.useAnimationId)(props, 'recharts-scatter-');
313 var [isAnimating, setIsAnimating] = (0, _react.useState)(false);
314 var handleAnimationEnd = (0, _react.useCallback)(() => {
315 // Scatter doesn't have onAnimationEnd prop, and if we want to add it we do it here
316 // if (typeof onAnimationEnd === 'function') {
317 // onAnimationEnd();
318 // }
319 setIsAnimating(false);
320 }, []);
321 var handleAnimationStart = (0, _react.useCallback)(() => {
322 // Scatter doesn't have onAnimationStart prop, and if we want to add it we do it here
323 // if (typeof onAnimationStart === 'function') {
324 // onAnimationStart();
325 // }
326 setIsAnimating(true);
327 }, []);
328 var showLabels = !isAnimating;
329 return /*#__PURE__*/React.createElement(ScatterLabelListProvider, {
330 showLabels: showLabels,
331 points: points
332 }, props.children, /*#__PURE__*/React.createElement(_JavascriptAnimate.JavascriptAnimate, {
333 animationId: animationId,
334 begin: animationBegin,
335 duration: animationDuration,
336 isActive: isAnimationActive,
337 easing: animationEasing,
338 onAnimationEnd: handleAnimationEnd,
339 onAnimationStart: handleAnimationStart,
340 key: animationId
341 }, t => {
342 var stepData = t === 1 ? points : points === null || points === void 0 ? void 0 : points.map((entry, index) => {
343 var prev = prevPoints && prevPoints[index];
344 if (prev) {
345 return _objectSpread(_objectSpread({}, entry), {}, {
346 cx: entry.cx == null ? undefined : (0, _DataUtils.interpolate)(prev.cx, entry.cx, t),
347 cy: entry.cy == null ? undefined : (0, _DataUtils.interpolate)(prev.cy, entry.cy, t),
348 size: (0, _DataUtils.interpolate)(prev.size, entry.size, t)
349 });
350 }
351 return _objectSpread(_objectSpread({}, entry), {}, {
352 size: (0, _DataUtils.interpolate)(0, entry.size, t)
353 });
354 });
355 if (t > 0) {
356 // eslint-disable-next-line no-param-reassign
357 previousPointsRef.current = stepData;
358 }
359 return /*#__PURE__*/React.createElement(_Layer.Layer, null, /*#__PURE__*/React.createElement(ScatterSymbols, {
360 points: stepData,
361 allOtherScatterProps: props,
362 showLabels: showLabels
363 }));
364 }), /*#__PURE__*/React.createElement(_LabelList.LabelListFromLabelProp, {
365 label: props.label
366 }));
367}
368function computeScatterPoints(_ref5) {
369 var {
370 displayedData,
371 xAxis,
372 yAxis,
373 zAxis,
374 scatterSettings,
375 xAxisTicks,
376 yAxisTicks,
377 cells
378 } = _ref5;
379 var xAxisDataKey = (0, _DataUtils.isNullish)(xAxis.dataKey) ? scatterSettings.dataKey : xAxis.dataKey;
380 var yAxisDataKey = (0, _DataUtils.isNullish)(yAxis.dataKey) ? scatterSettings.dataKey : yAxis.dataKey;
381 var zAxisDataKey = zAxis && zAxis.dataKey;
382 var defaultRangeZ = zAxis ? zAxis.range : _axisSelectors.implicitZAxis.range;
383 var defaultZ = defaultRangeZ && defaultRangeZ[0];
384 var xBandSize = xAxis.scale.bandwidth ? xAxis.scale.bandwidth() : 0;
385 var yBandSize = yAxis.scale.bandwidth ? yAxis.scale.bandwidth() : 0;
386 return displayedData.map((entry, index) => {
387 var x = (0, _ChartUtils.getValueByDataKey)(entry, xAxisDataKey);
388 var y = (0, _ChartUtils.getValueByDataKey)(entry, yAxisDataKey);
389 var z = !(0, _DataUtils.isNullish)(zAxisDataKey) && (0, _ChartUtils.getValueByDataKey)(entry, zAxisDataKey) || '-';
390 var tooltipPayload = [{
391 name: (0, _DataUtils.isNullish)(xAxis.dataKey) ? scatterSettings.name : xAxis.name || String(xAxis.dataKey),
392 unit: xAxis.unit || '',
393 // @ts-expect-error getValueByDataKey does not validate the output type
394 value: x,
395 payload: entry,
396 dataKey: xAxisDataKey,
397 type: scatterSettings.tooltipType
398 }, {
399 name: (0, _DataUtils.isNullish)(yAxis.dataKey) ? scatterSettings.name : yAxis.name || String(yAxis.dataKey),
400 unit: yAxis.unit || '',
401 // @ts-expect-error getValueByDataKey does not validate the output type
402 value: y,
403 payload: entry,
404 dataKey: yAxisDataKey,
405 type: scatterSettings.tooltipType
406 }];
407 if (z !== '-' && zAxis != null) {
408 tooltipPayload.push({
409 // @ts-expect-error name prop should not have dataKey in it
410 name: zAxis.name || zAxis.dataKey,
411 unit: zAxis.unit || '',
412 // @ts-expect-error getValueByDataKey does not validate the output type
413 value: z,
414 payload: entry,
415 dataKey: zAxisDataKey,
416 type: scatterSettings.tooltipType
417 });
418 }
419 var cx = (0, _ChartUtils.getCateCoordinateOfLine)({
420 axis: xAxis,
421 ticks: xAxisTicks,
422 bandSize: xBandSize,
423 entry,
424 index,
425 dataKey: xAxisDataKey
426 });
427 var cy = (0, _ChartUtils.getCateCoordinateOfLine)({
428 axis: yAxis,
429 ticks: yAxisTicks,
430 bandSize: yBandSize,
431 entry,
432 index,
433 dataKey: yAxisDataKey
434 });
435 var size = z !== '-' && zAxis != null ? zAxis.scale.map(z) : defaultZ;
436 var radius = size == null ? 0 : Math.sqrt(Math.max(size, 0) / Math.PI);
437 return _objectSpread(_objectSpread({}, entry), {}, {
438 cx,
439 cy,
440 x: cx == null ? undefined : cx - radius,
441 y: cy == null ? undefined : cy - radius,
442 width: 2 * radius,
443 height: 2 * radius,
444 size,
445 node: {
446 x,
447 y,
448 z
449 },
450 tooltipPayload,
451 tooltipPosition: {
452 x: cx,
453 y: cy
454 },
455 payload: entry
456 }, cells && cells[index] && cells[index].props);
457 });
458}
459var errorBarDataPointFormatter = (dataPoint, dataKey, direction) => {
460 return {
461 x: dataPoint.cx,
462 y: dataPoint.cy,
463 value: direction === 'x' ? Number(dataPoint.node.x) : Number(dataPoint.node.y),
464 // @ts-expect-error getValueByDataKey does not validate the output type
465 errorVal: (0, _ChartUtils.getValueByDataKey)(dataPoint, dataKey)
466 };
467};
468function ScatterWithId(props) {
469 var {
470 hide,
471 points,
472 className,
473 needClip,
474 xAxisId,
475 yAxisId,
476 id
477 } = props;
478 var previousPointsRef = (0, _react.useRef)(null);
479 if (hide) {
480 return null;
481 }
482 var layerClass = (0, _clsx.clsx)('recharts-scatter', className);
483 var clipPathId = id;
484 return /*#__PURE__*/React.createElement(_ZIndexLayer.ZIndexLayer, {
485 zIndex: props.zIndex
486 }, /*#__PURE__*/React.createElement(_Layer.Layer, {
487 className: layerClass,
488 clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined,
489 id: id
490 }, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(_GraphicalItemClipPath.GraphicalItemClipPath, {
491 clipPathId: clipPathId,
492 xAxisId: xAxisId,
493 yAxisId: yAxisId
494 })), /*#__PURE__*/React.createElement(_ErrorBarContext.SetErrorBarContext, {
495 xAxisId: xAxisId,
496 yAxisId: yAxisId,
497 data: points,
498 dataPointFormatter: errorBarDataPointFormatter,
499 errorBarOffset: 0
500 }, /*#__PURE__*/React.createElement(_Layer.Layer, {
501 key: "recharts-scatter-symbols"
502 }, /*#__PURE__*/React.createElement(SymbolsWithAnimation, {
503 props: props,
504 previousPointsRef: previousPointsRef
505 })))));
506}
507var defaultScatterProps = exports.defaultScatterProps = {
508 xAxisId: 0,
509 yAxisId: 0,
510 zAxisId: 0,
511 label: false,
512 line: false,
513 legendType: 'circle',
514 lineType: 'joint',
515 lineJointType: 'linear',
516 shape: 'circle',
517 hide: false,
518 isAnimationActive: 'auto',
519 animationBegin: 0,
520 animationDuration: 400,
521 animationEasing: 'linear',
522 zIndex: _DefaultZIndexes.DefaultZIndexes.scatter
523};
524function ScatterImpl(props) {
525 var _resolveDefaultProps = (0, _resolveDefaultProps2.resolveDefaultProps)(props, defaultScatterProps),
526 {
527 animationBegin,
528 animationDuration,
529 animationEasing,
530 hide,
531 isAnimationActive,
532 legendType,
533 lineJointType,
534 lineType,
535 shape,
536 xAxisId,
537 yAxisId,
538 zAxisId
539 } = _resolveDefaultProps,
540 everythingElse = _objectWithoutProperties(_resolveDefaultProps, _excluded3);
541 var {
542 needClip
543 } = (0, _GraphicalItemClipPath.useNeedsClip)(xAxisId, yAxisId);
544 var cells = (0, _react.useMemo)(() => (0, _ReactUtils.findAllByType)(props.children, _Cell.Cell), [props.children]);
545 var isPanorama = (0, _PanoramaContext.useIsPanorama)();
546 var points = (0, _hooks.useAppSelector)(state => {
547 return (0, _scatterSelectors.selectScatterPoints)(state, xAxisId, yAxisId, zAxisId, props.id, cells, isPanorama);
548 });
549 if (needClip == null) {
550 return null;
551 }
552 if (points == null) {
553 return null;
554 }
555 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetScatterTooltipEntrySettings, {
556 dataKey: props.dataKey,
557 points: points,
558 stroke: props.stroke,
559 strokeWidth: props.strokeWidth,
560 fill: props.fill,
561 name: props.name,
562 hide: props.hide,
563 tooltipType: props.tooltipType,
564 id: props.id
565 }), /*#__PURE__*/React.createElement(ScatterWithId, _extends({}, everythingElse, {
566 xAxisId: xAxisId,
567 yAxisId: yAxisId,
568 zAxisId: zAxisId,
569 lineType: lineType,
570 lineJointType: lineJointType,
571 legendType: legendType,
572 shape: shape,
573 hide: hide,
574 isAnimationActive: isAnimationActive,
575 animationBegin: animationBegin,
576 animationDuration: animationDuration,
577 animationEasing: animationEasing,
578 points: points,
579 needClip: needClip
580 })));
581}
582function ScatterFn(outsideProps) {
583 var props = (0, _resolveDefaultProps2.resolveDefaultProps)(outsideProps, defaultScatterProps);
584 var isPanorama = (0, _PanoramaContext.useIsPanorama)();
585 return /*#__PURE__*/React.createElement(_RegisterGraphicalItemId.RegisterGraphicalItemId, {
586 id: props.id,
587 type: "scatter"
588 }, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_SetLegendPayload.SetLegendPayload, {
589 legendPayload: computeLegendPayloadFromScatterProps(props)
590 }), /*#__PURE__*/React.createElement(_SetGraphicalItem.SetCartesianGraphicalItem, {
591 type: "scatter",
592 id: id,
593 data: props.data,
594 xAxisId: props.xAxisId,
595 yAxisId: props.yAxisId,
596 zAxisId: props.zAxisId,
597 dataKey: props.dataKey,
598 hide: props.hide,
599 name: props.name,
600 tooltipType: props.tooltipType,
601 isPanorama: isPanorama
602 }), /*#__PURE__*/React.createElement(ScatterImpl, _extends({}, props, {
603 id: id
604 }))));
605}
606
607/**
608 * @provides LabelListContext
609 * @provides ErrorBarContext
610 * @provides CellReader
611 * @consumes CartesianChartContext
612 */
613var Scatter = exports.Scatter = /*#__PURE__*/React.memo(ScatterFn, _propsAreEqual.propsAreEqual);
614Scatter.displayName = 'Scatter';
Note: See TracBrowser for help on using the repository browser.