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