source: node_modules/recharts/es6/component/ActivePoints.js@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 3.9 KB
Line 
1function 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; }
2function _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; }
3function _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; }
4function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5function _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); }
6import * as React from 'react';
7import { cloneElement, isValidElement } from 'react';
8import { adaptEventHandlers } from '../util/types';
9import { Dot } from '../shape/Dot';
10import { Layer } from '../container/Layer';
11import { useAppSelector } from '../state/hooks';
12import { selectActiveTooltipIndex } from '../state/selectors/tooltipSelectors';
13import { useActiveTooltipDataPoints } from '../hooks';
14import { isNullish } from '../util/DataUtils';
15import { svgPropertiesNoEventsFromUnknown } from '../util/svgPropertiesNoEvents';
16import { ZIndexLayer } from '../zIndex/ZIndexLayer';
17import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
18var ActivePoint = _ref => {
19 var {
20 point,
21 childIndex,
22 mainColor,
23 activeDot,
24 dataKey,
25 clipPath
26 } = _ref;
27 if (activeDot === false || point.x == null || point.y == null) {
28 return null;
29 }
30 var dotPropsTyped = {
31 index: childIndex,
32 dataKey,
33 cx: point.x,
34 cy: point.y,
35 r: 4,
36 fill: mainColor !== null && mainColor !== void 0 ? mainColor : 'none',
37 strokeWidth: 2,
38 stroke: '#fff',
39 payload: point.payload,
40 value: point.value
41 };
42
43 // @ts-expect-error svgPropertiesNoEventsFromUnknown(activeDot) is contributing unknown props
44 var dotProps = _objectSpread(_objectSpread(_objectSpread({}, dotPropsTyped), svgPropertiesNoEventsFromUnknown(activeDot)), adaptEventHandlers(activeDot));
45 var dot;
46 if (/*#__PURE__*/isValidElement(activeDot)) {
47 // @ts-expect-error we're improperly typing events
48 dot = /*#__PURE__*/cloneElement(activeDot, dotProps);
49 } else if (typeof activeDot === 'function') {
50 dot = activeDot(dotProps);
51 } else {
52 dot = /*#__PURE__*/React.createElement(Dot, dotProps);
53 }
54 return /*#__PURE__*/React.createElement(Layer, {
55 className: "recharts-active-dot",
56 clipPath: clipPath
57 }, dot);
58};
59export function ActivePoints(_ref2) {
60 var {
61 points,
62 mainColor,
63 activeDot,
64 itemDataKey,
65 clipPath,
66 zIndex = DefaultZIndexes.activeDot
67 } = _ref2;
68 var activeTooltipIndex = useAppSelector(selectActiveTooltipIndex);
69 var activeDataPoints = useActiveTooltipDataPoints();
70 if (points == null || activeDataPoints == null) {
71 return null;
72 }
73 var activePoint = points.find(p => activeDataPoints.includes(p.payload));
74 if (isNullish(activePoint)) {
75 return null;
76 }
77 return /*#__PURE__*/React.createElement(ZIndexLayer, {
78 zIndex: zIndex
79 }, /*#__PURE__*/React.createElement(ActivePoint, {
80 point: activePoint,
81 childIndex: Number(activeTooltipIndex),
82 mainColor: mainColor,
83 dataKey: itemDataKey,
84 activeDot: activeDot,
85 clipPath: clipPath
86 }));
87}
Note: See TracBrowser for help on using the repository browser.