| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.GraphicalItemClipPath = GraphicalItemClipPath;
|
|---|
| 7 | exports.useNeedsClip = useNeedsClip;
|
|---|
| 8 | var React = _interopRequireWildcard(require("react"));
|
|---|
| 9 | var _hooks = require("../state/hooks");
|
|---|
| 10 | var _axisSelectors = require("../state/selectors/axisSelectors");
|
|---|
| 11 | var _hooks2 = require("../hooks");
|
|---|
| 12 | function _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); }
|
|---|
| 13 | function 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 | }
|
|---|
| 26 | function 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 | } |
|---|