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
package/dist/es/utils/chart.mjs
CHANGED
|
@@ -1,186 +1,248 @@
|
|
|
1
|
-
import { isNan
|
|
2
|
-
import { formatAngleOfSector
|
|
3
|
-
import { findEntryInArray
|
|
4
|
-
import { toRaw
|
|
5
|
-
import { stack
|
|
6
|
-
import { get
|
|
1
|
+
import { isNan, isNullish, isNumOrStr, isNumber } from "./validate.mjs";
|
|
2
|
+
import { formatAngleOfSector, getAngleOfPoint, polarToCartesian, reverseFormatAngleOfSector } from "./polar.mjs";
|
|
3
|
+
import { findEntryInArray, mathSign } from "./data.mjs";
|
|
4
|
+
import { toRaw } from "vue";
|
|
5
|
+
import { stack, stackOffsetExpand, stackOffsetNone, stackOffsetSilhouette, stackOffsetWiggle, stackOrderNone } from "victory-vendor/d3-shape";
|
|
6
|
+
import { get, isNaN, sortBy } from "lodash-es";
|
|
7
7
|
//#region src/utils/chart.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Get the ticks of an axis
|
|
10
|
+
* @param {object} axis The configuration of an axis
|
|
11
|
+
* @param {boolean} isGrid Whether or not are the ticks in grid
|
|
12
|
+
* @param {boolean} isAll Return the ticks of all the points or not
|
|
13
|
+
* @return {Array} Ticks
|
|
14
|
+
*/
|
|
15
|
+
function getTicksOfAxis(axis, isGrid, isAll) {
|
|
16
|
+
if (!axis) return null;
|
|
17
|
+
const { duplicateDomain, type, range, scale, realScaleType, isCategorical, categoricalDomain, tickCount, ticks, niceTicks, axisType } = axis;
|
|
18
|
+
if (!scale) return null;
|
|
19
|
+
const offsetForBand = realScaleType === "scaleBand" ? scale.bandwidth() / 2 : 2;
|
|
20
|
+
let offset = (isGrid || isAll) && type === "category" && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
|
|
21
|
+
offset = axisType === "angleAxis" && range.length >= 2 ? mathSign(range[0] - range[1]) * 2 * offset : offset;
|
|
22
|
+
if (isGrid && (ticks || niceTicks)) return (ticks || niceTicks).map((entry, index) => {
|
|
23
|
+
return {
|
|
24
|
+
coordinate: scale(duplicateDomain ? duplicateDomain.indexOf(entry) : entry) + offset,
|
|
25
|
+
value: entry,
|
|
26
|
+
offset,
|
|
27
|
+
index
|
|
28
|
+
};
|
|
29
|
+
}).filter((row) => !isNaN(row.coordinate));
|
|
30
|
+
if (isCategorical && categoricalDomain) return categoricalDomain.map((entry, index) => ({
|
|
31
|
+
coordinate: scale(entry) + offset,
|
|
32
|
+
value: entry,
|
|
33
|
+
index,
|
|
34
|
+
offset
|
|
35
|
+
}));
|
|
36
|
+
if (scale.ticks && !isAll) return scale.ticks(tickCount).map((entry, index) => ({
|
|
37
|
+
coordinate: scale(entry) + offset,
|
|
38
|
+
value: entry,
|
|
39
|
+
offset,
|
|
40
|
+
index
|
|
41
|
+
}));
|
|
42
|
+
return scale.domain().map((entry, index) => ({
|
|
43
|
+
coordinate: scale(entry) + offset,
|
|
44
|
+
value: duplicateDomain ? duplicateDomain[entry] : entry,
|
|
45
|
+
index,
|
|
46
|
+
offset
|
|
33
47
|
}));
|
|
34
48
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
49
|
+
function getValueByDataKey(obj, dataKey, defaultValue) {
|
|
50
|
+
if (isNullish(obj) || isNullish(dataKey)) return defaultValue;
|
|
51
|
+
if (isNumOrStr(dataKey)) return get(toRaw(obj), dataKey, defaultValue);
|
|
52
|
+
if (typeof dataKey === "function") return dataKey(obj);
|
|
53
|
+
return defaultValue;
|
|
37
54
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
55
|
+
var MIN_VALUE_REG = /^dataMin\s*-\s*(\d+(\.\d+)?)$/;
|
|
56
|
+
var MAX_VALUE_REG = /^dataMax\s*\+\s*(\d+(\.\d+)?)$/;
|
|
57
|
+
/**
|
|
58
|
+
* Calculate the size between two category
|
|
59
|
+
* @param {object} axis The options of axis
|
|
60
|
+
* @param {Array} ticks The ticks of axis
|
|
61
|
+
* @param {boolean} isBar if items in axis are bars
|
|
62
|
+
* @return {number} Size
|
|
63
|
+
*/
|
|
64
|
+
function getBandSizeOfAxis(axis, ticks, isBar) {
|
|
65
|
+
if (axis && axis.scale && axis.scale.bandwidth) {
|
|
66
|
+
const bandWidth = axis.scale.bandwidth();
|
|
67
|
+
if (!isBar || bandWidth > 0) return bandWidth;
|
|
43
68
|
}
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
69
|
+
if (axis && ticks && ticks.length >= 2) {
|
|
70
|
+
const orderedTicks = sortBy(ticks, (o) => o.coordinate);
|
|
71
|
+
let bandSize = Infinity;
|
|
72
|
+
for (let i = 1, len = orderedTicks.length; i < len; i++) {
|
|
73
|
+
const cur = orderedTicks[i];
|
|
74
|
+
const prev = orderedTicks[i - 1];
|
|
75
|
+
bandSize = Math.min((cur.coordinate || 0) - (prev.coordinate || 0), bandSize);
|
|
49
76
|
}
|
|
50
|
-
return
|
|
77
|
+
return bandSize === Infinity ? 0 : bandSize;
|
|
51
78
|
}
|
|
52
|
-
return
|
|
79
|
+
return isBar ? void 0 : 0;
|
|
53
80
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Both value and domain are tuples of two numbers
|
|
83
|
+
* - but the type stays as array of numbers until we have better support in rest of the app
|
|
84
|
+
* @param value input that will be truncated
|
|
85
|
+
* @param domain boundaries
|
|
86
|
+
* @returns tuple of two numbers
|
|
87
|
+
*/
|
|
88
|
+
function truncateByDomain(value, domain) {
|
|
89
|
+
if (!domain || domain.length !== 2 || !isNumber(domain[0]) || !isNumber(domain[1])) return value;
|
|
90
|
+
const minValue = Math.min(domain[0], domain[1]);
|
|
91
|
+
const maxValue = Math.max(domain[0], domain[1]);
|
|
92
|
+
const result = [value[0], value[1]];
|
|
93
|
+
if (!isNumber(value[0]) || value[0] < minValue) result[0] = minValue;
|
|
94
|
+
if (!isNumber(value[1]) || value[1] > maxValue) result[1] = maxValue;
|
|
95
|
+
if (result[0] > maxValue) result[0] = maxValue;
|
|
96
|
+
if (result[1] < minValue) result[1] = minValue;
|
|
97
|
+
return result;
|
|
58
98
|
}
|
|
59
|
-
function
|
|
60
|
-
return
|
|
99
|
+
function getNormalizedStackId(publicStackId) {
|
|
100
|
+
return publicStackId == null ? void 0 : String(publicStackId);
|
|
61
101
|
}
|
|
62
|
-
function
|
|
63
|
-
if (
|
|
64
|
-
if (!
|
|
65
|
-
|
|
66
|
-
if (
|
|
102
|
+
function getCateCoordinateOfLine({ axis, ticks, bandSize, entry, index, dataKey }) {
|
|
103
|
+
if (axis.type === "category") {
|
|
104
|
+
if (!axis.allowDuplicatedCategory && axis.dataKey && !isNullish(entry[axis.dataKey])) {
|
|
105
|
+
const matchedTick = findEntryInArray(ticks, "value", entry[axis.dataKey]);
|
|
106
|
+
if (matchedTick) return matchedTick.coordinate + bandSize / 2;
|
|
67
107
|
}
|
|
68
|
-
return
|
|
108
|
+
return ticks[index] ? ticks[index].coordinate + bandSize / 2 : null;
|
|
69
109
|
}
|
|
70
|
-
|
|
71
|
-
return
|
|
110
|
+
const value = getValueByDataKey(entry, !isNullish(dataKey) ? dataKey : axis.dataKey);
|
|
111
|
+
return !isNullish(value) ? axis.scale(value) : null;
|
|
72
112
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
113
|
+
function getChartPointer(event) {
|
|
114
|
+
const target = event.currentTarget;
|
|
115
|
+
const rect = target.getBoundingClientRect();
|
|
116
|
+
const scaleX = rect.width / target.offsetWidth;
|
|
117
|
+
const scaleY = rect.height / target.offsetHeight;
|
|
75
118
|
return {
|
|
76
|
-
chartX: Math.round((
|
|
77
|
-
chartY: Math.round((
|
|
119
|
+
chartX: Math.round((event.clientX - rect.left) / scaleX),
|
|
120
|
+
chartY: Math.round((event.clientY - rect.top) / scaleY)
|
|
78
121
|
};
|
|
79
122
|
}
|
|
80
|
-
function
|
|
123
|
+
function getTooltipEntry({ tooltipEntrySettings, dataKey, payload, value, name }) {
|
|
81
124
|
return {
|
|
82
|
-
...
|
|
83
|
-
dataKey
|
|
84
|
-
payload
|
|
85
|
-
value
|
|
86
|
-
name
|
|
125
|
+
...tooltipEntrySettings,
|
|
126
|
+
dataKey,
|
|
127
|
+
payload,
|
|
128
|
+
value,
|
|
129
|
+
name
|
|
87
130
|
};
|
|
88
131
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
132
|
+
function calculateTooltipPos(rangeObj, layout) {
|
|
133
|
+
if (layout === "horizontal") return rangeObj.x;
|
|
134
|
+
if (layout === "vertical") return rangeObj.y;
|
|
135
|
+
if (layout === "centric") return rangeObj.angle;
|
|
136
|
+
return rangeObj.radius;
|
|
91
137
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
x
|
|
95
|
-
y
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
138
|
+
function inRangeOfSector({ x, y }, viewBox) {
|
|
139
|
+
const { radius, angle } = getAngleOfPoint({
|
|
140
|
+
x,
|
|
141
|
+
y
|
|
142
|
+
}, viewBox);
|
|
143
|
+
const { innerRadius, outerRadius } = viewBox;
|
|
144
|
+
if (radius < innerRadius || radius > outerRadius) return null;
|
|
145
|
+
if (radius === 0) return null;
|
|
146
|
+
const { startAngle, endAngle } = formatAngleOfSector(viewBox);
|
|
147
|
+
let formatAngle = angle;
|
|
148
|
+
let inRange;
|
|
149
|
+
if (startAngle <= endAngle) {
|
|
150
|
+
while (formatAngle > endAngle) formatAngle -= 360;
|
|
151
|
+
while (formatAngle < startAngle) formatAngle += 360;
|
|
152
|
+
inRange = formatAngle >= startAngle && formatAngle <= endAngle;
|
|
103
153
|
} else {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
154
|
+
while (formatAngle > startAngle) formatAngle -= 360;
|
|
155
|
+
while (formatAngle < endAngle) formatAngle += 360;
|
|
156
|
+
inRange = formatAngle >= endAngle && formatAngle <= startAngle;
|
|
107
157
|
}
|
|
108
|
-
|
|
109
|
-
...
|
|
110
|
-
radius
|
|
111
|
-
angle:
|
|
112
|
-
}
|
|
158
|
+
if (inRange) return {
|
|
159
|
+
...viewBox,
|
|
160
|
+
radius,
|
|
161
|
+
angle: reverseFormatAngleOfSector(formatAngle, viewBox)
|
|
162
|
+
};
|
|
163
|
+
return null;
|
|
113
164
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
x
|
|
117
|
-
y
|
|
118
|
-
} : null
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
165
|
+
function inRange(x, y, layout, polarViewBox, offset) {
|
|
166
|
+
if (layout === "horizontal" || layout === "vertical") return x >= offset.left && x <= offset.left + offset.width && y >= offset.top && y <= offset.top + offset.height ? {
|
|
167
|
+
x,
|
|
168
|
+
y
|
|
169
|
+
} : null;
|
|
170
|
+
if (polarViewBox) return inRangeOfSector({
|
|
171
|
+
x,
|
|
172
|
+
y
|
|
173
|
+
}, polarViewBox);
|
|
174
|
+
return null;
|
|
122
175
|
}
|
|
123
|
-
function
|
|
124
|
-
let
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
176
|
+
function calculateActiveTickIndex(coordinate, ticks, unsortedTicks, axisType, range) {
|
|
177
|
+
let index = -1;
|
|
178
|
+
const len = ticks?.length ?? 0;
|
|
179
|
+
if (len <= 1) return 0;
|
|
180
|
+
if (axisType === "angleAxis" && range != null && Math.abs(Math.abs(range[1] - range[0]) - 360) <= 1e-6) for (let i = 0; i < len; i++) {
|
|
181
|
+
const before = i > 0 ? unsortedTicks[i - 1].coordinate : unsortedTicks[len - 1].coordinate;
|
|
182
|
+
const cur = unsortedTicks[i].coordinate;
|
|
183
|
+
const after = i >= len - 1 ? unsortedTicks[0].coordinate : unsortedTicks[i + 1].coordinate;
|
|
184
|
+
let sameDirectionCoord;
|
|
185
|
+
if (mathSign(cur - before) !== mathSign(after - cur)) {
|
|
186
|
+
const diffInterval = [];
|
|
187
|
+
if (mathSign(after - cur) === mathSign(range[1] - range[0])) {
|
|
188
|
+
sameDirectionCoord = after;
|
|
189
|
+
const curInRange = cur + range[1] - range[0];
|
|
190
|
+
diffInterval[0] = Math.min(curInRange, (curInRange + before) / 2);
|
|
191
|
+
diffInterval[1] = Math.max(curInRange, (curInRange + before) / 2);
|
|
134
192
|
} else {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
193
|
+
sameDirectionCoord = before;
|
|
194
|
+
const afterInRange = after + range[1] - range[0];
|
|
195
|
+
diffInterval[0] = Math.min(cur, (afterInRange + cur) / 2);
|
|
196
|
+
diffInterval[1] = Math.max(cur, (afterInRange + cur) / 2);
|
|
138
197
|
}
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
198
|
+
const sameInterval = [Math.min(cur, (sameDirectionCoord + cur) / 2), Math.max(cur, (sameDirectionCoord + cur) / 2)];
|
|
199
|
+
if (coordinate > sameInterval[0] && coordinate <= sameInterval[1] || coordinate >= diffInterval[0] && coordinate <= diffInterval[1]) {
|
|
200
|
+
index = unsortedTicks[i].index;
|
|
142
201
|
break;
|
|
143
202
|
}
|
|
144
203
|
} else {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
204
|
+
const minValue = Math.min(before, after);
|
|
205
|
+
const maxValue = Math.max(before, after);
|
|
206
|
+
if (coordinate > (minValue + cur) / 2 && coordinate <= (maxValue + cur) / 2) {
|
|
207
|
+
index = unsortedTicks[i].index;
|
|
148
208
|
break;
|
|
149
209
|
}
|
|
150
210
|
}
|
|
151
211
|
}
|
|
152
|
-
else for (let
|
|
153
|
-
|
|
212
|
+
else for (let i = 0; i < len; i++) if (i === 0 && coordinate <= (ticks[i].coordinate + ticks[i + 1].coordinate) / 2 || i > 0 && i < len - 1 && coordinate > (ticks[i].coordinate + ticks[i - 1].coordinate) / 2 && coordinate <= (ticks[i].coordinate + ticks[i + 1].coordinate) / 2 || i === len - 1 && coordinate > (ticks[i].coordinate + ticks[i - 1].coordinate) / 2) {
|
|
213
|
+
index = ticks[i].index;
|
|
154
214
|
break;
|
|
155
215
|
}
|
|
156
|
-
return
|
|
216
|
+
return index;
|
|
157
217
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
if (
|
|
162
|
-
x:
|
|
163
|
-
y:
|
|
218
|
+
function getActiveCoordinate(layout, tooltipTicks, activeIndex, rangeObj) {
|
|
219
|
+
const entry = tooltipTicks.find((tick) => tick && tick.index === activeIndex);
|
|
220
|
+
if (entry) {
|
|
221
|
+
if (layout === "horizontal") return {
|
|
222
|
+
x: entry.coordinate,
|
|
223
|
+
y: rangeObj.y
|
|
164
224
|
};
|
|
165
|
-
if (
|
|
166
|
-
x:
|
|
167
|
-
y:
|
|
225
|
+
if (layout === "vertical") return {
|
|
226
|
+
x: rangeObj.x,
|
|
227
|
+
y: entry.coordinate
|
|
168
228
|
};
|
|
169
|
-
if (
|
|
170
|
-
|
|
229
|
+
if (layout === "centric") {
|
|
230
|
+
const angle = entry.coordinate;
|
|
231
|
+
const { radius } = rangeObj;
|
|
171
232
|
return {
|
|
172
|
-
...
|
|
173
|
-
...
|
|
174
|
-
angle
|
|
175
|
-
radius
|
|
233
|
+
...rangeObj,
|
|
234
|
+
...polarToCartesian(rangeObj.cx, rangeObj.cy, radius, angle),
|
|
235
|
+
angle,
|
|
236
|
+
radius
|
|
176
237
|
};
|
|
177
238
|
}
|
|
178
|
-
|
|
239
|
+
const radius = entry.coordinate;
|
|
240
|
+
const { angle } = rangeObj;
|
|
179
241
|
return {
|
|
180
|
-
...
|
|
181
|
-
...
|
|
182
|
-
angle
|
|
183
|
-
radius
|
|
242
|
+
...rangeObj,
|
|
243
|
+
...polarToCartesian(rangeObj.cx, rangeObj.cy, radius, angle),
|
|
244
|
+
angle,
|
|
245
|
+
radius
|
|
184
246
|
};
|
|
185
247
|
}
|
|
186
248
|
return {
|
|
@@ -188,78 +250,117 @@ function P(e, t, n, r) {
|
|
|
188
250
|
y: 0
|
|
189
251
|
};
|
|
190
252
|
}
|
|
191
|
-
function
|
|
192
|
-
return [
|
|
253
|
+
function makeDomainFinite(domain) {
|
|
254
|
+
return [domain[0] === Infinity ? 0 : domain[0], domain[1] === -Infinity ? 0 : domain[1]];
|
|
193
255
|
}
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
return [Math.min(...
|
|
256
|
+
function getDomainOfSingle(data) {
|
|
257
|
+
const flat = data.flat(2).filter(isNumber);
|
|
258
|
+
return [Math.min(...flat), Math.max(...flat)];
|
|
197
259
|
}
|
|
198
|
-
function
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
260
|
+
function getDomainOfStackGroups(stackGroups, startIndex, endIndex) {
|
|
261
|
+
if (stackGroups == null) return;
|
|
262
|
+
return makeDomainFinite(Object.keys(stackGroups).reduce((result, stackId) => {
|
|
263
|
+
const { stackedData } = stackGroups[stackId];
|
|
264
|
+
const domain = stackedData.reduce((res, entry) => {
|
|
265
|
+
const s = getDomainOfSingle(entry.slice(startIndex, endIndex + 1));
|
|
266
|
+
return [Math.min(res[0], s[0]), Math.max(res[1], s[1])];
|
|
203
267
|
}, [Infinity, -Infinity]);
|
|
204
|
-
return [Math.min(
|
|
268
|
+
return [Math.min(domain[0], result[0]), Math.max(domain[1], result[1])];
|
|
205
269
|
}, [Infinity, -Infinity]));
|
|
206
270
|
}
|
|
207
|
-
var
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
if (!
|
|
211
|
-
|
|
212
|
-
|
|
271
|
+
var EPS = 1e-4;
|
|
272
|
+
function checkDomainOfScale(scale) {
|
|
273
|
+
const domain = scale.domain();
|
|
274
|
+
if (!domain || domain.length <= 2) return;
|
|
275
|
+
const len = domain.length;
|
|
276
|
+
const range = scale.range();
|
|
277
|
+
const minValue = Math.min(range[0], range[1]) - EPS;
|
|
278
|
+
const maxValue = Math.max(range[0], range[1]) + EPS;
|
|
279
|
+
const first = scale(domain[0]);
|
|
280
|
+
const last = scale(domain[len - 1]);
|
|
281
|
+
if (first < minValue || first > maxValue || last < minValue || last > maxValue) scale.domain([domain[0], domain[len - 1]]);
|
|
213
282
|
}
|
|
214
|
-
function
|
|
215
|
-
if (
|
|
216
|
-
if (typeof
|
|
283
|
+
function getTooltipNameProp(nameFromItem, dataKey) {
|
|
284
|
+
if (nameFromItem) return String(nameFromItem);
|
|
285
|
+
if (typeof dataKey === "string") return dataKey;
|
|
217
286
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
287
|
+
function isClipDot(dot) {
|
|
288
|
+
if (dot && typeof dot === "object" && "clipDot" in dot) return Boolean(dot.clipDot);
|
|
289
|
+
return true;
|
|
220
290
|
}
|
|
221
|
-
var
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
291
|
+
var offsetSign = (series) => {
|
|
292
|
+
const n = series.length;
|
|
293
|
+
if (n <= 0) return;
|
|
294
|
+
for (let j = 0, m = series[0].length; j < m; ++j) {
|
|
295
|
+
let positive = 0;
|
|
296
|
+
let negative = 0;
|
|
297
|
+
for (let i = 0; i < n; ++i) {
|
|
298
|
+
const value = isNan(series[i][j][1]) ? series[i][j][0] : series[i][j][1];
|
|
299
|
+
if (value >= 0) {
|
|
300
|
+
series[i][j][0] = positive;
|
|
301
|
+
series[i][j][1] = positive + value;
|
|
302
|
+
positive = series[i][j][1];
|
|
303
|
+
} else {
|
|
304
|
+
series[i][j][0] = negative;
|
|
305
|
+
series[i][j][1] = negative + value;
|
|
306
|
+
negative = series[i][j][1];
|
|
229
307
|
}
|
|
230
308
|
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Replaces all negative values with zero when stacking data.
|
|
313
|
+
*
|
|
314
|
+
* If all values in the series are positive then this behaves the same as 'none' stacker.
|
|
315
|
+
*
|
|
316
|
+
* @param {Array} series from d3-shape Stack
|
|
317
|
+
* @return {Array} series with applied offset
|
|
318
|
+
*/
|
|
319
|
+
var offsetPositive = (series) => {
|
|
320
|
+
const n = series.length;
|
|
321
|
+
if (n <= 0) return;
|
|
322
|
+
for (let j = 0, m = series[0].length; j < m; ++j) {
|
|
323
|
+
let positive = 0;
|
|
324
|
+
for (let i = 0; i < n; ++i) {
|
|
325
|
+
const value = isNan(series[i][j][1]) ? series[i][j][0] : series[i][j][1];
|
|
326
|
+
if (value >= 0) {
|
|
327
|
+
series[i][j][0] = positive;
|
|
328
|
+
series[i][j][1] = positive + value;
|
|
329
|
+
positive = series[i][j][1];
|
|
330
|
+
} else {
|
|
331
|
+
series[i][j][0] = 0;
|
|
332
|
+
series[i][j][1] = 0;
|
|
243
333
|
}
|
|
244
334
|
}
|
|
245
335
|
}
|
|
246
336
|
};
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
337
|
+
var STACK_OFFSET_MAP = {
|
|
338
|
+
sign: offsetSign,
|
|
339
|
+
expand: stackOffsetExpand,
|
|
340
|
+
none: stackOffsetNone,
|
|
341
|
+
silhouette: stackOffsetSilhouette,
|
|
342
|
+
wiggle: stackOffsetWiggle,
|
|
343
|
+
positive: offsetPositive
|
|
344
|
+
};
|
|
345
|
+
function getStackedData(data, dataKeys, offsetType) {
|
|
346
|
+
const offsetAccessor = STACK_OFFSET_MAP[offsetType];
|
|
347
|
+
return stack().keys(dataKeys).value((d, key) => +getValueByDataKey(d, key, 0)).order(stackOrderNone).offset(offsetAccessor)(data);
|
|
250
348
|
}
|
|
251
|
-
function
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
349
|
+
function getBaseValueOfBar({ numericAxis }) {
|
|
350
|
+
const domain = numericAxis.scale.domain();
|
|
351
|
+
if (numericAxis.type === "number") {
|
|
352
|
+
const minValue = Math.min(domain[0], domain[1]);
|
|
353
|
+
const maxValue = Math.max(domain[0], domain[1]);
|
|
354
|
+
if (minValue <= 0 && maxValue >= 0) return 0;
|
|
355
|
+
if (maxValue < 0) return maxValue;
|
|
356
|
+
return minValue;
|
|
256
357
|
}
|
|
257
|
-
return
|
|
358
|
+
return domain[0];
|
|
258
359
|
}
|
|
259
|
-
function
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
return
|
|
360
|
+
function getCateCoordinateOfBar({ axis, ticks, offset, bandSize, entry, index }) {
|
|
361
|
+
if (axis.type === "category") return ticks[index] ? ticks[index].coordinate + offset : null;
|
|
362
|
+
const value = getValueByDataKey(entry, axis.dataKey, axis.scale.domain()[index]);
|
|
363
|
+
return !isNullish(value) ? axis.scale(value) - bandSize / 2 + offset : null;
|
|
263
364
|
}
|
|
264
365
|
//#endregion
|
|
265
|
-
export {
|
|
366
|
+
export { MAX_VALUE_REG, MIN_VALUE_REG, calculateActiveTickIndex, calculateTooltipPos, checkDomainOfScale, getActiveCoordinate, getBandSizeOfAxis, getBaseValueOfBar, getCateCoordinateOfBar, getCateCoordinateOfLine, getChartPointer, getDomainOfStackGroups, getNormalizedStackId, getStackedData, getTicksOfAxis, getTooltipEntry, getTooltipNameProp, getValueByDataKey, inRange, isClipDot, truncateByDomain };
|
package/dist/es/utils/const.mjs
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
//#region src/utils/const.ts
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* We use this attribute to identify which element is the one that the user is touching.
|
|
4
|
+
* The index is the position of the element in the data array.
|
|
5
|
+
* This can be either a number (for array-based charts) or a string (for the charts that have a matrix-shaped data).
|
|
6
|
+
*/
|
|
7
|
+
var DATA_ITEM_INDEX_ATTRIBUTE_NAME = "data-recharts-item-index";
|
|
8
|
+
/**
|
|
9
|
+
* We use this attribute to identify which element is the one that the user is touching.
|
|
10
|
+
* DataKey works here as a kind of identifier for the element. It's not a perfect identifier for ~two~ three reasons:
|
|
11
|
+
*
|
|
12
|
+
* 1. There can be two different elements with the same dataKey; we won't know which is it
|
|
13
|
+
* 2. DataKey can be a function, and that serialized will be a `[Function: anonymous]` string
|
|
14
|
+
* which means we will be able to identify that it was a function but can't tell which one.
|
|
15
|
+
* This will lead to some weird bugs. A proper fix would be to either:
|
|
16
|
+
* a) use a unique identifier for each element (passed from props, or generated)
|
|
17
|
+
* b) figure out how to compare the dataKey or graphical item by object reference
|
|
18
|
+
*
|
|
19
|
+
* a) is a fuss because we don't have the unique identifier in props,
|
|
20
|
+
* and b) is possible most of the time except for touchMove events which work differently from mouseEnter/mouseLeave:
|
|
21
|
+
* - while mouseEnter is fired for the element that the mouse is over,
|
|
22
|
+
* touchMove is fired for the element where user has started touching. As the finger moves,
|
|
23
|
+
* we can identify the element that the user is touching by using the elementFromPoint method,
|
|
24
|
+
* but it keeps calling the handler on the element where touchStart was fired.
|
|
25
|
+
*
|
|
26
|
+
* Okay and now I discovered a third reason: the dataKey can be undefined and that's still fine
|
|
27
|
+
* because if dataKey is undefined then graphical elements assume the dataKey of the axes.
|
|
28
|
+
* Which makes it a convenient way of using recharts to render a chart but horrible identifier.
|
|
29
|
+
*/
|
|
30
|
+
var DATA_ITEM_DATAKEY_ATTRIBUTE_NAME = "data-recharts-item-data-key";
|
|
3
31
|
//#endregion
|
|
4
|
-
export {
|
|
32
|
+
export { DATA_ITEM_DATAKEY_ATTRIBUTE_NAME, DATA_ITEM_INDEX_ATTRIBUTE_NAME };
|