source: node_modules/recharts/es6/container/RootSurface.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: 3.9 KB
Line 
1var _excluded = ["children"];
2function _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; }
3function _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; }
4function _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); }
5import * as React from 'react';
6import { forwardRef } from 'react';
7import { useChartHeight, useChartWidth } from '../context/chartLayoutContext';
8import { useAccessibilityLayer } from '../context/accessibilityContext';
9import { useIsPanorama } from '../context/PanoramaContext';
10import { Surface } from './Surface';
11import { useAppSelector } from '../state/hooks';
12import { selectBrushDimensions } from '../state/selectors/brushSelectors';
13import { isPositiveNumber } from '../util/isWellBehavedNumber';
14import { AllZIndexPortals } from '../zIndex/ZIndexPortal';
15var FULL_WIDTH_AND_HEIGHT = {
16 width: '100%',
17 height: '100%',
18 /*
19 * display: block is necessary here because the default for an SVG is display: inline,
20 * which in some browsers (Chrome) adds a little bit of extra space above and below the SVG
21 * to make space for the descender of letters like "g" and "y". This throws off the height calculation
22 * and causes the container to grow indefinitely on each render with responsive=true.
23 * Display: block removes that extra space.
24 *
25 * Interestingly, Firefox does not have this problem, but it doesn't hurt to add the style anyway.
26 */
27 display: 'block'
28};
29var MainChartSurface = /*#__PURE__*/forwardRef((props, ref) => {
30 var width = useChartWidth();
31 var height = useChartHeight();
32 var hasAccessibilityLayer = useAccessibilityLayer();
33 if (!isPositiveNumber(width) || !isPositiveNumber(height)) {
34 return null;
35 }
36 var {
37 children,
38 otherAttributes,
39 title,
40 desc
41 } = props;
42 var tabIndex, role;
43 if (otherAttributes != null) {
44 if (typeof otherAttributes.tabIndex === 'number') {
45 tabIndex = otherAttributes.tabIndex;
46 } else {
47 tabIndex = hasAccessibilityLayer ? 0 : undefined;
48 }
49 if (typeof otherAttributes.role === 'string') {
50 role = otherAttributes.role;
51 } else {
52 role = hasAccessibilityLayer ? 'application' : undefined;
53 }
54 }
55 return /*#__PURE__*/React.createElement(Surface, _extends({}, otherAttributes, {
56 title: title,
57 desc: desc,
58 role: role,
59 tabIndex: tabIndex,
60 width: width,
61 height: height,
62 style: FULL_WIDTH_AND_HEIGHT,
63 ref: ref
64 }), children);
65});
66var BrushPanoramaSurface = _ref => {
67 var {
68 children
69 } = _ref;
70 var brushDimensions = useAppSelector(selectBrushDimensions);
71 if (!brushDimensions) {
72 return null;
73 }
74 var {
75 width,
76 height,
77 y,
78 x
79 } = brushDimensions;
80 return /*#__PURE__*/React.createElement(Surface, {
81 width: width,
82 height: height,
83 x: x,
84 y: y
85 }, children);
86};
87export var RootSurface = /*#__PURE__*/forwardRef((_ref2, ref) => {
88 var {
89 children
90 } = _ref2,
91 rest = _objectWithoutProperties(_ref2, _excluded);
92 var isPanorama = useIsPanorama();
93 if (isPanorama) {
94 return /*#__PURE__*/React.createElement(BrushPanoramaSurface, null, /*#__PURE__*/React.createElement(AllZIndexPortals, {
95 isPanorama: true
96 }, children));
97 }
98 return /*#__PURE__*/React.createElement(MainChartSurface, _extends({
99 ref: ref
100 }, rest), /*#__PURE__*/React.createElement(AllZIndexPortals, {
101 isPanorama: false
102 }, children));
103});
Note: See TracBrowser for help on using the repository browser.