@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,248 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineTooltipPayload.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 { findEntryInArray } from '../../../util/DataUtils';
|
|
53
|
+
import { getTooltipEntry, getValueByDataKey } from '../../../util/ChartUtils';
|
|
54
|
+
import { getSliced } from '../../../util/getSliced';
|
|
55
|
+
function parseName(value) {
|
|
56
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
function parseUnit(value) {
|
|
62
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
function parseDataKey(value) {
|
|
68
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === 'function') {
|
|
72
|
+
return (obj) => value(obj);
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
function parseColor(value) {
|
|
77
|
+
if (typeof value === 'string') {
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
function parseTooltipPayloadItem(item) {
|
|
83
|
+
if (item == null || typeof item !== 'object') {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
var name = 'name' in item ? parseName(item.name) : undefined;
|
|
87
|
+
var unit = 'unit' in item ? parseUnit(item.unit) : undefined;
|
|
88
|
+
var dataKey = 'dataKey' in item ? parseDataKey(item.dataKey) : undefined;
|
|
89
|
+
var payload = 'payload' in item ? item.payload : undefined;
|
|
90
|
+
var color = 'color' in item ? parseColor(item.color) : undefined;
|
|
91
|
+
var fill = 'fill' in item ? parseColor(item.fill) : undefined;
|
|
92
|
+
return {
|
|
93
|
+
name,
|
|
94
|
+
unit,
|
|
95
|
+
dataKey,
|
|
96
|
+
payload,
|
|
97
|
+
color,
|
|
98
|
+
fill,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function selectFinalData(dataDefinedOnItem, dataDefinedOnChart) {
|
|
102
|
+
/*
|
|
103
|
+
* If a payload has data specified directly from the graphical item, prefer that.
|
|
104
|
+
* Otherwise, fill in data from the chart level, using the same index.
|
|
105
|
+
*/
|
|
106
|
+
if (dataDefinedOnItem != null) {
|
|
107
|
+
return dataDefinedOnItem;
|
|
108
|
+
}
|
|
109
|
+
return dataDefinedOnChart;
|
|
110
|
+
}
|
|
111
|
+
export var combineTooltipPayload = (
|
|
112
|
+
tooltipPayloadConfigurations,
|
|
113
|
+
activeIndex,
|
|
114
|
+
chartDataState,
|
|
115
|
+
tooltipAxisDataKey,
|
|
116
|
+
activeLabel,
|
|
117
|
+
tooltipPayloadSearcher,
|
|
118
|
+
tooltipEventType,
|
|
119
|
+
) => {
|
|
120
|
+
if (activeIndex == null || tooltipPayloadSearcher == null) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
var chartData = chartDataState.chartData,
|
|
124
|
+
computedData = chartDataState.computedData,
|
|
125
|
+
dataStartIndex = chartDataState.dataStartIndex,
|
|
126
|
+
dataEndIndex = chartDataState.dataEndIndex;
|
|
127
|
+
var init = [];
|
|
128
|
+
return tooltipPayloadConfigurations.reduce((agg, _ref) => {
|
|
129
|
+
var _settings$dataKey;
|
|
130
|
+
var dataDefinedOnItem = _ref.dataDefinedOnItem,
|
|
131
|
+
settings = _ref.settings;
|
|
132
|
+
var finalData = selectFinalData(dataDefinedOnItem, chartData);
|
|
133
|
+
var sliced = Array.isArray(finalData)
|
|
134
|
+
? getSliced(finalData, dataStartIndex, dataEndIndex)
|
|
135
|
+
: finalData;
|
|
136
|
+
var finalDataKey =
|
|
137
|
+
(_settings$dataKey = settings === null || settings === void 0 ? void 0 : settings.dataKey) !==
|
|
138
|
+
null && _settings$dataKey !== void 0
|
|
139
|
+
? _settings$dataKey
|
|
140
|
+
: tooltipAxisDataKey;
|
|
141
|
+
// BaseAxisProps does not support nameKey but it could!
|
|
142
|
+
var finalNameKey = settings === null || settings === void 0 ? void 0 : settings.nameKey; // ?? tooltipAxis?.nameKey;
|
|
143
|
+
var tooltipPayload;
|
|
144
|
+
if (
|
|
145
|
+
tooltipAxisDataKey &&
|
|
146
|
+
Array.isArray(sliced) &&
|
|
147
|
+
/*
|
|
148
|
+
* findEntryInArray won't work for Scatter because Scatter provides an array of arrays
|
|
149
|
+
* as tooltip payloads and findEntryInArray is not prepared to handle that.
|
|
150
|
+
* Sad but also ScatterChart only allows 'item' tooltipEventType
|
|
151
|
+
* and also this is only a problem if there are multiple Scatters and each has its own data array
|
|
152
|
+
* so let's fix that some other time.
|
|
153
|
+
*/
|
|
154
|
+
!Array.isArray(sliced[0]) &&
|
|
155
|
+
/*
|
|
156
|
+
* If the tooltipEventType is 'axis', we should search for the dataKey in the sliced data
|
|
157
|
+
* because thanks to allowDuplicatedCategory=false, the order of elements in the array
|
|
158
|
+
* no longer matches the order of elements in the original data
|
|
159
|
+
* and so we need to search by the active dataKey + label rather than by index.
|
|
160
|
+
*
|
|
161
|
+
* The same happens if multiple graphical items are present in the chart
|
|
162
|
+
* and each of them has its own data array. Those arrays get concatenated
|
|
163
|
+
* and again the tooltip index no longer matches the original data.
|
|
164
|
+
*
|
|
165
|
+
* On the other hand the tooltipEventType 'item' should always search by index
|
|
166
|
+
* because we get the index from interacting over the individual elements
|
|
167
|
+
* which is always accurate, irrespective of the allowDuplicatedCategory setting.
|
|
168
|
+
*/
|
|
169
|
+
tooltipEventType === 'axis'
|
|
170
|
+
) {
|
|
171
|
+
tooltipPayload = findEntryInArray(sliced, tooltipAxisDataKey, activeLabel);
|
|
172
|
+
} else {
|
|
173
|
+
/*
|
|
174
|
+
* This is a problem because it assumes that the index is pointing to the displayed data
|
|
175
|
+
* which it isn't because the index is pointing to the tooltip ticks array.
|
|
176
|
+
* The above approach (with findEntryInArray) is the correct one, but it only works
|
|
177
|
+
* if the axis dataKey is defined explicitly, and if the data is an array of objects.
|
|
178
|
+
*/
|
|
179
|
+
tooltipPayload = tooltipPayloadSearcher(sliced, activeIndex, computedData, finalNameKey);
|
|
180
|
+
}
|
|
181
|
+
if (Array.isArray(tooltipPayload)) {
|
|
182
|
+
tooltipPayload.forEach((item) => {
|
|
183
|
+
var _parsedItem$color, _parsedItem$fill;
|
|
184
|
+
var parsedItem = parseTooltipPayloadItem(item);
|
|
185
|
+
var itemName = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.name;
|
|
186
|
+
var itemDataKey =
|
|
187
|
+
parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.dataKey;
|
|
188
|
+
var itemPayload =
|
|
189
|
+
parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.payload;
|
|
190
|
+
var newSettings = _objectSpread(
|
|
191
|
+
_objectSpread({}, settings),
|
|
192
|
+
{},
|
|
193
|
+
{
|
|
194
|
+
name: itemName,
|
|
195
|
+
unit: parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.unit,
|
|
196
|
+
// Preserve item-level color/fill from graphical items.
|
|
197
|
+
color:
|
|
198
|
+
(_parsedItem$color =
|
|
199
|
+
parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.color) !==
|
|
200
|
+
null && _parsedItem$color !== void 0
|
|
201
|
+
? _parsedItem$color
|
|
202
|
+
: settings === null || settings === void 0
|
|
203
|
+
? void 0
|
|
204
|
+
: settings.color,
|
|
205
|
+
fill:
|
|
206
|
+
(_parsedItem$fill =
|
|
207
|
+
parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.fill) !== null &&
|
|
208
|
+
_parsedItem$fill !== void 0
|
|
209
|
+
? _parsedItem$fill
|
|
210
|
+
: settings === null || settings === void 0
|
|
211
|
+
? void 0
|
|
212
|
+
: settings.fill,
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
agg.push(
|
|
216
|
+
getTooltipEntry({
|
|
217
|
+
tooltipEntrySettings: newSettings,
|
|
218
|
+
dataKey: itemDataKey,
|
|
219
|
+
payload: itemPayload,
|
|
220
|
+
value: getValueByDataKey(itemPayload, itemDataKey),
|
|
221
|
+
name: itemName == null ? undefined : String(itemName),
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
} else {
|
|
226
|
+
var _getValueByDataKey;
|
|
227
|
+
// I am not quite sure why these two branches (Array vs Array of Arrays) have to behave differently - I imagine we should unify these. 3.x breaking change?
|
|
228
|
+
agg.push(
|
|
229
|
+
getTooltipEntry({
|
|
230
|
+
tooltipEntrySettings: settings,
|
|
231
|
+
dataKey: finalDataKey,
|
|
232
|
+
payload: tooltipPayload,
|
|
233
|
+
// getValueByDataKey does not validate the output type
|
|
234
|
+
value: getValueByDataKey(tooltipPayload, finalDataKey),
|
|
235
|
+
// getValueByDataKey does not validate the output type
|
|
236
|
+
name:
|
|
237
|
+
(_getValueByDataKey = getValueByDataKey(tooltipPayload, finalNameKey)) !== null &&
|
|
238
|
+
_getValueByDataKey !== void 0
|
|
239
|
+
? _getValueByDataKey
|
|
240
|
+
: settings === null || settings === void 0
|
|
241
|
+
? void 0
|
|
242
|
+
: settings.name,
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return agg;
|
|
247
|
+
}, init);
|
|
248
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/combiners/combineTooltipPayloadConfigurations.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
export var combineTooltipPayloadConfigurations = (
|
|
4
|
+
tooltipState,
|
|
5
|
+
tooltipEventType,
|
|
6
|
+
trigger,
|
|
7
|
+
defaultIndex,
|
|
8
|
+
) => {
|
|
9
|
+
// if tooltip reacts to axis interaction, then we display all items at the same time.
|
|
10
|
+
if (tooltipEventType === 'axis') {
|
|
11
|
+
return tooltipState.tooltipItemPayloads;
|
|
12
|
+
}
|
|
13
|
+
/*
|
|
14
|
+
* By now we already know that tooltipEventType is 'item', so we can only search in itemInteractions.
|
|
15
|
+
* item means that only the hovered or clicked item will be present in the tooltip.
|
|
16
|
+
*/
|
|
17
|
+
if (tooltipState.tooltipItemPayloads.length === 0) {
|
|
18
|
+
// No point filtering if the payload is empty
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
var filterByGraphicalItemId;
|
|
22
|
+
if (trigger === 'hover') {
|
|
23
|
+
filterByGraphicalItemId = tooltipState.itemInteraction.hover.graphicalItemId;
|
|
24
|
+
} else {
|
|
25
|
+
filterByGraphicalItemId = tooltipState.itemInteraction.click.graphicalItemId;
|
|
26
|
+
}
|
|
27
|
+
if (tooltipState.syncInteraction.active && filterByGraphicalItemId == null) {
|
|
28
|
+
/*
|
|
29
|
+
* When a tooltip is synchronised from another chart, the local itemInteraction
|
|
30
|
+
* has no graphicalItemId because the user hasn't hovered over this chart.
|
|
31
|
+
* In that case we show all tooltip items so the receiving chart can display
|
|
32
|
+
* its own data at the synced index — matching the behaviour of axis-type tooltips.
|
|
33
|
+
*/
|
|
34
|
+
return tooltipState.tooltipItemPayloads;
|
|
35
|
+
}
|
|
36
|
+
if (
|
|
37
|
+
filterByGraphicalItemId == null &&
|
|
38
|
+
(defaultIndex != null || tooltipState.keyboardInteraction.active)
|
|
39
|
+
) {
|
|
40
|
+
/*
|
|
41
|
+
* So when we use `defaultIndex` - we don't have a dataKey to filter by because user did not hover over anything yet.
|
|
42
|
+
* In that case let's display the first item in the tooltip; after all, this is `item` interaction case,
|
|
43
|
+
* so we should display only one item at a time instead of all.
|
|
44
|
+
*/
|
|
45
|
+
var firstItemPayload = tooltipState.tooltipItemPayloads[0];
|
|
46
|
+
if (firstItemPayload != null) {
|
|
47
|
+
return [firstItemPayload];
|
|
48
|
+
}
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return tooltipState.tooltipItemPayloads.filter((tpc) => {
|
|
52
|
+
var _tpc$settings;
|
|
53
|
+
return (
|
|
54
|
+
((_tpc$settings = tpc.settings) === null || _tpc$settings === void 0
|
|
55
|
+
? void 0
|
|
56
|
+
: _tpc$settings.graphicalItemId) === filterByGraphicalItemId
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/containerSelectors.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
export var selectChartWidth = (state) => state.layout.width;
|
|
4
|
+
export var selectChartHeight = (state) => state.layout.height;
|
|
5
|
+
export var selectContainerScale = (state) => state.layout.scale;
|
|
6
|
+
export var selectMargin = (state) => state.layout.margin;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/dataSelectors.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { createSelector } from 'reselect';
|
|
4
|
+
/**
|
|
5
|
+
* This selector always returns the data with the indexes set by a Brush.
|
|
6
|
+
* Trouble is, that might or might not be what you want.
|
|
7
|
+
*
|
|
8
|
+
* In charts with Brush, you will sometimes want to select the full range of data, and sometimes the one decided by the Brush
|
|
9
|
+
* - even if the Brush is active, the panorama inside the Brush should show the full range of data.
|
|
10
|
+
*
|
|
11
|
+
* So instead of this selector, consider using either selectChartDataAndAlwaysIgnoreIndexes or selectChartDataWithIndexesIfNotInPanorama
|
|
12
|
+
*
|
|
13
|
+
* @param state RechartsRootState
|
|
14
|
+
* @returns data defined on the chart root element, such as BarChart or ScatterChart
|
|
15
|
+
*/
|
|
16
|
+
export var selectChartDataWithIndexes = (state) => state.chartData;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This selector will always return the full range of data, ignoring the indexes set by a Brush.
|
|
20
|
+
* Useful for when you want to render the full range of data, even if a Brush is active.
|
|
21
|
+
* For example: in the Brush panorama, in Legend, in Tooltip.
|
|
22
|
+
*/
|
|
23
|
+
export var selectChartDataAndAlwaysIgnoreIndexes = createSelector(
|
|
24
|
+
[selectChartDataWithIndexes],
|
|
25
|
+
(dataState) => {
|
|
26
|
+
var dataEndIndex = dataState.chartData != null ? dataState.chartData.length - 1 : 0;
|
|
27
|
+
return {
|
|
28
|
+
chartData: dataState.chartData,
|
|
29
|
+
computedData: dataState.computedData,
|
|
30
|
+
dataEndIndex,
|
|
31
|
+
dataStartIndex: 0,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
export var selectChartDataWithIndexesIfNotInPanoramaPosition4 = (
|
|
36
|
+
state,
|
|
37
|
+
_unused1,
|
|
38
|
+
_unused2,
|
|
39
|
+
isPanorama,
|
|
40
|
+
) => {
|
|
41
|
+
if (isPanorama) {
|
|
42
|
+
return selectChartDataAndAlwaysIgnoreIndexes(state);
|
|
43
|
+
}
|
|
44
|
+
return selectChartDataWithIndexes(state);
|
|
45
|
+
};
|
|
46
|
+
export var selectChartDataWithIndexesIfNotInPanoramaPosition3 = (state, _unused1, isPanorama) => {
|
|
47
|
+
if (isPanorama) {
|
|
48
|
+
return selectChartDataAndAlwaysIgnoreIndexes(state);
|
|
49
|
+
}
|
|
50
|
+
return selectChartDataWithIndexes(state);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns the chart-level data slice (respecting Brush indexes), memoized by content so that
|
|
55
|
+
* spurious Immer reference changes (e.g. dispatching `setChartData(undefined)` when data is
|
|
56
|
+
* already `undefined`) do not propagate to downstream selectors.
|
|
57
|
+
*
|
|
58
|
+
* Used when a selector needs chart-level data but must avoid extra recomputes when the
|
|
59
|
+
* data content has not actually changed.
|
|
60
|
+
*/
|
|
61
|
+
export var selectChartDataSliceIfNotInPanorama = createSelector(
|
|
62
|
+
[selectChartDataWithIndexesIfNotInPanoramaPosition4],
|
|
63
|
+
(_ref) => {
|
|
64
|
+
var chartData = _ref.chartData,
|
|
65
|
+
dataStartIndex = _ref.dataStartIndex,
|
|
66
|
+
dataEndIndex = _ref.dataEndIndex;
|
|
67
|
+
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns the chart-level data slice (ignoring Brush indexes), memoized by content.
|
|
73
|
+
* Used in tooltip and polar selectors that always need the full data range.
|
|
74
|
+
*/
|
|
75
|
+
export var selectChartDataSliceIgnoringIndexes = createSelector(
|
|
76
|
+
[selectChartDataAndAlwaysIgnoreIndexes],
|
|
77
|
+
(_ref2) => {
|
|
78
|
+
var chartData = _ref2.chartData,
|
|
79
|
+
dataStartIndex = _ref2.dataStartIndex,
|
|
80
|
+
dataEndIndex = _ref2.dataEndIndex;
|
|
81
|
+
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns the chart-level data slice (with Brush indexes applied), memoized by content.
|
|
87
|
+
* Used in tooltip selectors.
|
|
88
|
+
*/
|
|
89
|
+
export var selectChartDataSliceWithIndexes = createSelector(
|
|
90
|
+
[selectChartDataWithIndexes],
|
|
91
|
+
(_ref3) => {
|
|
92
|
+
var chartData = _ref3.chartData,
|
|
93
|
+
dataStartIndex = _ref3.dataStartIndex,
|
|
94
|
+
dataEndIndex = _ref3.dataEndIndex;
|
|
95
|
+
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
|
|
96
|
+
},
|
|
97
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/graphicalItemSelectors.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { defaultAxisId } from '../cartesianAxisSlice';
|
|
4
|
+
export function selectXAxisIdFromGraphicalItemId(state, id) {
|
|
5
|
+
var _state$graphicalItems, _state$graphicalItems2;
|
|
6
|
+
return (_state$graphicalItems =
|
|
7
|
+
(_state$graphicalItems2 = state.graphicalItems.cartesianItems.find(
|
|
8
|
+
(item) => item.id === id,
|
|
9
|
+
)) === null || _state$graphicalItems2 === void 0
|
|
10
|
+
? void 0
|
|
11
|
+
: _state$graphicalItems2.xAxisId) !== null && _state$graphicalItems !== void 0
|
|
12
|
+
? _state$graphicalItems
|
|
13
|
+
: defaultAxisId;
|
|
14
|
+
}
|
|
15
|
+
export function selectYAxisIdFromGraphicalItemId(state, id) {
|
|
16
|
+
var _state$graphicalItems3, _state$graphicalItems4;
|
|
17
|
+
return (_state$graphicalItems3 =
|
|
18
|
+
(_state$graphicalItems4 = state.graphicalItems.cartesianItems.find(
|
|
19
|
+
(item) => item.id === id,
|
|
20
|
+
)) === null || _state$graphicalItems4 === void 0
|
|
21
|
+
? void 0
|
|
22
|
+
: _state$graphicalItems4.yAxisId) !== null && _state$graphicalItems3 !== void 0
|
|
23
|
+
? _state$graphicalItems3
|
|
24
|
+
: defaultAxisId;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/legendSelectors.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
// Sanctioned deviation: es-toolkit compat imports normalized to the ESM barrel
|
|
4
|
+
// ('es-toolkit/compat') — the per-function subpaths are CJS-only and break
|
|
5
|
+
// consumers that compile this binding from source (vite dev prebundle).
|
|
6
|
+
import { createSelector } from 'reselect';
|
|
7
|
+
import { sortBy } from 'es-toolkit/compat';
|
|
8
|
+
export var selectLegendSettings = (state) => state.legend.settings;
|
|
9
|
+
export var selectLegendSize = (state) => state.legend.size;
|
|
10
|
+
var selectAllLegendPayload2DArray = (state) => state.legend.payload;
|
|
11
|
+
export var selectLegendPayload = createSelector(
|
|
12
|
+
[selectAllLegendPayload2DArray, selectLegendSettings],
|
|
13
|
+
(payloads, _ref) => {
|
|
14
|
+
var itemSorter = _ref.itemSorter;
|
|
15
|
+
var flat = payloads.flat(1);
|
|
16
|
+
return itemSorter ? sortBy(flat, itemSorter) : flat;
|
|
17
|
+
},
|
|
18
|
+
);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/lineSelectors.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
import { createSelector } from 'reselect';
|
|
4
|
+
import { computeLinePoints } from '../../cartesian/Line';
|
|
5
|
+
import { selectChartDataWithIndexesIfNotInPanoramaPosition4 } from './dataSelectors';
|
|
6
|
+
import { selectChartLayout } from '../../context/chartLayoutContext';
|
|
7
|
+
import {
|
|
8
|
+
selectAxisWithScale,
|
|
9
|
+
selectTicksOfGraphicalItem,
|
|
10
|
+
selectUnfilteredCartesianItems,
|
|
11
|
+
} from './axisSelectors';
|
|
12
|
+
import { getBandSizeOfAxis, isCategoricalAxis } from '../../util/ChartUtils';
|
|
13
|
+
var selectXAxisWithScale = (state, xAxisId, _yAxisId, isPanorama) =>
|
|
14
|
+
selectAxisWithScale(state, 'xAxis', xAxisId, isPanorama);
|
|
15
|
+
var selectXAxisTicks = (state, xAxisId, _yAxisId, isPanorama) =>
|
|
16
|
+
selectTicksOfGraphicalItem(state, 'xAxis', xAxisId, isPanorama);
|
|
17
|
+
var selectYAxisWithScale = (state, _xAxisId, yAxisId, isPanorama) =>
|
|
18
|
+
selectAxisWithScale(state, 'yAxis', yAxisId, isPanorama);
|
|
19
|
+
var selectYAxisTicks = (state, _xAxisId, yAxisId, isPanorama) =>
|
|
20
|
+
selectTicksOfGraphicalItem(state, 'yAxis', yAxisId, isPanorama);
|
|
21
|
+
var selectBandSize = createSelector(
|
|
22
|
+
[
|
|
23
|
+
selectChartLayout,
|
|
24
|
+
selectXAxisWithScale,
|
|
25
|
+
selectYAxisWithScale,
|
|
26
|
+
selectXAxisTicks,
|
|
27
|
+
selectYAxisTicks,
|
|
28
|
+
],
|
|
29
|
+
(layout, xAxis, yAxis, xAxisTicks, yAxisTicks) => {
|
|
30
|
+
if (isCategoricalAxis(layout, 'xAxis')) {
|
|
31
|
+
return getBandSizeOfAxis(xAxis, xAxisTicks, false);
|
|
32
|
+
}
|
|
33
|
+
return getBandSizeOfAxis(yAxis, yAxisTicks, false);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
var pickLineId = (_state, _xAxisId, _yAxisId, _isPanorama, id) => id;
|
|
37
|
+
function isLineSettings(item) {
|
|
38
|
+
return item.type === 'line';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* There is a race condition problem because we read some data from props and some from the state.
|
|
43
|
+
* The state is updated through a dispatch and is one render behind,
|
|
44
|
+
* and so we have this weird one tick render where the displayedData in one selector have the old dataKey
|
|
45
|
+
* but the new dataKey in another selector.
|
|
46
|
+
*
|
|
47
|
+
* So here instead of reading the dataKey from the props, we always read it from the state.
|
|
48
|
+
*/
|
|
49
|
+
var selectSynchronisedLineSettings = createSelector(
|
|
50
|
+
[selectUnfilteredCartesianItems, pickLineId],
|
|
51
|
+
(graphicalItems, id) => graphicalItems.filter(isLineSettings).find((x) => x.id === id),
|
|
52
|
+
);
|
|
53
|
+
export var selectLinePoints = createSelector(
|
|
54
|
+
[
|
|
55
|
+
selectChartLayout,
|
|
56
|
+
selectXAxisWithScale,
|
|
57
|
+
selectYAxisWithScale,
|
|
58
|
+
selectXAxisTicks,
|
|
59
|
+
selectYAxisTicks,
|
|
60
|
+
selectSynchronisedLineSettings,
|
|
61
|
+
selectBandSize,
|
|
62
|
+
selectChartDataWithIndexesIfNotInPanoramaPosition4,
|
|
63
|
+
],
|
|
64
|
+
(layout, xAxis, yAxis, xAxisTicks, yAxisTicks, lineSettings, bandSize, _ref) => {
|
|
65
|
+
var chartData = _ref.chartData,
|
|
66
|
+
dataStartIndex = _ref.dataStartIndex,
|
|
67
|
+
dataEndIndex = _ref.dataEndIndex;
|
|
68
|
+
if (
|
|
69
|
+
lineSettings == null ||
|
|
70
|
+
xAxis == null ||
|
|
71
|
+
yAxis == null ||
|
|
72
|
+
xAxisTicks == null ||
|
|
73
|
+
yAxisTicks == null ||
|
|
74
|
+
xAxisTicks.length === 0 ||
|
|
75
|
+
yAxisTicks.length === 0 ||
|
|
76
|
+
bandSize == null ||
|
|
77
|
+
(layout !== 'horizontal' && layout !== 'vertical')
|
|
78
|
+
) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
var dataKey = lineSettings.dataKey,
|
|
82
|
+
data = lineSettings.data;
|
|
83
|
+
var displayedData;
|
|
84
|
+
if (data != null && data.length > 0) {
|
|
85
|
+
displayedData = data;
|
|
86
|
+
} else {
|
|
87
|
+
displayedData =
|
|
88
|
+
chartData === null || chartData === void 0
|
|
89
|
+
? void 0
|
|
90
|
+
: chartData.slice(dataStartIndex, dataEndIndex + 1);
|
|
91
|
+
}
|
|
92
|
+
if (displayedData == null) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
return computeLinePoints({
|
|
96
|
+
layout,
|
|
97
|
+
xAxis,
|
|
98
|
+
yAxis,
|
|
99
|
+
xAxisTicks,
|
|
100
|
+
yAxisTicks,
|
|
101
|
+
dataKey,
|
|
102
|
+
bandSize,
|
|
103
|
+
displayedData,
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Vendored verbatim from recharts@3.9.2 es6/state/selectors/numberDomainEqualityCheck.js (framework-agnostic).
|
|
2
|
+
// Do not edit — update by re-vendoring when the recharts devDependency moves.
|
|
3
|
+
export var numberDomainEqualityCheck = (a, b) => {
|
|
4
|
+
if (a === b) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (a == null || b == null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
11
|
+
};
|