| 1 | function 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; }
|
|---|
| 2 | function _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; }
|
|---|
| 3 | function _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; }
|
|---|
| 4 | function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|---|
| 5 | function _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); }
|
|---|
| 6 | import { createSelector } from 'reselect';
|
|---|
| 7 | import { computeRadarPoints } from '../../polar/Radar';
|
|---|
| 8 | import { selectPolarAxisScale, selectPolarAxisTicks } from './polarScaleSelectors';
|
|---|
| 9 | import { selectAngleAxis, selectPolarViewBox, selectRadiusAxis } from './polarAxisSelectors';
|
|---|
| 10 | import { selectChartDataAndAlwaysIgnoreIndexes } from './dataSelectors';
|
|---|
| 11 | import { selectChartLayout } from '../../context/chartLayoutContext';
|
|---|
| 12 | import { getBandSizeOfAxis, isCategoricalAxis } from '../../util/ChartUtils';
|
|---|
| 13 | import { selectUnfilteredPolarItems } from './polarSelectors';
|
|---|
| 14 | var selectRadiusAxisScale = (state, radiusAxisId) => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId);
|
|---|
| 15 | var selectRadiusAxisForRadar = createSelector([selectRadiusAxisScale], scale => {
|
|---|
| 16 | if (scale == null) {
|
|---|
| 17 | return undefined;
|
|---|
| 18 | }
|
|---|
| 19 | return {
|
|---|
| 20 | scale
|
|---|
| 21 | };
|
|---|
| 22 | });
|
|---|
| 23 | export 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 | });
|
|---|
| 31 | var selectRadiusAxisTicks = (state, radiusAxisId, _angleAxisId, isPanorama) => {
|
|---|
| 32 | return selectPolarAxisTicks(state, 'radiusAxis', radiusAxisId, isPanorama);
|
|---|
| 33 | };
|
|---|
| 34 | var selectAngleAxisForRadar = (state, _radiusAxisId, angleAxisId) => selectAngleAxis(state, angleAxisId);
|
|---|
| 35 | var selectPolarAxisScaleForRadar = (state, _radiusAxisId, angleAxisId) => selectPolarAxisScale(state, 'angleAxis', angleAxisId);
|
|---|
| 36 | export 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 | });
|
|---|
| 44 | var selectAngleAxisTicks = (state, _radiusAxisId, angleAxisId, isPanorama) => {
|
|---|
| 45 | return selectPolarAxisTicks(state, 'angleAxis', angleAxisId, isPanorama);
|
|---|
| 46 | };
|
|---|
| 47 | export 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 | });
|
|---|
| 59 | var pickId = (_state, _radiusAxisId, _angleAxisId, _isPanorama, radarId) => radarId;
|
|---|
| 60 | var 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 | });
|
|---|
| 66 | var 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 | });
|
|---|
| 75 | export 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 | }); |
|---|