@octanejs/recharts 0.1.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/LICENSE +21 -0
- package/package.json +53 -0
- package/src/animation/AnimatedItems.tsrx +82 -0
- package/src/animation/AnimationControllerImpl.js +33 -0
- package/src/animation/AnimationHandle.js +291 -0
- package/src/animation/JavascriptAnimate.tsrx +81 -0
- package/src/animation/easing.js +193 -0
- package/src/animation/matchBy.js +279 -0
- package/src/animation/timeoutController.js +49 -0
- package/src/animation/useAnimationController.ts +22 -0
- package/src/animation/useAnimationStartSnapshot.ts +43 -0
- package/src/animation/util.js +11 -0
- package/src/cartesian/Bar.ts +4 -0
- package/src/cartesian/Bar.tsrx +716 -0
- package/src/cartesian/Bar.tsrx.d.ts +4 -0
- package/src/cartesian/BarStack.tsrx +97 -0
- package/src/cartesian/BarStack.tsrx.d.ts +6 -0
- package/src/cartesian/CartesianAxis.tsrx +413 -0
- package/src/cartesian/CartesianAxis.tsrx.d.ts +3 -0
- package/src/cartesian/GraphicalItemClipPath.tsrx +44 -0
- package/src/cartesian/Line.ts +4 -0
- package/src/cartesian/Line.tsrx +544 -0
- package/src/cartesian/Line.tsrx.d.ts +4 -0
- package/src/cartesian/LineDrawShape.tsrx +106 -0
- package/src/cartesian/LineDrawShape.tsrx.d.ts +2 -0
- package/src/cartesian/XAxis.tsrx +156 -0
- package/src/cartesian/XAxis.tsrx.d.ts +3 -0
- package/src/cartesian/YAxis.tsrx +183 -0
- package/src/cartesian/YAxis.tsrx.d.ts +3 -0
- package/src/cartesian/getCartesianPosition.js +277 -0
- package/src/cartesian/getEquidistantTicks.js +133 -0
- package/src/cartesian/getTicks.js +280 -0
- package/src/cartesian/useAnimatedLineLength.ts +33 -0
- package/src/chart/BarChart.tsrx +22 -0
- package/src/chart/BarChart.tsrx.d.ts +2 -0
- package/src/chart/CartesianChart.tsrx +76 -0
- package/src/chart/CartesianChart.tsrx.d.ts +10 -0
- package/src/chart/CategoricalChart.tsrx +54 -0
- package/src/chart/LineChart.tsrx +22 -0
- package/src/chart/LineChart.tsrx.d.ts +2 -0
- package/src/chart/RechartsWrapper.tsrx +294 -0
- package/src/component/ActivePoints.tsrx +76 -0
- package/src/component/Cell.ts +37 -0
- package/src/component/Dots.tsrx +74 -0
- package/src/component/Label.tsrx +309 -0
- package/src/component/Label.tsrx.d.ts +12 -0
- package/src/component/LabelList.tsrx +83 -0
- package/src/component/LabelList.tsrx.d.ts +8 -0
- package/src/component/ResponsiveContainer.ts +22 -0
- package/src/component/Text.tsrx +281 -0
- package/src/component/Text.tsrx.d.ts +9 -0
- package/src/component/responsiveContainerUtils.js +111 -0
- package/src/container/ClipPathProvider.tsrx +29 -0
- package/src/container/Layer.tsrx +9 -0
- package/src/container/Layer.tsrx.d.ts +6 -0
- package/src/container/RootSurface.tsrx +76 -0
- package/src/container/Surface.tsrx +23 -0
- package/src/container/Surface.tsrx.d.ts +12 -0
- package/src/context/CellsContext.ts +80 -0
- package/src/context/ErrorBarContext.tsrx +53 -0
- package/src/context/PanoramaContext.ts +10 -0
- package/src/context/RegisterGraphicalItemId.tsrx +19 -0
- package/src/context/accessibilityContext.js +10 -0
- package/src/context/chartDataContext.ts +57 -0
- package/src/context/chartLayoutContext.ts +171 -0
- package/src/context/legendPortalContext.ts +5 -0
- package/src/context/tooltipContext.js +55 -0
- package/src/context/tooltipPortalContext.ts +5 -0
- package/src/hooks.js +509 -0
- package/src/index.ts +64 -0
- package/src/internal.ts +37 -0
- package/src/polar/defaultPolarAngleAxisProps.js +27 -0
- package/src/polar/defaultPolarRadiusAxisProps.js +24 -0
- package/src/shape/Cross.tsrx +25 -0
- package/src/shape/Cross.tsrx.d.ts +12 -0
- package/src/shape/Curve.tsrx +132 -0
- package/src/shape/Curve.tsrx.d.ts +42 -0
- package/src/shape/Dot.tsrx +21 -0
- package/src/shape/Dot.tsrx.d.ts +9 -0
- package/src/shape/Polygon.tsrx +95 -0
- package/src/shape/Polygon.tsrx.d.ts +13 -0
- package/src/shape/Rectangle.tsrx +162 -0
- package/src/shape/Rectangle.tsrx.d.ts +31 -0
- package/src/shape/Sector.tsrx +219 -0
- package/src/shape/Sector.tsrx.d.ts +29 -0
- package/src/shape/Symbols.tsrx +95 -0
- package/src/shape/Symbols.tsrx.d.ts +15 -0
- package/src/shape/Trapezoid.tsrx +56 -0
- package/src/shape/Trapezoid.tsrx.d.ts +29 -0
- package/src/state/RechartsReduxContext.ts +7 -0
- package/src/state/RechartsStoreProvider.tsrx +24 -0
- package/src/state/ReportChartProps.ts +13 -0
- package/src/state/ReportEventSettings.ts +15 -0
- package/src/state/ReportMainChartProps.ts +22 -0
- package/src/state/SetGraphicalItem.ts +61 -0
- package/src/state/SetLegendPayload.ts +61 -0
- package/src/state/SetTooltipEntrySettings.ts +40 -0
- package/src/state/brushSlice.js +36 -0
- package/src/state/cartesianAxisSlice.js +256 -0
- package/src/state/chartDataSlice.js +67 -0
- package/src/state/errorBarSlice.js +53 -0
- package/src/state/eventSettingsSlice.js +25 -0
- package/src/state/externalEventsMiddleware.js +127 -0
- package/src/state/graphicalItemsSlice.js +91 -0
- package/src/state/hooks.ts +46 -0
- package/src/state/keyboardEventsMiddleware.js +226 -0
- package/src/state/layoutSlice.js +57 -0
- package/src/state/legendSlice.js +83 -0
- package/src/state/mouseEventsMiddleware.js +130 -0
- package/src/state/optionsSlice.js +45 -0
- package/src/state/polarAxisSlice.js +33 -0
- package/src/state/polarOptionsSlice.js +26 -0
- package/src/state/reduxDevtoolsJsonStringifyReplacer.js +14 -0
- package/src/state/referenceElementsSlice.js +51 -0
- package/src/state/renderedTicksSlice.js +41 -0
- package/src/state/rootPropsSlice.js +48 -0
- package/src/state/selectors/arrayEqualityCheck.js +32 -0
- package/src/state/selectors/axisSelectors.js +2113 -0
- package/src/state/selectors/barSelectors.js +263 -0
- package/src/state/selectors/barStackSelectors.js +65 -0
- package/src/state/selectors/brushSelectors.js +21 -0
- package/src/state/selectors/combiners/combineActiveLabel.js +18 -0
- package/src/state/selectors/combiners/combineActiveTooltipIndex.js +75 -0
- package/src/state/selectors/combiners/combineAllBarPositions.js +169 -0
- package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +11 -0
- package/src/state/selectors/combiners/combineBarPosition.js +17 -0
- package/src/state/selectors/combiners/combineBarSizeList.js +115 -0
- package/src/state/selectors/combiners/combineCheckedDomain.js +44 -0
- package/src/state/selectors/combiners/combineConfiguredScale.js +46 -0
- package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +48 -0
- package/src/state/selectors/combiners/combineDisplayedStackedData.js +54 -0
- package/src/state/selectors/combiners/combineInverseScaleFunction.js +12 -0
- package/src/state/selectors/combiners/combineRealScaleType.js +36 -0
- package/src/state/selectors/combiners/combineStackedData.js +22 -0
- package/src/state/selectors/combiners/combineTooltipInteractionState.js +121 -0
- package/src/state/selectors/combiners/combineTooltipPayload.js +248 -0
- package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.js +59 -0
- package/src/state/selectors/containerSelectors.js +6 -0
- package/src/state/selectors/dataSelectors.js +97 -0
- package/src/state/selectors/graphicalItemSelectors.js +25 -0
- package/src/state/selectors/legendSelectors.js +18 -0
- package/src/state/selectors/lineSelectors.js +106 -0
- package/src/state/selectors/numberDomainEqualityCheck.js +11 -0
- package/src/state/selectors/pickAxisId.js +3 -0
- package/src/state/selectors/pickAxisType.js +3 -0
- package/src/state/selectors/polarAxisSelectors.js +237 -0
- package/src/state/selectors/rootPropsSelectors.js +13 -0
- package/src/state/selectors/selectActivePropsFromChartPointer.js +23 -0
- package/src/state/selectors/selectAllAxes.js +15 -0
- package/src/state/selectors/selectChartOffset.js +12 -0
- package/src/state/selectors/selectChartOffsetInternal.js +174 -0
- package/src/state/selectors/selectPlotArea.js +19 -0
- package/src/state/selectors/selectTooltipAxisId.js +3 -0
- package/src/state/selectors/selectTooltipAxisType.js +25 -0
- package/src/state/selectors/selectTooltipEventType.js +27 -0
- package/src/state/selectors/selectTooltipPayloadSearcher.js +3 -0
- package/src/state/selectors/selectTooltipSettings.js +3 -0
- package/src/state/selectors/selectTooltipState.js +3 -0
- package/src/state/selectors/selectors.js +222 -0
- package/src/state/selectors/tooltipSelectors.js +471 -0
- package/src/state/selectors/touchSelectors.js +31 -0
- package/src/state/store.js +101 -0
- package/src/state/tooltipSlice.js +237 -0
- package/src/state/touchEventsMiddleware.js +140 -0
- package/src/state/types/StackedGraphicalItem.js +18 -0
- package/src/state/zIndexSlice.js +167 -0
- package/src/synchronisation/syncSelectors.js +5 -0
- package/src/synchronisation/useChartSynchronisation.tsrx +285 -0
- package/src/util/ActiveShapeUtils.tsrx +62 -0
- package/src/util/BarUtils.tsrx +35 -0
- package/src/util/CartesianUtils.js +66 -0
- package/src/util/ChartUtils.js +630 -0
- package/src/util/Constants.js +42 -0
- package/src/util/DOMUtils.js +180 -0
- package/src/util/DataUtils.js +199 -0
- package/src/util/Events.js +7 -0
- package/src/util/Global.js +13 -0
- package/src/util/LRUCache.js +58 -0
- package/src/util/LogUtils.js +29 -0
- package/src/util/PolarUtils.js +190 -0
- package/src/util/ReactUtils.ts +94 -0
- package/src/util/ReduceCSSCalc.js +260 -0
- package/src/util/TickUtils.js +43 -0
- package/src/util/YAxisUtils.js +43 -0
- package/src/util/axisPropsAreEqual.js +63 -0
- package/src/util/createEventProxy.js +18 -0
- package/src/util/excludeEventProps.js +172 -0
- package/src/util/getActiveCoordinate.js +253 -0
- package/src/util/getAxisTypeBasedOnLayout.js +17 -0
- package/src/util/getClassNameFromUnknown.js +8 -0
- package/src/util/getEveryNth.js +29 -0
- package/src/util/getRadiusAndStrokeWidthFromDot.js +28 -0
- package/src/util/getRelativeCoordinate.js +96 -0
- package/src/util/getSliced.js +11 -0
- package/src/util/isDomainSpecifiedByUser.js +255 -0
- package/src/util/isWellBehavedNumber.js +8 -0
- package/src/util/propsAreEqual.js +96 -0
- package/src/util/resolveDefaultProps.js +131 -0
- package/src/util/round.js +39 -0
- package/src/util/scale/RechartsScale.js +68 -0
- package/src/util/scale/createCategoricalInverse.js +77 -0
- package/src/util/scale/getNiceTickValues.js +354 -0
- package/src/util/scale/index.js +3 -0
- package/src/util/scale/util/arithmetic.js +51 -0
- package/src/util/stacks/getStackSeriesIdentifier.js +10 -0
- package/src/util/svgPropertiesAndEvents.ts +29 -0
- package/src/util/svgPropertiesNoEvents.js +383 -0
- package/src/util/types.ts +59 -0
- package/src/util/useAnimationId.ts +14 -0
- package/src/util/useId.ts +13 -0
- package/src/util/usePrefersReducedMotion.ts +30 -0
- package/src/util/useReportScale.ts +26 -0
- package/src/util/useUniqueId.js +34 -0
- package/src/zIndex/DefaultZIndexes.js +75 -0
- package/src/zIndex/ZIndexLayer.tsrx +80 -0
- package/src/zIndex/ZIndexLayer.tsrx.d.ts +2 -0
- package/src/zIndex/ZIndexPortal.tsrx +43 -0
- package/src/zIndex/getZIndexFromUnknown.js +15 -0
- package/src/zIndex/zIndexSelectors.js +45 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineBarSizeList.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
function _slicedToArray(r, e) {
|
|
4
|
+
return (
|
|
5
|
+
_arrayWithHoles(r) ||
|
|
6
|
+
_iterableToArrayLimit(r, e) ||
|
|
7
|
+
_unsupportedIterableToArray(r, e) ||
|
|
8
|
+
_nonIterableRest()
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function _nonIterableRest() {
|
|
12
|
+
throw new TypeError(
|
|
13
|
+
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function _unsupportedIterableToArray(r, a) {
|
|
17
|
+
if (r) {
|
|
18
|
+
if ('string' == typeof r) return _arrayLikeToArray(r, a);
|
|
19
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
20
|
+
return (
|
|
21
|
+
'Object' === t && r.constructor && (t = r.constructor.name),
|
|
22
|
+
'Map' === t || 'Set' === t
|
|
23
|
+
? Array.from(r)
|
|
24
|
+
: 'Arguments' === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
|
|
25
|
+
? _arrayLikeToArray(r, a)
|
|
26
|
+
: void 0
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _arrayLikeToArray(r, a) {
|
|
31
|
+
(null == a || a > r.length) && (a = r.length);
|
|
32
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
function _iterableToArrayLimit(r, l) {
|
|
36
|
+
var t =
|
|
37
|
+
null == r ? null : ('undefined' != typeof Symbol && r[Symbol.iterator]) || r['@@iterator'];
|
|
38
|
+
if (null != t) {
|
|
39
|
+
var e,
|
|
40
|
+
n,
|
|
41
|
+
i,
|
|
42
|
+
u,
|
|
43
|
+
a = [],
|
|
44
|
+
f = !0,
|
|
45
|
+
o = !1;
|
|
46
|
+
try {
|
|
47
|
+
if (((i = (t = t.call(r)).next), 0 === l)) {
|
|
48
|
+
if (Object(t) !== t) return;
|
|
49
|
+
f = !1;
|
|
50
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
51
|
+
} catch (r) {
|
|
52
|
+
((o = !0), (n = r));
|
|
53
|
+
} finally {
|
|
54
|
+
try {
|
|
55
|
+
if (!f && null != t.return && ((u = t.return()), Object(u) !== u)) return;
|
|
56
|
+
} finally {
|
|
57
|
+
if (o) throw n;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return a;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function _arrayWithHoles(r) {
|
|
64
|
+
if (Array.isArray(r)) return r;
|
|
65
|
+
}
|
|
66
|
+
import { isStacked } from '../../types/StackedGraphicalItem';
|
|
67
|
+
import { getPercentValue, isNullish } from '../../../util/DataUtils';
|
|
68
|
+
var getBarSize = (globalSize, totalSize, selfSize) => {
|
|
69
|
+
var barSize = selfSize !== null && selfSize !== void 0 ? selfSize : globalSize;
|
|
70
|
+
if (isNullish(barSize)) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return getPercentValue(barSize, totalSize, 0);
|
|
74
|
+
};
|
|
75
|
+
export var combineBarSizeList = (allBars, globalSize, totalSize) => {
|
|
76
|
+
var initialValue = {};
|
|
77
|
+
var stackedBars = allBars.filter(isStacked);
|
|
78
|
+
var unstackedBars = allBars.filter((b) => b.stackId == null);
|
|
79
|
+
var groupByStack = stackedBars.reduce((acc, bar) => {
|
|
80
|
+
var s = acc[bar.stackId];
|
|
81
|
+
if (s == null) {
|
|
82
|
+
s = [];
|
|
83
|
+
}
|
|
84
|
+
s.push(bar);
|
|
85
|
+
acc[bar.stackId] = s;
|
|
86
|
+
return acc;
|
|
87
|
+
}, initialValue);
|
|
88
|
+
var stackedSizeList = Object.entries(groupByStack).map((_ref) => {
|
|
89
|
+
var _bars$;
|
|
90
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
91
|
+
stackId = _ref2[0],
|
|
92
|
+
bars = _ref2[1];
|
|
93
|
+
var dataKeys = bars.map((b) => b.dataKey);
|
|
94
|
+
var barSize = getBarSize(
|
|
95
|
+
globalSize,
|
|
96
|
+
totalSize,
|
|
97
|
+
(_bars$ = bars[0]) === null || _bars$ === void 0 ? void 0 : _bars$.barSize,
|
|
98
|
+
);
|
|
99
|
+
return {
|
|
100
|
+
stackId,
|
|
101
|
+
dataKeys,
|
|
102
|
+
barSize,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
var unstackedSizeList = unstackedBars.map((b) => {
|
|
106
|
+
var dataKeys = [b.dataKey].filter((dk) => dk != null);
|
|
107
|
+
var barSize = getBarSize(globalSize, totalSize, b.barSize);
|
|
108
|
+
return {
|
|
109
|
+
stackId: undefined,
|
|
110
|
+
dataKeys,
|
|
111
|
+
barSize,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
return [...stackedSizeList, ...unstackedSizeList];
|
|
115
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineCheckedDomain.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { isWellFormedNumberDomain } from '../../../util/isDomainSpecifiedByUser';
|
|
4
|
+
import { isWellBehavedNumber } from '../../../util/isWellBehavedNumber';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This function validates and transforms the axis domain so that it is safe to use in the provided scale.
|
|
8
|
+
*/
|
|
9
|
+
export var combineCheckedDomain = (realScaleType, axisDomain) => {
|
|
10
|
+
if (axisDomain == null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
switch (realScaleType) {
|
|
14
|
+
case 'linear': {
|
|
15
|
+
/*
|
|
16
|
+
* linear scale only reads the first two numbers in the domain, and ignores everything else.
|
|
17
|
+
* So if it happens that someone somehow gave us a bigger domain,
|
|
18
|
+
* let's pick the min and max from it.
|
|
19
|
+
*/
|
|
20
|
+
if (!isWellFormedNumberDomain(axisDomain)) {
|
|
21
|
+
var min, max;
|
|
22
|
+
for (var i = 0; i < axisDomain.length; i++) {
|
|
23
|
+
var value = axisDomain[i];
|
|
24
|
+
if (!isWellBehavedNumber(value)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (min === undefined || value < min) {
|
|
28
|
+
min = value;
|
|
29
|
+
}
|
|
30
|
+
if (max === undefined || value > max) {
|
|
31
|
+
max = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (min !== undefined && max !== undefined) {
|
|
35
|
+
return [min, max];
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return axisDomain;
|
|
40
|
+
}
|
|
41
|
+
default:
|
|
42
|
+
return axisDomain;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineConfiguredScale.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import * as d3Scales from 'victory-vendor/d3-scale';
|
|
4
|
+
import { upperFirst } from '../../../util/DataUtils';
|
|
5
|
+
function getD3ScaleFromType(realScaleType) {
|
|
6
|
+
var scales = d3Scales;
|
|
7
|
+
if (realScaleType in scales && typeof scales[realScaleType] === 'function') {
|
|
8
|
+
return scales[realScaleType]();
|
|
9
|
+
}
|
|
10
|
+
var name = 'scale'.concat(upperFirst(realScaleType));
|
|
11
|
+
if (name in scales && typeof scales[name] === 'function') {
|
|
12
|
+
return scales[name]();
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Converts external scale definition into internal RechartsScale definition.
|
|
19
|
+
* @param scale custom function scale - if you have the `string` from outside, use `combineRealScaleType` first which will validate it and return RechartsScaleType or undefined
|
|
20
|
+
* @param axisDomain
|
|
21
|
+
* @param axisRange
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export function combineConfiguredScaleInternal(scale, axisDomain, axisRange) {
|
|
25
|
+
if (typeof scale === 'function') {
|
|
26
|
+
return scale.copy().domain(axisDomain).range(axisRange);
|
|
27
|
+
}
|
|
28
|
+
if (scale == null) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
var d3ScaleFunction = getD3ScaleFromType(scale);
|
|
32
|
+
if (d3ScaleFunction == null) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
d3ScaleFunction.domain(axisDomain).range(axisRange);
|
|
36
|
+
return d3ScaleFunction;
|
|
37
|
+
}
|
|
38
|
+
export function combineConfiguredScale(axis, realScaleType, axisDomain, axisRange) {
|
|
39
|
+
if (axisDomain == null || axisRange == null) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (typeof axis.scale === 'function') {
|
|
43
|
+
return combineConfiguredScaleInternal(axis.scale, axisDomain, axisRange);
|
|
44
|
+
}
|
|
45
|
+
return combineConfiguredScaleInternal(realScaleType, axisDomain, axisRange);
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineCoordinateForDefaultIndex.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
export var combineCoordinateForDefaultIndex = (
|
|
4
|
+
width,
|
|
5
|
+
height,
|
|
6
|
+
layout,
|
|
7
|
+
offset,
|
|
8
|
+
tooltipTicks,
|
|
9
|
+
defaultIndex,
|
|
10
|
+
tooltipConfigurations,
|
|
11
|
+
) => {
|
|
12
|
+
if (defaultIndex == null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
/*
|
|
16
|
+
* With defaultIndex alone, we don't have enough information to decide _which_ of the multiple tooltips to display.
|
|
17
|
+
* Maybe one day we could add new prop `activeGraphicalItemId` to the chart to help with that.
|
|
18
|
+
* Until then, we choose the first one.
|
|
19
|
+
*/
|
|
20
|
+
var firstConfiguration = tooltipConfigurations[0];
|
|
21
|
+
var maybePosition =
|
|
22
|
+
firstConfiguration === null || firstConfiguration === void 0
|
|
23
|
+
? void 0
|
|
24
|
+
: firstConfiguration.getPosition(defaultIndex);
|
|
25
|
+
if (maybePosition != null) {
|
|
26
|
+
return maybePosition;
|
|
27
|
+
}
|
|
28
|
+
var tick =
|
|
29
|
+
tooltipTicks === null || tooltipTicks === void 0 ? void 0 : tooltipTicks[Number(defaultIndex)];
|
|
30
|
+
if (!tick) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
switch (layout) {
|
|
34
|
+
case 'horizontal': {
|
|
35
|
+
return {
|
|
36
|
+
x: tick.coordinate,
|
|
37
|
+
y: (offset.top + height) / 2,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
// This logic is not super sound - it conflates vertical, radial, centric layouts into just one. TODO improve!
|
|
42
|
+
return {
|
|
43
|
+
x: (offset.left + width) / 2,
|
|
44
|
+
y: tick.coordinate,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineDisplayedStackedData.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { getStackSeriesIdentifier } from '../../../util/stacks/getStackSeriesIdentifier';
|
|
4
|
+
import { getValueByDataKey } from '../../../util/ChartUtils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* In a stacked chart, each graphical item has its own data. That data could be either:
|
|
8
|
+
* - defined on the chart root, in which case the item gets a unique dataKey
|
|
9
|
+
* - or defined on the item itself, in which case multiple items can share the same dataKey
|
|
10
|
+
*
|
|
11
|
+
* That means we cannot use the dataKey as a unique identifier for the item.
|
|
12
|
+
*
|
|
13
|
+
* This type represents a single data point in a stacked chart, where each key is a series identifier
|
|
14
|
+
* and the value is the numeric value for that series using the numerical axis dataKey.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export function combineDisplayedStackedData(stackedGraphicalItems, _ref, tooltipAxisSettings) {
|
|
18
|
+
var _ref$chartData = _ref.chartData,
|
|
19
|
+
chartData = _ref$chartData === void 0 ? [] : _ref$chartData;
|
|
20
|
+
var allowDuplicatedCategory = tooltipAxisSettings.allowDuplicatedCategory,
|
|
21
|
+
tooltipDataKey = tooltipAxisSettings.dataKey;
|
|
22
|
+
|
|
23
|
+
// A map of tooltip data keys to the stacked data points
|
|
24
|
+
var knownItemsByDataKey = new Map();
|
|
25
|
+
stackedGraphicalItems.forEach((item) => {
|
|
26
|
+
var _item$data;
|
|
27
|
+
// If there is no data on the individual item then we use the root chart data
|
|
28
|
+
var resolvedData =
|
|
29
|
+
(_item$data = item.data) !== null && _item$data !== void 0 ? _item$data : chartData;
|
|
30
|
+
if (resolvedData == null || resolvedData.length === 0) {
|
|
31
|
+
// if that doesn't work then we skip this item
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var stackIdentifier = getStackSeriesIdentifier(item);
|
|
35
|
+
resolvedData.forEach((entry, index) => {
|
|
36
|
+
var tooltipValue =
|
|
37
|
+
tooltipDataKey == null || allowDuplicatedCategory
|
|
38
|
+
? index
|
|
39
|
+
: String(getValueByDataKey(entry, tooltipDataKey, null));
|
|
40
|
+
var numericValue = getValueByDataKey(entry, item.dataKey, 0);
|
|
41
|
+
var curr;
|
|
42
|
+
if (knownItemsByDataKey.has(tooltipValue)) {
|
|
43
|
+
curr = knownItemsByDataKey.get(tooltipValue);
|
|
44
|
+
} else {
|
|
45
|
+
curr = {};
|
|
46
|
+
}
|
|
47
|
+
Object.assign(curr, {
|
|
48
|
+
[stackIdentifier]: numericValue,
|
|
49
|
+
});
|
|
50
|
+
knownItemsByDataKey.set(tooltipValue, curr);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return Array.from(knownItemsByDataKey.values());
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineInverseScaleFunction.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { createCategoricalInverse } from '../../../util/scale/createCategoricalInverse';
|
|
4
|
+
export function combineInverseScaleFunction(configuredScale) {
|
|
5
|
+
if (configuredScale == null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if ('invert' in configuredScale && typeof configuredScale.invert === 'function') {
|
|
9
|
+
return configuredScale.invert.bind(configuredScale);
|
|
10
|
+
}
|
|
11
|
+
return createCategoricalInverse(configuredScale, undefined);
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineRealScaleType.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import * as d3Scales from 'victory-vendor/d3-scale';
|
|
4
|
+
import { upperFirst } from '../../../util/DataUtils';
|
|
5
|
+
function getD3ScaleName(name) {
|
|
6
|
+
return 'scale'.concat(upperFirst(name));
|
|
7
|
+
}
|
|
8
|
+
function isSupportedScaleName(name) {
|
|
9
|
+
return getD3ScaleName(name) in d3Scales;
|
|
10
|
+
}
|
|
11
|
+
export var combineRealScaleType = (axisConfig, hasBar, chartType) => {
|
|
12
|
+
if (axisConfig == null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
var scale = axisConfig.scale,
|
|
16
|
+
type = axisConfig.type;
|
|
17
|
+
if (scale === 'auto') {
|
|
18
|
+
if (
|
|
19
|
+
type === 'category' &&
|
|
20
|
+
chartType &&
|
|
21
|
+
(chartType.indexOf('LineChart') >= 0 ||
|
|
22
|
+
chartType.indexOf('AreaChart') >= 0 ||
|
|
23
|
+
(chartType.indexOf('ComposedChart') >= 0 && !hasBar))
|
|
24
|
+
) {
|
|
25
|
+
return 'point';
|
|
26
|
+
}
|
|
27
|
+
if (type === 'category') {
|
|
28
|
+
return 'band';
|
|
29
|
+
}
|
|
30
|
+
return 'linear';
|
|
31
|
+
}
|
|
32
|
+
if (typeof scale === 'string') {
|
|
33
|
+
return isSupportedScaleName(scale) ? scale : 'point';
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineStackedData.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { getStackSeriesIdentifier } from '../../../util/stacks/getStackSeriesIdentifier';
|
|
4
|
+
export var combineStackedData = (stackGroups, barSettings) => {
|
|
5
|
+
var stackSeriesIdentifier = getStackSeriesIdentifier(barSettings);
|
|
6
|
+
if (!stackGroups || stackSeriesIdentifier == null || barSettings == null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
var stackId = barSettings.stackId;
|
|
10
|
+
if (stackId == null) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
var stackGroup = stackGroups[stackId];
|
|
14
|
+
if (!stackGroup) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
var stackedData = stackGroup.stackedData;
|
|
18
|
+
if (!stackedData) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return stackedData.find((sd) => sd.key === stackSeriesIdentifier);
|
|
22
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineTooltipInteractionState.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
function ownKeys(e, r) {
|
|
4
|
+
var t = Object.keys(e);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
+
(r &&
|
|
8
|
+
(o = o.filter(function (r) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
10
|
+
})),
|
|
11
|
+
t.push.apply(t, o));
|
|
12
|
+
}
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
function _objectSpread(e) {
|
|
16
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
17
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
18
|
+
r % 2
|
|
19
|
+
? ownKeys(Object(t), !0).forEach(function (r) {
|
|
20
|
+
_defineProperty(e, r, t[r]);
|
|
21
|
+
})
|
|
22
|
+
: Object.getOwnPropertyDescriptors
|
|
23
|
+
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
|
|
24
|
+
: ownKeys(Object(t)).forEach(function (r) {
|
|
25
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
function _defineProperty(e, r, t) {
|
|
31
|
+
return (
|
|
32
|
+
(r = _toPropertyKey(r)) in e
|
|
33
|
+
? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 })
|
|
34
|
+
: (e[r] = t),
|
|
35
|
+
e
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function _toPropertyKey(t) {
|
|
39
|
+
var i = _toPrimitive(t, 'string');
|
|
40
|
+
return 'symbol' == typeof i ? i : i + '';
|
|
41
|
+
}
|
|
42
|
+
function _toPrimitive(t, r) {
|
|
43
|
+
if ('object' != typeof t || !t) return t;
|
|
44
|
+
var e = t[Symbol.toPrimitive];
|
|
45
|
+
if (void 0 !== e) {
|
|
46
|
+
var i = e.call(t, r || 'default');
|
|
47
|
+
if ('object' != typeof i) return i;
|
|
48
|
+
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
49
|
+
}
|
|
50
|
+
return ('string' === r ? String : Number)(t);
|
|
51
|
+
}
|
|
52
|
+
import { noInteraction } from '../../tooltipSlice';
|
|
53
|
+
function chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger) {
|
|
54
|
+
if (tooltipEventType === 'axis') {
|
|
55
|
+
if (trigger === 'click') {
|
|
56
|
+
return tooltipState.axisInteraction.click;
|
|
57
|
+
}
|
|
58
|
+
return tooltipState.axisInteraction.hover;
|
|
59
|
+
}
|
|
60
|
+
if (trigger === 'click') {
|
|
61
|
+
return tooltipState.itemInteraction.click;
|
|
62
|
+
}
|
|
63
|
+
return tooltipState.itemInteraction.hover;
|
|
64
|
+
}
|
|
65
|
+
function hasBeenActivePreviously(tooltipInteractionState) {
|
|
66
|
+
return tooltipInteractionState.index != null;
|
|
67
|
+
}
|
|
68
|
+
export var combineTooltipInteractionState = (
|
|
69
|
+
tooltipState,
|
|
70
|
+
tooltipEventType,
|
|
71
|
+
trigger,
|
|
72
|
+
defaultIndex,
|
|
73
|
+
) => {
|
|
74
|
+
if (tooltipEventType == null) {
|
|
75
|
+
return noInteraction;
|
|
76
|
+
}
|
|
77
|
+
var appropriateMouseInteraction = chooseAppropriateMouseInteraction(
|
|
78
|
+
tooltipState,
|
|
79
|
+
tooltipEventType,
|
|
80
|
+
trigger,
|
|
81
|
+
);
|
|
82
|
+
if (appropriateMouseInteraction == null) {
|
|
83
|
+
return noInteraction;
|
|
84
|
+
}
|
|
85
|
+
if (appropriateMouseInteraction.active) {
|
|
86
|
+
return appropriateMouseInteraction;
|
|
87
|
+
}
|
|
88
|
+
if (tooltipState.keyboardInteraction.active) {
|
|
89
|
+
return tooltipState.keyboardInteraction;
|
|
90
|
+
}
|
|
91
|
+
if (tooltipState.syncInteraction.active && tooltipState.syncInteraction.index != null) {
|
|
92
|
+
return tooltipState.syncInteraction;
|
|
93
|
+
}
|
|
94
|
+
var activeFromProps = tooltipState.settings.active === true;
|
|
95
|
+
if (hasBeenActivePreviously(appropriateMouseInteraction)) {
|
|
96
|
+
if (activeFromProps) {
|
|
97
|
+
return _objectSpread(
|
|
98
|
+
_objectSpread({}, appropriateMouseInteraction),
|
|
99
|
+
{},
|
|
100
|
+
{
|
|
101
|
+
active: true,
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
} else if (defaultIndex != null) {
|
|
106
|
+
return {
|
|
107
|
+
active: true,
|
|
108
|
+
coordinate: undefined,
|
|
109
|
+
dataKey: undefined,
|
|
110
|
+
index: defaultIndex,
|
|
111
|
+
graphicalItemId: undefined,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return _objectSpread(
|
|
115
|
+
_objectSpread({}, noInteraction),
|
|
116
|
+
{},
|
|
117
|
+
{
|
|
118
|
+
coordinate: appropriateMouseInteraction.coordinate,
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
};
|