source: node_modules/recharts/es6/state/selectors/radarSelectors.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: 5.1 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 { createSelector } from 'reselect';
7import { computeRadarPoints } from '../../polar/Radar';
8import { selectPolarAxisScale, selectPolarAxisTicks } from './polarScaleSelectors';
9import { selectAngleAxis, selectPolarViewBox, selectRadiusAxis } from './polarAxisSelectors';
10import { selectChartDataAndAlwaysIgnoreIndexes } from './dataSelectors';
11import { selectChartLayout } from '../../context/chartLayoutContext';
12import { getBandSizeOfAxis, isCategoricalAxis } from '../../util/ChartUtils';
13import { selectUnfilteredPolarItems } from './polarSelectors';
14var selectRadiusAxisScale = (state, radiusAxisId) => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId);
15var selectRadiusAxisForRadar = createSelector([selectRadiusAxisScale], scale => {
16 if (scale == null) {
17 return undefined;
18 }
19 return {
20 scale
21 };
22});
23export var selectRadiusAxisForBandSize = createSelector([selectRadiusAxis, selectRadiusAxisScale], (axisSettings, scale) => {
24 if (axisSettings == null || scale == null) {
25 return undefined;
26 }
27 return _objectSpread(_objectSpread({}, axisSettings), {}, {
28 scale
29 });
30});
31var selectRadiusAxisTicks = (state, radiusAxisId, _angleAxisId, isPanorama) => {
32 return selectPolarAxisTicks(state, 'radiusAxis', radiusAxisId, isPanorama);
33};
34var selectAngleAxisForRadar = (state, _radiusAxisId, angleAxisId) => selectAngleAxis(state, angleAxisId);
35var selectPolarAxisScaleForRadar = (state, _radiusAxisId, angleAxisId) => selectPolarAxisScale(state, 'angleAxis', angleAxisId);
36export var selectAngleAxisForBandSize = createSelector([selectAngleAxisForRadar, selectPolarAxisScaleForRadar], (axisSettings, scale) => {
37 if (axisSettings == null || scale == null) {
38 return undefined;
39 }
40 return _objectSpread(_objectSpread({}, axisSettings), {}, {
41 scale
42 });
43});
44var selectAngleAxisTicks = (state, _radiusAxisId, angleAxisId, isPanorama) => {
45 return selectPolarAxisTicks(state, 'angleAxis', angleAxisId, isPanorama);
46};
47export var selectAngleAxisWithScaleAndViewport = createSelector([selectAngleAxisForRadar, selectPolarAxisScaleForRadar, selectPolarViewBox], (axisOptions, scale, polarViewBox) => {
48 if (polarViewBox == null || scale == null) {
49 return undefined;
50 }
51 return {
52 scale,
53 type: axisOptions.type,
54 dataKey: axisOptions.dataKey,
55 cx: polarViewBox.cx,
56 cy: polarViewBox.cy
57 };
58});
59var pickId = (_state, _radiusAxisId, _angleAxisId, _isPanorama, radarId) => radarId;
60var selectBandSizeOfAxis = createSelector([selectChartLayout, selectRadiusAxisForBandSize, selectRadiusAxisTicks, selectAngleAxisForBandSize, selectAngleAxisTicks], (layout, radiusAxis, radiusAxisTicks, angleAxis, angleAxisTicks) => {
61 if (isCategoricalAxis(layout, 'radiusAxis')) {
62 return getBandSizeOfAxis(radiusAxis, radiusAxisTicks, false);
63 }
64 return getBandSizeOfAxis(angleAxis, angleAxisTicks, false);
65});
66var selectSynchronisedRadarDataKey = createSelector([selectUnfilteredPolarItems, pickId], (graphicalItems, radarId) => {
67 if (graphicalItems == null) {
68 return undefined;
69 }
70 // Find the radar item with the given radarId
71 var pgis = graphicalItems.find(item => item.type === 'radar' && radarId === item.id);
72 // If found, return its dataKey
73 return pgis === null || pgis === void 0 ? void 0 : pgis.dataKey;
74});
75export var selectRadarPoints = createSelector([selectRadiusAxisForRadar, selectAngleAxisWithScaleAndViewport, selectChartDataAndAlwaysIgnoreIndexes, selectSynchronisedRadarDataKey, selectBandSizeOfAxis], (radiusAxis, angleAxis, _ref, dataKey, bandSize) => {
76 var {
77 chartData,
78 dataStartIndex,
79 dataEndIndex
80 } = _ref;
81 if (radiusAxis == null || angleAxis == null || chartData == null || bandSize == null || dataKey == null) {
82 return undefined;
83 }
84 var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
85 return computeRadarPoints({
86 radiusAxis,
87 angleAxis,
88 displayedData,
89 dataKey,
90 bandSize
91 });
92});
Note: See TracBrowser for help on using the repository browser.