| 1 | import { createSelector } from 'reselect';
|
|---|
| 2 | import { combineAxisTicks, combineCategoricalDomain, combineGraphicalItemTicks, combineScaleFunction, selectRenderableAxisSettings, selectDuplicateDomain, selectRealScaleType } from './axisSelectors';
|
|---|
| 3 | import { selectAngleAxis, selectAngleAxisRangeWithReversed, selectRadiusAxis, selectRadiusAxisRangeWithReversed } from './polarAxisSelectors';
|
|---|
| 4 | import { selectChartLayout } from '../../context/chartLayoutContext';
|
|---|
| 5 | import { selectPolarAppliedValues, selectPolarAxisCheckedDomain, selectPolarNiceTicks } from './polarSelectors';
|
|---|
| 6 | import { pickAxisType } from './pickAxisType';
|
|---|
| 7 | export var selectPolarAxis = (state, axisType, axisId) => {
|
|---|
| 8 | switch (axisType) {
|
|---|
| 9 | case 'angleAxis':
|
|---|
| 10 | {
|
|---|
| 11 | return selectAngleAxis(state, axisId);
|
|---|
| 12 | }
|
|---|
| 13 | case 'radiusAxis':
|
|---|
| 14 | {
|
|---|
| 15 | return selectRadiusAxis(state, axisId);
|
|---|
| 16 | }
|
|---|
| 17 | default:
|
|---|
| 18 | {
|
|---|
| 19 | throw new Error("Unexpected axis type: ".concat(axisType));
|
|---|
| 20 | }
|
|---|
| 21 | }
|
|---|
| 22 | };
|
|---|
| 23 | var selectPolarAxisRangeWithReversed = (state, axisType, axisId) => {
|
|---|
| 24 | switch (axisType) {
|
|---|
| 25 | case 'angleAxis':
|
|---|
| 26 | {
|
|---|
| 27 | return selectAngleAxisRangeWithReversed(state, axisId);
|
|---|
| 28 | }
|
|---|
| 29 | case 'radiusAxis':
|
|---|
| 30 | {
|
|---|
| 31 | return selectRadiusAxisRangeWithReversed(state, axisId);
|
|---|
| 32 | }
|
|---|
| 33 | default:
|
|---|
| 34 | {
|
|---|
| 35 | throw new Error("Unexpected axis type: ".concat(axisType));
|
|---|
| 36 | }
|
|---|
| 37 | }
|
|---|
| 38 | };
|
|---|
| 39 | export var selectPolarAxisScale = createSelector([selectPolarAxis, selectRealScaleType, selectPolarAxisCheckedDomain, selectPolarAxisRangeWithReversed], combineScaleFunction);
|
|---|
| 40 | export var selectPolarCategoricalDomain = createSelector([selectChartLayout, selectPolarAppliedValues, selectRenderableAxisSettings, pickAxisType], combineCategoricalDomain);
|
|---|
| 41 | export var selectPolarAxisTicks = createSelector([selectChartLayout, selectPolarAxis, selectRealScaleType, selectPolarAxisScale, selectPolarNiceTicks, selectPolarAxisRangeWithReversed, selectDuplicateDomain, selectPolarCategoricalDomain, pickAxisType], combineAxisTicks);
|
|---|
| 42 | export var selectPolarAngleAxisTicks = createSelector([selectPolarAxisTicks], ticks => {
|
|---|
| 43 | /*
|
|---|
| 44 | * Angle axis is circular; so here we need to look for ticks that overlap (i.e., 0 and 360 degrees)
|
|---|
| 45 | * and remove the duplicate tick to avoid rendering issues.
|
|---|
| 46 | */
|
|---|
| 47 | if (!ticks) {
|
|---|
| 48 | return undefined;
|
|---|
| 49 | }
|
|---|
| 50 | var uniqueTicksMap = new Map();
|
|---|
| 51 | ticks.forEach(tick => {
|
|---|
| 52 | var normalizedCoordinate = (tick.coordinate + 360) % 360;
|
|---|
| 53 | if (!uniqueTicksMap.has(normalizedCoordinate)) {
|
|---|
| 54 | uniqueTicksMap.set(normalizedCoordinate, tick);
|
|---|
| 55 | }
|
|---|
| 56 | });
|
|---|
| 57 | return Array.from(uniqueTicksMap.values());
|
|---|
| 58 | });
|
|---|
| 59 | export var selectPolarGraphicalItemAxisTicks = createSelector([selectChartLayout, selectPolarAxis, selectPolarAxisScale, selectPolarAxisRangeWithReversed, selectDuplicateDomain, selectPolarCategoricalDomain, pickAxisType], combineGraphicalItemTicks); |
|---|