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