| [a762898] | 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 { computeRadialBarDataItems } from '../../polar/RadialBar';
|
|---|
| 8 | import { selectChartDataAndAlwaysIgnoreIndexes, selectChartDataWithIndexes } from './dataSelectors';
|
|---|
| 9 | import { selectPolarAxisScale, selectPolarAxisTicks, selectPolarGraphicalItemAxisTicks } from './polarScaleSelectors';
|
|---|
| 10 | import { combineStackGroups, selectTooltipAxis } from './axisSelectors';
|
|---|
| 11 | import { selectAngleAxis, selectPolarViewBox, selectRadiusAxis } from './polarAxisSelectors';
|
|---|
| 12 | import { selectChartLayout } from '../../context/chartLayoutContext';
|
|---|
| 13 | import { getBandSizeOfAxis, getBaseValueOfBar, isCategoricalAxis } from '../../util/ChartUtils';
|
|---|
| 14 | import { selectBarCategoryGap, selectBarGap, selectReverseStackOrder, selectRootBarSize, selectRootMaxBarSize, selectStackOffsetType } from './rootPropsSelectors';
|
|---|
| 15 | import { selectPolarItemsSettings, selectUnfilteredPolarItems } from './polarSelectors';
|
|---|
| 16 | import { isNullish } from '../../util/DataUtils';
|
|---|
| 17 | import { combineDisplayedStackedData } from './combiners/combineDisplayedStackedData';
|
|---|
| 18 | import { isStacked } from '../types/StackedGraphicalItem';
|
|---|
| 19 | import { combineBarSizeList } from './combiners/combineBarSizeList';
|
|---|
| 20 | import { combineAllBarPositions } from './combiners/combineAllBarPositions';
|
|---|
| 21 | import { combineStackedData } from './combiners/combineStackedData';
|
|---|
| 22 | import { combineBarPosition } from './combiners/combineBarPosition';
|
|---|
| 23 | var selectRadiusAxisForRadialBar = (state, radiusAxisId) => selectRadiusAxis(state, radiusAxisId);
|
|---|
| 24 | var selectRadiusAxisScaleForRadar = (state, radiusAxisId) => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId);
|
|---|
| 25 | export var selectRadiusAxisWithScale = createSelector([selectRadiusAxisForRadialBar, selectRadiusAxisScaleForRadar], (axis, scale) => {
|
|---|
| 26 | if (axis == null || scale == null) {
|
|---|
| 27 | return undefined;
|
|---|
| 28 | }
|
|---|
| 29 | return _objectSpread(_objectSpread({}, axis), {}, {
|
|---|
| 30 | scale
|
|---|
| 31 | });
|
|---|
| 32 | });
|
|---|
| 33 | export var selectRadiusAxisTicks = (state, radiusAxisId) => {
|
|---|
| 34 | return selectPolarGraphicalItemAxisTicks(state, 'radiusAxis', radiusAxisId, false);
|
|---|
| 35 | };
|
|---|
| 36 | var selectAngleAxisForRadialBar = (state, _radiusAxisId, angleAxisId) => selectAngleAxis(state, angleAxisId);
|
|---|
| 37 | var selectAngleAxisScaleForRadialBar = (state, _radiusAxisId, angleAxisId) => selectPolarAxisScale(state, 'angleAxis', angleAxisId);
|
|---|
| 38 | export var selectAngleAxisWithScale = createSelector([selectAngleAxisForRadialBar, selectAngleAxisScaleForRadialBar], (axis, scale) => {
|
|---|
| 39 | if (axis == null || scale == null) {
|
|---|
| 40 | return undefined;
|
|---|
| 41 | }
|
|---|
| 42 | return _objectSpread(_objectSpread({}, axis), {}, {
|
|---|
| 43 | scale
|
|---|
| 44 | });
|
|---|
| 45 | });
|
|---|
| 46 | var selectAngleAxisTicks = (state, _radiusAxisId, angleAxisId) => {
|
|---|
| 47 | // here we can hardcode isPanorama to false because radialBar does not support panorama mode
|
|---|
| 48 | return selectPolarAxisTicks(state, 'angleAxis', angleAxisId, false);
|
|---|
| 49 | };
|
|---|
| 50 | var pickRadialBarSettings = (_state, _radiusAxisId, _angleAxisId, radialBarSettings) => radialBarSettings;
|
|---|
| 51 | var selectSynchronisedRadialBarSettings = createSelector([selectUnfilteredPolarItems, pickRadialBarSettings], (graphicalItems, radialBarSettingsFromProps) => {
|
|---|
| 52 | if (graphicalItems.some(pgis => pgis.type === 'radialBar' && radialBarSettingsFromProps.dataKey === pgis.dataKey && radialBarSettingsFromProps.stackId === pgis.stackId)) {
|
|---|
| 53 | return radialBarSettingsFromProps;
|
|---|
| 54 | }
|
|---|
| 55 | return undefined;
|
|---|
| 56 | });
|
|---|
| 57 | export var selectBandSizeOfPolarAxis = createSelector([selectChartLayout, selectRadiusAxisWithScale, selectRadiusAxisTicks, selectAngleAxisWithScale, selectAngleAxisTicks], (layout, radiusAxis, radiusAxisTicks, angleAxis, angleAxisTicks) => {
|
|---|
| 58 | if (isCategoricalAxis(layout, 'radiusAxis')) {
|
|---|
| 59 | return getBandSizeOfAxis(radiusAxis, radiusAxisTicks, false);
|
|---|
| 60 | }
|
|---|
| 61 | return getBandSizeOfAxis(angleAxis, angleAxisTicks, false);
|
|---|
| 62 | });
|
|---|
| 63 | export var selectBaseValue = createSelector([selectAngleAxisWithScale, selectRadiusAxisWithScale, selectChartLayout], (angleAxis, radiusAxis, layout) => {
|
|---|
| 64 | var numericAxis = layout === 'radial' ? angleAxis : radiusAxis;
|
|---|
| 65 | if (numericAxis == null || numericAxis.scale == null) {
|
|---|
| 66 | return undefined;
|
|---|
| 67 | }
|
|---|
| 68 | return getBaseValueOfBar({
|
|---|
| 69 | numericAxis
|
|---|
| 70 | });
|
|---|
| 71 | });
|
|---|
| 72 | var pickCells = (_state, _radiusAxisId, _angleAxisId, _radialBarSettings, cells) => cells;
|
|---|
| 73 | var pickAngleAxisId = (_state, _radiusAxisId, angleAxisId, _radialBarSettings, _cells) => angleAxisId;
|
|---|
| 74 | var pickRadiusAxisId = (_state, radiusAxisId, _angleAxisId, _radialBarSettings, _cells) => radiusAxisId;
|
|---|
| 75 | export var pickMaxBarSize = (_state, _radiusAxisId, _angleAxisId, radialBarSettings, _cells) => radialBarSettings.maxBarSize;
|
|---|
| 76 | var isRadialBar = item => item.type === 'radialBar';
|
|---|
| 77 | var selectAllVisibleRadialBars = createSelector([selectChartLayout, selectUnfilteredPolarItems, pickAngleAxisId, pickRadiusAxisId], (layout, allItems, angleAxisId, radiusAxisId) => {
|
|---|
| 78 | return allItems.filter(i => {
|
|---|
| 79 | if (layout === 'centric') {
|
|---|
| 80 | return i.angleAxisId === angleAxisId;
|
|---|
| 81 | }
|
|---|
| 82 | return i.radiusAxisId === radiusAxisId;
|
|---|
| 83 | }).filter(i => i.hide === false).filter(isRadialBar);
|
|---|
| 84 | });
|
|---|
| 85 |
|
|---|
| 86 | /**
|
|---|
| 87 | * The generator never returned the totalSize which means that barSize in polar chart can not support percent values.
|
|---|
| 88 | * We can add that if we want to I suppose.
|
|---|
| 89 | * @returns undefined - but it should be a total size of numerical axis in polar chart
|
|---|
| 90 | */
|
|---|
| 91 | var selectPolarBarAxisSize = () => undefined;
|
|---|
| 92 | export var selectPolarBarSizeList = createSelector([selectAllVisibleRadialBars, selectRootBarSize, selectPolarBarAxisSize], combineBarSizeList);
|
|---|
| 93 | export var selectPolarBarBandSize = createSelector([selectChartLayout, selectRootMaxBarSize, selectAngleAxisWithScale, selectAngleAxisTicks, selectRadiusAxisWithScale, selectRadiusAxisTicks, pickMaxBarSize], (layout, globalMaxBarSize, angleAxis, angleAxisTicks, radiusAxis, radiusAxisTicks, childMaxBarSize) => {
|
|---|
| 94 | var _ref2, _getBandSizeOfAxis2;
|
|---|
| 95 | var maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
|
|---|
| 96 | if (layout === 'centric') {
|
|---|
| 97 | var _ref, _getBandSizeOfAxis;
|
|---|
| 98 | return (_ref = (_getBandSizeOfAxis = getBandSizeOfAxis(angleAxis, angleAxisTicks, true)) !== null && _getBandSizeOfAxis !== void 0 ? _getBandSizeOfAxis : maxBarSize) !== null && _ref !== void 0 ? _ref : 0;
|
|---|
| 99 | }
|
|---|
| 100 | return (_ref2 = (_getBandSizeOfAxis2 = getBandSizeOfAxis(radiusAxis, radiusAxisTicks, true)) !== null && _getBandSizeOfAxis2 !== void 0 ? _getBandSizeOfAxis2 : maxBarSize) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
|---|
| 101 | });
|
|---|
| 102 | export var selectAllPolarBarPositions = createSelector([selectPolarBarSizeList, selectRootMaxBarSize, selectBarGap, selectBarCategoryGap, selectPolarBarBandSize, selectBandSizeOfPolarAxis, pickMaxBarSize], combineAllBarPositions);
|
|---|
| 103 | export var selectPolarBarPosition = createSelector([selectAllPolarBarPositions, selectSynchronisedRadialBarSettings], combineBarPosition);
|
|---|
| 104 | var selectStackedRadialBars = createSelector([selectPolarItemsSettings], allPolarItems => allPolarItems.filter(isRadialBar).filter(isStacked));
|
|---|
| 105 | var selectPolarCombinedStackedData = createSelector([selectStackedRadialBars, selectChartDataAndAlwaysIgnoreIndexes, selectTooltipAxis], combineDisplayedStackedData);
|
|---|
| 106 | var selectStackGroups = createSelector([selectPolarCombinedStackedData, selectStackedRadialBars, selectStackOffsetType, selectReverseStackOrder], combineStackGroups);
|
|---|
| 107 | var selectRadialBarStackGroups = (state, radiusAxisId, angleAxisId) => {
|
|---|
| 108 | var layout = selectChartLayout(state);
|
|---|
| 109 | if (layout === 'centric') {
|
|---|
| 110 | return selectStackGroups(state, 'radiusAxis', radiusAxisId);
|
|---|
| 111 | }
|
|---|
| 112 | return selectStackGroups(state, 'angleAxis', angleAxisId);
|
|---|
| 113 | };
|
|---|
| 114 | var selectPolarStackedData = createSelector([selectRadialBarStackGroups, selectSynchronisedRadialBarSettings], combineStackedData);
|
|---|
| 115 | export var selectRadialBarSectors = createSelector([selectAngleAxisWithScale, selectAngleAxisTicks, selectRadiusAxisWithScale, selectRadiusAxisTicks, selectChartDataWithIndexes, selectSynchronisedRadialBarSettings, selectBandSizeOfPolarAxis, selectChartLayout, selectBaseValue, selectPolarViewBox, pickCells, selectPolarBarPosition, selectPolarStackedData], (angleAxis, angleAxisTicks, radiusAxis, radiusAxisTicks, _ref3, radialBarSettings, bandSize, layout, baseValue, polarViewBox, cells, pos, stackedData) => {
|
|---|
| 116 | var {
|
|---|
| 117 | chartData,
|
|---|
| 118 | dataStartIndex,
|
|---|
| 119 | dataEndIndex
|
|---|
| 120 | } = _ref3;
|
|---|
| 121 | if (radialBarSettings == null || radiusAxis == null || angleAxis == null || chartData == null || bandSize == null || pos == null || layout !== 'centric' && layout !== 'radial' || radiusAxisTicks == null || polarViewBox == null) {
|
|---|
| 122 | return [];
|
|---|
| 123 | }
|
|---|
| 124 | var {
|
|---|
| 125 | dataKey,
|
|---|
| 126 | minPointSize
|
|---|
| 127 | } = radialBarSettings;
|
|---|
| 128 | var {
|
|---|
| 129 | cx,
|
|---|
| 130 | cy,
|
|---|
| 131 | startAngle,
|
|---|
| 132 | endAngle
|
|---|
| 133 | } = polarViewBox;
|
|---|
| 134 | var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
|
|---|
| 135 | var numericAxis = layout === 'centric' ? radiusAxis : angleAxis;
|
|---|
| 136 | var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
|
|---|
| 137 | return computeRadialBarDataItems({
|
|---|
| 138 | angleAxis,
|
|---|
| 139 | angleAxisTicks,
|
|---|
| 140 | bandSize,
|
|---|
| 141 | baseValue,
|
|---|
| 142 | cells,
|
|---|
| 143 | cx,
|
|---|
| 144 | cy,
|
|---|
| 145 | dataKey,
|
|---|
| 146 | dataStartIndex,
|
|---|
| 147 | displayedData,
|
|---|
| 148 | endAngle,
|
|---|
| 149 | layout,
|
|---|
| 150 | minPointSize,
|
|---|
| 151 | pos,
|
|---|
| 152 | radiusAxis,
|
|---|
| 153 | radiusAxisTicks,
|
|---|
| 154 | stackedData,
|
|---|
| 155 | stackedDomain,
|
|---|
| 156 | startAngle
|
|---|
| 157 | });
|
|---|
| 158 | });
|
|---|
| 159 | export var selectRadialBarLegendPayload = createSelector([selectChartDataAndAlwaysIgnoreIndexes, (_s, l) => l], (_ref4, legendType) => {
|
|---|
| 160 | var {
|
|---|
| 161 | chartData,
|
|---|
| 162 | dataStartIndex,
|
|---|
| 163 | dataEndIndex
|
|---|
| 164 | } = _ref4;
|
|---|
| 165 | if (chartData == null) {
|
|---|
| 166 | return [];
|
|---|
| 167 | }
|
|---|
| 168 | var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
|
|---|
| 169 | if (displayedData.length === 0) {
|
|---|
| 170 | return [];
|
|---|
| 171 | }
|
|---|
| 172 | return displayedData.map(entry => {
|
|---|
| 173 | return {
|
|---|
| 174 | type: legendType,
|
|---|
| 175 | // @ts-expect-error we need a better typing for our data inputs
|
|---|
| 176 | value: entry.name,
|
|---|
| 177 | // @ts-expect-error we need a better typing for our data inputs
|
|---|
| 178 | color: entry.fill,
|
|---|
| 179 | // @ts-expect-error we need a better typing for our data inputs
|
|---|
| 180 | payload: entry
|
|---|
| 181 | };
|
|---|
| 182 | });
|
|---|
| 183 | }); |
|---|