@solidports/recharts 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +40 -2
- package/dist/index.js +14238 -7174
- package/dist/{dev.js → index.jsx} +18367 -15900
- package/dist/server.js +48178 -0
- package/package.json +36 -19
- package/src/animation/AnimatedItems.tsx +0 -183
- package/src/animation/AnimationController.ts +0 -33
- package/src/animation/AnimationControllerImpl.ts +0 -36
- package/src/animation/AnimationHandle.ts +0 -307
- package/src/animation/CSSTransitionAnimate.tsx +0 -170
- package/src/animation/JavascriptAnimate.tsx +0 -119
- package/src/animation/easing.ts +0 -221
- package/src/animation/matchBy.ts +0 -164
- package/src/animation/timeoutController.ts +0 -70
- package/src/animation/useAnimationController.tsx +0 -34
- package/src/animation/useAnimationStartSnapshot.ts +0 -118
- package/src/animation/util.ts +0 -41
- package/src/cartesian/Area.tsx +0 -915
- package/src/cartesian/AreaRevealShape.tsx +0 -190
- package/src/cartesian/Bar.tsx +0 -1369
- package/src/cartesian/BarStack.tsx +0 -152
- package/src/cartesian/Brush.tsx +0 -951
- package/src/cartesian/CartesianAxis.tsx +0 -722
- package/src/cartesian/CartesianGrid.tsx +0 -711
- package/src/cartesian/ErrorBar.tsx +0 -361
- package/src/cartesian/Funnel.tsx +0 -803
- package/src/cartesian/GraphicalItemClipPath.tsx +0 -67
- package/src/cartesian/Line.tsx +0 -863
- package/src/cartesian/LineDrawShape.tsx +0 -89
- package/src/cartesian/ReferenceArea.tsx +0 -331
- package/src/cartesian/ReferenceDot.tsx +0 -304
- package/src/cartesian/ReferenceLine.tsx +0 -474
- package/src/cartesian/Scatter.tsx +0 -888
- package/src/cartesian/XAxis.tsx +0 -433
- package/src/cartesian/YAxis.tsx +0 -443
- package/src/cartesian/ZAxis.tsx +0 -155
- package/src/cartesian/cartesianPositionToCSSTranslate.tsx +0 -29
- package/src/cartesian/cartesianViewBoxToTrapezoid.tsx +0 -21
- package/src/cartesian/getCartesianPosition.tsx +0 -267
- package/src/cartesian/getEquidistantTicks.ts +0 -144
- package/src/cartesian/getTicks.ts +0 -225
- package/src/cartesian/isOutsidePosition.ts +0 -15
- package/src/cartesian/useAnimatedLineLength.ts +0 -54
- package/src/chart/AreaChart.tsx +0 -29
- package/src/chart/BarChart.tsx +0 -29
- package/src/chart/CartesianChart.tsx +0 -131
- package/src/chart/CategoricalChart.tsx +0 -94
- package/src/chart/ComposedChart.tsx +0 -29
- package/src/chart/FunnelChart.tsx +0 -29
- package/src/chart/LineChart.tsx +0 -29
- package/src/chart/PieChart.tsx +0 -50
- package/src/chart/PolarChart.tsx +0 -164
- package/src/chart/RadarChart.tsx +0 -70
- package/src/chart/RadialBarChart.tsx +0 -46
- package/src/chart/RechartsWrapper.tsx +0 -551
- package/src/chart/Sankey.tsx +0 -1534
- package/src/chart/ScatterChart.tsx +0 -29
- package/src/chart/SunburstChart.tsx +0 -504
- package/src/chart/Treemap.tsx +0 -1223
- package/src/chart/createInitialRootProps.ts +0 -24
- package/src/chart/types.ts +0 -53
- package/src/component/ActivePoints.tsx +0 -144
- package/src/component/Cell.tsx +0 -37
- package/src/component/Cursor.tsx +0 -185
- package/src/component/Customized.tsx +0 -50
- package/src/component/DefaultLegendContent.tsx +0 -348
- package/src/component/DefaultTooltipContent.tsx +0 -224
- package/src/component/Dots.tsx +0 -157
- package/src/component/Label.tsx +0 -636
- package/src/component/LabelList.tsx +0 -375
- package/src/component/Legend.tsx +0 -512
- package/src/component/ResponsiveContainer.tsx +0 -348
- package/src/component/Text.tsx +0 -541
- package/src/component/Tooltip.tsx +0 -470
- package/src/component/TooltipBoundingBox.tsx +0 -146
- package/src/component/responsiveContainerUtils.ts +0 -134
- package/src/container/ClipPathProvider.tsx +0 -51
- package/src/container/Layer.tsx +0 -38
- package/src/container/RootSurface.tsx +0 -120
- package/src/container/Surface.tsx +0 -61
- package/src/context/CellsContext.tsx +0 -54
- package/src/context/ErrorBarContext.tsx +0 -146
- package/src/context/GraphicalItemChildrenScope.tsx +0 -18
- package/src/context/PanoramaContext.tsx +0 -9
- package/src/context/RegisterGraphicalItemId.tsx +0 -30
- package/src/context/accessibilityContext.tsx +0 -6
- package/src/context/brushUpdateContext.tsx +0 -9
- package/src/context/chartDataContext.tsx +0 -97
- package/src/context/chartLayoutContext.tsx +0 -201
- package/src/context/legendPayloadContext.tsx +0 -20
- package/src/context/legendPortalContext.tsx +0 -12
- package/src/context/tooltipContext.tsx +0 -89
- package/src/context/tooltipPortalContext.tsx +0 -12
- package/src/context/useTooltipAxis.ts +0 -22
- package/src/hooks.ts +0 -476
- package/src/index.ts +0 -280
- package/src/polar/Pie.tsx +0 -1360
- package/src/polar/PolarAngleAxis.tsx +0 -616
- package/src/polar/PolarGrid.tsx +0 -312
- package/src/polar/PolarRadiusAxis.tsx +0 -547
- package/src/polar/Radar.tsx +0 -734
- package/src/polar/RadialBar.tsx +0 -917
- package/src/polar/defaultPolarAngleAxisProps.tsx +0 -27
- package/src/polar/defaultPolarRadiusAxisProps.tsx +0 -25
- package/src/shape/Cross.tsx +0 -89
- package/src/shape/Curve.tsx +0 -343
- package/src/shape/Dot.tsx +0 -70
- package/src/shape/Polygon.tsx +0 -195
- package/src/shape/Rectangle.tsx +0 -470
- package/src/shape/Sector.tsx +0 -347
- package/src/shape/Symbols.tsx +0 -139
- package/src/shape/Trapezoid.tsx +0 -280
- package/src/state/RechartsStateContext.tsx +0 -12
- package/src/state/RechartsStateProvider.tsx +0 -87
- package/src/state/RechartsStoreContext.tsx +0 -25
- package/src/state/RechartsStoreProvider.tsx +0 -35
- package/src/state/ReportChartProps.tsx +0 -40
- package/src/state/ReportEventSettings.tsx +0 -30
- package/src/state/ReportMainChartProps.tsx +0 -61
- package/src/state/ReportPolarOptions.tsx +0 -35
- package/src/state/SetGraphicalItem.ts +0 -79
- package/src/state/SetLegendPayload.ts +0 -134
- package/src/state/SetTooltipEntrySettings.tsx +0 -72
- package/src/state/actions.ts +0 -464
- package/src/state/brushSlice.ts +0 -13
- package/src/state/cartesianAxisSlice.ts +0 -141
- package/src/state/chartDataSlice.ts +0 -50
- package/src/state/chartState.ts +0 -297
- package/src/state/errorBarSlice.ts +0 -29
- package/src/state/eventSettingsSlice.ts +0 -8
- package/src/state/events.ts +0 -76
- package/src/state/externalEventsMiddleware.ts +0 -255
- package/src/state/graphicalItemsSlice.ts +0 -74
- package/src/state/hooks/useChartSelectors.tsx +0 -45
- package/src/state/keyboardEventsMiddleware.ts +0 -228
- package/src/state/layoutSlice.ts +0 -21
- package/src/state/legendSlice.ts +0 -57
- package/src/state/mouseEventsMiddleware.ts +0 -185
- package/src/state/optionsSlice.ts +0 -47
- package/src/state/polarAxisSlice.ts +0 -10
- package/src/state/polarOptionsSlice.ts +0 -12
- package/src/state/rawData.ts +0 -26
- package/src/state/referenceElementsSlice.ts +0 -40
- package/src/state/renderedTicksSlice.ts +0 -15
- package/src/state/rootPropsSlice.ts +0 -47
- package/src/state/selectors/areaSelectors.ts +0 -240
- package/src/state/selectors/arrayEqualityCheck.ts +0 -29
- package/src/state/selectors/axisSelectors.ts +0 -2157
- package/src/state/selectors/barSelectors.ts +0 -310
- package/src/state/selectors/barStackSelectors.ts +0 -77
- package/src/state/selectors/brushSelectors.ts +0 -33
- package/src/state/selectors/chartSelector.ts +0 -185
- package/src/state/selectors/combiners/combineActiveLabel.ts +0 -16
- package/src/state/selectors/combiners/combineActiveTooltipIndex.ts +0 -95
- package/src/state/selectors/combiners/combineAllBarPositions.ts +0 -122
- package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +0 -16
- package/src/state/selectors/combiners/combineBarPosition.ts +0 -23
- package/src/state/selectors/combiners/combineBarSizeList.ts +0 -80
- package/src/state/selectors/combiners/combineCheckedDomain.ts +0 -48
- package/src/state/selectors/combiners/combineConfiguredScale.ts +0 -111
- package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +0 -45
- package/src/state/selectors/combiners/combineDisplayedStackedData.ts +0 -50
- package/src/state/selectors/combiners/combineInverseScaleFunction.ts +0 -16
- package/src/state/selectors/combiners/combineRealScaleType.ts +0 -44
- package/src/state/selectors/combiners/combineStackedData.ts +0 -27
- package/src/state/selectors/combiners/combineTooltipInteractionState.ts +0 -86
- package/src/state/selectors/combiners/combineTooltipPayload.ts +0 -205
- package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts +0 -58
- package/src/state/selectors/containerSelectors.ts +0 -12
- package/src/state/selectors/dataSelectors.ts +0 -88
- package/src/state/selectors/funnelSelectors.ts +0 -75
- package/src/state/selectors/graphicalItemSelectors.ts +0 -30
- package/src/state/selectors/legendSelectors.ts +0 -29
- package/src/state/selectors/lineSelectors.ts +0 -134
- package/src/state/selectors/numberDomainEqualityCheck.ts +0 -14
- package/src/state/selectors/pickAxisId.ts +0 -5
- package/src/state/selectors/pickAxisType.ts +0 -3
- package/src/state/selectors/pieSelectors.ts +0 -97
- package/src/state/selectors/polarAxisSelectors.ts +0 -201
- package/src/state/selectors/polarGridSelectors.ts +0 -28
- package/src/state/selectors/polarScaleSelectors.ts +0 -133
- package/src/state/selectors/polarSelectors.ts +0 -219
- package/src/state/selectors/radarSelectors.ts +0 -191
- package/src/state/selectors/radialBarSelectors.ts +0 -435
- package/src/state/selectors/rootPropsSelectors.ts +0 -25
- package/src/state/selectors/scatterSelectors.ts +0 -96
- package/src/state/selectors/selectActivePropsFromChartPointer.ts +0 -26
- package/src/state/selectors/selectAllAxes.ts +0 -17
- package/src/state/selectors/selectChartOffset.ts +0 -16
- package/src/state/selectors/selectChartOffsetInternal.ts +0 -136
- package/src/state/selectors/selectLegendArea.ts +0 -20
- package/src/state/selectors/selectPlotArea.ts +0 -22
- package/src/state/selectors/selectTooltipAxisId.ts +0 -7
- package/src/state/selectors/selectTooltipAxisType.ts +0 -32
- package/src/state/selectors/selectTooltipEventType.ts +0 -48
- package/src/state/selectors/selectTooltipPayloadSearcher.ts +0 -6
- package/src/state/selectors/selectTooltipSettings.ts +0 -39
- package/src/state/selectors/selectTooltipState.ts +0 -8
- package/src/state/selectors/selectors.ts +0 -271
- package/src/state/selectors/tooltipSelectors.ts +0 -578
- package/src/state/selectors/touchSelectors.ts +0 -31
- package/src/state/store.ts +0 -29
- package/src/state/storeIdentity.ts +0 -9
- package/src/state/teardownWrite.ts +0 -10
- package/src/state/tooltipInteraction.ts +0 -23
- package/src/state/tooltipSlice.ts +0 -334
- package/src/state/touchEventsMiddleware.ts +0 -214
- package/src/state/types/AnimationSettings.ts +0 -20
- package/src/state/types/AreaSettings.ts +0 -14
- package/src/state/types/BarSettings.ts +0 -15
- package/src/state/types/LineSettings.ts +0 -9
- package/src/state/types/PieSettings.ts +0 -34
- package/src/state/types/RadarSettings.ts +0 -5
- package/src/state/types/RadialBarSettings.ts +0 -10
- package/src/state/types/ScatterSettings.ts +0 -12
- package/src/state/types/StackedGraphicalItem.ts +0 -34
- package/src/state/useChartState.ts +0 -17
- package/src/state/zIndexSlice.ts +0 -39
- package/src/synchronisation/syncSelectors.ts +0 -7
- package/src/synchronisation/types.ts +0 -44
- package/src/synchronisation/useChartSynchronisation.tsx +0 -404
- package/src/theme/RechartsTheme.ts +0 -16
- package/src/theme/RechartsThemeContext.ts +0 -19
- package/src/theme/darkTheme.ts +0 -13
- package/src/theme/graphicalItemIdentity.ts +0 -70
- package/src/theme/legacyTheme.ts +0 -17
- package/src/theme/lightTheme.ts +0 -13
- package/src/types.ts +0 -54
- package/src/util/ActiveShapeUtils.tsx +0 -162
- package/src/util/BarUtils.tsx +0 -62
- package/src/util/BarePortal.tsx +0 -50
- package/src/util/CamelCaseSVGAttrs.ts +0 -34
- package/src/util/CartesianUtils.ts +0 -48
- package/src/util/ChartUtils.ts +0 -802
- package/src/util/Constants.ts +0 -42
- package/src/util/CssPrefixUtils.ts +0 -20
- package/src/util/DOMUtils.ts +0 -129
- package/src/util/DataUtils.ts +0 -216
- package/src/util/Events.ts +0 -16
- package/src/util/FunnelUtils.tsx +0 -15
- package/src/util/Global.ts +0 -12
- package/src/util/IfOverflow.ts +0 -15
- package/src/util/LRUCache.ts +0 -41
- package/src/util/LogUtils.ts +0 -22
- package/src/util/PolarUtils.ts +0 -132
- package/src/util/RadialBarUtils.tsx +0 -24
- package/src/util/ReactUtils.ts +0 -95
- package/src/util/ReduceCSSCalc.ts +0 -187
- package/src/util/ScatterUtils.tsx +0 -52
- package/src/util/ShapeElementProps.tsx +0 -87
- package/src/util/TickUtils.ts +0 -60
- package/src/util/XAxisUtils.ts +0 -48
- package/src/util/YAxisUtils.ts +0 -48
- package/src/util/axisPropsAreEqual.ts +0 -48
- package/src/util/createCartesianCharts.tsx +0 -150
- package/src/util/createEventProxy.ts +0 -20
- package/src/util/createPolarCharts.tsx +0 -112
- package/src/util/cursor/getCursorPoints.ts +0 -46
- package/src/util/cursor/getCursorRectangle.ts +0 -28
- package/src/util/cursor/getRadialCursorPoints.ts +0 -32
- package/src/util/excludeEventProps.ts +0 -171
- package/src/util/getActiveCoordinate.ts +0 -213
- package/src/util/getAxisTypeBasedOnLayout.ts +0 -21
- package/src/util/getClassNameFromUnknown.ts +0 -6
- package/src/util/getEveryNth.ts +0 -27
- package/src/util/getRadiusAndStrokeWidthFromDot.ts +0 -35
- package/src/util/getRelativeCoordinate.ts +0 -80
- package/src/util/getSliced.ts +0 -13
- package/src/util/hoverDedupe.ts +0 -41
- package/src/util/isDomainSpecifiedByUser.ts +0 -219
- package/src/util/isWellBehavedNumber.ts +0 -7
- package/src/util/pathTotalLength.ts +0 -25
- package/src/util/payload/getUniqPayload.ts +0 -28
- package/src/util/propsAreEqual.ts +0 -121
- package/src/util/resolveDefaultProps.ts +0 -161
- package/src/util/round.ts +0 -32
- package/src/util/scale/CartesianScaleHelper.ts +0 -72
- package/src/util/scale/CustomScaleDefinition.ts +0 -81
- package/src/util/scale/RechartsScale.ts +0 -130
- package/src/util/scale/createCategoricalInverse.ts +0 -72
- package/src/util/scale/getNiceTickValues.ts +0 -311
- package/src/util/scale/index.ts +0 -2
- package/src/util/scale/util/arithmetic.ts +0 -54
- package/src/util/solid-1-compat.ts +0 -310
- package/src/util/solidJsxCamelAugment.d.ts +0 -84
- package/src/util/stacks/getStackSeriesIdentifier.ts +0 -21
- package/src/util/stacks/stackTypes.ts +0 -60
- package/src/util/structurallyEqual.ts +0 -31
- package/src/util/svgPropertiesAndEvents.ts +0 -53
- package/src/util/svgPropertiesNoEvents.ts +0 -571
- package/src/util/tooltip/translate.ts +0 -171
- package/src/util/typedDataKey.ts +0 -48
- package/src/util/types.ts +0 -1560
- package/src/util/useAnimationId.ts +0 -31
- package/src/util/useElementOffset.ts +0 -110
- package/src/util/useId.ts +0 -8
- package/src/util/usePrefersReducedMotion.ts +0 -48
- package/src/util/useReportScale.ts +0 -24
- package/src/util/useUniqueId.ts +0 -30
- package/src/zIndex/DefaultZIndexes.ts +0 -84
- package/src/zIndex/ZIndexLayer.tsx +0 -121
- package/src/zIndex/ZIndexPortal.tsx +0 -79
- package/src/zIndex/getZIndexFromUnknown.ts +0 -14
- package/src/zIndex/zIndexSelectors.ts +0 -48
package/src/polar/Radar.tsx
DELETED
|
@@ -1,734 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle, sort-keys */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { svgPropertiesAndEvents } from "../util/svgPropertiesAndEvents"
|
|
4
|
-
import type { WithoutRemoveFalse } from "../util/types"
|
|
5
|
-
import type { CamelCaseSVGAttrs } from "../util/CamelCaseSVGAttrs"
|
|
6
|
-
import { createMemo, Show, useContext, createEffect } from 'solid-js';
|
|
7
|
-
import last from "es-toolkit/compat/last"
|
|
8
|
-
|
|
9
|
-
import { clsx } from "clsx"
|
|
10
|
-
import { interpolate, isNullish, noop } from "../util/DataUtils"
|
|
11
|
-
import { polarToCartesian } from "../util/PolarUtils"
|
|
12
|
-
import { getTooltipNameProp, getValueByDataKey } from "../util/ChartUtils"
|
|
13
|
-
import { Polygon } from "../shape/Polygon"
|
|
14
|
-
import { Layer } from "../container/Layer"
|
|
15
|
-
import {
|
|
16
|
-
LabelListContextBridge,
|
|
17
|
-
CartesianLabelListContextProvider,
|
|
18
|
-
CartesianLabelListEntry,
|
|
19
|
-
ImplicitLabelListType,
|
|
20
|
-
LabelListFromLabelProp,
|
|
21
|
-
} from "../component/LabelList"
|
|
22
|
-
import { Dots } from "../component/Dots"
|
|
23
|
-
import {
|
|
24
|
-
ActiveDotType,
|
|
25
|
-
AnimationDuration,
|
|
26
|
-
AnimationTiming,
|
|
27
|
-
DataConsumer,
|
|
28
|
-
DataKey,
|
|
29
|
-
DotType,
|
|
30
|
-
LegendType,
|
|
31
|
-
TooltipType,
|
|
32
|
-
TrapezoidViewBox,
|
|
33
|
-
} from "../util/types"
|
|
34
|
-
import type { LegendPayload } from "../component/DefaultLegendContent"
|
|
35
|
-
import { ActivePoints } from "../component/ActivePoints"
|
|
36
|
-
import { TooltipPayloadConfiguration } from "../state/tooltipSlice"
|
|
37
|
-
import { SetTooltipEntrySettings } from "../state/SetTooltipEntrySettings"
|
|
38
|
-
import { selectRadarPoints } from "../state/selectors/radarSelectors"
|
|
39
|
-
import { useChartStore } from "../state/RechartsStoreContext"
|
|
40
|
-
import { RechartsStateContext } from "../state/RechartsStateContext"
|
|
41
|
-
import type { AngleAxisSettings, RadiusAxisSettings } from "../state/polarAxisSlice"
|
|
42
|
-
import { useIsPanorama } from "../context/PanoramaContext"
|
|
43
|
-
import { SetPolarLegendPayload } from "../state/SetLegendPayload"
|
|
44
|
-
import { useAnimationId } from "../util/useAnimationId"
|
|
45
|
-
import { RegisterGraphicalItemId } from "../context/RegisterGraphicalItemId"
|
|
46
|
-
import { SetPolarGraphicalItem } from "../state/SetGraphicalItem"
|
|
47
|
-
import { svgPropertiesNoEvents } from "../util/svgPropertiesNoEvents"
|
|
48
|
-
import { AnimatedItems, useAnimationCallbacks } from "../animation/AnimatedItems"
|
|
49
|
-
import type { AnimationInterpolateFn } from "../animation/AnimatedItems"
|
|
50
|
-
import { matchAnimationItems, matchByIndex } from "../animation/matchBy"
|
|
51
|
-
import type { AnimationMatchByProp } from "../animation/matchBy"
|
|
52
|
-
import { useAnimationStartSnapshot } from "../animation/useAnimationStartSnapshot"
|
|
53
|
-
import { usePolarChartLayout } from "../context/chartLayoutContext"
|
|
54
|
-
import type { PolarLayout } from "../util/types"
|
|
55
|
-
import type { RequiresDefaultProps } from "../util/resolveDefaultProps"
|
|
56
|
-
import { WithIdRequired } from "../util/useUniqueId"
|
|
57
|
-
import { ZIndexable, ZIndexLayer } from "../zIndex/ZIndexLayer"
|
|
58
|
-
import { DefaultZIndexes } from "../zIndex/DefaultZIndexes"
|
|
59
|
-
import { RechartsScale } from "../util/scale/RechartsScale"
|
|
60
|
-
|
|
61
|
-
import { mergeProps, splitProps } from '../util/solid-1-compat';
|
|
62
|
-
export interface RadarPoint {
|
|
63
|
-
x: number
|
|
64
|
-
y: number
|
|
65
|
-
cx?: number
|
|
66
|
-
cy?: number
|
|
67
|
-
angle: number
|
|
68
|
-
radius?: number
|
|
69
|
-
value?: number
|
|
70
|
-
payload?: unknown
|
|
71
|
-
name?: string | number
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface RadarProps<DataPointType = unknown, DataValueType = unknown>
|
|
75
|
-
extends ZIndexable, DataConsumer<DataPointType, DataValueType> {
|
|
76
|
-
/**
|
|
77
|
-
* @defaultValue true
|
|
78
|
-
*/
|
|
79
|
-
activeDot?: ActiveDotType
|
|
80
|
-
/**
|
|
81
|
-
* @defaultValue 0
|
|
82
|
-
*/
|
|
83
|
-
angleAxisId?: string | number
|
|
84
|
-
/**
|
|
85
|
-
* Specifies when the animation should begin, the unit of this option is ms.
|
|
86
|
-
* @defaultValue 0
|
|
87
|
-
*/
|
|
88
|
-
animationBegin?: number
|
|
89
|
-
/**
|
|
90
|
-
* Specifies the duration of animation, the unit of this option is ms.
|
|
91
|
-
* @defaultValue 1500
|
|
92
|
-
*/
|
|
93
|
-
animationDuration?: AnimationDuration
|
|
94
|
-
/**
|
|
95
|
-
* The type of easing function.
|
|
96
|
-
* @defaultValue ease
|
|
97
|
-
*/
|
|
98
|
-
animationEasing?: AnimationTiming
|
|
99
|
-
/**
|
|
100
|
-
* Custom animation function for interpolating data items.
|
|
101
|
-
* When provided, this replaces the default animation interpolation.
|
|
102
|
-
*
|
|
103
|
-
* @since 3.9
|
|
104
|
-
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
105
|
-
*/
|
|
106
|
-
animationInterpolateFn?: AnimationInterpolateFn<RadarPoint, PolarLayout>
|
|
107
|
-
/**
|
|
108
|
-
* Strategy for matching previous items to next items during animation.
|
|
109
|
-
*
|
|
110
|
-
* - `matchByIndex` (default): match by array position with proportional stretching
|
|
111
|
-
* - `matchAppend`: match sequentially by index and treat newly appended items as new
|
|
112
|
-
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
113
|
-
* - Custom function `(item, index) => key`: match by the returned key
|
|
114
|
-
*
|
|
115
|
-
* @defaultValue index
|
|
116
|
-
*/
|
|
117
|
-
animationMatchBy?: AnimationMatchByProp<RadarPoint>
|
|
118
|
-
baseLinePoints?: RadarPoint[]
|
|
119
|
-
className?: string
|
|
120
|
-
connectNulls?: boolean
|
|
121
|
-
/**
|
|
122
|
-
* Renders a circle element at each data point. Options:
|
|
123
|
-
*
|
|
124
|
-
* - `false`: no dots are drawn;
|
|
125
|
-
* - `true`: renders the dots with default settings;
|
|
126
|
-
* - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
|
|
127
|
-
* - `Element`: the custom dot element;
|
|
128
|
-
* - `function`: a render function of the custom dot.
|
|
129
|
-
*
|
|
130
|
-
* @defaultValue false
|
|
131
|
-
*/
|
|
132
|
-
dot?: DotType
|
|
133
|
-
/**
|
|
134
|
-
* @defaultValue false
|
|
135
|
-
*/
|
|
136
|
-
hide?: boolean
|
|
137
|
-
/**
|
|
138
|
-
* If set false, animation of polygon will be disabled.
|
|
139
|
-
* If set "auto", animation is disabled during SSR and when the user prefers reduced motion.
|
|
140
|
-
* @defaultValue auto
|
|
141
|
-
*/
|
|
142
|
-
isAnimationActive?: boolean | "auto"
|
|
143
|
-
isRange?: boolean
|
|
144
|
-
/**
|
|
145
|
-
* Renders one label for each point. Options:
|
|
146
|
-
* - `true`: renders default labels;
|
|
147
|
-
* - `false`: no labels are rendered;
|
|
148
|
-
* - `object`: the props of LabelList component;
|
|
149
|
-
* - `Element`: a custom label element;
|
|
150
|
-
* - `function`: a render function of custom label.
|
|
151
|
-
*
|
|
152
|
-
* @defaultValue false
|
|
153
|
-
*/
|
|
154
|
-
label?: ImplicitLabelListType
|
|
155
|
-
/**
|
|
156
|
-
* The type of icon in legend. If set to 'none', no legend item will be rendered.
|
|
157
|
-
* @defaultValue rect
|
|
158
|
-
*/
|
|
159
|
-
legendType?: LegendType
|
|
160
|
-
/**
|
|
161
|
-
* The customized event handler of animation end
|
|
162
|
-
*/
|
|
163
|
-
onAnimationEnd?: () => void
|
|
164
|
-
/**
|
|
165
|
-
* The customized event handler of animation start
|
|
166
|
-
*/
|
|
167
|
-
onAnimationStart?: () => void
|
|
168
|
-
onMouseEnter?: (props: InternalRadarProps, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
169
|
-
onMouseLeave?: (props: InternalRadarProps, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
170
|
-
/**
|
|
171
|
-
* @defaultValue 0
|
|
172
|
-
*/
|
|
173
|
-
radiusAxisId?: string | number
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* If set a function, the function will be called to render customized shape.
|
|
177
|
-
*/
|
|
178
|
-
shape?: (props: Record<string, unknown>) => JSX.Element
|
|
179
|
-
/**
|
|
180
|
-
* The name of this graphical item, used in tooltip and legend.
|
|
181
|
-
*/
|
|
182
|
-
name?: string | number
|
|
183
|
-
tooltipType?: TooltipType
|
|
184
|
-
/**
|
|
185
|
-
* @defaultValue 100
|
|
186
|
-
*/
|
|
187
|
-
zIndex?: number
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export type RadiusAxisForRadar = { scale: RechartsScale }
|
|
191
|
-
export type AngleAxisForRadar = {
|
|
192
|
-
scale: RechartsScale
|
|
193
|
-
type: "number" | "category"
|
|
194
|
-
dataKey: DataKey<unknown> | undefined
|
|
195
|
-
cx: number
|
|
196
|
-
cy: number
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/* eslint-disable-next-line typescript-eslint/no-explicit-any -- upstream contract: untyped items accept any data */
|
|
200
|
-
export type Props<DataPointType = any, DataValueType = any> = WithoutRemoveFalse<
|
|
201
|
-
Omit<JSX.GSVGAttributes<SVGGraphicsElement>, "onMouseEnter" | "onMouseLeave" | "points" | "ref">
|
|
202
|
-
> &
|
|
203
|
-
CamelCaseSVGAttrs &
|
|
204
|
-
RadarProps<DataPointType, DataValueType>
|
|
205
|
-
|
|
206
|
-
export type RadarComposedData = {
|
|
207
|
-
points: RadarPoint[]
|
|
208
|
-
baseLinePoints: RadarPoint[]
|
|
209
|
-
isRange: boolean
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function getLegendItemColor(
|
|
213
|
-
stroke: string | undefined,
|
|
214
|
-
fill: string | undefined,
|
|
215
|
-
): string | undefined {
|
|
216
|
-
return stroke && stroke !== "none" ? stroke : fill
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/* eslint-disable solid/reactivity -- plain utility fn; Props parameter is not a Solid reactive proxy at this call site */
|
|
220
|
-
const computeLegendPayloadFromRadarSectors = (
|
|
221
|
-
props: PropsWithDefaults,
|
|
222
|
-
): ReadonlyArray<LegendPayload> => {
|
|
223
|
-
return [
|
|
224
|
-
{
|
|
225
|
-
color: getLegendItemColor(props.stroke, props.fill),
|
|
226
|
-
dataKey: props.dataKey,
|
|
227
|
-
inactive: props.hide,
|
|
228
|
-
payload: props,
|
|
229
|
-
type: props.legendType,
|
|
230
|
-
value: getTooltipNameProp(props.name, props.dataKey),
|
|
231
|
-
},
|
|
232
|
-
]
|
|
233
|
-
}
|
|
234
|
-
/* eslint-enable solid/reactivity */
|
|
235
|
-
|
|
236
|
-
function SetRadarTooltipEntrySettings(
|
|
237
|
-
props: Pick<
|
|
238
|
-
WithIdRequired<PropsWithDefaults>,
|
|
239
|
-
"dataKey" | "stroke" | "strokeWidth" | "fill" | "name" | "hide" | "tooltipType" | "id"
|
|
240
|
-
>,
|
|
241
|
-
): JSX.Element {
|
|
242
|
-
/* GOTCHA-005: createMemo so reactive props flow into the settings object. */
|
|
243
|
-
const tooltipEntrySettings = createMemo<TooltipPayloadConfiguration>(() => ({
|
|
244
|
-
/*
|
|
245
|
-
* I suppose this here _could_ return props.points
|
|
246
|
-
* because while Radar does not support item tooltip mode, it _could_ support it.
|
|
247
|
-
* But when I actually do return the points here, a defaultIndex test starts failing.
|
|
248
|
-
* So, undefined it is.
|
|
249
|
-
*/
|
|
250
|
-
dataDefinedOnItem: undefined,
|
|
251
|
-
getPosition: noop,
|
|
252
|
-
settings: {
|
|
253
|
-
color: getLegendItemColor(props.stroke, props.fill),
|
|
254
|
-
dataKey: props.dataKey,
|
|
255
|
-
fill: props.fill,
|
|
256
|
-
graphicalItemId: props.id,
|
|
257
|
-
hide: props.hide,
|
|
258
|
-
name: getTooltipNameProp(props.name, props.dataKey),
|
|
259
|
-
nameKey: undefined,
|
|
260
|
-
stroke: props.stroke,
|
|
261
|
-
strokeWidth: props.strokeWidth,
|
|
262
|
-
type: props.tooltipType,
|
|
263
|
-
unit: "",
|
|
264
|
-
},
|
|
265
|
-
}))
|
|
266
|
-
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings()} />
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function RadarDotsWrapper(props: {
|
|
270
|
-
points: ReadonlyArray<RadarPoint>
|
|
271
|
-
radarProps: PropsWithDefaults
|
|
272
|
-
}): JSX.Element {
|
|
273
|
-
const [, propsWithoutId] = splitProps(props.radarProps, ["id", "children"])
|
|
274
|
-
const baseProps = createMemo(() => svgPropertiesNoEvents(propsWithoutId))
|
|
275
|
-
|
|
276
|
-
return (
|
|
277
|
-
<Dots
|
|
278
|
-
points={props.points}
|
|
279
|
-
dot={props.radarProps.dot}
|
|
280
|
-
className="recharts-radar-dots"
|
|
281
|
-
dotClassName="recharts-radar-dot"
|
|
282
|
-
dataKey={props.radarProps.dataKey}
|
|
283
|
-
baseProps={baseProps()}
|
|
284
|
-
/>
|
|
285
|
-
)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function computeRadarPoints({
|
|
289
|
-
radiusAxis,
|
|
290
|
-
angleAxis,
|
|
291
|
-
displayedData,
|
|
292
|
-
dataKey,
|
|
293
|
-
bandSize,
|
|
294
|
-
}: {
|
|
295
|
-
radiusAxis: RadiusAxisForRadar
|
|
296
|
-
angleAxis: AngleAxisForRadar
|
|
297
|
-
displayedData: unknown[]
|
|
298
|
-
dataKey: RadarProps["dataKey"]
|
|
299
|
-
bandSize: number
|
|
300
|
-
}): RadarComposedData {
|
|
301
|
-
const { cx, cy } = angleAxis
|
|
302
|
-
let isRange = false
|
|
303
|
-
const points: RadarPoint[] = []
|
|
304
|
-
const angleBandSize = angleAxis.type !== "number" ? (bandSize ?? 0) : 0
|
|
305
|
-
|
|
306
|
-
displayedData.forEach((entry, i) => {
|
|
307
|
-
const name = getValueByDataKey(entry, angleAxis.dataKey, i)
|
|
308
|
-
const value = getValueByDataKey(entry, dataKey)
|
|
309
|
-
const angle: number = (angleAxis.scale.map(name) ?? 0) + angleBandSize
|
|
310
|
-
const pointValue = Array.isArray(value) ? last(value) : value
|
|
311
|
-
const radius: number = isNullish(pointValue) ? 0 : (radiusAxis.scale.map(pointValue) ?? 0)
|
|
312
|
-
|
|
313
|
-
if (Array.isArray(value) && value.length >= 2) {
|
|
314
|
-
isRange = true
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
points.push({
|
|
318
|
-
...polarToCartesian(cx, cy, radius, angle),
|
|
319
|
-
angle,
|
|
320
|
-
cx,
|
|
321
|
-
cy,
|
|
322
|
-
name,
|
|
323
|
-
payload: entry,
|
|
324
|
-
radius,
|
|
325
|
-
value: value as number | undefined,
|
|
326
|
-
})
|
|
327
|
-
})
|
|
328
|
-
const baseLinePoints: RadarPoint[] = []
|
|
329
|
-
|
|
330
|
-
if (isRange) {
|
|
331
|
-
points.forEach((point: RadarPoint) => {
|
|
332
|
-
if (Array.isArray(point.value)) {
|
|
333
|
-
const baseValue = point.value[0]
|
|
334
|
-
const radius: number = isNullish(baseValue) ? 0 : (radiusAxis.scale.map(baseValue) ?? 0)
|
|
335
|
-
|
|
336
|
-
baseLinePoints.push({
|
|
337
|
-
...point,
|
|
338
|
-
radius,
|
|
339
|
-
...polarToCartesian(cx, cy, radius, point.angle),
|
|
340
|
-
})
|
|
341
|
-
} else {
|
|
342
|
-
baseLinePoints.push(point)
|
|
343
|
-
}
|
|
344
|
-
})
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return { baseLinePoints, isRange, points }
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function RadarLabelListProvider(props: {
|
|
351
|
-
showLabels: boolean
|
|
352
|
-
points: ReadonlyArray<RadarPoint>
|
|
353
|
-
children: JSX.Element
|
|
354
|
-
}): JSX.Element {
|
|
355
|
-
const labelListEntries = createMemo((): ReadonlyArray<CartesianLabelListEntry> =>
|
|
356
|
-
props.points.map((point): CartesianLabelListEntry => {
|
|
357
|
-
const viewBox: TrapezoidViewBox = {
|
|
358
|
-
height: 0,
|
|
359
|
-
lowerWidth: 0,
|
|
360
|
-
upperWidth: 0,
|
|
361
|
-
width: 0,
|
|
362
|
-
x: point.x,
|
|
363
|
-
y: point.y,
|
|
364
|
-
}
|
|
365
|
-
return {
|
|
366
|
-
...viewBox,
|
|
367
|
-
fill: undefined,
|
|
368
|
-
parentViewBox: undefined,
|
|
369
|
-
payload: point.payload,
|
|
370
|
-
value: point.value ?? "",
|
|
371
|
-
viewBox,
|
|
372
|
-
}
|
|
373
|
-
}),
|
|
374
|
-
)
|
|
375
|
-
|
|
376
|
-
/* eslint-disable solid/reactivity -- Provider value reads labelListEntries() and props.showLabels inside JSX attribute; both are reactive */
|
|
377
|
-
return (
|
|
378
|
-
<CartesianLabelListContextProvider value={props.showLabels ? labelListEntries() : undefined}>
|
|
379
|
-
{props.children}
|
|
380
|
-
</CartesianLabelListContextProvider>
|
|
381
|
-
)
|
|
382
|
-
/* eslint-enable solid/reactivity */
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/* eslint-disable solid/reactivity -- props.points null check and props.radarProps.shape structural check are stable at mount; event handlers close over stable references */
|
|
386
|
-
function StaticPolygon(props: {
|
|
387
|
-
points: ReadonlyArray<RadarPoint>
|
|
388
|
-
baseLinePoints: ReadonlyArray<RadarPoint>
|
|
389
|
-
radarProps: InternalRadarProps
|
|
390
|
-
}): JSX.Element {
|
|
391
|
-
return <>{renderStaticPolygon(props)}</>
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* Runs inside StaticPolygon's JSX expression so every reactive read is tracked. */
|
|
395
|
-
function renderStaticPolygon(props: {
|
|
396
|
-
points: ReadonlyArray<RadarPoint>
|
|
397
|
-
baseLinePoints: ReadonlyArray<RadarPoint>
|
|
398
|
-
radarProps: InternalRadarProps
|
|
399
|
-
}): JSX.Element {
|
|
400
|
-
if (props.points == null) {
|
|
401
|
-
return null
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/* GOTCHA-016-C: dedupe across enter/over and leave/out events so user.hover doesn't double-fire. */
|
|
405
|
-
let entered = false
|
|
406
|
-
const handleMouseEnter = (e: MouseEvent & { currentTarget: SVGGraphicsElement }) => {
|
|
407
|
-
if (entered) return
|
|
408
|
-
entered = true
|
|
409
|
-
if (props.radarProps.onMouseEnter) {
|
|
410
|
-
props.radarProps.onMouseEnter(props.radarProps, e)
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const handleMouseLeave = (e: MouseEvent & { currentTarget: SVGGraphicsElement }) => {
|
|
415
|
-
if (!entered) return
|
|
416
|
-
entered = false
|
|
417
|
-
if (props.radarProps.onMouseLeave) {
|
|
418
|
-
props.radarProps.onMouseLeave(props.radarProps, e)
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
let radar: JSX.Element
|
|
423
|
-
if (typeof props.radarProps.shape === "function") {
|
|
424
|
-
radar = props.radarProps.shape({ ...props.radarProps, points: props.points })
|
|
425
|
-
} else {
|
|
426
|
-
radar = (
|
|
427
|
-
<Polygon
|
|
428
|
-
{...(svgPropertiesAndEvents(props.radarProps) as Record<string, unknown>)}
|
|
429
|
-
/* GOTCHA-016-C: mirror enter/leave on over/out; the user's own over/out still fire. */
|
|
430
|
-
onMouseEnter={handleMouseEnter}
|
|
431
|
-
onMouseOver={(e: MouseEvent & { currentTarget: SVGGraphicsElement }) => {
|
|
432
|
-
;(props.radarProps.onMouseOver as ((e: MouseEvent) => void) | undefined)?.(e)
|
|
433
|
-
handleMouseEnter(e)
|
|
434
|
-
}}
|
|
435
|
-
onMouseLeave={handleMouseLeave}
|
|
436
|
-
onMouseOut={(e: MouseEvent & { currentTarget: SVGGraphicsElement }) => {
|
|
437
|
-
;(props.radarProps.onMouseOut as ((e: MouseEvent) => void) | undefined)?.(e)
|
|
438
|
-
handleMouseLeave(e)
|
|
439
|
-
}}
|
|
440
|
-
points={props.points}
|
|
441
|
-
baseLinePoints={props.radarProps.isRange ? props.baseLinePoints : undefined}
|
|
442
|
-
connectNulls={props.radarProps.connectNulls}
|
|
443
|
-
/>
|
|
444
|
-
)
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/* points attr on <g> mirrors polygon coords — getAttribute("points") detects
|
|
448
|
-
reactivity in tests; SVG <g> doesn't spec points but jsdom/browsers return
|
|
449
|
-
unknown attrs. Solid's JSX transform tracks props.points read in attr position. */
|
|
450
|
-
const gProps = {
|
|
451
|
-
class: "recharts-radar-polygon",
|
|
452
|
-
get points() { return props.points.map((p) => `${p.x},${p.y}`).join(" ") },
|
|
453
|
-
} as JSX.GSVGAttributes<SVGGElement>
|
|
454
|
-
|
|
455
|
-
return (
|
|
456
|
-
<g {...gProps}>
|
|
457
|
-
{radar}
|
|
458
|
-
<RadarDotsWrapper radarProps={props.radarProps} points={props.points} />
|
|
459
|
-
</g>
|
|
460
|
-
)
|
|
461
|
-
}
|
|
462
|
-
/* eslint-enable solid/reactivity */
|
|
463
|
-
|
|
464
|
-
const defaultRadarAnimateItems: AnimationInterpolateFn<RadarPoint, PolarLayout> = (items, animationElapsedTime) => {
|
|
465
|
-
if (items == null) return []
|
|
466
|
-
if (animationElapsedTime === 1) {
|
|
467
|
-
return items.flatMap((item) => (item.status === "removed" ? [] : [item.next]))
|
|
468
|
-
}
|
|
469
|
-
return items.flatMap((item) => {
|
|
470
|
-
if (item.status === "removed") return []
|
|
471
|
-
if (item.status === "matched") {
|
|
472
|
-
return [
|
|
473
|
-
{
|
|
474
|
-
...item.next,
|
|
475
|
-
x: interpolate(item.prev.x, item.next.x, animationElapsedTime),
|
|
476
|
-
y: interpolate(item.prev.y, item.next.y, animationElapsedTime),
|
|
477
|
-
},
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
// added: animate from center
|
|
481
|
-
return [
|
|
482
|
-
{
|
|
483
|
-
...item.next,
|
|
484
|
-
x: interpolate(item.next.cx, item.next.x, animationElapsedTime),
|
|
485
|
-
y: interpolate(item.next.cy, item.next.y, animationElapsedTime),
|
|
486
|
-
},
|
|
487
|
-
]
|
|
488
|
-
})
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
function PolygonWithAnimation(props: {
|
|
492
|
-
radarProps: InternalRadarProps
|
|
493
|
-
previousPointsRef: { current: ReadonlyArray<RadarPoint> | undefined }
|
|
494
|
-
previousBaseLinePointsRef: { current: ReadonlyArray<RadarPoint> | undefined }
|
|
495
|
-
}): JSX.Element {
|
|
496
|
-
/* Upstream keys the baseline snapshot on the same input as the points
|
|
497
|
-
animation; a content-compared id over `points` flips exactly when the
|
|
498
|
-
AnimatedItems animation restarts. */
|
|
499
|
-
const baseLineAnimationId = useAnimationId(() => props.radarProps.points, "recharts-radar-baseline-")
|
|
500
|
-
const baseLineAnimationState = useAnimationStartSnapshot(
|
|
501
|
-
baseLineAnimationId,
|
|
502
|
-
/* eslint-disable-next-line solid/reactivity -- the ref box is a stable mutable container */
|
|
503
|
-
props.previousBaseLinePointsRef,
|
|
504
|
-
)
|
|
505
|
-
const baseLineAnimationItems = createMemo(() =>
|
|
506
|
-
matchAnimationItems(
|
|
507
|
-
baseLineAnimationState.frozenStartValue() ?? null,
|
|
508
|
-
props.radarProps.baseLinePoints,
|
|
509
|
-
props.radarProps.animationMatchBy,
|
|
510
|
-
),
|
|
511
|
-
)
|
|
512
|
-
|
|
513
|
-
const { isAnimating, handleAnimationStart, handleAnimationEnd } = useAnimationCallbacks(
|
|
514
|
-
() => props.radarProps.onAnimationStart,
|
|
515
|
-
() => props.radarProps.onAnimationEnd,
|
|
516
|
-
)
|
|
517
|
-
const layout = createMemo(() => usePolarChartLayout())
|
|
518
|
-
|
|
519
|
-
return (
|
|
520
|
-
<Show when={layout()}>
|
|
521
|
-
{(polarLayout) => (
|
|
522
|
-
<RadarLabelListProvider showLabels={!isAnimating()} points={props.radarProps.points}>
|
|
523
|
-
<AnimatedItems
|
|
524
|
-
animationInput={props.radarProps.points}
|
|
525
|
-
animationIdPrefix="recharts-radar-"
|
|
526
|
-
items={props.radarProps.points}
|
|
527
|
-
previousItemsRef={props.previousPointsRef}
|
|
528
|
-
isAnimationActive={props.radarProps.isAnimationActive}
|
|
529
|
-
animationBegin={props.radarProps.animationBegin}
|
|
530
|
-
animationDuration={props.radarProps.animationDuration}
|
|
531
|
-
animationEasing={props.radarProps.animationEasing}
|
|
532
|
-
onAnimationStart={handleAnimationStart}
|
|
533
|
-
onAnimationEnd={handleAnimationEnd}
|
|
534
|
-
animationInterpolateFn={props.radarProps.animationInterpolateFn}
|
|
535
|
-
animationMatchBy={props.radarProps.animationMatchBy}
|
|
536
|
-
layout={polarLayout()}
|
|
537
|
-
>
|
|
538
|
-
{(stepData, animationElapsedTime) => {
|
|
539
|
-
const stepBaseLinePoints = createMemo(() => {
|
|
540
|
-
const t = animationElapsedTime()
|
|
541
|
-
return t === 1
|
|
542
|
-
? props.radarProps.baseLinePoints
|
|
543
|
-
: props.radarProps.animationInterpolateFn(baseLineAnimationItems(), t, polarLayout())
|
|
544
|
-
})
|
|
545
|
-
createEffect(
|
|
546
|
-
() => ({ step: stepBaseLinePoints(), t: animationElapsedTime() }),
|
|
547
|
-
({ step, t }) => {
|
|
548
|
-
baseLineAnimationState.syncStepValue(step, t)
|
|
549
|
-
},
|
|
550
|
-
)
|
|
551
|
-
return (
|
|
552
|
-
<StaticPolygon
|
|
553
|
-
points={stepData()}
|
|
554
|
-
baseLinePoints={stepBaseLinePoints()}
|
|
555
|
-
radarProps={props.radarProps}
|
|
556
|
-
/>
|
|
557
|
-
)
|
|
558
|
-
}}
|
|
559
|
-
</AnimatedItems>
|
|
560
|
-
<LabelListFromLabelProp label={props.radarProps.label} />
|
|
561
|
-
{props.radarProps.children}
|
|
562
|
-
</RadarLabelListProvider>
|
|
563
|
-
)}
|
|
564
|
-
</Show>
|
|
565
|
-
)
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
function RenderPolygon(props: InternalRadarProps): JSX.Element {
|
|
569
|
-
const previousPointsRef: { current: ReadonlyArray<RadarPoint> | undefined } = { current: undefined }
|
|
570
|
-
const previousBaseLinePointsRef: { current: ReadonlyArray<RadarPoint> | undefined } = {
|
|
571
|
-
current: undefined,
|
|
572
|
-
}
|
|
573
|
-
return (
|
|
574
|
-
<PolygonWithAnimation
|
|
575
|
-
radarProps={props}
|
|
576
|
-
previousPointsRef={previousPointsRef}
|
|
577
|
-
previousBaseLinePointsRef={previousBaseLinePointsRef}
|
|
578
|
-
/>
|
|
579
|
-
)
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
export const defaultRadarProps = {
|
|
583
|
-
activeDot: true,
|
|
584
|
-
angleAxisId: 0,
|
|
585
|
-
animationBegin: 0,
|
|
586
|
-
animationDuration: 1500,
|
|
587
|
-
animationEasing: "ease",
|
|
588
|
-
animationInterpolateFn: defaultRadarAnimateItems,
|
|
589
|
-
animationMatchBy: matchByIndex,
|
|
590
|
-
dot: false,
|
|
591
|
-
hide: false,
|
|
592
|
-
isAnimationActive: "auto",
|
|
593
|
-
label: false,
|
|
594
|
-
legendType: "rect",
|
|
595
|
-
radiusAxisId: 0,
|
|
596
|
-
zIndex: DefaultZIndexes.area,
|
|
597
|
-
} as const satisfies Partial<Props>
|
|
598
|
-
|
|
599
|
-
type PropsWithDefaults = RequiresDefaultProps<Props, typeof defaultRadarProps>
|
|
600
|
-
|
|
601
|
-
export type InternalRadarProps = WithIdRequired<PropsWithDefaults> & RadarComposedData
|
|
602
|
-
|
|
603
|
-
function RadarWithState(props: InternalRadarProps): JSX.Element {
|
|
604
|
-
const layerClass = () => clsx("recharts-radar", props.className)
|
|
605
|
-
|
|
606
|
-
return (
|
|
607
|
-
<Show when={!props.hide}>
|
|
608
|
-
<ZIndexLayer zIndex={props.zIndex}>
|
|
609
|
-
<Layer class={layerClass()}>
|
|
610
|
-
<RenderPolygon {...props} />
|
|
611
|
-
</Layer>
|
|
612
|
-
<ActivePoints
|
|
613
|
-
points={props.points}
|
|
614
|
-
mainColor={getLegendItemColor(props.stroke, props.fill)}
|
|
615
|
-
itemDataKey={props.dataKey}
|
|
616
|
-
activeDot={props.activeDot}
|
|
617
|
-
/>
|
|
618
|
-
</ZIndexLayer>
|
|
619
|
-
</Show>
|
|
620
|
-
)
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
function RadarImpl(props: WithIdRequired<PropsWithDefaults>): JSX.Element {
|
|
624
|
-
const isPanorama = useIsPanorama()
|
|
625
|
-
const ctx = useChartStore()
|
|
626
|
-
const stateCtx = useContext(RechartsStateContext)
|
|
627
|
-
|
|
628
|
-
const radarPoints = createMemo(() => {
|
|
629
|
-
/* Read angle/radius/item settings from new chartState so mutations invalidate
|
|
630
|
-
this memo. When present, pass as overrides so selector chain recomputes
|
|
631
|
-
scale from override domain/type rather than legacy store values. */
|
|
632
|
-
const angleId = String(props.angleAxisId ?? 0)
|
|
633
|
-
const radiusId = String(props.radiusAxisId ?? 0)
|
|
634
|
-
const solidState = stateCtx?.state
|
|
635
|
-
const angleEntry = solidState?.polarAxes.angleAxis[angleId]
|
|
636
|
-
/* Spread to enumerate all fields — Solid only tracks accessed properties,
|
|
637
|
-
so spread forces subscriptions to every setting key on mutation. */
|
|
638
|
-
const solidAngle = angleEntry?.settings != null
|
|
639
|
-
? ({ ...angleEntry.settings } as AngleAxisSettings)
|
|
640
|
-
: undefined
|
|
641
|
-
const radiusEntry = solidState?.polarAxes.radiusAxis[radiusId]
|
|
642
|
-
const solidRadius = radiusEntry?.settings != null
|
|
643
|
-
? ({ ...radiusEntry.settings } as RadiusAxisSettings)
|
|
644
|
-
: undefined
|
|
645
|
-
void solidRadius
|
|
646
|
-
void solidState?.graphicalItems[props.id]
|
|
647
|
-
|
|
648
|
-
if (!ctx) {
|
|
649
|
-
return undefined
|
|
650
|
-
}
|
|
651
|
-
return selectRadarPoints(
|
|
652
|
-
ctx.store,
|
|
653
|
-
props.radiusAxisId,
|
|
654
|
-
props.angleAxisId,
|
|
655
|
-
isPanorama,
|
|
656
|
-
props.id,
|
|
657
|
-
solidAngle,
|
|
658
|
-
)
|
|
659
|
-
})
|
|
660
|
-
|
|
661
|
-
return (
|
|
662
|
-
<Show when={radarPoints()?.points != null && radarPoints()}>
|
|
663
|
-
{(rp) => (
|
|
664
|
-
<RadarWithState
|
|
665
|
-
{...props}
|
|
666
|
-
points={rp().points}
|
|
667
|
-
baseLinePoints={rp().baseLinePoints}
|
|
668
|
-
isRange={rp().isRange}
|
|
669
|
-
/>
|
|
670
|
-
)}
|
|
671
|
-
</Show>
|
|
672
|
-
)
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* @consumes PolarChartContext
|
|
677
|
-
* @provides LabelListContext
|
|
678
|
-
*/
|
|
679
|
-
function RadarFn(outsideProps: Props): JSX.Element {
|
|
680
|
-
/* GOTCHA-013: split children before mergeProps so RegisterGraphicalItemId scope
|
|
681
|
-
captures children. mergeProps over resolveDefaultProps (GOTCHA-005-C / 008-D):
|
|
682
|
-
resolveDefaultProps `{ ...realProps }` spread snapshots the props proxy, freezing
|
|
683
|
-
reactive props at first render — dataKey/data/etc never update on signal change.
|
|
684
|
-
mergeProps preserves the lazy proxy through the defaults layer. */
|
|
685
|
-
const [childrenProps, restProps] = splitProps(outsideProps, ["children"])
|
|
686
|
-
const props = mergeProps(defaultRadarProps, restProps) as PropsWithDefaults
|
|
687
|
-
return (
|
|
688
|
-
<RegisterGraphicalItemId id={props.id} type="radar">
|
|
689
|
-
{(id: string) => (
|
|
690
|
-
<LabelListContextBridge>
|
|
691
|
-
{(() => {
|
|
692
|
-
/* Memoize children inside Provider scope (GOTCHA-013). */
|
|
693
|
-
const memoizedChildren = createMemo(() => childrenProps.children)
|
|
694
|
-
return (
|
|
695
|
-
<>
|
|
696
|
-
<SetPolarGraphicalItem
|
|
697
|
-
type="radar"
|
|
698
|
-
id={id}
|
|
699
|
-
data={undefined}
|
|
700
|
-
dataKey={props.dataKey}
|
|
701
|
-
hide={props.hide}
|
|
702
|
-
angleAxisId={props.angleAxisId}
|
|
703
|
-
radiusAxisId={props.radiusAxisId}
|
|
704
|
-
/>
|
|
705
|
-
<SetPolarLegendPayload legendPayload={computeLegendPayloadFromRadarSectors(props)} />
|
|
706
|
-
<SetRadarTooltipEntrySettings
|
|
707
|
-
dataKey={props.dataKey}
|
|
708
|
-
stroke={props.stroke}
|
|
709
|
-
strokeWidth={props.strokeWidth}
|
|
710
|
-
fill={props.fill}
|
|
711
|
-
name={props.name}
|
|
712
|
-
hide={props.hide}
|
|
713
|
-
tooltipType={props.tooltipType}
|
|
714
|
-
id={id}
|
|
715
|
-
/>
|
|
716
|
-
<RadarImpl {...props} id={id}>
|
|
717
|
-
{memoizedChildren()}
|
|
718
|
-
</RadarImpl>
|
|
719
|
-
</>
|
|
720
|
-
)
|
|
721
|
-
})()}
|
|
722
|
-
</LabelListContextBridge>
|
|
723
|
-
)}
|
|
724
|
-
</RegisterGraphicalItemId>
|
|
725
|
-
)
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* Typed entry point: the generics constrain props at the call site, like upstream.
|
|
730
|
-
*/
|
|
731
|
-
/* eslint-disable-next-line typescript-eslint/no-explicit-any -- upstream contract: untyped usage accepts any data */
|
|
732
|
-
export const Radar = RadarFn as (<DataPointType = any, DataValueType = any>(
|
|
733
|
-
props: Props<DataPointType, DataValueType>,
|
|
734
|
-
) => JSX.Element) & { displayName?: string }
|