vccs 0.1.0 → 0.3.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/README.md +151 -0
- package/dist/animation/Animate.d.ts +1 -1
- package/dist/cartesian/area/type.d.ts +3 -3
- package/dist/cartesian/bar/type.d.ts +1 -13
- package/dist/cartesian/brush/components/Slide.d.ts +1 -1
- package/dist/cartesian/brush/components/TravellerLayer.d.ts +1 -1
- package/dist/cartesian/brush/type.d.ts +2 -1
- package/dist/cartesian/cartesian-axis/CartesianAxis.d.ts +2 -1
- 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 -6
- package/dist/cartesian/index.d.ts +2 -0
- package/dist/cartesian/line/Line.d.ts +7 -13
- package/dist/cartesian/line/type.d.ts +4 -17
- package/dist/cartesian/reference-area/ReferenceArea.d.ts +16 -16
- package/dist/cartesian/reference-dot/ReferenceDot.d.ts +143 -0
- package/dist/cartesian/reference-dot/index.d.ts +2 -0
- package/dist/cartesian/reference-line/ReferenceLine.d.ts +8 -8
- package/dist/cartesian/scatter/Scatter.d.ts +1 -1
- package/dist/chart/FunnelChart.d.ts +1 -0
- package/dist/chart/RechartsWrapper.d.ts +7 -3
- package/dist/chart/Surface.d.ts +2 -1
- package/dist/chart/Treemap.d.ts +237 -0
- package/dist/chart/generateCategoricalChart.d.ts +2 -1
- package/dist/chart/index.d.ts +2 -0
- package/dist/chart/treemapUtils.d.ts +22 -0
- package/dist/components/Customized.d.ts +23 -0
- package/dist/components/Text.d.ts +4 -4
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/label/Label.d.ts +3 -3
- package/dist/components/label/types.d.ts +1 -1
- package/dist/container/Surface.d.ts +3 -2
- 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 +13 -15
- 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 +78 -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 +11 -25
- 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 +162 -0
- package/dist/es/cartesian/funnel/type.mjs +78 -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 +13 -18
- package/dist/es/cartesian/line/utils.mjs +27 -26
- package/dist/es/cartesian/reference-area/ReferenceArea.mjs +79 -78
- package/dist/es/cartesian/reference-dot/ReferenceDot.mjs +134 -0
- package/dist/es/cartesian/reference-line/ReferenceLine.mjs +93 -84
- 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 +113 -89
- 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/Treemap.mjs +379 -0
- package/dist/es/chart/const.mjs +2 -2
- package/dist/es/chart/generateCategoricalChart.mjs +99 -89
- package/dist/es/chart/provideClipPathId.mjs +12 -7
- package/dist/es/chart/treemapUtils.mjs +32 -0
- package/dist/es/components/Cell.mjs +16 -4
- package/dist/es/components/Customized.mjs +43 -0
- 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 +10 -6
- 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 +71 -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 +25 -23
- 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/publicHooks.mjs +207 -0
- package/dist/es/hooks/useIsAnimating.mjs +28 -0
- package/dist/es/hooks/useSetupGraphicalItem.mjs +52 -43
- package/dist/es/index.mjs +54 -42
- package/dist/es/polar/pie/Pie.mjs +131 -115
- package/dist/es/polar/pie/type.mjs +8 -10
- 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 +71 -44
- package/dist/es/shape/Dot.mjs +12 -11
- package/dist/es/shape/Polygon.mjs +19 -0
- package/dist/es/shape/Rectangle.mjs +41 -30
- package/dist/es/shape/Sector.mjs +105 -79
- package/dist/es/shape/Symbols.mjs +45 -34
- package/dist/es/shape/Trapezoid.mjs +50 -0
- package/dist/es/state/ReportChartProps.mjs +23 -24
- 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 +24 -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 +784 -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/common.mjs +12 -0
- 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/cell.mjs +28 -0
- package/dist/es/utils/chart.mjs +298 -197
- package/dist/es/utils/const.mjs +30 -2
- package/dist/es/utils/createCategoricalInverse.mjs +46 -0
- 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/scale.mjs +46 -0
- 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/publicHooks.d.ts +143 -0
- package/dist/hooks/useIsAnimating.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/polar/pie/type.d.ts +2 -2
- package/dist/polar/radar/Radar.d.ts +4 -4
- package/dist/shape/Curve.d.ts +2 -1
- package/dist/shape/Polygon.d.ts +9 -0
- package/dist/shape/Rectangle.d.ts +0 -4
- package/dist/shape/Sector.d.ts +2 -2
- package/dist/shape/Symbols.d.ts +2 -1
- package/dist/shape/Trapezoid.d.ts +30 -0
- package/dist/shape/index.d.ts +2 -0
- package/dist/shape/types.d.ts +4 -5
- package/dist/state/ReportChartProps.d.ts +3 -3
- package/dist/state/graphicalItemsSlice.d.ts +1 -1
- package/dist/state/rootPropsSlice.d.ts +2 -2
- package/dist/state/selectors/axisSelectors.d.ts +5 -0
- package/dist/types/axis.d.ts +2 -2
- package/dist/types/bar.d.ts +2 -6
- package/dist/types/categorical.d.ts +2 -2
- package/dist/types/common.d.ts +7 -1
- package/dist/types/tooltip.d.ts +2 -2
- package/dist/utils/cell.d.ts +11 -0
- package/dist/utils/createCategoricalInverse.d.ts +16 -0
- package/dist/utils/scale.d.ts +23 -0
- package/package.json +2 -1
|
@@ -1,178 +1,241 @@
|
|
|
1
|
-
import { isNullish
|
|
2
|
-
import { selectChartDataWithIndexesIfNotInPanorama
|
|
3
|
-
import { selectChartOffset
|
|
4
|
-
import { selectBarCategoryGap
|
|
5
|
-
import { getPercentValue
|
|
6
|
-
import { selectChartLayout
|
|
7
|
-
import { getBandSizeOfAxis
|
|
8
|
-
import { selectAxisWithScale
|
|
9
|
-
import { computeBarRectangles
|
|
10
|
-
import { createSelector
|
|
1
|
+
import { isNullish } from "../../utils/validate.mjs";
|
|
2
|
+
import { selectChartDataWithIndexesIfNotInPanorama } from "./dataSelectors.mjs";
|
|
3
|
+
import { selectChartOffset } from "./selectChartOffset.mjs";
|
|
4
|
+
import { selectBarCategoryGap, selectBarGap, selectRootBarSize, selectRootMaxBarSize } from "./rootPropsSelectors.mjs";
|
|
5
|
+
import { getPercentValue } from "../../utils/data.mjs";
|
|
6
|
+
import { selectChartLayout } from "./common.mjs";
|
|
7
|
+
import { getBandSizeOfAxis } from "../../utils/chart.mjs";
|
|
8
|
+
import { selectAxisWithScale, selectCartesianAxisSize, selectStackGroups, selectTicksOfGraphicalItem, selectUnfilteredCartesianItems } from "./axisSelectors.mjs";
|
|
9
|
+
import { computeBarRectangles } from "../../cartesian/bar/utils.mjs";
|
|
10
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
11
11
|
//#region src/state/selectors/barSelectors.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
12
|
+
var pickXAxisId = (_state, xAxisId) => xAxisId;
|
|
13
|
+
var pickYAxisId = (_state, _xAxisId, yAxisId) => yAxisId;
|
|
14
|
+
function pickIsPanorama(_state, _xAxisId, _yAxisId, isPanorama) {
|
|
15
|
+
return isPanorama;
|
|
16
|
+
}
|
|
17
|
+
function pickBarSettings(_state, _xAxisId, _yAxisId, _isPanorama, barSettings) {
|
|
18
|
+
return barSettings;
|
|
19
|
+
}
|
|
20
|
+
function pickMaxBarSize(_state, _xAxisId, _yAxisId, _isPanorama, barSettings) {
|
|
21
|
+
return barSettings.maxBarSize;
|
|
22
|
+
}
|
|
23
|
+
function getBarSize(globalSize, totalSize, selfSize) {
|
|
24
|
+
const barSize = selfSize ?? globalSize;
|
|
25
|
+
return isNullish(barSize) ? void 0 : getPercentValue(barSize, totalSize, 0);
|
|
26
|
+
}
|
|
27
|
+
var selectAllVisibleBars = createSelector([
|
|
28
|
+
selectChartLayout,
|
|
29
|
+
selectUnfilteredCartesianItems,
|
|
30
|
+
pickXAxisId,
|
|
31
|
+
pickYAxisId,
|
|
32
|
+
pickIsPanorama
|
|
33
|
+
], (layout, allItems, xAxisId, yAxisId, isPanorama) => allItems.filter((i) => {
|
|
34
|
+
if (layout === "horizontal") return i.xAxisId === xAxisId;
|
|
35
|
+
return i.yAxisId === yAxisId;
|
|
36
|
+
}).filter((i) => i.isPanorama === isPanorama).filter((i) => i.hide === false).filter((i) => i.type === "bar"));
|
|
37
|
+
function selectBarStackGroups(state, xAxisId, yAxisId, isPanorama) {
|
|
38
|
+
if (selectChartLayout(state) === "horizontal") return selectStackGroups(state, "yAxis", yAxisId, isPanorama);
|
|
39
|
+
return selectStackGroups(state, "xAxis", xAxisId, isPanorama);
|
|
40
|
+
}
|
|
41
|
+
function selectBarCartesianAxisSize(state, xAxisId, yAxisId) {
|
|
42
|
+
if (selectChartLayout(state) === "horizontal") return selectCartesianAxisSize(state, "xAxis", xAxisId);
|
|
43
|
+
return selectCartesianAxisSize(state, "yAxis", yAxisId);
|
|
44
|
+
}
|
|
45
|
+
function combineBarSizeList(allBars, globalSize, totalSize) {
|
|
46
|
+
const initialValue = {};
|
|
47
|
+
const stackedBars = allBars.filter((b) => b.stackId != null);
|
|
48
|
+
const unstackedBars = allBars.filter((b) => b.stackId == null);
|
|
49
|
+
const groupByStack = stackedBars.reduce((acc, bar) => {
|
|
50
|
+
if (!acc[bar.stackId]) acc[bar.stackId] = [];
|
|
51
|
+
acc[bar.stackId].push(bar);
|
|
52
|
+
return acc;
|
|
53
|
+
}, initialValue);
|
|
54
|
+
const stackedSizeList = Object.entries(groupByStack).map(([stackId, bars]) => {
|
|
55
|
+
return {
|
|
56
|
+
stackId,
|
|
57
|
+
dataKeys: bars.map((b) => b.dataKey),
|
|
58
|
+
barSize: getBarSize(globalSize, totalSize, bars[0].barSize)
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
const unstackedSizeList = unstackedBars.map((b) => {
|
|
62
|
+
return {
|
|
63
|
+
stackId: void 0,
|
|
64
|
+
dataKeys: [b.dataKey],
|
|
65
|
+
barSize: getBarSize(globalSize, totalSize, b.barSize)
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return [...stackedSizeList, ...unstackedSizeList];
|
|
69
|
+
}
|
|
70
|
+
var selectBarSizeList = createSelector([
|
|
71
|
+
selectAllVisibleBars,
|
|
72
|
+
selectRootBarSize,
|
|
73
|
+
selectBarCartesianAxisSize
|
|
74
|
+
], combineBarSizeList);
|
|
75
|
+
function selectBarBandSize(state, xAxisId, yAxisId, isPanorama, barSettings) {
|
|
76
|
+
const layout = selectChartLayout(state);
|
|
77
|
+
const globalMaxBarSize = selectRootMaxBarSize(state);
|
|
78
|
+
const { maxBarSize: childMaxBarSize } = barSettings;
|
|
79
|
+
const maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
|
|
80
|
+
let axis, ticks;
|
|
81
|
+
if (layout === "horizontal") {
|
|
82
|
+
axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
|
|
83
|
+
ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
|
|
84
|
+
} else {
|
|
85
|
+
axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
|
|
86
|
+
ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
|
|
87
|
+
}
|
|
88
|
+
return getBandSizeOfAxis(axis, ticks, true) ?? maxBarSize ?? 0;
|
|
89
|
+
}
|
|
90
|
+
function selectAxisBandSize(state, xAxisId, yAxisId, isPanorama) {
|
|
91
|
+
const layout = selectChartLayout(state);
|
|
92
|
+
let axis, ticks;
|
|
93
|
+
if (layout === "horizontal") {
|
|
94
|
+
axis = selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
|
|
95
|
+
ticks = selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
|
|
96
|
+
} else {
|
|
97
|
+
axis = selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
|
|
98
|
+
ticks = selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
|
|
99
|
+
}
|
|
100
|
+
return getBandSizeOfAxis(axis, ticks);
|
|
101
|
+
}
|
|
102
|
+
function getBarPositions(barGap, barCategoryGap, bandSize, sizeList, maxBarSize) {
|
|
103
|
+
const len = sizeList.length;
|
|
104
|
+
if (len < 1) return null;
|
|
105
|
+
let realBarGap = getPercentValue(barGap, bandSize, 0, true);
|
|
106
|
+
let result;
|
|
107
|
+
const initialValue = [];
|
|
108
|
+
if (sizeList[0].barSize === +sizeList[0].barSize) {
|
|
109
|
+
let useFull = false;
|
|
110
|
+
let fullBarSize = bandSize / len;
|
|
111
|
+
let sum = sizeList.reduce((res, entry) => res + entry.barSize || 0, 0);
|
|
112
|
+
sum += (len - 1) * realBarGap;
|
|
113
|
+
if (sum >= bandSize) {
|
|
114
|
+
sum -= (len - 1) * realBarGap;
|
|
115
|
+
realBarGap = 0;
|
|
116
|
+
}
|
|
117
|
+
if (sum >= bandSize && fullBarSize > 0) {
|
|
118
|
+
useFull = true;
|
|
119
|
+
fullBarSize *= .9;
|
|
120
|
+
sum = len * fullBarSize;
|
|
121
|
+
}
|
|
122
|
+
let prev = {
|
|
123
|
+
offset: ((bandSize - sum) / 2 >> 0) - realBarGap,
|
|
73
124
|
size: 0
|
|
74
125
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
stackId:
|
|
78
|
-
dataKeys:
|
|
126
|
+
result = sizeList.reduce((res, entry) => {
|
|
127
|
+
const newPosition = {
|
|
128
|
+
stackId: entry.stackId,
|
|
129
|
+
dataKeys: entry.dataKeys,
|
|
79
130
|
position: {
|
|
80
|
-
offset:
|
|
81
|
-
size:
|
|
131
|
+
offset: prev.offset + prev.size + realBarGap,
|
|
132
|
+
size: useFull ? fullBarSize : entry.barSize
|
|
82
133
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
134
|
+
};
|
|
135
|
+
const newRes = [...res, newPosition];
|
|
136
|
+
prev = newRes[newRes.length - 1].position;
|
|
137
|
+
return newRes;
|
|
138
|
+
}, initialValue);
|
|
86
139
|
} else {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
stackId:
|
|
94
|
-
dataKeys:
|
|
140
|
+
const offset = getPercentValue(barCategoryGap, bandSize, 0, true);
|
|
141
|
+
if (bandSize - 2 * offset - (len - 1) * realBarGap <= 0) realBarGap = 0;
|
|
142
|
+
let originalSize = (bandSize - 2 * offset - (len - 1) * realBarGap) / len;
|
|
143
|
+
if (originalSize > 1) originalSize >>= 0;
|
|
144
|
+
const size = maxBarSize === +maxBarSize ? Math.min(originalSize, maxBarSize) : originalSize;
|
|
145
|
+
result = sizeList.reduce((res, entry, i) => [...res, {
|
|
146
|
+
stackId: entry.stackId,
|
|
147
|
+
dataKeys: entry.dataKeys,
|
|
95
148
|
position: {
|
|
96
|
-
offset:
|
|
97
|
-
size
|
|
149
|
+
offset: offset + (originalSize + realBarGap) * i + (originalSize - size) / 2,
|
|
150
|
+
size
|
|
98
151
|
}
|
|
99
|
-
}],
|
|
152
|
+
}], initialValue);
|
|
100
153
|
}
|
|
101
|
-
return
|
|
154
|
+
return result;
|
|
102
155
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
156
|
+
function combineAllBarPositions(sizeList, globalMaxBarSize, barGap, barCategoryGap, barBandSize, bandSize, childMaxBarSize) {
|
|
157
|
+
const maxBarSize = isNullish(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
|
|
158
|
+
let allBarPositions = getBarPositions(barGap, barCategoryGap, barBandSize !== bandSize ? barBandSize : bandSize, sizeList, maxBarSize);
|
|
159
|
+
if (barBandSize !== bandSize && allBarPositions != null) allBarPositions = allBarPositions.map((pos) => ({
|
|
160
|
+
...pos,
|
|
107
161
|
position: {
|
|
108
|
-
...
|
|
109
|
-
offset:
|
|
162
|
+
...pos.position,
|
|
163
|
+
offset: pos.position.offset - barBandSize / 2
|
|
110
164
|
}
|
|
111
|
-
}))
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
165
|
+
}));
|
|
166
|
+
return allBarPositions;
|
|
167
|
+
}
|
|
168
|
+
var selectAllBarPositions = createSelector([
|
|
169
|
+
selectBarSizeList,
|
|
170
|
+
selectRootMaxBarSize,
|
|
171
|
+
selectBarGap,
|
|
172
|
+
selectBarCategoryGap,
|
|
173
|
+
selectBarBandSize,
|
|
174
|
+
selectAxisBandSize,
|
|
175
|
+
pickMaxBarSize
|
|
176
|
+
], combineAllBarPositions);
|
|
177
|
+
function selectXAxisWithScale(state, xAxisId, _yAxisId, isPanorama) {
|
|
178
|
+
return selectAxisWithScale(state, "xAxis", xAxisId, isPanorama);
|
|
179
|
+
}
|
|
180
|
+
function selectYAxisWithScale(state, _xAxisId, yAxisId, isPanorama) {
|
|
181
|
+
return selectAxisWithScale(state, "yAxis", yAxisId, isPanorama);
|
|
182
|
+
}
|
|
183
|
+
function selectXAxisTicks(state, xAxisId, _yAxisId, isPanorama) {
|
|
184
|
+
return selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama);
|
|
185
|
+
}
|
|
186
|
+
function selectYAxisTicks(state, _xAxisId, yAxisId, isPanorama) {
|
|
187
|
+
return selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama);
|
|
188
|
+
}
|
|
189
|
+
var selectBarPosition = createSelector([selectAllBarPositions, pickBarSettings], (allBarPositions, barSettings) => {
|
|
190
|
+
if (allBarPositions == null) return;
|
|
191
|
+
const position = allBarPositions.find((p) => p.stackId === barSettings.stackId && p.dataKeys.includes(barSettings.dataKey));
|
|
192
|
+
if (position == null) return;
|
|
193
|
+
return position.position;
|
|
194
|
+
});
|
|
195
|
+
function combineStackedData(stackGroups, barSettings) {
|
|
196
|
+
if (!stackGroups || barSettings?.dataKey == null) return;
|
|
197
|
+
const { stackId } = barSettings;
|
|
198
|
+
const stackGroup = stackGroups[stackId];
|
|
199
|
+
if (!stackGroup) return;
|
|
200
|
+
const { stackedData } = stackGroup;
|
|
201
|
+
if (!stackedData) return;
|
|
202
|
+
return stackedData.find((sd) => sd.key === barSettings.dataKey);
|
|
203
|
+
}
|
|
204
|
+
var selectSynchronisedBarSettings = createSelector([selectUnfilteredCartesianItems, pickBarSettings], (graphicalItems, barSettingsFromProps) => {
|
|
205
|
+
if (graphicalItems.some((cgis) => cgis.type === "bar" && barSettingsFromProps.dataKey === cgis.dataKey && barSettingsFromProps.stackId === cgis.stackId && barSettingsFromProps.stackId === cgis.stackId)) return barSettingsFromProps;
|
|
138
206
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
xAxisTicks: r,
|
|
171
|
-
yAxisTicks: i,
|
|
172
|
-
stackedData: d,
|
|
173
|
-
displayedData: m,
|
|
174
|
-
offset: e
|
|
207
|
+
var selectBarRectangles = createSelector([
|
|
208
|
+
selectChartOffset,
|
|
209
|
+
selectXAxisWithScale,
|
|
210
|
+
selectYAxisWithScale,
|
|
211
|
+
selectXAxisTicks,
|
|
212
|
+
selectYAxisTicks,
|
|
213
|
+
selectBarPosition,
|
|
214
|
+
selectChartLayout,
|
|
215
|
+
selectChartDataWithIndexesIfNotInPanorama,
|
|
216
|
+
selectAxisBandSize,
|
|
217
|
+
createSelector([selectBarStackGroups, pickBarSettings], combineStackedData),
|
|
218
|
+
selectSynchronisedBarSettings
|
|
219
|
+
], (offset, xAxis, yAxis, xAxisTicks, yAxisTicks, pos, layout, { chartData, dataStartIndex, dataEndIndex }, bandSize, stackedData, barSettings) => {
|
|
220
|
+
if (barSettings == null || pos == null || layout !== "horizontal" && layout !== "vertical" || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null) return;
|
|
221
|
+
const { data } = barSettings;
|
|
222
|
+
let displayedData;
|
|
223
|
+
if ((data?.length ?? 0) > 0) displayedData = data;
|
|
224
|
+
else displayedData = chartData?.slice(dataStartIndex, dataEndIndex + 1);
|
|
225
|
+
if (displayedData == null) return;
|
|
226
|
+
return computeBarRectangles({
|
|
227
|
+
layout,
|
|
228
|
+
barSettings,
|
|
229
|
+
pos,
|
|
230
|
+
bandSize,
|
|
231
|
+
xAxis,
|
|
232
|
+
yAxis,
|
|
233
|
+
xAxisTicks,
|
|
234
|
+
yAxisTicks,
|
|
235
|
+
stackedData,
|
|
236
|
+
displayedData,
|
|
237
|
+
offset
|
|
175
238
|
});
|
|
176
239
|
});
|
|
177
240
|
//#endregion
|
|
178
|
-
export {
|
|
241
|
+
export { combineAllBarPositions, combineBarSizeList, combineStackedData, selectBarRectangles };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { isNumber
|
|
2
|
-
import { selectMargin
|
|
3
|
-
import { selectChartOffset
|
|
4
|
-
import { createSelector
|
|
1
|
+
import { isNumber } from "../../utils/validate.mjs";
|
|
2
|
+
import { selectMargin } from "./containerSelectors.mjs";
|
|
3
|
+
import { selectChartOffset } from "./selectChartOffset.mjs";
|
|
4
|
+
import { createSelector } from "@reduxjs/toolkit";
|
|
5
5
|
//#region src/state/selectors/brushSelectors.ts
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
var selectBrushSettings = (state) => state.brush;
|
|
7
|
+
var selectBrushDimensions = createSelector([
|
|
8
|
+
selectBrushSettings,
|
|
9
|
+
selectChartOffset,
|
|
10
|
+
selectMargin
|
|
11
|
+
], (brushSettings, offset, margin) => ({
|
|
12
|
+
height: brushSettings.height,
|
|
13
|
+
x: isNumber(brushSettings.x) ? brushSettings.x : offset.left,
|
|
14
|
+
y: isNumber(brushSettings.y) ? brushSettings.y : offset.top + offset.height + offset.brushBottom - (margin?.bottom || 0),
|
|
15
|
+
width: isNumber(brushSettings.width) ? brushSettings.width : offset.width
|
|
15
16
|
}));
|
|
16
17
|
//#endregion
|
|
17
|
-
export {
|
|
18
|
+
export { selectBrushDimensions, selectBrushSettings };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isNan
|
|
1
|
+
import { isNan } from "../../../utils/validate.mjs";
|
|
2
2
|
//#region src/state/selectors/combiners/combineActiveLabel.ts
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
if (
|
|
3
|
+
function combineActiveLabel(tooltipTicks, activeIndex) {
|
|
4
|
+
const n = Number(activeIndex);
|
|
5
|
+
if (isNan(n) || activeIndex == null) return;
|
|
6
|
+
return n >= 0 ? tooltipTicks?.[n]?.value : void 0;
|
|
6
7
|
}
|
|
7
8
|
//#endregion
|
|
8
|
-
export {
|
|
9
|
+
export { combineActiveLabel };
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
-
import { isWellBehavedNumber
|
|
2
|
-
import { getValueByDataKey
|
|
3
|
-
import { isWellFormedNumberDomain
|
|
1
|
+
import { isWellBehavedNumber } from "../../../utils/validate.mjs";
|
|
2
|
+
import { getValueByDataKey } from "../../../utils/chart.mjs";
|
|
3
|
+
import { isWellFormedNumberDomain } from "../../../utils/isDomainSpecifiedByUser.mjs";
|
|
4
4
|
//#region src/state/selectors/combiners/combineActiveTooltipIndex.ts
|
|
5
|
-
function
|
|
6
|
-
if (typeof
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
return Number.isFinite(
|
|
5
|
+
function toFiniteNumber(value) {
|
|
6
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
7
|
+
if (value instanceof Date) {
|
|
8
|
+
const numericValue = value.valueOf();
|
|
9
|
+
return Number.isFinite(numericValue) ? numericValue : void 0;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
return Number.isFinite(
|
|
11
|
+
const parsed = Number(value);
|
|
12
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
function isValueWithinNumberDomain(value, domain) {
|
|
15
|
+
const numericValue = toFiniteNumber(value);
|
|
16
|
+
const lowerBound = domain[0];
|
|
17
|
+
const upperBound = domain[1];
|
|
18
|
+
if (numericValue === void 0) return false;
|
|
19
|
+
return numericValue >= Math.min(lowerBound, upperBound) && numericValue <= Math.max(lowerBound, upperBound);
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
function isValueWithinDomain(entry, axisDataKey, domain) {
|
|
22
|
+
if (domain == null || axisDataKey == null) return true;
|
|
23
|
+
const value = getValueByDataKey(entry, axisDataKey);
|
|
24
|
+
if (value == null) return true;
|
|
25
|
+
if (!isWellFormedNumberDomain(domain)) return true;
|
|
26
|
+
return isValueWithinNumberDomain(value, domain);
|
|
22
27
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
if (!
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
function combineActiveTooltipIndex(tooltipInteraction, chartData, axisDataKey, domain) {
|
|
29
|
+
const desiredIndex = tooltipInteraction?.index;
|
|
30
|
+
if (desiredIndex == null) return null;
|
|
31
|
+
const indexAsNumber = Number(desiredIndex);
|
|
32
|
+
if (!isWellBehavedNumber(indexAsNumber)) return desiredIndex;
|
|
33
|
+
const lowerLimit = 0;
|
|
34
|
+
let upperLimit = Infinity;
|
|
35
|
+
if (chartData.length > 0) upperLimit = chartData.length - 1;
|
|
36
|
+
const clampedIndex = Math.max(lowerLimit, Math.min(indexAsNumber, upperLimit));
|
|
37
|
+
const entry = chartData[clampedIndex];
|
|
38
|
+
if (entry == null) return String(clampedIndex);
|
|
39
|
+
if (!isValueWithinDomain(entry, axisDataKey, domain)) return null;
|
|
40
|
+
return String(clampedIndex);
|
|
32
41
|
}
|
|
33
42
|
//#endregion
|
|
34
|
-
export {
|
|
43
|
+
export { combineActiveTooltipIndex };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
//#region src/state/selectors/combiners/combineAxisRangeWithReverse.ts
|
|
2
|
-
function
|
|
3
|
-
if (!
|
|
2
|
+
function combineAxisRangeWithReverse(axisSettings, axisRange) {
|
|
3
|
+
if (!axisSettings || !axisRange) return;
|
|
4
|
+
if (axisSettings?.reversed) return [axisRange[1], axisRange[0]];
|
|
5
|
+
return axisRange;
|
|
4
6
|
}
|
|
5
7
|
//#endregion
|
|
6
|
-
export {
|
|
8
|
+
export { combineAxisRangeWithReverse };
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
//#region src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
function combineCoordinateForDefaultIndex(width, height, layout, offset, tooltipTicks, defaultIndex, tooltipConfigurations, tooltipPayloadSearcher) {
|
|
3
|
+
if (defaultIndex == null || offset == null) return;
|
|
4
|
+
const firstConfiguration = tooltipConfigurations[0];
|
|
5
|
+
const maybePosition = firstConfiguration == null ? void 0 : tooltipPayloadSearcher?.(firstConfiguration.positions, defaultIndex);
|
|
6
|
+
if (maybePosition != null) return maybePosition;
|
|
7
|
+
const tick = tooltipTicks?.[Number(defaultIndex)];
|
|
8
|
+
if (!tick) return;
|
|
9
|
+
switch (layout) {
|
|
8
10
|
case "horizontal": return {
|
|
9
|
-
x:
|
|
10
|
-
y: (
|
|
11
|
+
x: tick.coordinate,
|
|
12
|
+
y: (offset.top + height) / 2
|
|
11
13
|
};
|
|
12
14
|
default: return {
|
|
13
|
-
x: (
|
|
14
|
-
y:
|
|
15
|
+
x: (offset.left + width) / 2,
|
|
16
|
+
y: tick.coordinate
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
//#endregion
|
|
19
|
-
export {
|
|
21
|
+
export { combineCoordinateForDefaultIndex };
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { noInteraction
|
|
1
|
+
import { noInteraction } from "../../tooltipSlice.mjs";
|
|
2
2
|
//#region src/state/selectors/combiners/combineTooltipInteractionState.ts
|
|
3
|
-
function
|
|
4
|
-
|
|
3
|
+
function chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger) {
|
|
4
|
+
if (tooltipEventType === "axis") {
|
|
5
|
+
if (trigger === "click") return tooltipState.axisInteraction.click;
|
|
6
|
+
return tooltipState.axisInteraction.hover;
|
|
7
|
+
}
|
|
8
|
+
if (trigger === "click") return tooltipState.itemInteraction.click;
|
|
9
|
+
return tooltipState.itemInteraction.hover;
|
|
5
10
|
}
|
|
6
|
-
function
|
|
7
|
-
return
|
|
11
|
+
function hasBeenActivePreviously(tooltipInteractionState) {
|
|
12
|
+
return tooltipInteractionState.index != null;
|
|
8
13
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
...
|
|
18
|
-
active:
|
|
14
|
+
function combineTooltipInteractionState(tooltipState, tooltipEventType, trigger, defaultIndex) {
|
|
15
|
+
const appropriateMouseInteraction = chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger);
|
|
16
|
+
if (appropriateMouseInteraction?.active) return appropriateMouseInteraction;
|
|
17
|
+
if (tooltipState.keyboardInteraction.active) return tooltipState.keyboardInteraction;
|
|
18
|
+
if (tooltipState.syncInteraction.active && tooltipState.syncInteraction.index != null) return tooltipState.syncInteraction;
|
|
19
|
+
const activeFromProps = tooltipState.settings.active === true;
|
|
20
|
+
if (hasBeenActivePreviously(appropriateMouseInteraction)) {
|
|
21
|
+
if (activeFromProps) return {
|
|
22
|
+
...appropriateMouseInteraction,
|
|
23
|
+
active: true
|
|
19
24
|
};
|
|
20
|
-
} else if (
|
|
21
|
-
active:
|
|
25
|
+
} else if (defaultIndex != null) return {
|
|
26
|
+
active: true,
|
|
22
27
|
coordinate: void 0,
|
|
23
28
|
dataKey: void 0,
|
|
24
|
-
index:
|
|
29
|
+
index: defaultIndex
|
|
25
30
|
};
|
|
26
31
|
return {
|
|
27
|
-
...
|
|
28
|
-
coordinate:
|
|
32
|
+
...noInteraction,
|
|
33
|
+
coordinate: appropriateMouseInteraction?.coordinate
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
36
|
//#endregion
|
|
32
|
-
export {
|
|
37
|
+
export { combineTooltipInteractionState };
|