source: node_modules/recharts/lib/cartesian/GraphicalItemClipPath.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: 2.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.GraphicalItemClipPath = GraphicalItemClipPath;
7exports.useNeedsClip = useNeedsClip;
8var React = _interopRequireWildcard(require("react"));
9var _hooks = require("../state/hooks");
10var _axisSelectors = require("../state/selectors/axisSelectors");
11var _hooks2 = require("../hooks");
12function _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); }
13function useNeedsClip(xAxisId, yAxisId) {
14 var _xAxis$allowDataOverf, _yAxis$allowDataOverf;
15 var xAxis = (0, _hooks.useAppSelector)(state => (0, _axisSelectors.selectXAxisSettings)(state, xAxisId));
16 var yAxis = (0, _hooks.useAppSelector)(state => (0, _axisSelectors.selectYAxisSettings)(state, yAxisId));
17 var needClipX = (_xAxis$allowDataOverf = xAxis === null || xAxis === void 0 ? void 0 : xAxis.allowDataOverflow) !== null && _xAxis$allowDataOverf !== void 0 ? _xAxis$allowDataOverf : _axisSelectors.implicitXAxis.allowDataOverflow;
18 var needClipY = (_yAxis$allowDataOverf = yAxis === null || yAxis === void 0 ? void 0 : yAxis.allowDataOverflow) !== null && _yAxis$allowDataOverf !== void 0 ? _yAxis$allowDataOverf : _axisSelectors.implicitYAxis.allowDataOverflow;
19 var needClip = needClipX || needClipY;
20 return {
21 needClip,
22 needClipX,
23 needClipY
24 };
25}
26function GraphicalItemClipPath(_ref) {
27 var {
28 xAxisId,
29 yAxisId,
30 clipPathId
31 } = _ref;
32 var plotArea = (0, _hooks2.usePlotArea)();
33 var {
34 needClipX,
35 needClipY,
36 needClip
37 } = useNeedsClip(xAxisId, yAxisId);
38 if (!needClip || !plotArea) {
39 return null;
40 }
41 var {
42 x,
43 y,
44 width,
45 height
46 } = plotArea;
47 return /*#__PURE__*/React.createElement("clipPath", {
48 id: "clipPath-".concat(clipPathId)
49 }, /*#__PURE__*/React.createElement("rect", {
50 x: needClipX ? x : x - width / 2,
51 y: needClipY ? y : y - height / 2,
52 width: needClipX ? width : width * 2,
53 height: needClipY ? height : height * 2
54 }));
55}
Note: See TracBrowser for help on using the repository browser.