vccs 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cartesian/funnel/Funnel.d.ts +2 -0
- package/dist/cartesian/funnel/index.d.ts +2 -0
- package/dist/cartesian/funnel/type.d.ts +74 -5
- package/dist/cartesian/index.d.ts +1 -0
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/index.d.ts +1 -0
- package/dist/es/animation/Animate.mjs +48 -22
- package/dist/es/cartesian/GraphicalItemClipPath.mjs +16 -15
- package/dist/es/cartesian/area/ActivePoints.mjs +44 -40
- package/dist/es/cartesian/area/Area.mjs +42 -31
- package/dist/es/cartesian/area/ClipRect.mjs +79 -58
- package/dist/es/cartesian/area/RenderArea.mjs +142 -108
- package/dist/es/cartesian/area/hooks/useArea.mjs +71 -47
- package/dist/es/cartesian/area/type.mjs +11 -11
- package/dist/es/cartesian/area/utils.mjs +69 -49
- package/dist/es/cartesian/axis/XAxis.mjs +87 -73
- package/dist/es/cartesian/axis/YAxis.mjs +67 -56
- package/dist/es/cartesian/bar/Bar.mjs +93 -71
- package/dist/es/cartesian/bar/components/BarBackground.mjs +22 -19
- package/dist/es/cartesian/bar/components/BarRectangles.mjs +117 -80
- package/dist/es/cartesian/bar/hooks/useBar.mjs +49 -37
- package/dist/es/cartesian/bar/type.mjs +9 -9
- package/dist/es/cartesian/bar/utils.mjs +97 -70
- package/dist/es/cartesian/cartesian-axis/CartesianAxis.mjs +165 -115
- package/dist/es/cartesian/cartesian-grid/Background.mjs +19 -16
- package/dist/es/cartesian/cartesian-grid/CartesianGrid.mjs +116 -97
- package/dist/es/cartesian/cartesian-grid/HorizontalGridLines.mjs +24 -23
- package/dist/es/cartesian/cartesian-grid/HorizontalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/VerticalGridLines.mjs +23 -22
- package/dist/es/cartesian/cartesian-grid/VerticalStripes.mjs +24 -24
- package/dist/es/cartesian/cartesian-grid/const.mjs +317 -10
- package/dist/es/cartesian/cartesian-grid/utils.mjs +18 -13
- package/dist/es/cartesian/error-bar/ErrorBar.mjs +111 -83
- package/dist/es/cartesian/error-bar/ErrorBarContext.mjs +13 -12
- package/dist/es/cartesian/funnel/Funnel.mjs +177 -0
- package/dist/es/cartesian/funnel/type.mjs +80 -0
- package/dist/es/cartesian/funnel/utils.mjs +102 -0
- package/dist/es/cartesian/line/ActivePoints.mjs +45 -41
- package/dist/es/cartesian/line/Line.mjs +41 -37
- package/dist/es/cartesian/line/StaticLine.mjs +191 -122
- package/dist/es/cartesian/line/hooks/useLine.mjs +60 -44
- package/dist/es/cartesian/line/type.mjs +11 -11
- package/dist/es/cartesian/line/utils.mjs +27 -26
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +86 -69
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +99 -77
- package/dist/es/cartesian/scatter/Scatter.mjs +168 -140
- package/dist/es/cartesian/scatter/hooks/useScatter.mjs +18 -14
- package/dist/es/cartesian/useNeedsClip.mjs +18 -9
- package/dist/es/cartesian/utils/get-ticks.mjs +103 -68
- package/dist/es/cartesian/z-axis/ZAxis.mjs +30 -28
- package/dist/es/chart/AreaChart.mjs +5 -5
- package/dist/es/chart/BarChart.mjs +5 -5
- package/dist/es/chart/ComposedChart.mjs +5 -5
- package/dist/es/chart/FunnelChart.mjs +11 -0
- package/dist/es/chart/LegendPortalContext.mjs +3 -3
- package/dist/es/chart/LineChart.mjs +5 -5
- package/dist/es/chart/PieChart.mjs +5 -5
- package/dist/es/chart/RadarChart.mjs +5 -5
- package/dist/es/chart/RadialBarChart.mjs +5 -5
- package/dist/es/chart/RechartsWrapper.mjs +111 -88
- package/dist/es/chart/ScatterChart.mjs +5 -5
- package/dist/es/chart/Surface.mjs +3 -3
- package/dist/es/chart/Surface.vue_vue_type_script_setup_true_lang.mjs +51 -45
- package/dist/es/chart/TooltipPortalContext.mjs +3 -3
- package/dist/es/chart/const.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +97 -88
- package/dist/es/chart/provideClipPathId.mjs +12 -7
- package/dist/es/components/Cell.mjs +16 -4
- package/dist/es/components/Text.mjs +3 -3
- package/dist/es/components/Text.vue_vue_type_script_setup_true_lang.mjs +106 -69
- package/dist/es/components/Tooltip.mjs +274 -199
- package/dist/es/components/label/Label.mjs +30 -26
- package/dist/es/components/label/LabelList.mjs +45 -39
- package/dist/es/components/label/types.mjs +8 -5
- package/dist/es/components/label/utils.mjs +194 -162
- package/dist/es/components/legend/Legend.mjs +82 -71
- package/dist/es/components/legend/LegendSymbol.mjs +40 -38
- package/dist/es/components/legend/hooks/useLegend.mjs +66 -46
- package/dist/es/components/legend/hooks/useLegendContent.mjs +52 -31
- package/dist/es/components/legend/type.mjs +2 -2
- package/dist/es/components/legend/utils.mjs +19 -11
- package/dist/es/components/utils.mjs +35 -22
- package/dist/es/container/ClipPath.mjs +14 -14
- package/dist/es/container/Layer.mjs +9 -7
- package/dist/es/container/ResponsiveContainer.mjs +3 -3
- package/dist/es/container/ResponsiveContainer.vue_vue_type_script_setup_true_lang.mjs +109 -77
- package/dist/es/container/Surface.mjs +23 -19
- package/dist/es/container/useSizeContext.mjs +3 -3
- package/dist/es/context/ChartDataContextProvider.mjs +19 -13
- package/dist/es/context/PanoramaContextProvider.mjs +15 -10
- package/dist/es/context/accessibilityContext.mjs +3 -3
- package/dist/es/context/cartesianLabelListContext.mjs +3 -3
- package/dist/es/context/chartLayoutContext.mjs +33 -30
- package/dist/es/context/cursorLayerContext.mjs +3 -3
- package/dist/es/context/graphicalLayerContext.mjs +3 -3
- package/dist/es/context/labelLayerContext.mjs +3 -3
- package/dist/es/context/polarLabelViewBoxContext.mjs +5 -5
- package/dist/es/context/useTooltipAxis.mjs +14 -12
- package/dist/es/events/useChartSynchronisation.mjs +91 -66
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
- package/dist/es/index.mjs +46 -42
- package/dist/es/polar/pie/Pie.mjs +131 -115
- package/dist/es/polar/pie/type.mjs +6 -6
- package/dist/es/polar/radar/PolarAngleAxis.mjs +103 -84
- package/dist/es/polar/radar/PolarGrid.mjs +72 -59
- package/dist/es/polar/radar/PolarRadiusAxis.mjs +90 -65
- package/dist/es/polar/radar/Radar.mjs +181 -145
- package/dist/es/polar/radial-bar/RadialBar.mjs +161 -140
- package/dist/es/polar/radial-bar/type.mjs +9 -9
- package/dist/es/shape/Cross.mjs +11 -10
- package/dist/es/shape/Curve.mjs +69 -43
- package/dist/es/shape/Dot.mjs +12 -11
- package/dist/es/shape/Rectangle.mjs +41 -26
- package/dist/es/shape/Sector.mjs +103 -75
- package/dist/es/shape/Symbols.mjs +45 -34
- package/dist/es/shape/Trapezoid.mjs +52 -0
- package/dist/es/state/ReportChartProps.mjs +21 -20
- package/dist/es/state/ReportMainChartProps.mjs +26 -21
- package/dist/es/state/ReportPolarOptions.mjs +23 -22
- package/dist/es/state/SetGraphicalItem.mjs +42 -27
- package/dist/es/state/SetLegendPayload.mjs +17 -13
- package/dist/es/state/SetTooltipEntrySettings.mjs +14 -12
- package/dist/es/state/brushSlice.mjs +12 -8
- package/dist/es/state/cartesianAxisSlice.mjs +23 -17
- package/dist/es/state/chartDataSlice.mjs +18 -13
- package/dist/es/state/externalEventsMiddleware.mjs +25 -15
- package/dist/es/state/graphicalItemsSlice.mjs +29 -25
- package/dist/es/state/hooks.mjs +4 -3
- package/dist/es/state/keyboardEventsMiddleware.mjs +50 -42
- package/dist/es/state/layoutSlice.mjs +18 -12
- package/dist/es/state/legendSlice.mjs +19 -14
- package/dist/es/state/mouseEventsMiddleware.mjs +31 -24
- package/dist/es/state/optionsSlice.mjs +14 -11
- package/dist/es/state/polarAxisSlice.mjs +15 -13
- package/dist/es/state/polarOptionsSlice.mjs +8 -6
- package/dist/es/state/reduxDevtoolsJsonStringifyReplacer.mjs +5 -3
- package/dist/es/state/referenceElementsSlice.mjs +21 -19
- package/dist/es/state/rootPropsSlice.mjs +20 -9
- package/dist/es/state/selectors/areaSelectors.mjs +65 -55
- package/dist/es/state/selectors/axisSelectors.mjs +755 -569
- package/dist/es/state/selectors/barSelectors.mjs +225 -162
- package/dist/es/state/selectors/brushSelectors.mjs +15 -14
- package/dist/es/state/selectors/combiners/combineActiveLabel.mjs +6 -5
- package/dist/es/state/selectors/combiners/combineActiveTooltipIndex.mjs +36 -27
- package/dist/es/state/selectors/combiners/combineAxisRangeWithReverse.mjs +5 -3
- package/dist/es/state/selectors/combiners/combineCoordinateForDefaultIndex.mjs +13 -11
- package/dist/es/state/selectors/combiners/combineTooltipInteractionState.mjs +26 -21
- package/dist/es/state/selectors/combiners/combineTooltipPayloadConfigurations.mjs +10 -6
- package/dist/es/state/selectors/common.mjs +2 -2
- package/dist/es/state/selectors/containerSelectors.mjs +5 -2
- package/dist/es/state/selectors/dataSelectors.mjs +28 -9
- package/dist/es/state/selectors/funnelSelectors.mjs +38 -0
- package/dist/es/state/selectors/legendSelectors.mjs +7 -6
- package/dist/es/state/selectors/lineSelectors.mjs +54 -47
- package/dist/es/state/selectors/pickAxisId.mjs +2 -2
- package/dist/es/state/selectors/pickAxisType.mjs +2 -2
- package/dist/es/state/selectors/pieSelectors.mjs +116 -81
- package/dist/es/state/selectors/polarAxisSelectors.mjs +113 -94
- package/dist/es/state/selectors/polarGridSelectors.mjs +13 -11
- package/dist/es/state/selectors/polarScaleSelectors.mjs +49 -46
- package/dist/es/state/selectors/polarSelectors.mjs +79 -62
- package/dist/es/state/selectors/radarSelectors.mjs +111 -91
- package/dist/es/state/selectors/radialBarSelectors.mjs +230 -183
- package/dist/es/state/selectors/rootPropsSelectors.mjs +11 -5
- package/dist/es/state/selectors/scatterSelectors.mjs +111 -95
- package/dist/es/state/selectors/selectActivePropsFromChartPointer.mjs +19 -17
- package/dist/es/state/selectors/selectAllAxes.mjs +8 -3
- package/dist/es/state/selectors/selectChartOffset.mjs +59 -50
- package/dist/es/state/selectors/selectChartOffsetInternal.mjs +55 -44
- package/dist/es/state/selectors/selectTooltipEventType.mjs +15 -14
- package/dist/es/state/selectors/selectTooltipPayloadSearcher.mjs +3 -3
- package/dist/es/state/selectors/selectTooltipSettings.mjs +2 -2
- package/dist/es/state/selectors/selectTooltipState.mjs +2 -2
- package/dist/es/state/selectors/selectors.mjs +94 -75
- package/dist/es/state/selectors/tooltipSelectors.mjs +253 -204
- package/dist/es/state/selectors/touchSelectors.mjs +17 -14
- package/dist/es/state/store.mjs +46 -46
- package/dist/es/state/tooltipSlice.mjs +64 -37
- package/dist/es/state/touchEventsMiddleware.mjs +35 -29
- package/dist/es/state/utils/useReportScale.mjs +16 -13
- package/dist/es/synchronisation/syncSelectors.mjs +3 -3
- package/dist/es/synchronisation/useChartSynchronisation.mjs +33 -19
- package/dist/es/types/event.mjs +164 -2
- package/dist/es/utils/ReduceCSSCalc.mjs +81 -49
- package/dist/es/utils/VueUtils.mjs +35 -14
- package/dist/es/utils/attrs.mjs +43 -26
- package/dist/es/utils/cartesian.mjs +47 -15
- package/dist/es/utils/chart.mjs +298 -197
- package/dist/es/utils/const.mjs +30 -2
- package/dist/es/utils/createContext.mjs +28 -9
- package/dist/es/utils/data-utils.mjs +9 -8
- package/dist/es/utils/data.mjs +35 -21
- package/dist/es/utils/events.mjs +5 -3
- package/dist/es/utils/getLinearRegression.mjs +28 -11
- package/dist/es/utils/grid.mjs +20 -5
- package/dist/es/utils/isDomainSpecifiedByUser.mjs +105 -54
- package/dist/es/utils/legend.mjs +13 -12
- package/dist/es/utils/log.mjs +10 -7
- package/dist/es/utils/payload/getUniqPayload.mjs +6 -4
- package/dist/es/utils/polar.mjs +37 -30
- package/dist/es/utils/props.mjs +16 -10
- package/dist/es/utils/resolveDefaultProps.mjs +23 -4
- package/dist/es/utils/scale/getNiceTickValues.mjs +127 -49
- package/dist/es/utils/scale/utils/arithmetic.mjs +49 -19
- package/dist/es/utils/scale/utils/utils.mjs +43 -24
- package/dist/es/utils/style.mjs +24 -13
- package/dist/es/utils/tick.mjs +34 -23
- package/dist/es/utils/tooltip/translate.mjs +63 -49
- package/dist/es/utils/validate.mjs +40 -29
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/shape/Trapezoid.d.ts +31 -0
- package/dist/shape/index.d.ts +1 -0
- package/dist/state/graphicalItemsSlice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,77 +1,90 @@
|
|
|
1
|
-
import { isCategoricalAxis
|
|
2
|
-
import { selectChartDataWithIndexes
|
|
3
|
-
import { selectChartHeight
|
|
4
|
-
import { selectAllXAxes
|
|
5
|
-
import { selectChartOffset
|
|
6
|
-
import { selectBrushDimensions
|
|
7
|
-
import { selectBarCategoryGap
|
|
8
|
-
import { combineAxisRangeWithReverse
|
|
9
|
-
import { getPercentValue
|
|
10
|
-
import { selectChartLayout
|
|
11
|
-
import { selectAngleAxis
|
|
12
|
-
import { pickAxisType
|
|
13
|
-
import { pickAxisId
|
|
14
|
-
import { checkDomainOfScale
|
|
15
|
-
import { isWellFormedNumberDomain
|
|
16
|
-
import { getNiceTickValues
|
|
17
|
-
import { createSelector
|
|
18
|
-
import { range
|
|
19
|
-
import * as
|
|
1
|
+
import { isCategoricalAxis, isNan, isNumOrStr, isNumber, isWellBehavedNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { selectChartDataWithIndexes, selectChartDataWithIndexesIfNotInPanorama } from "./dataSelectors.mjs";
|
|
3
|
+
import { selectChartHeight, selectChartWidth } from "./containerSelectors.mjs";
|
|
4
|
+
import { selectAllXAxes, selectAllYAxes } from "./selectAllAxes.mjs";
|
|
5
|
+
import { selectChartOffset } from "./selectChartOffset.mjs";
|
|
6
|
+
import { selectBrushDimensions, selectBrushSettings } from "./brushSelectors.mjs";
|
|
7
|
+
import { selectBarCategoryGap, selectChartName, selectStackOffsetType } from "./rootPropsSelectors.mjs";
|
|
8
|
+
import { combineAxisRangeWithReverse } from "./combiners/combineAxisRangeWithReverse.mjs";
|
|
9
|
+
import { getPercentValue, hasDuplicate, mathSign } from "../../utils/data.mjs";
|
|
10
|
+
import { selectChartLayout } from "./common.mjs";
|
|
11
|
+
import { selectAngleAxis, selectAngleAxisRange, selectRadiusAxis, selectRadiusAxisRange } from "./polarAxisSelectors.mjs";
|
|
12
|
+
import { pickAxisType } from "./pickAxisType.mjs";
|
|
13
|
+
import { pickAxisId } from "./pickAxisId.mjs";
|
|
14
|
+
import { checkDomainOfScale, getDomainOfStackGroups, getStackedData, getValueByDataKey } from "../../utils/chart.mjs";
|
|
15
|
+
import { isWellFormedNumberDomain, numericalDomainSpecifiedWithoutRequiringData, parseNumericalUserDomain } from "../../utils/isDomainSpecifiedByUser.mjs";
|
|
16
|
+
import { getNiceTickValues, getTickValuesFixedDomain } from "../../utils/scale/getNiceTickValues.mjs";
|
|
17
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
18
|
+
import { range, upperFirst } from "lodash-es";
|
|
19
|
+
import * as d3Scales from "victory-vendor/d3-scale";
|
|
20
20
|
//#region src/state/selectors/axisSelectors.ts
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
var defaultNumericDomain = [0, "auto"];
|
|
22
|
+
/**
|
|
23
|
+
* If an axis is not explicitly defined as an element,
|
|
24
|
+
* we still need to render something in the chart and we need
|
|
25
|
+
* some object to hold the domain and default settings.
|
|
26
|
+
*/
|
|
27
|
+
var implicitXAxis = {
|
|
28
|
+
allowDataOverflow: false,
|
|
29
|
+
allowDecimals: true,
|
|
30
|
+
allowDuplicatedCategory: true,
|
|
25
31
|
angle: 0,
|
|
26
32
|
dataKey: void 0,
|
|
27
33
|
domain: void 0,
|
|
28
34
|
height: 30,
|
|
29
|
-
hide:
|
|
35
|
+
hide: true,
|
|
30
36
|
id: void 0,
|
|
31
|
-
includeHidden:
|
|
37
|
+
includeHidden: false,
|
|
32
38
|
interval: "preserveEnd",
|
|
33
39
|
minTickGap: 5,
|
|
34
|
-
mirror:
|
|
40
|
+
mirror: false,
|
|
35
41
|
name: void 0,
|
|
36
42
|
orientation: "bottom",
|
|
37
43
|
padding: {
|
|
38
44
|
left: 0,
|
|
39
45
|
right: 0
|
|
40
46
|
},
|
|
41
|
-
reversed:
|
|
47
|
+
reversed: false,
|
|
42
48
|
scale: "auto",
|
|
43
|
-
tick:
|
|
49
|
+
tick: true,
|
|
44
50
|
tickCount: 5,
|
|
45
51
|
tickFormatter: void 0,
|
|
46
52
|
ticks: void 0,
|
|
47
53
|
type: "category",
|
|
48
54
|
unit: void 0
|
|
49
55
|
};
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
function selectXAxisSettings(state, axisId) {
|
|
57
|
+
const axis = state.cartesianAxis.xAxis[axisId];
|
|
58
|
+
if (axis == null) return implicitXAxis;
|
|
59
|
+
return axis;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* If an axis is not explicitly defined as an element,
|
|
63
|
+
* we still need to render something in the chart and we need
|
|
64
|
+
* some object to hold the domain and default settings.
|
|
65
|
+
*/
|
|
66
|
+
var implicitYAxis = {
|
|
67
|
+
allowDataOverflow: false,
|
|
68
|
+
allowDecimals: true,
|
|
69
|
+
allowDuplicatedCategory: true,
|
|
57
70
|
angle: 0,
|
|
58
71
|
dataKey: void 0,
|
|
59
|
-
domain:
|
|
60
|
-
hide:
|
|
72
|
+
domain: defaultNumericDomain,
|
|
73
|
+
hide: true,
|
|
61
74
|
id: void 0,
|
|
62
|
-
includeHidden:
|
|
75
|
+
includeHidden: false,
|
|
63
76
|
interval: "preserveEnd",
|
|
64
77
|
minTickGap: 5,
|
|
65
|
-
mirror:
|
|
78
|
+
mirror: false,
|
|
66
79
|
name: void 0,
|
|
67
80
|
orientation: "left",
|
|
68
81
|
padding: {
|
|
69
82
|
top: 0,
|
|
70
83
|
bottom: 0
|
|
71
84
|
},
|
|
72
|
-
reversed:
|
|
85
|
+
reversed: false,
|
|
73
86
|
scale: "auto",
|
|
74
|
-
tick:
|
|
87
|
+
tick: true,
|
|
75
88
|
tickCount: 5,
|
|
76
89
|
tickFormatter: void 0,
|
|
77
90
|
ticks: void 0,
|
|
@@ -79,15 +92,17 @@ var ye = {
|
|
|
79
92
|
unit: void 0,
|
|
80
93
|
width: 60
|
|
81
94
|
};
|
|
82
|
-
function
|
|
83
|
-
|
|
95
|
+
function selectYAxisSettings(state, axisId) {
|
|
96
|
+
const axis = state.cartesianAxis.yAxis[axisId];
|
|
97
|
+
if (axis == null) return implicitYAxis;
|
|
98
|
+
return axis;
|
|
84
99
|
}
|
|
85
|
-
var
|
|
100
|
+
var implicitZAxis = {
|
|
86
101
|
domain: [0, "auto"],
|
|
87
|
-
includeHidden:
|
|
88
|
-
reversed:
|
|
89
|
-
allowDataOverflow:
|
|
90
|
-
allowDuplicatedCategory:
|
|
102
|
+
includeHidden: false,
|
|
103
|
+
reversed: false,
|
|
104
|
+
allowDataOverflow: false,
|
|
105
|
+
allowDuplicatedCategory: false,
|
|
91
106
|
dataKey: void 0,
|
|
92
107
|
id: void 0,
|
|
93
108
|
name: "",
|
|
@@ -96,598 +111,769 @@ var be = {
|
|
|
96
111
|
type: "number",
|
|
97
112
|
unit: ""
|
|
98
113
|
};
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case "
|
|
107
|
-
case "
|
|
108
|
-
case "
|
|
109
|
-
|
|
114
|
+
function selectZAxisSettings(state, axisId) {
|
|
115
|
+
const axis = state.cartesianAxis.zAxis[axisId];
|
|
116
|
+
if (axis == null) return implicitZAxis;
|
|
117
|
+
return axis;
|
|
118
|
+
}
|
|
119
|
+
function selectBaseAxis(state, axisType, axisId) {
|
|
120
|
+
switch (axisType) {
|
|
121
|
+
case "xAxis": return selectXAxisSettings(state, axisId);
|
|
122
|
+
case "yAxis": return selectYAxisSettings(state, axisId);
|
|
123
|
+
case "zAxis": return selectZAxisSettings(state, axisId);
|
|
124
|
+
case "angleAxis": return selectAngleAxis(state, axisId);
|
|
125
|
+
case "radiusAxis": return selectRadiusAxis(state, axisId);
|
|
126
|
+
default: throw new Error(`Unexpected axis type: ${axisType}`);
|
|
110
127
|
}
|
|
111
128
|
}
|
|
112
|
-
function
|
|
113
|
-
switch (
|
|
114
|
-
case "xAxis": return
|
|
115
|
-
case "yAxis": return
|
|
116
|
-
default: throw Error(`Unexpected axis type: ${
|
|
129
|
+
function selectCartesianAxisSettings(state, axisType, axisId) {
|
|
130
|
+
switch (axisType) {
|
|
131
|
+
case "xAxis": return selectXAxisSettings(state, axisId);
|
|
132
|
+
case "yAxis": return selectYAxisSettings(state, axisId);
|
|
133
|
+
default: throw new Error(`Unexpected axis type: ${axisType}`);
|
|
117
134
|
}
|
|
118
135
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Selects either an X or Y axis. Doesn't work with Z axis - for that, instead use selectBaseAxis.
|
|
138
|
+
* @param state Root state
|
|
139
|
+
* @param axisType xAxis | yAxis
|
|
140
|
+
* @param axisId xAxisId | yAxisId
|
|
141
|
+
* @returns axis settings object
|
|
142
|
+
*/
|
|
143
|
+
function selectAxisSettings(state, axisType, axisId = 0) {
|
|
144
|
+
switch (axisType) {
|
|
145
|
+
case "xAxis": return selectXAxisSettings(state, axisId);
|
|
146
|
+
case "yAxis": return selectYAxisSettings(state, axisId);
|
|
147
|
+
case "angleAxis": return selectAngleAxis(state, axisId);
|
|
148
|
+
case "radiusAxis": return selectRadiusAxis(state, axisId);
|
|
149
|
+
default: throw new Error(`Unexpected axis type: ${axisType}`);
|
|
126
150
|
}
|
|
127
151
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
152
|
+
/**
|
|
153
|
+
* @param state RechartsRootState
|
|
154
|
+
* @return boolean true if there is at least one Bar or RadialBar
|
|
155
|
+
*/
|
|
156
|
+
function selectHasBar(state) {
|
|
157
|
+
return state.graphicalItems.cartesianItems.some((item) => item.type === "bar") || state.graphicalItems.polarItems.some((item) => item.type === "radialBar");
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Filters CartesianGraphicalItemSettings by the relevant axis ID
|
|
161
|
+
* @param axisType 'xAxis' | 'yAxis' | 'zAxis' | 'radiusAxis' | 'angleAxis'
|
|
162
|
+
* @param axisId from props, defaults to 0
|
|
163
|
+
*
|
|
164
|
+
* @returns Predicate function that return true for CartesianGraphicalItemSettings that are relevant to the specified axis
|
|
165
|
+
*/
|
|
166
|
+
function itemAxisPredicate(axisType, axisId) {
|
|
167
|
+
return (item) => {
|
|
168
|
+
switch (axisType) {
|
|
169
|
+
case "xAxis": return "xAxisId" in item && item.xAxisId === axisId;
|
|
170
|
+
case "yAxis": return "yAxisId" in item && item.yAxisId === axisId;
|
|
171
|
+
case "zAxis": return "zAxisId" in item && item.zAxisId === axisId;
|
|
172
|
+
case "angleAxis": return "angleAxisId" in item && item.angleAxisId === axisId;
|
|
173
|
+
case "radiusAxis": return "radiusAxisId" in item && item.radiusAxisId === axisId;
|
|
174
|
+
default: return false;
|
|
140
175
|
}
|
|
141
176
|
};
|
|
142
177
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
var
|
|
147
|
-
function
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
function selectUnfilteredCartesianItems(state) {
|
|
179
|
+
return state.graphicalItems.cartesianItems;
|
|
180
|
+
}
|
|
181
|
+
var selectAxisPredicate = createSelector([pickAxisType, pickAxisId], itemAxisPredicate);
|
|
182
|
+
function combineGraphicalItemsSettings(graphicalItems, axisSettings, axisPredicate) {
|
|
183
|
+
return graphicalItems.filter(axisPredicate).filter((item) => {
|
|
184
|
+
if (axisSettings?.includeHidden === true) return true;
|
|
185
|
+
return !item.hide;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
var selectCartesianItemsSettings = createSelector([
|
|
189
|
+
selectUnfilteredCartesianItems,
|
|
190
|
+
selectBaseAxis,
|
|
191
|
+
selectAxisPredicate
|
|
192
|
+
], combineGraphicalItemsSettings);
|
|
193
|
+
function filterGraphicalNotStackedItems(cartesianItems) {
|
|
194
|
+
return cartesianItems.filter((item) => item.stackId === void 0);
|
|
195
|
+
}
|
|
196
|
+
var selectCartesianItemsSettingsExceptStacked = createSelector([selectCartesianItemsSettings], filterGraphicalNotStackedItems);
|
|
197
|
+
function combineGraphicalItemsData(cartesianItems) {
|
|
198
|
+
return cartesianItems.map((item) => item.data).filter(Boolean).flat(1);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* This is a "cheap" selector - it returns the data but doesn't iterate them, so it is not sensitive on the array length.
|
|
202
|
+
* Also does not apply dataKey yet.
|
|
203
|
+
* @param state RechartsRootState
|
|
204
|
+
* @returns data defined on the chart graphical items, such as Line or Scatter or Pie, and filtered with appropriate dataKey
|
|
205
|
+
*/
|
|
206
|
+
var selectCartesianGraphicalItemsData = createSelector([selectCartesianItemsSettings], combineGraphicalItemsData);
|
|
207
|
+
function combineDisplayedData(graphicalItemsData, { chartData = [], dataStartIndex, dataEndIndex }) {
|
|
208
|
+
if (graphicalItemsData.length > 0) return graphicalItemsData;
|
|
209
|
+
return chartData.slice(dataStartIndex, dataEndIndex + 1);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* This selector will return all data there is in the chart: graphical items, chart root, all together.
|
|
213
|
+
* Useful for figuring out an axis domain (because that needs to know of everything),
|
|
214
|
+
* not useful for rendering individual graphical elements (because they need to know which data is theirs and which is not).
|
|
215
|
+
*
|
|
216
|
+
* This function will discard the original indexes, so it is also not useful for anything that depends on ordering.
|
|
217
|
+
*/
|
|
218
|
+
var selectDisplayedData = createSelector([selectCartesianGraphicalItemsData, selectChartDataWithIndexesIfNotInPanorama], combineDisplayedData);
|
|
219
|
+
function combineAppliedValues(data, axisSettings, items) {
|
|
220
|
+
if (axisSettings?.dataKey != null) return data.map((item) => ({ value: getValueByDataKey(item, axisSettings.dataKey) }));
|
|
221
|
+
if (items.length > 0) return items.map((item) => item.dataKey).flatMap((dataKey) => data.map((entry) => ({ value: getValueByDataKey(entry, dataKey) })));
|
|
222
|
+
return data.map((entry) => ({ value: entry }));
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* This selector will return all values with the appropriate dataKey applied on them.
|
|
226
|
+
* Which dataKey is appropriate depends on where it is defined.
|
|
227
|
+
*
|
|
228
|
+
* This is an expensive selector - it will iterate all data and compute their value using the provided dataKey.
|
|
229
|
+
*/
|
|
230
|
+
var selectAllAppliedValues = createSelector([
|
|
231
|
+
selectDisplayedData,
|
|
232
|
+
selectBaseAxis,
|
|
233
|
+
selectCartesianItemsSettings
|
|
234
|
+
], combineAppliedValues);
|
|
235
|
+
function isErrorBarRelevantForAxisType(axisType, errorBar) {
|
|
236
|
+
switch (axisType) {
|
|
237
|
+
case "xAxis": return errorBar.direction === "x";
|
|
238
|
+
case "yAxis": return errorBar.direction === "y";
|
|
239
|
+
default: return false;
|
|
180
240
|
}
|
|
181
241
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
242
|
+
function onlyAllowNumbers(data) {
|
|
243
|
+
return data.filter((v) => isNumOrStr(v) || v instanceof Date).map(Number).filter((n) => isNan(n) === false);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @param entry One item in the 'data' array. Could be anything really - this is defined externally. This is the raw, before dataKey application
|
|
247
|
+
* @param appliedValue This is the result of applying the 'main' dataKey on the `entry`.
|
|
248
|
+
* @param relevantErrorBars Error bars that are relevant for the current axis and layout and all that.
|
|
249
|
+
* @return either undefined or an array of ErrorValue
|
|
250
|
+
*/
|
|
251
|
+
function getErrorDomainByDataKey(entry, appliedValue, relevantErrorBars) {
|
|
252
|
+
if (!relevantErrorBars || typeof appliedValue !== "number" || isNan(appliedValue)) return [];
|
|
253
|
+
if (!relevantErrorBars.length) return [];
|
|
254
|
+
return onlyAllowNumbers(relevantErrorBars.flatMap((eb) => {
|
|
255
|
+
const errorValue = getValueByDataKey(entry, eb.dataKey);
|
|
256
|
+
let lowBound, highBound;
|
|
257
|
+
if (Array.isArray(errorValue)) [lowBound, highBound] = errorValue;
|
|
258
|
+
else lowBound = highBound = errorValue;
|
|
259
|
+
if (!isWellBehavedNumber(lowBound) || !isWellBehavedNumber(highBound)) return;
|
|
260
|
+
return [appliedValue - lowBound, appliedValue + highBound];
|
|
261
|
+
}));
|
|
184
262
|
}
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
263
|
+
function combineStackGroups(displayedData, items, stackOffsetType) {
|
|
264
|
+
const itemsGroup = items.reduce((acc, item) => {
|
|
265
|
+
if (item.stackId == null) return acc;
|
|
266
|
+
if (acc[item.stackId] == null) acc[item.stackId] = [];
|
|
267
|
+
acc[item.stackId].push(item);
|
|
268
|
+
return acc;
|
|
269
|
+
}, {});
|
|
270
|
+
return Object.fromEntries(Object.entries(itemsGroup).map(([stackId, graphicalItems]) => {
|
|
271
|
+
return [stackId, {
|
|
272
|
+
stackedData: getStackedData(displayedData, graphicalItems.map((i) => i.dataKey), stackOffsetType),
|
|
273
|
+
graphicalItems
|
|
274
|
+
}];
|
|
189
275
|
}));
|
|
190
276
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Stack groups are groups of graphical items that stack on each other.
|
|
279
|
+
* Stack is a function of axis type (X, Y), axis ID, and stack ID.
|
|
280
|
+
* Graphical items that do not have a stack ID are not going to be present in stack groups.
|
|
281
|
+
*/
|
|
282
|
+
var selectStackGroups = createSelector([
|
|
283
|
+
selectDisplayedData,
|
|
284
|
+
selectCartesianItemsSettings,
|
|
285
|
+
selectStackOffsetType
|
|
286
|
+
], combineStackGroups);
|
|
287
|
+
function combineDomainOfStackGroups(stackGroups, { dataStartIndex, dataEndIndex }, axisType) {
|
|
288
|
+
if (axisType === "zAxis") return;
|
|
289
|
+
const domainOfStackGroups = getDomainOfStackGroups(stackGroups, dataStartIndex, dataEndIndex);
|
|
290
|
+
if (domainOfStackGroups != null && domainOfStackGroups[0] === 0 && domainOfStackGroups[1] === 0) return;
|
|
291
|
+
return domainOfStackGroups;
|
|
292
|
+
}
|
|
293
|
+
var selectDomainOfStackGroups = createSelector([
|
|
294
|
+
selectStackGroups,
|
|
295
|
+
selectChartDataWithIndexes,
|
|
296
|
+
pickAxisType
|
|
297
|
+
], combineDomainOfStackGroups);
|
|
298
|
+
function combineAppliedNumericalValuesIncludingErrorValues(data, axisSettings, items, axisType) {
|
|
299
|
+
if (items.length > 0) return data.flatMap((entry) => {
|
|
300
|
+
return items.flatMap((item) => {
|
|
301
|
+
const relevantErrorBars = item.errorBars?.filter((errorBar) => isErrorBarRelevantForAxisType(axisType, errorBar));
|
|
302
|
+
const valueByDataKey = getValueByDataKey(entry, axisSettings.dataKey || item.dataKey);
|
|
303
|
+
return {
|
|
304
|
+
value: valueByDataKey,
|
|
305
|
+
errorDomain: getErrorDomainByDataKey(entry, valueByDataKey, relevantErrorBars)
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
}).filter(Boolean);
|
|
309
|
+
if (axisSettings?.dataKey != null) return data.map((item) => ({
|
|
310
|
+
value: getValueByDataKey(item, axisSettings.dataKey),
|
|
222
311
|
errorDomain: []
|
|
223
|
-
}))
|
|
224
|
-
|
|
312
|
+
}));
|
|
313
|
+
return data.map((entry) => ({
|
|
314
|
+
value: entry,
|
|
225
315
|
errorDomain: []
|
|
226
316
|
}));
|
|
227
317
|
}
|
|
228
|
-
var
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
318
|
+
var selectAllAppliedNumericalValuesIncludingErrorValues = createSelector(selectDisplayedData, selectBaseAxis, selectCartesianItemsSettingsExceptStacked, pickAxisType, combineAppliedNumericalValuesIncludingErrorValues);
|
|
319
|
+
function onlyAllowNumbersAndStringsAndDates(item) {
|
|
320
|
+
const { value } = item;
|
|
321
|
+
if (isNumOrStr(value) || value instanceof Date) return value;
|
|
322
|
+
}
|
|
323
|
+
function computeNumericalDomain(dataWithErrorDomains) {
|
|
324
|
+
const onlyNumbers = onlyAllowNumbers(dataWithErrorDomains.flatMap((d) => [d.value, d.errorDomain]).flat(1));
|
|
325
|
+
if (onlyNumbers.length === 0) return;
|
|
326
|
+
return [Math.min(...onlyNumbers), Math.max(...onlyNumbers)];
|
|
327
|
+
}
|
|
328
|
+
function computeDomainOfTypeCategory(allDataSquished, axisSettings, isCategorical) {
|
|
329
|
+
const categoricalDomain = allDataSquished.map(onlyAllowNumbersAndStringsAndDates).filter((v) => v != null);
|
|
330
|
+
if (isCategorical && (axisSettings.dataKey == null || axisSettings.allowDuplicatedCategory && hasDuplicate(categoricalDomain))) return range(0, allDataSquished.length);
|
|
331
|
+
if (axisSettings.allowDuplicatedCategory) return categoricalDomain;
|
|
332
|
+
return Array.from(new Set(categoricalDomain));
|
|
333
|
+
}
|
|
334
|
+
function getDomainDefinition(axisSettings) {
|
|
335
|
+
if (axisSettings == null || !("domain" in axisSettings)) return defaultNumericDomain;
|
|
336
|
+
if (axisSettings.domain != null) return axisSettings.domain;
|
|
337
|
+
if (axisSettings.ticks != null) {
|
|
338
|
+
if (axisSettings.type === "number") {
|
|
339
|
+
const allValues = onlyAllowNumbers(axisSettings.ticks);
|
|
340
|
+
return [Math.min(...allValues), Math.max(...allValues)];
|
|
248
341
|
}
|
|
249
|
-
if (
|
|
342
|
+
if (axisSettings.type === "category") return axisSettings.ticks.map(String);
|
|
250
343
|
}
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
return [Math.min(...
|
|
258
|
-
}
|
|
259
|
-
function
|
|
260
|
-
return
|
|
261
|
-
}
|
|
262
|
-
function
|
|
263
|
-
return
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
var
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
344
|
+
return axisSettings?.domain ?? defaultNumericDomain;
|
|
345
|
+
}
|
|
346
|
+
function mergeDomains(...domains) {
|
|
347
|
+
const allDomains = domains.filter(Boolean);
|
|
348
|
+
if (allDomains.length === 0) return;
|
|
349
|
+
const allNumbers = allDomains.flat().filter(isNumber);
|
|
350
|
+
return [Math.min(...allNumbers), Math.max(...allNumbers)];
|
|
351
|
+
}
|
|
352
|
+
function selectReferenceDots(state) {
|
|
353
|
+
return state.referenceElements.dots;
|
|
354
|
+
}
|
|
355
|
+
function filterReferenceElements(elements, axisType, axisId) {
|
|
356
|
+
return elements.filter((el) => el.ifOverflow === "extendDomain").filter((el) => {
|
|
357
|
+
if (axisType === "xAxis") return el.xAxisId === axisId;
|
|
358
|
+
return el.yAxisId === axisId;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
var selectReferenceDotsByAxis = createSelector([
|
|
362
|
+
selectReferenceDots,
|
|
363
|
+
pickAxisType,
|
|
364
|
+
pickAxisId
|
|
365
|
+
], filterReferenceElements);
|
|
366
|
+
function selectReferenceAreas(state) {
|
|
367
|
+
return state.referenceElements.areas;
|
|
368
|
+
}
|
|
369
|
+
var selectReferenceAreasByAxis = createSelector([
|
|
370
|
+
selectReferenceAreas,
|
|
371
|
+
pickAxisType,
|
|
372
|
+
pickAxisId
|
|
373
|
+
], filterReferenceElements);
|
|
374
|
+
function selectReferenceLines(state) {
|
|
375
|
+
return state.referenceElements.lines;
|
|
376
|
+
}
|
|
377
|
+
var selectReferenceLinesByAxis = createSelector([
|
|
378
|
+
selectReferenceLines,
|
|
379
|
+
pickAxisType,
|
|
380
|
+
pickAxisId
|
|
381
|
+
], filterReferenceElements);
|
|
382
|
+
function combineDotsDomain(dots, axisType) {
|
|
383
|
+
const allCoords = onlyAllowNumbers(dots.map((dot) => axisType === "xAxis" ? dot.x : dot.y));
|
|
384
|
+
if (allCoords.length === 0) return;
|
|
385
|
+
return [Math.min(...allCoords), Math.max(...allCoords)];
|
|
386
|
+
}
|
|
387
|
+
var selectReferenceDotsDomain = createSelector(selectReferenceDotsByAxis, pickAxisType, combineDotsDomain);
|
|
388
|
+
function combineAreasDomain(areas, axisType) {
|
|
389
|
+
const allCoords = onlyAllowNumbers(areas.flatMap((area) => [axisType === "xAxis" ? area.x1 : area.y1, axisType === "xAxis" ? area.x2 : area.y2]));
|
|
390
|
+
if (allCoords.length === 0) return;
|
|
391
|
+
return [Math.min(...allCoords), Math.max(...allCoords)];
|
|
392
|
+
}
|
|
393
|
+
var selectReferenceAreasDomain = createSelector([selectReferenceAreasByAxis, pickAxisType], combineAreasDomain);
|
|
394
|
+
function combineLinesDomain(lines, axisType) {
|
|
395
|
+
const allCoords = onlyAllowNumbers(lines.map((line) => axisType === "xAxis" ? line.x : line.y));
|
|
396
|
+
if (allCoords.length === 0) return;
|
|
397
|
+
return [Math.min(...allCoords), Math.max(...allCoords)];
|
|
398
|
+
}
|
|
399
|
+
var selectReferenceElementsDomain = createSelector(selectReferenceDotsDomain, createSelector(selectReferenceLinesByAxis, pickAxisType, combineLinesDomain), selectReferenceAreasDomain, (dotsDomain, linesDomain, areasDomain) => {
|
|
400
|
+
return mergeDomains(dotsDomain, areasDomain, linesDomain);
|
|
401
|
+
});
|
|
402
|
+
var selectDomainDefinition = createSelector([selectBaseAxis], getDomainDefinition);
|
|
403
|
+
function combineNumericalDomain(axisSettings, domainDefinition, domainOfStackGroups, allDataWithErrorDomains, referenceElementsDomain) {
|
|
404
|
+
const domainFromUserPreference = numericalDomainSpecifiedWithoutRequiringData(domainDefinition, axisSettings.allowDataOverflow);
|
|
405
|
+
if (domainFromUserPreference != null) return domainFromUserPreference;
|
|
406
|
+
return parseNumericalUserDomain(domainDefinition, mergeDomains(domainOfStackGroups, referenceElementsDomain, computeNumericalDomain(allDataWithErrorDomains)), axisSettings.allowDataOverflow);
|
|
407
|
+
}
|
|
408
|
+
var selectNumericalDomain = createSelector([
|
|
409
|
+
selectBaseAxis,
|
|
410
|
+
selectDomainDefinition,
|
|
411
|
+
selectDomainOfStackGroups,
|
|
412
|
+
selectAllAppliedNumericalValuesIncludingErrorValues,
|
|
413
|
+
selectReferenceElementsDomain
|
|
414
|
+
], combineNumericalDomain);
|
|
415
|
+
/**
|
|
416
|
+
* Expand by design maps everything between 0 and 1,
|
|
417
|
+
* there is nothing to compute.
|
|
418
|
+
* See https://d3js.org/d3-shape/stack#stack-offsets
|
|
419
|
+
*/
|
|
420
|
+
var expandDomain = [0, 1];
|
|
421
|
+
function combineAxisDomain(axisSettings, layout, displayedData, allAppliedValues, stackOffsetType, axisType, numericalDomain) {
|
|
422
|
+
if ((axisSettings == null || displayedData == null || displayedData.length === 0) && numericalDomain === void 0) return;
|
|
423
|
+
const { dataKey, type } = axisSettings;
|
|
424
|
+
const isCategorical = isCategoricalAxis(layout, axisType);
|
|
425
|
+
if (isCategorical && dataKey == null) {
|
|
426
|
+
const domainLen = Array.isArray(axisSettings.domain) ? axisSettings.domain.length : 0;
|
|
427
|
+
return range(0, Math.max(displayedData.length, domainLen));
|
|
317
428
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
429
|
+
if (type === "category") return computeDomainOfTypeCategory(allAppliedValues, axisSettings, isCategorical);
|
|
430
|
+
if (stackOffsetType === "expand") return expandDomain;
|
|
431
|
+
return numericalDomain;
|
|
432
|
+
}
|
|
433
|
+
var selectAxisDomain = createSelector([
|
|
434
|
+
selectBaseAxis,
|
|
435
|
+
selectChartLayout,
|
|
436
|
+
selectDisplayedData,
|
|
437
|
+
selectAllAppliedValues,
|
|
438
|
+
selectStackOffsetType,
|
|
439
|
+
pickAxisType,
|
|
440
|
+
selectNumericalDomain
|
|
441
|
+
], combineAxisDomain);
|
|
442
|
+
function combineRealScaleType(axisConfig, hasBar, chartType) {
|
|
443
|
+
if (axisConfig == null) return;
|
|
444
|
+
const { scale, type } = axisConfig;
|
|
445
|
+
if (scale === "auto") {
|
|
446
|
+
if (type === "category" && chartType && (chartType.includes("LineChart") || chartType.includes("AreaChart") || chartType.includes("ComposedChart") && !hasBar)) return "point";
|
|
447
|
+
if (type === "category") return "band";
|
|
448
|
+
return "linear";
|
|
336
449
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
k,
|
|
341
|
-
m
|
|
342
|
-
], et);
|
|
343
|
-
function tt(e) {
|
|
344
|
-
if (e == null) return;
|
|
345
|
-
if (e in S) return S[e]();
|
|
346
|
-
let t = `scale${_e(e)}`;
|
|
347
|
-
if (t in S) return S[t]();
|
|
348
|
-
}
|
|
349
|
-
function G(e, t, n, r) {
|
|
350
|
-
if (n == null || r == null) return;
|
|
351
|
-
if (typeof e.scale == "function") return e.scale.copy().domain(n).range(r);
|
|
352
|
-
let i = tt(t);
|
|
353
|
-
if (i == null) return;
|
|
354
|
-
let a = i.domain(n).range(r);
|
|
355
|
-
return ce(a), a;
|
|
356
|
-
}
|
|
357
|
-
function nt(e, t, n) {
|
|
358
|
-
let r = z(t);
|
|
359
|
-
if (!(n !== "auto" && n !== "linear")) {
|
|
360
|
-
if (t != null && t.tickCount && Array.isArray(r) && (r[0] === "auto" || r[1] === "auto") && de(e)) return me(e, t.tickCount, t.allowDecimals);
|
|
361
|
-
if (t != null && t.tickCount && t.type === "number" && e != null) return he(e, t.tickCount, t.allowDecimals);
|
|
450
|
+
if (typeof scale === "string") {
|
|
451
|
+
const name = `scale${upperFirst(scale)}`;
|
|
452
|
+
return name in d3Scales ? name : "point";
|
|
362
453
|
}
|
|
363
454
|
}
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
],
|
|
369
|
-
function
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
455
|
+
var selectRealScaleType = createSelector([
|
|
456
|
+
selectBaseAxis,
|
|
457
|
+
selectHasBar,
|
|
458
|
+
selectChartName
|
|
459
|
+
], combineRealScaleType);
|
|
460
|
+
function getD3ScaleFromType(realScaleType) {
|
|
461
|
+
if (realScaleType == null) return;
|
|
462
|
+
if (realScaleType in d3Scales) return d3Scales[realScaleType]();
|
|
463
|
+
const name = `scale${upperFirst(realScaleType)}`;
|
|
464
|
+
if (name in d3Scales) return d3Scales[name]();
|
|
465
|
+
}
|
|
466
|
+
function combineScaleFunction(axis, realScaleType, axisDomain, axisRange) {
|
|
467
|
+
if (axisDomain == null || axisRange == null) return;
|
|
468
|
+
if (typeof axis.scale === "function") return axis.scale.copy().domain(axisDomain).range(axisRange);
|
|
469
|
+
const d3ScaleFunction = getD3ScaleFromType(realScaleType);
|
|
470
|
+
if (d3ScaleFunction == null) return;
|
|
471
|
+
const scale = d3ScaleFunction.domain(axisDomain).range(axisRange);
|
|
472
|
+
checkDomainOfScale(scale);
|
|
473
|
+
return scale;
|
|
474
|
+
}
|
|
475
|
+
function combineNiceTicks(axisDomain, axisSettings, realScaleType) {
|
|
476
|
+
const domainDefinition = getDomainDefinition(axisSettings);
|
|
477
|
+
if (realScaleType !== "auto" && realScaleType !== "linear") return;
|
|
478
|
+
if (axisSettings != null && axisSettings.tickCount && Array.isArray(domainDefinition) && (domainDefinition[0] === "auto" || domainDefinition[1] === "auto") && isWellFormedNumberDomain(axisDomain)) return getNiceTickValues(axisDomain, axisSettings.tickCount, axisSettings.allowDecimals);
|
|
479
|
+
if (axisSettings != null && axisSettings.tickCount && axisSettings.type === "number" && axisDomain != null) return getTickValuesFixedDomain(axisDomain, axisSettings.tickCount, axisSettings.allowDecimals);
|
|
480
|
+
}
|
|
481
|
+
var selectNiceTicks = createSelector([
|
|
482
|
+
selectAxisDomain,
|
|
483
|
+
selectAxisSettings,
|
|
484
|
+
selectRealScaleType
|
|
485
|
+
], combineNiceTicks);
|
|
486
|
+
function combineAxisDomainWithNiceTicks(axisSettings, domain, niceTicks, axisType) {
|
|
487
|
+
if (axisType !== "angleAxis" && axisSettings?.type === "number" && isWellFormedNumberDomain(domain) && Array.isArray(niceTicks) && niceTicks.length > 0) {
|
|
488
|
+
const minFromDomain = domain[0];
|
|
489
|
+
const minFromTicks = niceTicks[0];
|
|
490
|
+
const maxFromDomain = domain[1];
|
|
491
|
+
const maxFromTicks = niceTicks[niceTicks.length - 1];
|
|
492
|
+
return [Math.min(minFromDomain, minFromTicks), Math.max(maxFromDomain, maxFromTicks)];
|
|
373
493
|
}
|
|
374
|
-
return
|
|
375
|
-
}
|
|
376
|
-
var
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
],
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
494
|
+
return domain;
|
|
495
|
+
}
|
|
496
|
+
var selectAxisDomainIncludingNiceTicks = createSelector([
|
|
497
|
+
selectBaseAxis,
|
|
498
|
+
selectAxisDomain,
|
|
499
|
+
selectNiceTicks,
|
|
500
|
+
pickAxisType
|
|
501
|
+
], combineAxisDomainWithNiceTicks);
|
|
502
|
+
var selectCalculatedPadding = createSelector(createSelector(selectAllAppliedValues, selectBaseAxis, (allDataSquished, axisSettings) => {
|
|
503
|
+
if (!axisSettings || axisSettings.type !== "number") return;
|
|
504
|
+
let smallestDistanceBetweenValues = Infinity;
|
|
505
|
+
const sortedValues = Array.from(onlyAllowNumbers(allDataSquished.map((d) => d.value))).sort((a, b) => a - b);
|
|
506
|
+
if (sortedValues.length < 2) return Infinity;
|
|
507
|
+
const diff = sortedValues[sortedValues.length - 1] - sortedValues[0];
|
|
508
|
+
if (diff === 0) return Infinity;
|
|
509
|
+
for (let i = 0; i < sortedValues.length - 1; i++) {
|
|
510
|
+
const distance = sortedValues[i + 1] - sortedValues[i];
|
|
511
|
+
smallestDistanceBetweenValues = Math.min(smallestDistanceBetweenValues, distance);
|
|
390
512
|
}
|
|
391
|
-
return
|
|
392
|
-
}),
|
|
393
|
-
if (!
|
|
394
|
-
|
|
395
|
-
if (
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
513
|
+
return smallestDistanceBetweenValues / diff;
|
|
514
|
+
}), selectChartLayout, selectBarCategoryGap, selectChartOffset, (_1, _2, _3, padding) => padding, (smallestDistanceInPercent, layout, barCategoryGap, offset, padding) => {
|
|
515
|
+
if (!isWellBehavedNumber(smallestDistanceInPercent)) return 0;
|
|
516
|
+
const rangeWidth = layout === "vertical" ? offset.height : offset.width;
|
|
517
|
+
if (padding === "gap") return smallestDistanceInPercent * rangeWidth / 2;
|
|
518
|
+
if (padding === "no-gap") {
|
|
519
|
+
const gap = getPercentValue(barCategoryGap, smallestDistanceInPercent * rangeWidth);
|
|
520
|
+
const halfBand = smallestDistanceInPercent * rangeWidth / 2;
|
|
521
|
+
return halfBand - gap - (halfBand - gap) / rangeWidth * gap;
|
|
399
522
|
}
|
|
400
523
|
return 0;
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
524
|
+
});
|
|
525
|
+
var selectCalculatedXAxisPadding = (state, axisId) => {
|
|
526
|
+
const xAxisSettings = selectXAxisSettings(state, axisId);
|
|
527
|
+
if (xAxisSettings == null || typeof xAxisSettings.padding !== "string") return 0;
|
|
528
|
+
return selectCalculatedPadding(state, "xAxis", axisId, xAxisSettings.padding);
|
|
529
|
+
};
|
|
530
|
+
var selectCalculatedYAxisPadding = (state, axisId) => {
|
|
531
|
+
const yAxisSettings = selectYAxisSettings(state, axisId);
|
|
532
|
+
if (yAxisSettings == null || typeof yAxisSettings.padding !== "string") return 0;
|
|
533
|
+
return selectCalculatedPadding(state, "yAxis", axisId, yAxisSettings.padding);
|
|
534
|
+
};
|
|
535
|
+
var selectXAxisPadding = createSelector(selectXAxisSettings, selectCalculatedXAxisPadding, (xAxisSettings, calculated) => {
|
|
536
|
+
if (xAxisSettings == null) return {
|
|
409
537
|
left: 0,
|
|
410
538
|
right: 0
|
|
411
539
|
};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
left:
|
|
415
|
-
right:
|
|
416
|
-
} : {
|
|
417
|
-
left: (n.left ?? 0) + t,
|
|
418
|
-
right: (n.right ?? 0) + t
|
|
540
|
+
const { padding } = xAxisSettings;
|
|
541
|
+
if (typeof padding === "string") return {
|
|
542
|
+
left: calculated,
|
|
543
|
+
right: calculated
|
|
419
544
|
};
|
|
420
|
-
|
|
421
|
-
|
|
545
|
+
return {
|
|
546
|
+
left: (padding.left ?? 0) + calculated,
|
|
547
|
+
right: (padding.right ?? 0) + calculated
|
|
548
|
+
};
|
|
549
|
+
});
|
|
550
|
+
var selectYAxisPadding = createSelector(selectYAxisSettings, selectCalculatedYAxisPadding, (yAxisSettings, calculated) => {
|
|
551
|
+
if (yAxisSettings == null) return {
|
|
422
552
|
top: 0,
|
|
423
553
|
bottom: 0
|
|
424
554
|
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
top:
|
|
428
|
-
bottom:
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
555
|
+
const { padding } = yAxisSettings;
|
|
556
|
+
if (typeof padding === "string") return {
|
|
557
|
+
top: calculated,
|
|
558
|
+
bottom: calculated
|
|
559
|
+
};
|
|
560
|
+
return {
|
|
561
|
+
top: (padding.top ?? 0) + calculated,
|
|
562
|
+
bottom: (padding.bottom ?? 0) + calculated
|
|
432
563
|
};
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
564
|
+
});
|
|
565
|
+
var combineXAxisRange = createSelector([
|
|
566
|
+
selectChartOffset,
|
|
567
|
+
selectXAxisPadding,
|
|
568
|
+
selectBrushDimensions,
|
|
569
|
+
selectBrushSettings,
|
|
570
|
+
(_state, _axisId, isPanorama) => isPanorama
|
|
571
|
+
], (offset, padding, brushDimensions, { padding: brushPadding }, isPanorama) => {
|
|
572
|
+
if (isPanorama) return [brushPadding.left, brushDimensions.width - brushPadding.right];
|
|
573
|
+
return [offset.left + padding.left, offset.left + offset.width - padding.right];
|
|
574
|
+
});
|
|
575
|
+
var combineYAxisRange = createSelector([
|
|
576
|
+
selectChartOffset,
|
|
577
|
+
selectChartLayout,
|
|
578
|
+
selectYAxisPadding,
|
|
579
|
+
selectBrushDimensions,
|
|
580
|
+
selectBrushSettings,
|
|
581
|
+
(_state, _axisId, isPanorama) => isPanorama
|
|
582
|
+
], (offset, layout, padding, brushDimensions, { padding: brushPadding }, isPanorama) => {
|
|
583
|
+
if (isPanorama) return [brushDimensions.height - brushPadding.bottom, brushPadding.top];
|
|
584
|
+
if (layout === "horizontal") return [offset.top + offset.height - padding.bottom, offset.top + padding.top];
|
|
585
|
+
return [offset.top + padding.top, offset.top + offset.height - padding.bottom];
|
|
586
|
+
});
|
|
587
|
+
function selectAxisRange(state, axisType, axisId, isPanorama) {
|
|
588
|
+
switch (axisType) {
|
|
589
|
+
case "xAxis": return combineXAxisRange(state, axisId, isPanorama);
|
|
590
|
+
case "yAxis": return combineYAxisRange(state, axisId, isPanorama);
|
|
591
|
+
case "zAxis": return selectZAxisSettings(state, axisId)?.range;
|
|
592
|
+
case "angleAxis": return selectAngleAxisRange(state);
|
|
593
|
+
case "radiusAxis": return selectRadiusAxisRange(state, axisId);
|
|
454
594
|
default: return;
|
|
455
595
|
}
|
|
456
596
|
}
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
597
|
+
var selectAxisRangeWithReverse = createSelector([selectBaseAxis, selectAxisRange], combineAxisRangeWithReverse);
|
|
598
|
+
var selectAxisScale = createSelector([
|
|
599
|
+
selectBaseAxis,
|
|
600
|
+
selectRealScaleType,
|
|
601
|
+
selectAxisDomainIncludingNiceTicks,
|
|
602
|
+
selectAxisRangeWithReverse
|
|
603
|
+
], combineScaleFunction);
|
|
604
|
+
createSelector(selectCartesianItemsSettings, pickAxisType, (items, axisType) => {
|
|
605
|
+
return items.flatMap((item) => {
|
|
606
|
+
return item.errorBars ?? [];
|
|
607
|
+
}).filter((e) => {
|
|
608
|
+
return isErrorBarRelevantForAxisType(axisType, e);
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
function compareIds(a, b) {
|
|
612
|
+
if (a.id < b.id) return -1;
|
|
613
|
+
if (a.id > b.id) return 1;
|
|
614
|
+
return 0;
|
|
615
|
+
}
|
|
616
|
+
var pickAxisOrientation = (_state, orientation) => orientation;
|
|
617
|
+
var pickMirror = (_state, _orientation, mirror) => mirror;
|
|
618
|
+
var selectAllXAxesWithOffsetType = createSelector(selectAllXAxes, pickAxisOrientation, pickMirror, (allAxes, orientation, mirror) => allAxes.filter((axis) => axis.orientation === orientation).filter((axis) => axis.mirror === mirror).sort(compareIds));
|
|
619
|
+
var selectAllYAxesWithOffsetType = createSelector(selectAllYAxes, pickAxisOrientation, pickMirror, (allAxes, orientation, mirror) => allAxes.filter((axis) => axis.orientation === orientation).filter((axis) => axis.mirror === mirror).sort(compareIds));
|
|
620
|
+
function getXAxisSize(offset, axisSettings) {
|
|
469
621
|
return {
|
|
470
|
-
width:
|
|
471
|
-
height:
|
|
622
|
+
width: offset.width,
|
|
623
|
+
height: axisSettings.height
|
|
472
624
|
};
|
|
473
625
|
}
|
|
474
|
-
function
|
|
626
|
+
function getYAxisSize(offset, axisSettings) {
|
|
475
627
|
return {
|
|
476
|
-
width:
|
|
477
|
-
height:
|
|
628
|
+
width: axisSettings.width,
|
|
629
|
+
height: offset.height
|
|
478
630
|
};
|
|
479
631
|
}
|
|
480
|
-
var
|
|
481
|
-
function
|
|
482
|
-
switch (
|
|
483
|
-
case "top": return
|
|
484
|
-
case "bottom": return
|
|
632
|
+
var selectXAxisSize = createSelector(selectChartOffset, selectXAxisSettings, getXAxisSize);
|
|
633
|
+
function combineXAxisPositionStartingPoint(offset, orientation, chartHeight) {
|
|
634
|
+
switch (orientation) {
|
|
635
|
+
case "top": return offset.top;
|
|
636
|
+
case "bottom": return chartHeight - offset.bottom;
|
|
485
637
|
default: return 0;
|
|
486
638
|
}
|
|
487
639
|
}
|
|
488
|
-
function
|
|
489
|
-
switch (
|
|
490
|
-
case "left": return
|
|
491
|
-
case "right": return
|
|
640
|
+
function combineYAxisPositionStartingPoint(offset, orientation, chartWidth) {
|
|
641
|
+
switch (orientation) {
|
|
642
|
+
case "left": return offset.left;
|
|
643
|
+
case "right": return chartWidth - offset.right;
|
|
492
644
|
default: return 0;
|
|
493
645
|
}
|
|
494
646
|
}
|
|
495
|
-
var
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
647
|
+
var selectAllXAxesOffsetSteps = createSelector(selectChartHeight, selectChartOffset, selectAllXAxesWithOffsetType, pickAxisOrientation, pickMirror, (chartHeight, offset, allAxesWithSameOffsetType, orientation, mirror) => {
|
|
648
|
+
const steps = {};
|
|
649
|
+
let position;
|
|
650
|
+
allAxesWithSameOffsetType.forEach((axis) => {
|
|
651
|
+
const axisSize = getXAxisSize(offset, axis);
|
|
652
|
+
if (position == null) position = combineXAxisPositionStartingPoint(offset, orientation, chartHeight);
|
|
653
|
+
const needSpace = orientation === "top" && !mirror || orientation === "bottom" && mirror;
|
|
654
|
+
steps[axis.id] = position - Number(needSpace) * axisSize.height;
|
|
655
|
+
position += (needSpace ? -1 : 1) * axisSize.height;
|
|
656
|
+
});
|
|
657
|
+
return steps;
|
|
658
|
+
});
|
|
659
|
+
var selectAllYAxesOffsetSteps = createSelector(selectChartWidth, selectChartOffset, selectAllYAxesWithOffsetType, pickAxisOrientation, pickMirror, (chartWidth, offset, allAxesWithSameOffsetType, orientation, mirror) => {
|
|
660
|
+
const steps = {};
|
|
661
|
+
let position;
|
|
662
|
+
allAxesWithSameOffsetType.forEach((axis) => {
|
|
663
|
+
const axisSize = getYAxisSize(offset, axis);
|
|
664
|
+
if (position == null) position = combineYAxisPositionStartingPoint(offset, orientation, chartWidth);
|
|
665
|
+
const needSpace = orientation === "left" && !mirror || orientation === "right" && mirror;
|
|
666
|
+
steps[axis.id] = position - Number(needSpace) * axisSize.width;
|
|
667
|
+
position += (needSpace ? -1 : 1) * axisSize.width;
|
|
668
|
+
});
|
|
669
|
+
return steps;
|
|
511
670
|
});
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
671
|
+
function selectXAxisPosition(state, axisId) {
|
|
672
|
+
const offset = selectChartOffset(state);
|
|
673
|
+
const axisSettings = selectXAxisSettings(state, axisId);
|
|
674
|
+
if (axisSettings == null) return;
|
|
675
|
+
const stepOfThisAxis = selectAllXAxesOffsetSteps(state, axisSettings.orientation, axisSettings.mirror)[axisId];
|
|
676
|
+
if (stepOfThisAxis == null) return {
|
|
677
|
+
x: offset.left,
|
|
518
678
|
y: 0
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
679
|
+
};
|
|
680
|
+
return {
|
|
681
|
+
x: offset.left,
|
|
682
|
+
y: stepOfThisAxis
|
|
522
683
|
};
|
|
523
684
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
685
|
+
function selectYAxisPosition(state, axisId) {
|
|
686
|
+
const offset = selectChartOffset(state);
|
|
687
|
+
const axisSettings = selectYAxisSettings(state, axisId);
|
|
688
|
+
if (axisSettings == null) return;
|
|
689
|
+
const stepOfThisAxis = selectAllYAxesOffsetSteps(state, axisSettings.orientation, axisSettings.mirror)[axisId];
|
|
690
|
+
if (stepOfThisAxis == null) return {
|
|
529
691
|
x: 0,
|
|
530
|
-
y:
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
692
|
+
y: offset.top
|
|
693
|
+
};
|
|
694
|
+
return {
|
|
695
|
+
x: stepOfThisAxis,
|
|
696
|
+
y: offset.top
|
|
534
697
|
};
|
|
535
698
|
}
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
699
|
+
var selectYAxisSize = createSelector(selectChartOffset, selectYAxisSettings, (offset, axisSettings) => {
|
|
700
|
+
return {
|
|
701
|
+
width: axisSettings.width,
|
|
702
|
+
height: offset.height
|
|
703
|
+
};
|
|
704
|
+
});
|
|
705
|
+
function selectCartesianAxisSize(state, axisType, axisId) {
|
|
706
|
+
switch (axisType) {
|
|
707
|
+
case "xAxis": return selectXAxisSize(state, axisId).width;
|
|
708
|
+
case "yAxis": return selectYAxisSize(state, axisId).height;
|
|
544
709
|
default: return;
|
|
545
710
|
}
|
|
546
711
|
}
|
|
547
|
-
function
|
|
548
|
-
if (
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
712
|
+
function combineDuplicateDomain(chartLayout, appliedValues, axis, axisType) {
|
|
713
|
+
if (axis == null) return;
|
|
714
|
+
const { allowDuplicatedCategory, type, dataKey } = axis;
|
|
715
|
+
const isCategorical = isCategoricalAxis(chartLayout, axisType);
|
|
716
|
+
const allData = appliedValues.map((av) => av.value);
|
|
717
|
+
if (dataKey && isCategorical && type === "category" && allowDuplicatedCategory && hasDuplicate(allData)) return allData;
|
|
718
|
+
}
|
|
719
|
+
var selectDuplicateDomain = createSelector([
|
|
720
|
+
selectChartLayout,
|
|
721
|
+
selectAllAppliedValues,
|
|
722
|
+
selectBaseAxis,
|
|
723
|
+
pickAxisType
|
|
724
|
+
], combineDuplicateDomain);
|
|
725
|
+
function combineCategoricalDomain(layout, appliedValues, axis, axisType) {
|
|
726
|
+
if (axis == null || axis.dataKey == null) return;
|
|
727
|
+
const { type, scale } = axis;
|
|
728
|
+
if (isCategoricalAxis(layout, axisType) && (type === "number" || scale !== "auto")) return appliedValues.map((d) => d.value);
|
|
729
|
+
}
|
|
730
|
+
var selectCategoricalDomain = createSelector([
|
|
731
|
+
selectChartLayout,
|
|
732
|
+
selectAllAppliedValues,
|
|
733
|
+
selectAxisSettings,
|
|
734
|
+
pickAxisType
|
|
735
|
+
], combineCategoricalDomain);
|
|
736
|
+
var selectAxisPropsNeededForCartesianGridTicksGenerator = createSelector([
|
|
737
|
+
selectChartLayout,
|
|
738
|
+
selectCartesianAxisSettings,
|
|
739
|
+
selectRealScaleType,
|
|
740
|
+
selectAxisScale,
|
|
741
|
+
selectDuplicateDomain,
|
|
742
|
+
selectCategoricalDomain,
|
|
743
|
+
selectAxisRange,
|
|
744
|
+
selectNiceTicks,
|
|
745
|
+
pickAxisType
|
|
746
|
+
], (layout, axis, realScaleType, scale, duplicateDomain, categoricalDomain, axisRange, niceTicks, axisType) => {
|
|
747
|
+
if (axis == null) return null;
|
|
748
|
+
const isCategorical = isCategoricalAxis(layout, axisType);
|
|
581
749
|
return {
|
|
582
|
-
angle:
|
|
583
|
-
interval:
|
|
584
|
-
minTickGap:
|
|
585
|
-
orientation:
|
|
586
|
-
tick:
|
|
587
|
-
tickCount:
|
|
588
|
-
tickFormatter:
|
|
589
|
-
ticks:
|
|
590
|
-
type:
|
|
591
|
-
unit:
|
|
592
|
-
axisType
|
|
593
|
-
categoricalDomain
|
|
594
|
-
duplicateDomain
|
|
595
|
-
isCategorical
|
|
596
|
-
niceTicks
|
|
597
|
-
range:
|
|
598
|
-
realScaleType
|
|
599
|
-
scale
|
|
750
|
+
angle: axis.angle,
|
|
751
|
+
interval: axis.interval,
|
|
752
|
+
minTickGap: axis.minTickGap,
|
|
753
|
+
orientation: axis.orientation,
|
|
754
|
+
tick: axis.tick,
|
|
755
|
+
tickCount: axis.tickCount,
|
|
756
|
+
tickFormatter: axis.tickFormatter,
|
|
757
|
+
ticks: axis.ticks,
|
|
758
|
+
type: axis.type,
|
|
759
|
+
unit: axis.unit,
|
|
760
|
+
axisType,
|
|
761
|
+
categoricalDomain,
|
|
762
|
+
duplicateDomain,
|
|
763
|
+
isCategorical,
|
|
764
|
+
niceTicks,
|
|
765
|
+
range: axisRange,
|
|
766
|
+
realScaleType,
|
|
767
|
+
scale
|
|
600
768
|
};
|
|
601
769
|
});
|
|
602
|
-
function
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
})
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
770
|
+
function combineAxisTicks(layout, axis, realScaleType, scale, niceTicks, axisRange, duplicateDomain, categoricalDomain, axisType) {
|
|
771
|
+
if (axis == null || scale == null) return;
|
|
772
|
+
const isCategorical = isCategoricalAxis(layout, axisType);
|
|
773
|
+
const { type, ticks, tickCount } = axis;
|
|
774
|
+
const offsetForBand = realScaleType === "scaleBand" ? scale.bandwidth() / 2 : 2;
|
|
775
|
+
let offset = type === "category" && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
|
|
776
|
+
offset = axisType === "angleAxis" && axisRange?.length >= 2 ? mathSign(axisRange[0] - axisRange[1]) * 2 * offset : offset;
|
|
777
|
+
const ticksOrNiceTicks = ticks || niceTicks;
|
|
778
|
+
if (ticksOrNiceTicks) return ticksOrNiceTicks.map((entry, index) => {
|
|
779
|
+
return {
|
|
780
|
+
index,
|
|
781
|
+
coordinate: scale(duplicateDomain ? duplicateDomain.indexOf(entry) : entry) + offset,
|
|
782
|
+
value: entry,
|
|
783
|
+
offset
|
|
784
|
+
};
|
|
785
|
+
}).filter((row) => !isNan(row.coordinate));
|
|
786
|
+
if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
|
|
787
|
+
coordinate: scale(entry) + offset,
|
|
788
|
+
value: entry,
|
|
789
|
+
index,
|
|
790
|
+
offset
|
|
791
|
+
}));
|
|
792
|
+
if (scale.ticks) return scale.ticks(tickCount).map((entry) => ({
|
|
793
|
+
coordinate: scale(entry) + offset,
|
|
794
|
+
value: entry,
|
|
795
|
+
offset
|
|
796
|
+
}));
|
|
797
|
+
return scale.domain().map((entry, index) => ({
|
|
798
|
+
coordinate: scale(entry) + offset,
|
|
799
|
+
value: duplicateDomain ? duplicateDomain[entry] : entry,
|
|
800
|
+
index,
|
|
801
|
+
offset
|
|
626
802
|
}));
|
|
627
803
|
}
|
|
628
|
-
var
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
],
|
|
639
|
-
function
|
|
640
|
-
if (
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
coordinate:
|
|
653
|
-
value:
|
|
654
|
-
|
|
655
|
-
|
|
804
|
+
var selectTicksOfAxis = createSelector([
|
|
805
|
+
selectChartLayout,
|
|
806
|
+
selectAxisSettings,
|
|
807
|
+
selectRealScaleType,
|
|
808
|
+
selectAxisScale,
|
|
809
|
+
selectNiceTicks,
|
|
810
|
+
selectAxisRange,
|
|
811
|
+
selectDuplicateDomain,
|
|
812
|
+
selectCategoricalDomain,
|
|
813
|
+
pickAxisType
|
|
814
|
+
], combineAxisTicks);
|
|
815
|
+
function combineGraphicalItemTicks(layout, axis, scale, axisRange, duplicateDomain, categoricalDomain, axisType) {
|
|
816
|
+
if (axis == null || scale == null || axisRange == null || axisRange[0] === axisRange[1]) return null;
|
|
817
|
+
const isCategorical = isCategoricalAxis(layout, axisType);
|
|
818
|
+
const { tickCount } = axis;
|
|
819
|
+
let offset = 0;
|
|
820
|
+
offset = axisType === "angleAxis" && axisRange?.length >= 2 ? mathSign(axisRange[0] - axisRange[1]) * 2 * offset : offset;
|
|
821
|
+
if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
|
|
822
|
+
coordinate: scale(entry) + offset,
|
|
823
|
+
value: entry,
|
|
824
|
+
index,
|
|
825
|
+
offset
|
|
826
|
+
}));
|
|
827
|
+
if (scale.ticks) return scale.ticks(tickCount).map((entry) => ({
|
|
828
|
+
coordinate: scale(entry) + offset,
|
|
829
|
+
value: entry,
|
|
830
|
+
offset
|
|
831
|
+
}));
|
|
832
|
+
return scale.domain().map((entry, index) => ({
|
|
833
|
+
coordinate: scale(entry) + offset,
|
|
834
|
+
value: duplicateDomain ? duplicateDomain[entry] : entry,
|
|
835
|
+
index,
|
|
836
|
+
offset
|
|
656
837
|
}));
|
|
657
838
|
}
|
|
658
|
-
var
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
],
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
839
|
+
var selectTicksOfGraphicalItem = createSelector([
|
|
840
|
+
selectChartLayout,
|
|
841
|
+
selectAxisSettings,
|
|
842
|
+
selectAxisScale,
|
|
843
|
+
selectAxisRange,
|
|
844
|
+
selectDuplicateDomain,
|
|
845
|
+
selectCategoricalDomain,
|
|
846
|
+
pickAxisType
|
|
847
|
+
], combineGraphicalItemTicks);
|
|
848
|
+
var selectAxisWithScale = createSelector(selectBaseAxis, selectAxisScale, (axis, scale) => {
|
|
849
|
+
if (axis == null || scale == null) return;
|
|
850
|
+
return {
|
|
851
|
+
...axis,
|
|
852
|
+
scale
|
|
670
853
|
};
|
|
671
|
-
})
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
854
|
+
});
|
|
855
|
+
var selectZAxisWithScale = createSelector((state, _axisType, axisId) => selectZAxisSettings(state, axisId), createSelector([
|
|
856
|
+
selectBaseAxis,
|
|
857
|
+
selectRealScaleType,
|
|
858
|
+
selectAxisDomain,
|
|
859
|
+
selectAxisRangeWithReverse
|
|
860
|
+
], combineScaleFunction), (axis, scale) => {
|
|
861
|
+
if (axis == null || scale == null) return;
|
|
862
|
+
return {
|
|
863
|
+
...axis,
|
|
864
|
+
scale
|
|
680
865
|
};
|
|
681
|
-
})
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
case "
|
|
866
|
+
});
|
|
867
|
+
var selectChartDirection = createSelector([
|
|
868
|
+
selectChartLayout,
|
|
869
|
+
selectAllXAxes,
|
|
870
|
+
selectAllYAxes
|
|
871
|
+
], (layout, allXAxes, allYAxes) => {
|
|
872
|
+
switch (layout) {
|
|
873
|
+
case "horizontal": return allXAxes.some((axis) => axis.reversed) ? "right-to-left" : "left-to-right";
|
|
874
|
+
case "vertical": return allYAxes.some((axis) => axis.reversed) ? "bottom-to-top" : "top-to-bottom";
|
|
689
875
|
default: return;
|
|
690
876
|
}
|
|
691
877
|
});
|
|
692
878
|
//#endregion
|
|
693
|
-
export {
|
|
879
|
+
export { combineAppliedNumericalValuesIncludingErrorValues, combineAppliedValues, combineAreasDomain, combineAxisDomain, combineAxisDomainWithNiceTicks, combineAxisTicks, combineCategoricalDomain, combineDisplayedData, combineDomainOfStackGroups, combineDotsDomain, combineDuplicateDomain, combineGraphicalItemTicks, combineGraphicalItemsData, combineGraphicalItemsSettings, combineLinesDomain, combineNiceTicks, combineNumericalDomain, combineRealScaleType, combineScaleFunction, combineStackGroups, filterGraphicalNotStackedItems, filterReferenceElements, getDomainDefinition, implicitXAxis, implicitYAxis, implicitZAxis, itemAxisPredicate, mergeDomains, selectAxisPropsNeededForCartesianGridTicksGenerator, selectAxisRange, selectAxisScale, selectAxisSettings, selectAxisWithScale, selectBaseAxis, selectCartesianAxisSize, selectChartDirection, selectDomainDefinition, selectDuplicateDomain, selectHasBar, selectRealScaleType, selectReferenceAreas, selectReferenceDots, selectReferenceLines, selectStackGroups, selectTicksOfAxis, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems, selectXAxisPosition, selectXAxisSettings, selectXAxisSize, selectYAxisPosition, selectYAxisSettings, selectYAxisSize, selectZAxisWithScale };
|