| 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 { selectChartHeight, selectChartWidth } from './containerSelectors';
|
|---|
| 8 | import { selectChartOffsetInternal } from './selectChartOffsetInternal';
|
|---|
| 9 | import { getMaxRadius } from '../../util/PolarUtils';
|
|---|
| 10 | import { getPercentValue } from '../../util/DataUtils';
|
|---|
| 11 | import { defaultPolarAngleAxisProps } from '../../polar/defaultPolarAngleAxisProps';
|
|---|
| 12 | import { defaultPolarRadiusAxisProps } from '../../polar/defaultPolarRadiusAxisProps';
|
|---|
| 13 | import { combineAxisRangeWithReverse } from './combiners/combineAxisRangeWithReverse';
|
|---|
| 14 | import { selectChartLayout, selectPolarChartLayout } from '../../context/chartLayoutContext';
|
|---|
| 15 | import { getAxisTypeBasedOnLayout } from '../../util/getAxisTypeBasedOnLayout';
|
|---|
| 16 | export var implicitAngleAxis = {
|
|---|
| 17 | allowDataOverflow: defaultPolarAngleAxisProps.allowDataOverflow,
|
|---|
| 18 | allowDecimals: defaultPolarAngleAxisProps.allowDecimals,
|
|---|
| 19 | allowDuplicatedCategory: false,
|
|---|
| 20 | // defaultPolarAngleAxisProps.allowDuplicatedCategory has it set to true but the actual axis rendering ignores the prop because reasons,
|
|---|
| 21 | dataKey: undefined,
|
|---|
| 22 | domain: undefined,
|
|---|
| 23 | id: defaultPolarAngleAxisProps.angleAxisId,
|
|---|
| 24 | includeHidden: false,
|
|---|
| 25 | name: undefined,
|
|---|
| 26 | reversed: defaultPolarAngleAxisProps.reversed,
|
|---|
| 27 | scale: defaultPolarAngleAxisProps.scale,
|
|---|
| 28 | tick: defaultPolarAngleAxisProps.tick,
|
|---|
| 29 | tickCount: undefined,
|
|---|
| 30 | ticks: undefined,
|
|---|
| 31 | type: defaultPolarAngleAxisProps.type,
|
|---|
| 32 | unit: undefined
|
|---|
| 33 | };
|
|---|
| 34 | export var implicitRadiusAxis = {
|
|---|
| 35 | allowDataOverflow: defaultPolarRadiusAxisProps.allowDataOverflow,
|
|---|
| 36 | allowDecimals: defaultPolarRadiusAxisProps.allowDecimals,
|
|---|
| 37 | allowDuplicatedCategory: defaultPolarRadiusAxisProps.allowDuplicatedCategory,
|
|---|
| 38 | dataKey: undefined,
|
|---|
| 39 | domain: undefined,
|
|---|
| 40 | id: defaultPolarRadiusAxisProps.radiusAxisId,
|
|---|
| 41 | includeHidden: defaultPolarRadiusAxisProps.includeHidden,
|
|---|
| 42 | name: undefined,
|
|---|
| 43 | reversed: defaultPolarRadiusAxisProps.reversed,
|
|---|
| 44 | scale: defaultPolarRadiusAxisProps.scale,
|
|---|
| 45 | tick: defaultPolarRadiusAxisProps.tick,
|
|---|
| 46 | tickCount: defaultPolarRadiusAxisProps.tickCount,
|
|---|
| 47 | ticks: undefined,
|
|---|
| 48 | type: defaultPolarRadiusAxisProps.type,
|
|---|
| 49 | unit: undefined
|
|---|
| 50 | };
|
|---|
| 51 | var selectAngleAxisNoDefaults = (state, angleAxisId) => {
|
|---|
| 52 | if (angleAxisId == null) {
|
|---|
| 53 | return undefined;
|
|---|
| 54 | }
|
|---|
| 55 | return state.polarAxis.angleAxis[angleAxisId];
|
|---|
| 56 | };
|
|---|
| 57 | export var selectAngleAxis = createSelector([selectAngleAxisNoDefaults, selectPolarChartLayout], (angleAxisSettings, layout) => {
|
|---|
| 58 | var _getAxisTypeBasedOnLa;
|
|---|
| 59 | if (angleAxisSettings != null) {
|
|---|
| 60 | return angleAxisSettings;
|
|---|
| 61 | }
|
|---|
| 62 | var evaluatedType = (_getAxisTypeBasedOnLa = getAxisTypeBasedOnLayout(layout, 'angleAxis', implicitAngleAxis.type)) !== null && _getAxisTypeBasedOnLa !== void 0 ? _getAxisTypeBasedOnLa : 'category';
|
|---|
| 63 | return _objectSpread(_objectSpread({}, implicitAngleAxis), {}, {
|
|---|
| 64 | type: evaluatedType
|
|---|
| 65 | });
|
|---|
| 66 | });
|
|---|
| 67 | var selectRadiusAxisNoDefaults = (state, radiusAxisId) => {
|
|---|
| 68 | return state.polarAxis.radiusAxis[radiusAxisId];
|
|---|
| 69 | };
|
|---|
| 70 | export var selectRadiusAxis = createSelector([selectRadiusAxisNoDefaults, selectPolarChartLayout], (radiusAxisSettings, layout) => {
|
|---|
| 71 | var _getAxisTypeBasedOnLa2;
|
|---|
| 72 | if (radiusAxisSettings != null) {
|
|---|
| 73 | return radiusAxisSettings;
|
|---|
| 74 | }
|
|---|
| 75 | var evaluatedType = (_getAxisTypeBasedOnLa2 = getAxisTypeBasedOnLayout(layout, 'radiusAxis', implicitRadiusAxis.type)) !== null && _getAxisTypeBasedOnLa2 !== void 0 ? _getAxisTypeBasedOnLa2 : 'category';
|
|---|
| 76 | return _objectSpread(_objectSpread({}, implicitRadiusAxis), {}, {
|
|---|
| 77 | type: evaluatedType
|
|---|
| 78 | });
|
|---|
| 79 | });
|
|---|
| 80 | export var selectPolarOptions = state => state.polarOptions;
|
|---|
| 81 | export var selectMaxRadius = createSelector([selectChartWidth, selectChartHeight, selectChartOffsetInternal], getMaxRadius);
|
|---|
| 82 | var selectInnerRadius = createSelector([selectPolarOptions, selectMaxRadius], (polarChartOptions, maxRadius) => {
|
|---|
| 83 | if (polarChartOptions == null) {
|
|---|
| 84 | return undefined;
|
|---|
| 85 | }
|
|---|
| 86 | return getPercentValue(polarChartOptions.innerRadius, maxRadius, 0);
|
|---|
| 87 | });
|
|---|
| 88 | export var selectOuterRadius = createSelector([selectPolarOptions, selectMaxRadius], (polarChartOptions, maxRadius) => {
|
|---|
| 89 | if (polarChartOptions == null) {
|
|---|
| 90 | return undefined;
|
|---|
| 91 | }
|
|---|
| 92 | return getPercentValue(polarChartOptions.outerRadius, maxRadius, maxRadius * 0.8);
|
|---|
| 93 | });
|
|---|
| 94 | var combineAngleAxisRange = polarOptions => {
|
|---|
| 95 | if (polarOptions == null) {
|
|---|
| 96 | return [0, 0];
|
|---|
| 97 | }
|
|---|
| 98 | var {
|
|---|
| 99 | startAngle,
|
|---|
| 100 | endAngle
|
|---|
| 101 | } = polarOptions;
|
|---|
| 102 | return [startAngle, endAngle];
|
|---|
| 103 | };
|
|---|
| 104 | export var selectAngleAxisRange = createSelector([selectPolarOptions], combineAngleAxisRange);
|
|---|
| 105 | export var selectAngleAxisRangeWithReversed = createSelector([selectAngleAxis, selectAngleAxisRange], combineAxisRangeWithReverse);
|
|---|
| 106 | export var selectRadiusAxisRange = createSelector([selectMaxRadius, selectInnerRadius, selectOuterRadius], (maxRadius, innerRadius, outerRadius) => {
|
|---|
| 107 | if (maxRadius == null || innerRadius == null || outerRadius == null) {
|
|---|
| 108 | return undefined;
|
|---|
| 109 | }
|
|---|
| 110 | return [innerRadius, outerRadius];
|
|---|
| 111 | });
|
|---|
| 112 | export var selectRadiusAxisRangeWithReversed = createSelector([selectRadiusAxis, selectRadiusAxisRange], combineAxisRangeWithReverse);
|
|---|
| 113 | export var selectPolarViewBox = createSelector([selectChartLayout, selectPolarOptions, selectInnerRadius, selectOuterRadius, selectChartWidth, selectChartHeight], (layout, polarOptions, innerRadius, outerRadius, width, height) => {
|
|---|
| 114 | if (layout !== 'centric' && layout !== 'radial' || polarOptions == null || innerRadius == null || outerRadius == null) {
|
|---|
| 115 | return undefined;
|
|---|
| 116 | }
|
|---|
| 117 | var {
|
|---|
| 118 | cx,
|
|---|
| 119 | cy,
|
|---|
| 120 | startAngle,
|
|---|
| 121 | endAngle
|
|---|
| 122 | } = polarOptions;
|
|---|
| 123 | return {
|
|---|
| 124 | cx: getPercentValue(cx, width, width / 2),
|
|---|
| 125 | cy: getPercentValue(cy, height, height / 2),
|
|---|
| 126 | innerRadius,
|
|---|
| 127 | outerRadius,
|
|---|
| 128 | startAngle,
|
|---|
| 129 | endAngle,
|
|---|
| 130 | clockWise: false // this property look useful, why not use it?
|
|---|
| 131 | };
|
|---|
| 132 | }); |
|---|