@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/RadialBar.tsx
DELETED
|
@@ -1,917 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle, sort-keys */
|
|
2
|
-
import type { Formatter } from "../component/DefaultTooltipContent"
|
|
3
|
-
import type { JSX } from '@solidjs/web';
|
|
4
|
-
import { CellsContextProvider, createCellsRegistry } from "../context/CellsContext"
|
|
5
|
-
import type { CellsRegistry } from "../context/CellsContext"
|
|
6
|
-
import { createHoverDedupe } from "../util/hoverDedupe"
|
|
7
|
-
import { createMemo, Show, useContext } from 'solid-js';
|
|
8
|
-
import { clsx } from "clsx"
|
|
9
|
-
|
|
10
|
-
import { Series } from "victory-vendor/d3-shape"
|
|
11
|
-
import { parseCornerRadius, RadialBarSector, RadialBarSectorProps } from "../util/RadialBarUtils"
|
|
12
|
-
import { Props as SectorProps } from "../shape/Sector"
|
|
13
|
-
import { Layer } from "../container/Layer"
|
|
14
|
-
import {
|
|
15
|
-
LabelListContextBridge,
|
|
16
|
-
ImplicitLabelListType,
|
|
17
|
-
LabelListFromLabelProp,
|
|
18
|
-
PolarLabelListContextProvider,
|
|
19
|
-
PolarLabelListEntry,
|
|
20
|
-
} from "../component/LabelList"
|
|
21
|
-
import { interpolate, mathSign, noop } from "../util/DataUtils"
|
|
22
|
-
import {
|
|
23
|
-
BarPositionPosition,
|
|
24
|
-
getCateCoordinateOfBar,
|
|
25
|
-
getNormalizedStackId,
|
|
26
|
-
getTooltipNameProp,
|
|
27
|
-
getValueByDataKey,
|
|
28
|
-
truncateByDomain,
|
|
29
|
-
} from "../util/ChartUtils"
|
|
30
|
-
import {
|
|
31
|
-
ActiveShape,
|
|
32
|
-
adaptEventsOfChild,
|
|
33
|
-
AnimationDuration,
|
|
34
|
-
AnimationTiming,
|
|
35
|
-
DataConsumer,
|
|
36
|
-
DataKey,
|
|
37
|
-
LayoutType,
|
|
38
|
-
LegendType,
|
|
39
|
-
PolarViewBoxRequired,
|
|
40
|
-
PresentationAttributesAdaptChildEvent,
|
|
41
|
-
TickItem,
|
|
42
|
-
TooltipType,
|
|
43
|
-
} from "../util/types"
|
|
44
|
-
import {
|
|
45
|
-
TooltipTriggerInfo,
|
|
46
|
-
useMouseClickItemDispatch,
|
|
47
|
-
useMouseEnterItemDispatch,
|
|
48
|
-
useMouseLeaveItemDispatch,
|
|
49
|
-
} from "../context/tooltipContext"
|
|
50
|
-
import { TooltipPayloadConfiguration } from "../state/tooltipSlice"
|
|
51
|
-
import { SetTooltipEntrySettings } from "../state/SetTooltipEntrySettings"
|
|
52
|
-
import { BaseAxisWithScale } from "../state/selectors/axisSelectors"
|
|
53
|
-
import { ChartData } from "../state/chartDataSlice"
|
|
54
|
-
import {
|
|
55
|
-
selectRadialBarLegendPayload,
|
|
56
|
-
selectRadialBarSectors,
|
|
57
|
-
} from "../state/selectors/radialBarSelectors"
|
|
58
|
-
import { useChartStore } from "../state/RechartsStoreContext"
|
|
59
|
-
import { RechartsStateContext } from "../state/RechartsStateContext"
|
|
60
|
-
import type { AngleAxisSettings, RadiusAxisSettings } from "../state/polarAxisSlice"
|
|
61
|
-
import { selectActiveTooltipIndex } from "../state/selectors/tooltipSelectors"
|
|
62
|
-
import { SetPolarLegendPayload } from "../state/SetLegendPayload"
|
|
63
|
-
import { AxisId } from "../state/cartesianAxisSlice"
|
|
64
|
-
import { RegisterGraphicalItemId } from "../context/RegisterGraphicalItemId"
|
|
65
|
-
import { RadialBarSettings } from "../state/types/RadialBarSettings"
|
|
66
|
-
import { SetPolarGraphicalItem } from "../state/SetGraphicalItem"
|
|
67
|
-
import {
|
|
68
|
-
svgPropertiesNoEvents,
|
|
69
|
-
svgPropertiesNoEventsFromUnknown,
|
|
70
|
-
} from "../util/svgPropertiesNoEvents"
|
|
71
|
-
import { AnimatedItems, useAnimationCallbacks } from "../animation/AnimatedItems"
|
|
72
|
-
import type { AnimationInterpolateFn } from "../animation/AnimatedItems"
|
|
73
|
-
import { matchAppend } from "../animation/matchBy"
|
|
74
|
-
import type { AnimationMatchByProp } from "../animation/matchBy"
|
|
75
|
-
import { usePolarChartLayout } from "../context/chartLayoutContext"
|
|
76
|
-
import type { PolarLayout, ShapeAnimationProps } from "../util/types"
|
|
77
|
-
import { RequiresDefaultProps, resolveDefaultProps } from "../util/resolveDefaultProps"
|
|
78
|
-
import { WithIdRequired } from "../util/useUniqueId"
|
|
79
|
-
import { ZIndexable, ZIndexLayer } from "../zIndex/ZIndexLayer"
|
|
80
|
-
import { DefaultZIndexes } from "../zIndex/DefaultZIndexes"
|
|
81
|
-
import { getZIndexFromUnknown } from "../zIndex/getZIndexFromUnknown"
|
|
82
|
-
|
|
83
|
-
import { mergeProps, splitProps } from '../util/solid-1-compat';
|
|
84
|
-
const STABLE_EMPTY_ARRAY: readonly RadialBarDataItem[] = []
|
|
85
|
-
|
|
86
|
-
export type RadialBarDataItem = SectorProps &
|
|
87
|
-
PolarViewBoxRequired &
|
|
88
|
-
TooltipTriggerInfo & {
|
|
89
|
-
value?: unknown
|
|
90
|
-
payload?: unknown
|
|
91
|
-
background?: SectorProps
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
type RadialBarBackground = boolean | (ActiveShape<SectorProps> & ZIndexable)
|
|
95
|
-
|
|
96
|
-
type RadialBarSectorsProps = ShapeAnimationProps & {
|
|
97
|
-
sectors: ReadonlyArray<RadialBarDataItem>
|
|
98
|
-
allOtherRadialBarProps: InternalProps
|
|
99
|
-
showLabels: boolean
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function RadialBarLabelListProvider(props: {
|
|
103
|
-
showLabels: boolean
|
|
104
|
-
sectors: ReadonlyArray<RadialBarDataItem>
|
|
105
|
-
children: JSX.Element
|
|
106
|
-
}): JSX.Element {
|
|
107
|
-
const labelListEntries = createMemo((): ReadonlyArray<PolarLabelListEntry> =>
|
|
108
|
-
props.sectors.map(
|
|
109
|
-
(sector: RadialBarDataItem): PolarLabelListEntry => ({
|
|
110
|
-
clockWise: false,
|
|
111
|
-
fill: sector.fill,
|
|
112
|
-
parentViewBox: undefined,
|
|
113
|
-
payload: sector.payload,
|
|
114
|
-
value: sector.value,
|
|
115
|
-
viewBox: {
|
|
116
|
-
clockWise: false,
|
|
117
|
-
cx: sector.cx,
|
|
118
|
-
cy: sector.cy,
|
|
119
|
-
endAngle: sector.endAngle,
|
|
120
|
-
innerRadius: sector.innerRadius,
|
|
121
|
-
outerRadius: sector.outerRadius,
|
|
122
|
-
startAngle: sector.startAngle,
|
|
123
|
-
},
|
|
124
|
-
}),
|
|
125
|
-
),
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
/* eslint-disable solid/reactivity -- showLabels and labelListEntries() in JSX; reactive via Solid's JSX transform */
|
|
129
|
-
return (
|
|
130
|
-
<PolarLabelListContextProvider value={props.showLabels ? labelListEntries() : undefined}>
|
|
131
|
-
{props.children}
|
|
132
|
-
</PolarLabelListContextProvider>
|
|
133
|
-
)
|
|
134
|
-
/* eslint-enable solid/reactivity */
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function RadialBarSectorsComponent(props: RadialBarSectorsProps): JSX.Element {
|
|
138
|
-
/* GOTCHA-016-C: one entry per pointer move across both event pairs, shared by all items. */
|
|
139
|
-
const hover = createHoverDedupe()
|
|
140
|
-
const [local, others] = splitProps(props.allOtherRadialBarProps, [
|
|
141
|
-
"shape",
|
|
142
|
-
"activeShape",
|
|
143
|
-
"cornerRadius",
|
|
144
|
-
"id",
|
|
145
|
-
"children",
|
|
146
|
-
])
|
|
147
|
-
const id = local.id
|
|
148
|
-
const baseProps = createMemo(() => svgPropertiesNoEvents(others))
|
|
149
|
-
const ctx = useChartStore()
|
|
150
|
-
|
|
151
|
-
const activeIndex = createMemo(() =>
|
|
152
|
-
ctx ? selectActiveTooltipIndex(ctx.store) : undefined,
|
|
153
|
-
)
|
|
154
|
-
/* GOTCHA-005-D: destructuring froze handlers at setup; rebuild restOfAllOtherProps
|
|
155
|
-
on each access and pass live accessors to event-dispatch hooks. */
|
|
156
|
-
const restOfAllOtherProps = (): Record<string, unknown> => {
|
|
157
|
-
const { onMouseEnter, onClick, onMouseLeave, ...rest } =
|
|
158
|
-
props.allOtherRadialBarProps as unknown as Record<string, unknown>
|
|
159
|
-
void onMouseEnter
|
|
160
|
-
void onClick
|
|
161
|
-
void onMouseLeave
|
|
162
|
-
return rest
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const onMouseEnterFromContext = useMouseEnterItemDispatch(
|
|
166
|
-
() => props.allOtherRadialBarProps.onMouseEnter,
|
|
167
|
-
() => props.allOtherRadialBarProps.dataKey,
|
|
168
|
-
id,
|
|
169
|
-
)
|
|
170
|
-
const onMouseLeaveFromContext = useMouseLeaveItemDispatch(
|
|
171
|
-
() => props.allOtherRadialBarProps.onMouseLeave,
|
|
172
|
-
)
|
|
173
|
-
const onClickFromContext = useMouseClickItemDispatch(
|
|
174
|
-
() => props.allOtherRadialBarProps.onClick,
|
|
175
|
-
() => props.allOtherRadialBarProps.dataKey,
|
|
176
|
-
id,
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
/* eslint-disable solid/prefer-for -- map() is required here; <For keyed={false}> loses reactivity for activeShape changes since entry is snapshotted per slot */
|
|
180
|
-
return (
|
|
181
|
-
<Show when={props.sectors != null}>
|
|
182
|
-
<RadialBarLabelListProvider showLabels={props.showLabels} sectors={props.sectors ?? []}>
|
|
183
|
-
{(props.sectors ?? []).map((entry: RadialBarDataItem, i: number) => {
|
|
184
|
-
const isActive: boolean = Boolean(local.activeShape && activeIndex() === String(i))
|
|
185
|
-
const onMouseEnter = onMouseEnterFromContext(entry, i)
|
|
186
|
-
const onMouseLeave = onMouseLeaveFromContext(entry, i)
|
|
187
|
-
const onClick = onClickFromContext(entry, i)
|
|
188
|
-
|
|
189
|
-
/* GOTCHA-016-C: bind both enter/leave AND over/out, dedupe per-instance so user.hover (fires both) only dispatches once. */
|
|
190
|
-
const fireEnter = (e: MouseEvent) => {
|
|
191
|
-
if (!hover.enter(e)) return
|
|
192
|
-
onMouseEnter(e as MouseEvent & { currentTarget: SVGGraphicsElement })
|
|
193
|
-
}
|
|
194
|
-
const fireLeave = (e: MouseEvent) => {
|
|
195
|
-
if (!hover.leave(e)) return
|
|
196
|
-
onMouseLeave(e as MouseEvent & { currentTarget: SVGGraphicsElement })
|
|
197
|
-
}
|
|
198
|
-
const radialBarSectorProps: RadialBarSectorProps = {
|
|
199
|
-
...baseProps(),
|
|
200
|
-
cornerRadius: parseCornerRadius(local.cornerRadius),
|
|
201
|
-
...entry,
|
|
202
|
-
...adaptEventsOfChild(restOfAllOtherProps(), entry, i),
|
|
203
|
-
onMouseEnter: fireEnter,
|
|
204
|
-
onMouseOver: fireEnter,
|
|
205
|
-
onMouseLeave: fireLeave,
|
|
206
|
-
onMouseOut: fireLeave,
|
|
207
|
-
onClick: (e: MouseEvent) => onClick(e as MouseEvent & { currentTarget: SVGGraphicsElement }),
|
|
208
|
-
className: `recharts-radial-bar-sector ${(entry as { className?: string }).className ?? ""}`.trim(),
|
|
209
|
-
forceCornerRadius: others.forceCornerRadius,
|
|
210
|
-
cornerIsExternal: others.cornerIsExternal,
|
|
211
|
-
isActive,
|
|
212
|
-
/* read lazily where Shape renders it (an element option mints a shape per read) */
|
|
213
|
-
get option() {
|
|
214
|
-
return isActive ? local.activeShape : local.shape
|
|
215
|
-
},
|
|
216
|
-
index: i,
|
|
217
|
-
animationElapsedTime: props.animationElapsedTime,
|
|
218
|
-
isAnimating: props.isAnimating,
|
|
219
|
-
isEntrance: props.isEntrance,
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (isActive) {
|
|
223
|
-
return (
|
|
224
|
-
<ZIndexLayer zIndex={DefaultZIndexes.activeBar}>
|
|
225
|
-
<RadialBarSector {...radialBarSectorProps} />
|
|
226
|
-
</ZIndexLayer>
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return <RadialBarSector {...radialBarSectorProps} />
|
|
231
|
-
})}
|
|
232
|
-
<LabelListFromLabelProp label={props.allOtherRadialBarProps.label} />
|
|
233
|
-
{local.children}
|
|
234
|
-
</RadialBarLabelListProvider>
|
|
235
|
-
</Show>
|
|
236
|
-
)
|
|
237
|
-
/* eslint-enable solid/prefer-for */
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const defaultRadialBarAnimateItems: AnimationInterpolateFn<RadialBarDataItem, PolarLayout> = (
|
|
241
|
-
items,
|
|
242
|
-
animationElapsedTime,
|
|
243
|
-
) => {
|
|
244
|
-
if (items == null) return []
|
|
245
|
-
if (animationElapsedTime === 1) {
|
|
246
|
-
return items.flatMap((item) => (item.status === "removed" ? [] : [item.next]))
|
|
247
|
-
}
|
|
248
|
-
return items.flatMap((item) => {
|
|
249
|
-
if (item.status === "removed") return []
|
|
250
|
-
if (item.status === "matched") {
|
|
251
|
-
return [
|
|
252
|
-
{
|
|
253
|
-
...item.next,
|
|
254
|
-
endAngle: interpolate(item.prev.endAngle, item.next.endAngle, animationElapsedTime),
|
|
255
|
-
startAngle: interpolate(item.prev.startAngle, item.next.startAngle, animationElapsedTime),
|
|
256
|
-
},
|
|
257
|
-
]
|
|
258
|
-
}
|
|
259
|
-
// added
|
|
260
|
-
return [
|
|
261
|
-
{
|
|
262
|
-
...item.next,
|
|
263
|
-
endAngle: interpolate(item.next.startAngle, item.next.endAngle, animationElapsedTime),
|
|
264
|
-
},
|
|
265
|
-
]
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function SectorsWithAnimation(props: {
|
|
270
|
-
radialBarProps: InternalProps
|
|
271
|
-
previousSectorsRef: { current: ReadonlyArray<RadialBarDataItem> | null }
|
|
272
|
-
}): JSX.Element {
|
|
273
|
-
const { isAnimating, handleAnimationStart, handleAnimationEnd } = useAnimationCallbacks(
|
|
274
|
-
() => props.radialBarProps.onAnimationStart,
|
|
275
|
-
() => props.radialBarProps.onAnimationEnd,
|
|
276
|
-
)
|
|
277
|
-
const layout = createMemo(() => usePolarChartLayout())
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<Show when={layout()}>
|
|
281
|
-
{(polarLayout) => (
|
|
282
|
-
<AnimatedItems
|
|
283
|
-
animationInput={props.radialBarProps.sectors}
|
|
284
|
-
animationIdPrefix="recharts-radialbar-"
|
|
285
|
-
items={props.radialBarProps.sectors}
|
|
286
|
-
previousItemsRef={props.previousSectorsRef}
|
|
287
|
-
isAnimationActive={props.radialBarProps.isAnimationActive}
|
|
288
|
-
animationBegin={props.radialBarProps.animationBegin}
|
|
289
|
-
animationDuration={props.radialBarProps.animationDuration}
|
|
290
|
-
animationEasing={props.radialBarProps.animationEasing}
|
|
291
|
-
onAnimationStart={handleAnimationStart}
|
|
292
|
-
onAnimationEnd={handleAnimationEnd}
|
|
293
|
-
animationInterpolateFn={props.radialBarProps.animationInterpolateFn}
|
|
294
|
-
animationMatchBy={props.radialBarProps.animationMatchBy}
|
|
295
|
-
layout={polarLayout()}
|
|
296
|
-
>
|
|
297
|
-
{(stepData, animationElapsedTime, isEntrance) => (
|
|
298
|
-
<RadialBarSectorsComponent
|
|
299
|
-
sectors={stepData()}
|
|
300
|
-
allOtherRadialBarProps={props.radialBarProps}
|
|
301
|
-
showLabels={!isAnimating()}
|
|
302
|
-
animationElapsedTime={animationElapsedTime()}
|
|
303
|
-
isAnimating={isAnimating() || animationElapsedTime() < 1}
|
|
304
|
-
isEntrance={isEntrance()}
|
|
305
|
-
/>
|
|
306
|
-
)}
|
|
307
|
-
</AnimatedItems>
|
|
308
|
-
)}
|
|
309
|
-
</Show>
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function RenderSectors(props: InternalProps): JSX.Element {
|
|
314
|
-
const previousSectorsRef: { current: ReadonlyArray<RadialBarDataItem> | null } = {
|
|
315
|
-
current: null,
|
|
316
|
-
}
|
|
317
|
-
return <SectorsWithAnimation radialBarProps={props} previousSectorsRef={previousSectorsRef} />
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
interface InternalRadialBarProps<DataPointType = unknown, DataValueType = unknown>
|
|
321
|
-
extends DataConsumer<DataPointType, DataValueType>, ZIndexable {
|
|
322
|
-
activeShape?: ActiveShape<RadialBarSectorProps, SVGPathElement>
|
|
323
|
-
/**
|
|
324
|
-
* @defaultValue 0
|
|
325
|
-
*/
|
|
326
|
-
angleAxisId?: AxisId
|
|
327
|
-
/**
|
|
328
|
-
* Specifies when the animation should begin, the unit of this option is ms.
|
|
329
|
-
* @defaultValue 0
|
|
330
|
-
*/
|
|
331
|
-
animationBegin?: number
|
|
332
|
-
/**
|
|
333
|
-
* Specifies the duration of animation, the unit of this option is ms.
|
|
334
|
-
* @defaultValue 1500
|
|
335
|
-
*/
|
|
336
|
-
animationDuration?: AnimationDuration
|
|
337
|
-
/**
|
|
338
|
-
* The type of easing function.
|
|
339
|
-
* @defaultValue ease
|
|
340
|
-
*/
|
|
341
|
-
animationEasing?: AnimationTiming
|
|
342
|
-
/**
|
|
343
|
-
* Custom animation function for interpolating data items.
|
|
344
|
-
* When provided, this replaces the default animation interpolation.
|
|
345
|
-
*
|
|
346
|
-
* @since 3.9
|
|
347
|
-
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
348
|
-
*/
|
|
349
|
-
animationInterpolateFn?: AnimationInterpolateFn<RadialBarDataItem, PolarLayout>
|
|
350
|
-
/**
|
|
351
|
-
* Strategy for matching previous items to next items during animation.
|
|
352
|
-
*
|
|
353
|
-
* - `matchAppend` (default): match sequentially by index and treat newly appended items as new
|
|
354
|
-
* - `matchByIndex`: match by array position with proportional stretching
|
|
355
|
-
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
356
|
-
* - Custom function `(item, index) => key`: match by the returned key
|
|
357
|
-
*
|
|
358
|
-
* @defaultValue append
|
|
359
|
-
*/
|
|
360
|
-
animationMatchBy?: AnimationMatchByProp<RadialBarDataItem>
|
|
361
|
-
/**
|
|
362
|
-
* Renders a background for each bar. Options:
|
|
363
|
-
* - `false`: no background;
|
|
364
|
-
* - `true`: renders default background;
|
|
365
|
-
* - `object`: the props of background rectangle;
|
|
366
|
-
* - `Element`: a custom background element;
|
|
367
|
-
* - `function`: a render function of custom background.
|
|
368
|
-
*
|
|
369
|
-
* @defaultValue false
|
|
370
|
-
*/
|
|
371
|
-
background?: RadialBarBackground
|
|
372
|
-
/**
|
|
373
|
-
* The width or height of each bar. If the barSize is not specified,
|
|
374
|
-
* the size of the bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
|
|
375
|
-
*/
|
|
376
|
-
barSize?: number
|
|
377
|
-
className?: string
|
|
378
|
-
/**
|
|
379
|
-
* @defaultValue false
|
|
380
|
-
*/
|
|
381
|
-
cornerIsExternal?: boolean
|
|
382
|
-
/**
|
|
383
|
-
* @defaultValue 0
|
|
384
|
-
*/
|
|
385
|
-
cornerRadius?: string | number
|
|
386
|
-
/**
|
|
387
|
-
* Calculated radial bar sectors
|
|
388
|
-
*/
|
|
389
|
-
sectors: ReadonlyArray<RadialBarDataItem>
|
|
390
|
-
/**
|
|
391
|
-
* @defaultValue false
|
|
392
|
-
*/
|
|
393
|
-
forceCornerRadius?: boolean
|
|
394
|
-
/**
|
|
395
|
-
* @defaultValue false
|
|
396
|
-
*/
|
|
397
|
-
hide?: boolean
|
|
398
|
-
/**
|
|
399
|
-
* If set false, animation of radial bars will be disabled.
|
|
400
|
-
* If set "auto", animation is disabled during SSR and when the user prefers reduced motion.
|
|
401
|
-
* @defaultValue auto
|
|
402
|
-
*/
|
|
403
|
-
isAnimationActive?: boolean | "auto"
|
|
404
|
-
/**
|
|
405
|
-
* Renders one label for each data point. Options:
|
|
406
|
-
* - `true`: renders default labels;
|
|
407
|
-
* - `false`: no labels are rendered;
|
|
408
|
-
* - `object`: the props of LabelList component;
|
|
409
|
-
* - `Element`: a custom label element;
|
|
410
|
-
* - `function`: a render function of custom label.
|
|
411
|
-
*
|
|
412
|
-
* @defaultValue false
|
|
413
|
-
*/
|
|
414
|
-
label?: ImplicitLabelListType
|
|
415
|
-
/**
|
|
416
|
-
* The type of icon in legend. If set to 'none', no legend item will be rendered.
|
|
417
|
-
* @defaultValue rect
|
|
418
|
-
*/
|
|
419
|
-
legendType?: LegendType
|
|
420
|
-
maxBarSize?: number
|
|
421
|
-
/**
|
|
422
|
-
* @defaultValue 0
|
|
423
|
-
*/
|
|
424
|
-
minPointSize?: number
|
|
425
|
-
/**
|
|
426
|
-
* The customized event handler of animation end
|
|
427
|
-
*/
|
|
428
|
-
onAnimationEnd?: () => void
|
|
429
|
-
/**
|
|
430
|
-
* The customized event handler of animation start
|
|
431
|
-
*/
|
|
432
|
-
onAnimationStart?: () => void
|
|
433
|
-
/**
|
|
434
|
-
* The customized event handler of click in this chart.
|
|
435
|
-
*/
|
|
436
|
-
onClick?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
437
|
-
/**
|
|
438
|
-
* The customized event handler of mousedown in this chart.
|
|
439
|
-
*/
|
|
440
|
-
onMouseDown?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
441
|
-
/**
|
|
442
|
-
* The customized event handler of mouseup in this chart.
|
|
443
|
-
*/
|
|
444
|
-
onMouseUp?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
445
|
-
/**
|
|
446
|
-
* The customized event handler of mousemove in this chart.
|
|
447
|
-
*/
|
|
448
|
-
onMouseMove?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
449
|
-
/**
|
|
450
|
-
* The customized event handler of mouseover in this chart.
|
|
451
|
-
*/
|
|
452
|
-
onMouseOver?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
453
|
-
/**
|
|
454
|
-
* The customized event handler of mouseout in this chart.
|
|
455
|
-
*/
|
|
456
|
-
onMouseOut?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
457
|
-
/**
|
|
458
|
-
* The customized event handler of mouseenter in this chart.
|
|
459
|
-
*/
|
|
460
|
-
onMouseEnter?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
461
|
-
/**
|
|
462
|
-
* The customized event handler of mouseleave in this chart.
|
|
463
|
-
*/
|
|
464
|
-
onMouseLeave?: (data: RadialBarDataItem, index: number, e: MouseEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
465
|
-
onTouchStart?: (data: RadialBarDataItem, index: number, e: TouchEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
466
|
-
onTouchMove?: (data: RadialBarDataItem, index: number, e: TouchEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
467
|
-
onTouchEnd?: (data: RadialBarDataItem, index: number, e: TouchEvent & { currentTarget: SVGGraphicsElement }) => void
|
|
468
|
-
/**
|
|
469
|
-
* @defaultValue 0
|
|
470
|
-
*/
|
|
471
|
-
radiusAxisId?: AxisId
|
|
472
|
-
/**
|
|
473
|
-
* The name of this graphical item, used in tooltip and legend.
|
|
474
|
-
*/
|
|
475
|
-
name?: string | number
|
|
476
|
-
shape?: ActiveShape<RadialBarSectorProps, SVGPathElement>
|
|
477
|
-
stackId?: string | number
|
|
478
|
-
tooltipType?: TooltipType
|
|
479
|
-
/**
|
|
480
|
-
* Formats the value displayed in the tooltip for this RadialBar.
|
|
481
|
-
* When set, takes precedence over the `formatter` prop on the Tooltip component.
|
|
482
|
-
*/
|
|
483
|
-
formatter?: Formatter
|
|
484
|
-
/**
|
|
485
|
-
* @defaultValue 300
|
|
486
|
-
*/
|
|
487
|
-
zIndex?: number
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/* eslint-disable-next-line typescript-eslint/no-explicit-any -- upstream contract: untyped items accept any data */
|
|
491
|
-
export type RadialBarProps<DataPointType = any, DataValueType = any> = Omit<
|
|
492
|
-
PresentationAttributesAdaptChildEvent<RadialBarDataItem, SVGElement>,
|
|
493
|
-
"ref" | keyof InternalRadialBarProps
|
|
494
|
-
> &
|
|
495
|
-
Omit<InternalRadialBarProps<DataPointType, DataValueType>, "sectors">
|
|
496
|
-
|
|
497
|
-
type InternalProps = WithIdRequired<PropsWithDefaults> & Pick<InternalRadialBarProps, "sectors">
|
|
498
|
-
|
|
499
|
-
function SetRadialBarPayloadLegend(props: RadialBarProps): JSX.Element {
|
|
500
|
-
const ctx = useChartStore()
|
|
501
|
-
const legendPayload = createMemo(() =>
|
|
502
|
-
ctx ? selectRadialBarLegendPayload(ctx.store, props.legendType) : undefined,
|
|
503
|
-
)
|
|
504
|
-
return <SetPolarLegendPayload legendPayload={legendPayload() ?? []} />
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function SetRadialBarTooltipEntrySettings(
|
|
508
|
-
props: Pick<
|
|
509
|
-
InternalProps,
|
|
510
|
-
| "dataKey"
|
|
511
|
-
| "sectors"
|
|
512
|
-
| "stroke"
|
|
513
|
-
| "stroke-width"
|
|
514
|
-
| "name"
|
|
515
|
-
| "hide"
|
|
516
|
-
| "fill"
|
|
517
|
-
| "tooltipType"
|
|
518
|
-
| "formatter"
|
|
519
|
-
| "id"
|
|
520
|
-
>,
|
|
521
|
-
): JSX.Element {
|
|
522
|
-
/* GOTCHA-005: object literal in component body runs once at setup. React's
|
|
523
|
-
upstream rebuilds it every render via PureComponent re-eval; here we must
|
|
524
|
-
memoize so `props.sectors` updates flow through to dataDefinedOnItem and
|
|
525
|
-
SetTooltipEntrySettings observes a new identity to refresh the store. */
|
|
526
|
-
const tooltipEntrySettings = createMemo(
|
|
527
|
-
(): TooltipPayloadConfiguration => ({
|
|
528
|
-
dataDefinedOnItem: props.sectors,
|
|
529
|
-
getPosition: noop,
|
|
530
|
-
settings: {
|
|
531
|
-
color: props.fill,
|
|
532
|
-
dataKey: props.dataKey,
|
|
533
|
-
fill: props.fill,
|
|
534
|
-
formatter: props.formatter,
|
|
535
|
-
graphicalItemId: props.id,
|
|
536
|
-
hide: props.hide,
|
|
537
|
-
name: getTooltipNameProp(props.name, props.dataKey),
|
|
538
|
-
nameKey: undefined,
|
|
539
|
-
stroke: props.stroke,
|
|
540
|
-
strokeWidth: props["stroke-width"],
|
|
541
|
-
type: props.tooltipType,
|
|
542
|
-
unit: "",
|
|
543
|
-
},
|
|
544
|
-
}),
|
|
545
|
-
)
|
|
546
|
-
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings()} />
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
function RadialBarWithState(props: InternalProps): JSX.Element {
|
|
550
|
-
const renderBackground = (sectors?: ReadonlyArray<RadialBarDataItem>): JSX.Element => {
|
|
551
|
-
if (sectors == null) {
|
|
552
|
-
return null
|
|
553
|
-
}
|
|
554
|
-
const backgroundSvgProps = svgPropertiesNoEventsFromUnknown(props.background)
|
|
555
|
-
/* eslint-disable solid/prefer-for -- map() preserves per-entry reactivity; <For keyed={false}> snapshots entry at slot creation */
|
|
556
|
-
return (
|
|
557
|
-
<ZIndexLayer zIndex={getZIndexFromUnknown(props.background, DefaultZIndexes.barBackground)}>
|
|
558
|
-
{sectors.map((entry, i) => {
|
|
559
|
-
const { value: _value, background, ...rest } = entry
|
|
560
|
-
|
|
561
|
-
if (!background) {
|
|
562
|
-
return null
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const bgProps: RadialBarSectorProps = {
|
|
566
|
-
cornerRadius: parseCornerRadius(props.cornerRadius),
|
|
567
|
-
...rest,
|
|
568
|
-
fill: "#eee",
|
|
569
|
-
...background,
|
|
570
|
-
...backgroundSvgProps,
|
|
571
|
-
...adaptEventsOfChild(props, entry, i),
|
|
572
|
-
index: i,
|
|
573
|
-
className: clsx(
|
|
574
|
-
"recharts-radial-bar-background-sector",
|
|
575
|
-
String(backgroundSvgProps?.className),
|
|
576
|
-
),
|
|
577
|
-
option: background,
|
|
578
|
-
isActive: false,
|
|
579
|
-
} as RadialBarSectorProps
|
|
580
|
-
|
|
581
|
-
return <RadialBarSector {...bgProps} />
|
|
582
|
-
})}
|
|
583
|
-
</ZIndexLayer>
|
|
584
|
-
)
|
|
585
|
-
/* eslint-enable solid/prefer-for */
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
return (
|
|
589
|
-
<Show when={!props.hide}>
|
|
590
|
-
<ZIndexLayer zIndex={props.zIndex}>
|
|
591
|
-
<Layer class={clsx("recharts-area", props.className)}>
|
|
592
|
-
<Show when={props.background}>
|
|
593
|
-
<Layer class="recharts-radial-bar-background">{renderBackground(props.sectors)}</Layer>
|
|
594
|
-
</Show>
|
|
595
|
-
<Layer class="recharts-radial-bar-sectors">
|
|
596
|
-
<RenderSectors {...props} />
|
|
597
|
-
</Layer>
|
|
598
|
-
</Layer>
|
|
599
|
-
</ZIndexLayer>
|
|
600
|
-
</Show>
|
|
601
|
-
)
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function RadialBarImpl(props: WithIdRequired<PropsWithDefaults> & { cellsRegistry: CellsRegistry }): JSX.Element {
|
|
605
|
-
const cells = createMemo((): ReadonlyArray<Record<string, unknown>> | undefined => {
|
|
606
|
-
const list = props.cellsRegistry.cells()
|
|
607
|
-
return list.length === 0 ? undefined : (list as unknown as ReadonlyArray<Record<string, unknown>>)
|
|
608
|
-
})
|
|
609
|
-
const ctx = useChartStore()
|
|
610
|
-
const stateCtx = useContext(RechartsStateContext)
|
|
611
|
-
|
|
612
|
-
const radialBarSettings = createMemo(
|
|
613
|
-
(): RadialBarSettings => ({
|
|
614
|
-
angleAxisId: props.angleAxisId,
|
|
615
|
-
barSize: props.barSize,
|
|
616
|
-
data: undefined,
|
|
617
|
-
dataKey: props.dataKey,
|
|
618
|
-
hide: false,
|
|
619
|
-
id: props.id,
|
|
620
|
-
maxBarSize: props.maxBarSize,
|
|
621
|
-
minPointSize: props.minPointSize,
|
|
622
|
-
radiusAxisId: props.radiusAxisId,
|
|
623
|
-
stackId: getNormalizedStackId(props.stackId),
|
|
624
|
-
type: "radialBar",
|
|
625
|
-
}),
|
|
626
|
-
)
|
|
627
|
-
const sectors = createMemo(
|
|
628
|
-
(): ReadonlyArray<RadialBarDataItem> => {
|
|
629
|
-
/* Read angle/radius/item from Solid chartState so mutations invalidate this
|
|
630
|
-
memo. Pass as overrides so selector recomputes scale from override domain. */
|
|
631
|
-
const angleId = String(props.angleAxisId ?? 0)
|
|
632
|
-
const radiusId = String(props.radiusAxisId ?? 0)
|
|
633
|
-
const solidState = stateCtx?.state
|
|
634
|
-
const angleEntry = solidState?.polarAxes.angleAxis[angleId]
|
|
635
|
-
/* perf: keep proxy reference rather than spreading — spread allocates a new
|
|
636
|
-
object every memo run and forces every field subscription at once.
|
|
637
|
-
Explicit void-reads subscribe only to the mutable fields we care about. */
|
|
638
|
-
const solidAngle = angleEntry?.settings as AngleAxisSettings | undefined
|
|
639
|
-
void solidAngle?.domain
|
|
640
|
-
void solidAngle?.type
|
|
641
|
-
void solidAngle?.scale
|
|
642
|
-
const radiusEntry = solidState?.polarAxes.radiusAxis[radiusId]
|
|
643
|
-
const solidRadius = radiusEntry?.settings as RadiusAxisSettings | undefined
|
|
644
|
-
void solidRadius?.domain
|
|
645
|
-
void solidRadius?.type
|
|
646
|
-
void solidRadius?.scale
|
|
647
|
-
const solidItem = solidState?.graphicalItems[props.id]
|
|
648
|
-
/* Read maxBarSize from item settings to track graphicalItems mutations. */
|
|
649
|
-
const itemMaxBarSize = solidItem?.type === "radialBar"
|
|
650
|
-
? (solidItem.settings as RadialBarSettings).maxBarSize
|
|
651
|
-
: undefined
|
|
652
|
-
void itemMaxBarSize
|
|
653
|
-
|
|
654
|
-
if (!ctx) {
|
|
655
|
-
return STABLE_EMPTY_ARRAY
|
|
656
|
-
}
|
|
657
|
-
const settings = itemMaxBarSize !== undefined
|
|
658
|
-
? { ...radialBarSettings(), maxBarSize: itemMaxBarSize }
|
|
659
|
-
: radialBarSettings()
|
|
660
|
-
const result = selectRadialBarSectors(
|
|
661
|
-
ctx.store,
|
|
662
|
-
props.radiusAxisId,
|
|
663
|
-
props.angleAxisId,
|
|
664
|
-
settings,
|
|
665
|
-
cells(),
|
|
666
|
-
solidRadius,
|
|
667
|
-
solidAngle,
|
|
668
|
-
) ?? STABLE_EMPTY_ARRAY
|
|
669
|
-
return result
|
|
670
|
-
},
|
|
671
|
-
)
|
|
672
|
-
/* mergeProps preserves the getter so RadialBarWithState reads sectors reactively
|
|
673
|
-
on every re-render — static sectors={sectors()} would snapshot at setup. */
|
|
674
|
-
const radialBarWithStateProps = mergeProps(props, { get sectors() { return sectors() } })
|
|
675
|
-
return (
|
|
676
|
-
<>
|
|
677
|
-
<SetRadialBarTooltipEntrySettings
|
|
678
|
-
dataKey={props.dataKey}
|
|
679
|
-
sectors={sectors()}
|
|
680
|
-
stroke={props.stroke}
|
|
681
|
-
stroke-width={props["stroke-width"]}
|
|
682
|
-
name={props.name}
|
|
683
|
-
hide={props.hide}
|
|
684
|
-
fill={props.fill}
|
|
685
|
-
tooltipType={props.tooltipType}
|
|
686
|
-
formatter={props.formatter}
|
|
687
|
-
id={props.id}
|
|
688
|
-
/>
|
|
689
|
-
<RadialBarWithState {...radialBarWithStateProps} />
|
|
690
|
-
</>
|
|
691
|
-
)
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
export const defaultRadialBarProps = {
|
|
695
|
-
angleAxisId: 0,
|
|
696
|
-
animationBegin: 0,
|
|
697
|
-
animationDuration: 1500,
|
|
698
|
-
animationEasing: "ease",
|
|
699
|
-
animationInterpolateFn: defaultRadialBarAnimateItems,
|
|
700
|
-
animationMatchBy: matchAppend,
|
|
701
|
-
background: false,
|
|
702
|
-
cornerIsExternal: false,
|
|
703
|
-
cornerRadius: 0,
|
|
704
|
-
forceCornerRadius: false,
|
|
705
|
-
hide: false,
|
|
706
|
-
isAnimationActive: "auto",
|
|
707
|
-
label: false,
|
|
708
|
-
legendType: "rect",
|
|
709
|
-
minPointSize: 0,
|
|
710
|
-
radiusAxisId: 0,
|
|
711
|
-
zIndex: DefaultZIndexes.bar,
|
|
712
|
-
} as const satisfies Partial<RadialBarProps>
|
|
713
|
-
|
|
714
|
-
type PropsWithDefaults = RequiresDefaultProps<RadialBarProps, typeof defaultRadialBarProps>
|
|
715
|
-
|
|
716
|
-
export function computeRadialBarDataItems({
|
|
717
|
-
displayedData,
|
|
718
|
-
stackedData,
|
|
719
|
-
dataStartIndex,
|
|
720
|
-
stackedDomain,
|
|
721
|
-
dataKey,
|
|
722
|
-
baseValue,
|
|
723
|
-
layout,
|
|
724
|
-
radiusAxis,
|
|
725
|
-
radiusAxisTicks,
|
|
726
|
-
bandSize,
|
|
727
|
-
pos,
|
|
728
|
-
angleAxis,
|
|
729
|
-
minPointSize,
|
|
730
|
-
cx,
|
|
731
|
-
cy,
|
|
732
|
-
angleAxisTicks,
|
|
733
|
-
cells,
|
|
734
|
-
startAngle: rootStartAngle,
|
|
735
|
-
endAngle: rootEndAngle,
|
|
736
|
-
}: {
|
|
737
|
-
displayedData: ChartData
|
|
738
|
-
stackedData:
|
|
739
|
-
| Series<Record<string, unknown>, string | number | ((obj: unknown) => unknown)>
|
|
740
|
-
| undefined
|
|
741
|
-
dataStartIndex: number
|
|
742
|
-
stackedDomain: ReadonlyArray<unknown> | null
|
|
743
|
-
dataKey: DataKey<unknown> | undefined
|
|
744
|
-
baseValue: number | unknown
|
|
745
|
-
layout: LayoutType
|
|
746
|
-
radiusAxis: BaseAxisWithScale
|
|
747
|
-
radiusAxisTicks: ReadonlyArray<TickItem> | undefined
|
|
748
|
-
bandSize: number
|
|
749
|
-
pos: BarPositionPosition
|
|
750
|
-
angleAxis: BaseAxisWithScale
|
|
751
|
-
minPointSize: number
|
|
752
|
-
cx: number
|
|
753
|
-
cy: number
|
|
754
|
-
angleAxisTicks: ReadonlyArray<TickItem> | undefined
|
|
755
|
-
cells: ReadonlyArray<JSX.Element> | undefined
|
|
756
|
-
startAngle: number
|
|
757
|
-
endAngle: number
|
|
758
|
-
}): ReadonlyArray<RadialBarDataItem> {
|
|
759
|
-
if (angleAxisTicks == null || radiusAxisTicks == null) {
|
|
760
|
-
return STABLE_EMPTY_ARRAY
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
return (displayedData ?? []).map((entry: unknown, index: number) => {
|
|
764
|
-
let value: unknown
|
|
765
|
-
let innerRadius: number | null | undefined
|
|
766
|
-
let outerRadius: number | undefined
|
|
767
|
-
let startAngle: number | null
|
|
768
|
-
let endAngle: number = 0
|
|
769
|
-
let backgroundSector: Record<string, unknown> | undefined
|
|
770
|
-
|
|
771
|
-
if (stackedData) {
|
|
772
|
-
const stackEntry = stackedData[dataStartIndex + index]
|
|
773
|
-
if (stackEntry != null) {
|
|
774
|
-
value = truncateByDomain(stackEntry, stackedDomain as number[])
|
|
775
|
-
}
|
|
776
|
-
} else {
|
|
777
|
-
value = getValueByDataKey(entry, dataKey)
|
|
778
|
-
if (!Array.isArray(value)) {
|
|
779
|
-
value = [baseValue, value]
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
if (layout === "radial") {
|
|
784
|
-
startAngle = angleAxis.scale.map((value as number[])[0]) ?? rootStartAngle
|
|
785
|
-
endAngle = angleAxis.scale.map((value as number[])[1]) ?? rootEndAngle
|
|
786
|
-
innerRadius = getCateCoordinateOfBar({
|
|
787
|
-
axis: radiusAxis,
|
|
788
|
-
bandSize,
|
|
789
|
-
entry,
|
|
790
|
-
index,
|
|
791
|
-
offset: pos.offset,
|
|
792
|
-
ticks: radiusAxisTicks,
|
|
793
|
-
})
|
|
794
|
-
if (innerRadius != null && endAngle != null && startAngle != null) {
|
|
795
|
-
outerRadius = innerRadius + pos.size
|
|
796
|
-
const deltaAngle = endAngle - startAngle
|
|
797
|
-
|
|
798
|
-
if (Math.abs(minPointSize) > 0 && Math.abs(deltaAngle) < Math.abs(minPointSize)) {
|
|
799
|
-
const delta =
|
|
800
|
-
mathSign(deltaAngle || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaAngle))
|
|
801
|
-
|
|
802
|
-
endAngle += delta
|
|
803
|
-
}
|
|
804
|
-
backgroundSector = {
|
|
805
|
-
background: {
|
|
806
|
-
cx,
|
|
807
|
-
cy,
|
|
808
|
-
endAngle: rootEndAngle,
|
|
809
|
-
innerRadius,
|
|
810
|
-
outerRadius,
|
|
811
|
-
startAngle: rootStartAngle,
|
|
812
|
-
},
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
} else {
|
|
816
|
-
innerRadius = radiusAxis.scale.map((value as number[])[0])
|
|
817
|
-
outerRadius = radiusAxis.scale.map((value as number[])[1])
|
|
818
|
-
startAngle = getCateCoordinateOfBar({
|
|
819
|
-
axis: angleAxis,
|
|
820
|
-
bandSize,
|
|
821
|
-
entry,
|
|
822
|
-
index,
|
|
823
|
-
offset: pos.offset,
|
|
824
|
-
ticks: angleAxisTicks,
|
|
825
|
-
})
|
|
826
|
-
if (innerRadius != null && outerRadius != null && startAngle != null) {
|
|
827
|
-
endAngle = startAngle + pos.size
|
|
828
|
-
const deltaRadius = outerRadius - innerRadius
|
|
829
|
-
|
|
830
|
-
if (Math.abs(minPointSize) > 0 && Math.abs(deltaRadius) < Math.abs(minPointSize)) {
|
|
831
|
-
const delta =
|
|
832
|
-
mathSign(deltaRadius || minPointSize) * (Math.abs(minPointSize) - Math.abs(deltaRadius))
|
|
833
|
-
outerRadius += delta
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
return Object.assign(
|
|
839
|
-
{},
|
|
840
|
-
entry as Record<string, unknown>,
|
|
841
|
-
backgroundSector,
|
|
842
|
-
{
|
|
843
|
-
cx,
|
|
844
|
-
cy,
|
|
845
|
-
endAngle,
|
|
846
|
-
innerRadius,
|
|
847
|
-
outerRadius,
|
|
848
|
-
payload: entry,
|
|
849
|
-
startAngle,
|
|
850
|
-
value: stackedData ? value : (value as number[])[1],
|
|
851
|
-
},
|
|
852
|
-
cells && cells[index] && (cells[index] as unknown as { props: Record<string, unknown> }).props,
|
|
853
|
-
) as RadialBarDataItem
|
|
854
|
-
})
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
* @consumes PolarChartContext
|
|
859
|
-
* @provides LabelListContext
|
|
860
|
-
* @provides CellReader
|
|
861
|
-
*/
|
|
862
|
-
function RadialBarFn(outsideProps: RadialBarProps): JSX.Element {
|
|
863
|
-
/* GOTCHA-013: split children before resolveDefaultProps. The spread enumerates
|
|
864
|
-
the props proxy and reads `children` eagerly, instantiating user JSX before
|
|
865
|
-
RegisterGraphicalItemId installs its Provider. */
|
|
866
|
-
const [childrenProps, restProps] = splitProps(outsideProps, ["children"])
|
|
867
|
-
const props: PropsWithDefaults = resolveDefaultProps(restProps, defaultRadialBarProps)
|
|
868
|
-
return (
|
|
869
|
-
<RegisterGraphicalItemId id={props.id} type="radialBar">
|
|
870
|
-
{(id: string) => (
|
|
871
|
-
<LabelListContextBridge>
|
|
872
|
-
{(() => {
|
|
873
|
-
/* <Cell/> children register here; upstream reads them with findAllByType. */
|
|
874
|
-
const cellsRegistry = createCellsRegistry()
|
|
875
|
-
return (
|
|
876
|
-
<CellsContextProvider value={cellsRegistry}>
|
|
877
|
-
{(() => {
|
|
878
|
-
/* Memoize children inside Provider scope (GOTCHA-013). */
|
|
879
|
-
const memoizedChildren = createMemo(() => childrenProps.children)
|
|
880
|
-
return (
|
|
881
|
-
<>
|
|
882
|
-
<SetPolarGraphicalItem
|
|
883
|
-
type="radialBar"
|
|
884
|
-
id={id}
|
|
885
|
-
data={undefined}
|
|
886
|
-
dataKey={props.dataKey}
|
|
887
|
-
hide={props.hide ?? defaultRadialBarProps.hide}
|
|
888
|
-
angleAxisId={props.angleAxisId ?? defaultRadialBarProps.angleAxisId}
|
|
889
|
-
radiusAxisId={props.radiusAxisId ?? defaultRadialBarProps.radiusAxisId}
|
|
890
|
-
stackId={getNormalizedStackId(props.stackId)}
|
|
891
|
-
barSize={props.barSize}
|
|
892
|
-
minPointSize={props.minPointSize}
|
|
893
|
-
maxBarSize={props.maxBarSize}
|
|
894
|
-
/>
|
|
895
|
-
<SetRadialBarPayloadLegend {...props} />
|
|
896
|
-
<RadialBarImpl {...props} id={id} cellsRegistry={cellsRegistry}>
|
|
897
|
-
{memoizedChildren()}
|
|
898
|
-
</RadialBarImpl>
|
|
899
|
-
</>
|
|
900
|
-
)
|
|
901
|
-
})()}
|
|
902
|
-
</CellsContextProvider>
|
|
903
|
-
)
|
|
904
|
-
})()}
|
|
905
|
-
</LabelListContextBridge>
|
|
906
|
-
)}
|
|
907
|
-
</RegisterGraphicalItemId>
|
|
908
|
-
)
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* Typed entry point: the generics constrain props at the call site, like upstream.
|
|
913
|
-
*/
|
|
914
|
-
/* eslint-disable-next-line typescript-eslint/no-explicit-any -- upstream contract: untyped usage accepts any data */
|
|
915
|
-
export const RadialBar = RadialBarFn as (<DataPointType = any, DataValueType = any>(
|
|
916
|
-
props: RadialBarProps<DataPointType, DataValueType>,
|
|
917
|
-
) => JSX.Element) & { displayName?: string }
|