@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
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import { computeLinePoints, type LinePointItem } from "../../cartesian/Line"
|
|
3
|
-
import type { ChartState } from "../store"
|
|
4
|
-
import type { AxisId, XAxisSettings, YAxisSettings } from "../cartesianAxisSlice"
|
|
5
|
-
import { selectChartDataWithIndexesIfNotInPanoramaPosition4 } from "./dataSelectors"
|
|
6
|
-
import { selectChartLayout } from "../../context/chartLayoutContext"
|
|
7
|
-
import {
|
|
8
|
-
selectAxisWithScale,
|
|
9
|
-
selectTicksOfGraphicalItem,
|
|
10
|
-
selectUnfilteredCartesianItems,
|
|
11
|
-
} from "./axisSelectors"
|
|
12
|
-
import { getBandSizeOfAxis, isCategoricalAxis } from "../../util/ChartUtils"
|
|
13
|
-
import type { ChartData } from "../chartDataSlice"
|
|
14
|
-
import type { CartesianGraphicalItemSettings, GraphicalItemId } from "../graphicalItemsSlice"
|
|
15
|
-
import { chartSelector } from "./chartSelector"
|
|
16
|
-
import type { LineSettings } from "../types/LineSettings"
|
|
17
|
-
|
|
18
|
-
/** Optional overrides — when supplied, bypass the axis-settings lookup on hot animation frames. */
|
|
19
|
-
export type LineAxisOverrides = {
|
|
20
|
-
xAxis?: XAxisSettings
|
|
21
|
-
yAxis?: YAxisSettings
|
|
22
|
-
lineSettings?: LineSettings
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const selectXAxisWithScale = chartSelector((
|
|
26
|
-
state: ChartState,
|
|
27
|
-
xAxisId: AxisId,
|
|
28
|
-
_yAxisId: AxisId,
|
|
29
|
-
isPanorama: boolean,
|
|
30
|
-
override?: XAxisSettings,
|
|
31
|
-
) => selectAxisWithScale(state, "xAxis", xAxisId, isPanorama, override))
|
|
32
|
-
|
|
33
|
-
const selectXAxisTicks = chartSelector((
|
|
34
|
-
state: ChartState,
|
|
35
|
-
xAxisId: AxisId,
|
|
36
|
-
_yAxisId: AxisId,
|
|
37
|
-
isPanorama: boolean,
|
|
38
|
-
) => selectTicksOfGraphicalItem(state, "xAxis", xAxisId, isPanorama))
|
|
39
|
-
|
|
40
|
-
const selectYAxisWithScale = chartSelector((
|
|
41
|
-
state: ChartState,
|
|
42
|
-
_xAxisId: AxisId,
|
|
43
|
-
yAxisId: AxisId,
|
|
44
|
-
isPanorama: boolean,
|
|
45
|
-
override?: YAxisSettings,
|
|
46
|
-
) => selectAxisWithScale(state, "yAxis", yAxisId, isPanorama, override))
|
|
47
|
-
|
|
48
|
-
const selectYAxisTicks = chartSelector((
|
|
49
|
-
state: ChartState,
|
|
50
|
-
_xAxisId: AxisId,
|
|
51
|
-
yAxisId: AxisId,
|
|
52
|
-
isPanorama: boolean,
|
|
53
|
-
) => selectTicksOfGraphicalItem(state, "yAxis", yAxisId, isPanorama))
|
|
54
|
-
|
|
55
|
-
const selectBandSize = chartSelector(function selectBandSize(state: ChartState, xAxisId: AxisId, yAxisId: AxisId, isPanorama: boolean, overrides?: LineAxisOverrides) {
|
|
56
|
-
const layout = selectChartLayout(state)
|
|
57
|
-
const xAxis = selectXAxisWithScale(state, xAxisId, yAxisId, isPanorama, overrides?.xAxis)
|
|
58
|
-
const yAxis = selectYAxisWithScale(state, xAxisId, yAxisId, isPanorama, overrides?.yAxis)
|
|
59
|
-
const xAxisTicks = selectXAxisTicks(state, xAxisId, yAxisId, isPanorama)
|
|
60
|
-
const yAxisTicks = selectYAxisTicks(state, xAxisId, yAxisId, isPanorama)
|
|
61
|
-
if (isCategoricalAxis(layout, "xAxis")) {
|
|
62
|
-
return getBandSizeOfAxis(xAxis, xAxisTicks, false)
|
|
63
|
-
}
|
|
64
|
-
return getBandSizeOfAxis(yAxis, yAxisTicks, false)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
function isLineSettings(item: CartesianGraphicalItemSettings): item is LineSettings {
|
|
68
|
-
return item.type === "line"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* There is a race condition problem because we read some data from props and some from the state.
|
|
73
|
-
* The state is updated through a dispatch and is one render behind,
|
|
74
|
-
* and so we have this weird one tick render where the displayedData in one selector have the old dataKey
|
|
75
|
-
* but the new dataKey in another selector.
|
|
76
|
-
*
|
|
77
|
-
* So here instead of reading the dataKey from the props, we always read it from the state.
|
|
78
|
-
*/
|
|
79
|
-
const selectSynchronisedLineSettings = chartSelector(function selectSynchronisedLineSettings(state: ChartState, _xAxisId: AxisId, _yAxisId: AxisId, _isPanorama: boolean, id: GraphicalItemId): LineSettings | undefined {
|
|
80
|
-
const graphicalItems = selectUnfilteredCartesianItems(state)
|
|
81
|
-
return graphicalItems.filter(isLineSettings).find((x) => x.id === id)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
export const selectLinePoints = chartSelector(function selectLinePoints(state: ChartState, xAxisId: AxisId, yAxisId: AxisId, isPanorama: boolean, id: GraphicalItemId, overrides?: LineAxisOverrides): ReadonlyArray<LinePointItem> | undefined {
|
|
85
|
-
const layout = selectChartLayout(state)
|
|
86
|
-
const xAxis = selectXAxisWithScale(state, xAxisId, yAxisId, isPanorama, overrides?.xAxis)
|
|
87
|
-
const yAxis = selectYAxisWithScale(state, xAxisId, yAxisId, isPanorama, overrides?.yAxis)
|
|
88
|
-
const xAxisTicks = selectXAxisTicks(state, xAxisId, yAxisId, isPanorama)
|
|
89
|
-
const yAxisTicks = selectYAxisTicks(state, xAxisId, yAxisId, isPanorama)
|
|
90
|
-
const lineSettings =
|
|
91
|
-
overrides?.lineSettings ??
|
|
92
|
-
selectSynchronisedLineSettings(state, xAxisId, yAxisId, isPanorama, id)
|
|
93
|
-
const bandSize = selectBandSize(state, xAxisId, yAxisId, isPanorama, overrides)
|
|
94
|
-
const { chartData, dataStartIndex, dataEndIndex } =
|
|
95
|
-
selectChartDataWithIndexesIfNotInPanoramaPosition4(state, undefined, undefined, isPanorama)
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
lineSettings == null ||
|
|
99
|
-
xAxis == null ||
|
|
100
|
-
yAxis == null ||
|
|
101
|
-
xAxisTicks == null ||
|
|
102
|
-
yAxisTicks == null ||
|
|
103
|
-
xAxisTicks.length === 0 ||
|
|
104
|
-
yAxisTicks.length === 0 ||
|
|
105
|
-
bandSize == null ||
|
|
106
|
-
(layout !== "horizontal" && layout !== "vertical")
|
|
107
|
-
) {
|
|
108
|
-
return undefined
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const { dataKey, data } = lineSettings
|
|
112
|
-
let displayedData: ChartData | undefined
|
|
113
|
-
|
|
114
|
-
if (data != null && data.length > 0) {
|
|
115
|
-
displayedData = data
|
|
116
|
-
} else {
|
|
117
|
-
displayedData = chartData?.slice(dataStartIndex, dataEndIndex + 1)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (displayedData == null) {
|
|
121
|
-
return undefined
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return computeLinePoints({
|
|
125
|
-
bandSize,
|
|
126
|
-
dataKey,
|
|
127
|
-
displayedData,
|
|
128
|
-
layout,
|
|
129
|
-
xAxis,
|
|
130
|
-
xAxisTicks,
|
|
131
|
-
yAxis,
|
|
132
|
-
yAxisTicks,
|
|
133
|
-
})
|
|
134
|
-
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NumberDomain } from "../../util/types"
|
|
2
|
-
|
|
3
|
-
export const numberDomainEqualityCheck = (
|
|
4
|
-
a: NumberDomain | undefined,
|
|
5
|
-
b: NumberDomain | undefined,
|
|
6
|
-
): boolean => {
|
|
7
|
-
if (a === b) {
|
|
8
|
-
return true
|
|
9
|
-
}
|
|
10
|
-
if (a == null || b == null) {
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
return a[0] === b[0] && a[1] === b[1]
|
|
14
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { computePieSectors, type PieSectorDataItem } from "../../polar/Pie"
|
|
4
|
-
import type { ChartState } from "../store"
|
|
5
|
-
import { selectChartDataAndAlwaysIgnoreIndexes } from "./dataSelectors"
|
|
6
|
-
import type { ChartData, ChartDataState } from "../chartDataSlice"
|
|
7
|
-
import type { ChartOffsetInternal } from "../../util/types"
|
|
8
|
-
import { selectChartOffsetInternal } from "./selectChartOffsetInternal"
|
|
9
|
-
import type { LegendPayload } from "../../component/DefaultLegendContent"
|
|
10
|
-
import { getTooltipNameProp, getValueByDataKey } from "../../util/ChartUtils"
|
|
11
|
-
import { selectUnfilteredPolarItems } from "./polarSelectors"
|
|
12
|
-
import type { PieSettings } from "../types/PieSettings"
|
|
13
|
-
import { chartSelector } from "./chartSelector"
|
|
14
|
-
import type { GraphicalItemId } from "../graphicalItemsSlice"
|
|
15
|
-
|
|
16
|
-
const selectSynchronisedPieSettings = chartSelector(function selectSynchronisedPieSettings(state: ChartState, id: GraphicalItemId): PieSettings | undefined {
|
|
17
|
-
const graphicalItems = selectUnfilteredPolarItems(state)
|
|
18
|
-
return graphicalItems.filter((item) => item.type === "pie").find((item) => item.id === id) as
|
|
19
|
-
| PieSettings
|
|
20
|
-
| undefined
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const emptyArray: ReadonlyArray<Record<string, unknown>> = []
|
|
24
|
-
|
|
25
|
-
export const selectDisplayedData = chartSelector(function selectDisplayedData(state: ChartState, id: GraphicalItemId, cells: ReadonlyArray<Record<string, unknown>> | undefined, pieSettingsOverride?: PieSettings): ChartData | undefined {
|
|
26
|
-
const { chartData }: ChartDataState = selectChartDataAndAlwaysIgnoreIndexes(state)
|
|
27
|
-
const pieSettings = pieSettingsOverride ?? selectSynchronisedPieSettings(state, id)
|
|
28
|
-
const safeCells = cells?.length === 0 ? emptyArray : cells
|
|
29
|
-
|
|
30
|
-
if (pieSettings == null) {
|
|
31
|
-
return undefined
|
|
32
|
-
}
|
|
33
|
-
let displayedData: ChartData | undefined
|
|
34
|
-
if (pieSettings?.data != null && pieSettings.data.length > 0) {
|
|
35
|
-
displayedData = pieSettings.data
|
|
36
|
-
} else {
|
|
37
|
-
displayedData = chartData
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if ((!displayedData || !displayedData.length) && safeCells != null) {
|
|
41
|
-
/* registered cells are `{ props }` records, like upstream's Cell elements */
|
|
42
|
-
displayedData = safeCells.map((cell: Record<string, unknown>) =>
|
|
43
|
-
Object.assign({}, pieSettings.presentationProps, (cell as { props?: Record<string, unknown> }).props ?? cell),
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (displayedData == null) {
|
|
48
|
-
return undefined
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return displayedData
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
export const selectPieLegend = chartSelector(function selectPieLegend(state: ChartState, id: GraphicalItemId, cells: ReadonlyArray<Record<string, unknown>> | undefined): ReadonlyArray<LegendPayload> | undefined {
|
|
55
|
-
const displayedData = selectDisplayedData(state, id, cells)
|
|
56
|
-
const pieSettings = selectSynchronisedPieSettings(state, id)
|
|
57
|
-
const safeCells = cells?.length === 0 ? emptyArray : cells
|
|
58
|
-
|
|
59
|
-
if (displayedData == null || pieSettings == null) {
|
|
60
|
-
return undefined
|
|
61
|
-
}
|
|
62
|
-
return displayedData.map((entry, i): LegendPayload => {
|
|
63
|
-
const name = getValueByDataKey(entry, pieSettings.nameKey, pieSettings.name)
|
|
64
|
-
let color: string | undefined
|
|
65
|
-
const cellEntry = safeCells?.[i]
|
|
66
|
-
if (cellEntry != null && typeof cellEntry.fill === "string") {
|
|
67
|
-
color = cellEntry.fill
|
|
68
|
-
} else if (typeof entry === "object" && entry != null && "fill" in entry) {
|
|
69
|
-
color = (entry as Record<string, unknown>).fill as string
|
|
70
|
-
} else {
|
|
71
|
-
color = pieSettings.fill
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
color,
|
|
75
|
-
dataKey: pieSettings.dataKey,
|
|
76
|
-
payload: entry as Record<string, unknown>,
|
|
77
|
-
type: pieSettings.legendType,
|
|
78
|
-
value: getTooltipNameProp(name, pieSettings.dataKey),
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
export const selectPieSectors = chartSelector(function selectPieSectors(state: ChartState, id: GraphicalItemId, cells: ReadonlyArray<Record<string, unknown>> | undefined, pieSettingsOverride?: PieSettings): ReadonlyArray<PieSectorDataItem> | undefined {
|
|
84
|
-
const pieSettings = pieSettingsOverride ?? selectSynchronisedPieSettings(state, id)
|
|
85
|
-
const displayedData = selectDisplayedData(state, id, cells, pieSettings)
|
|
86
|
-
const offset: ChartOffsetInternal = selectChartOffsetInternal(state)
|
|
87
|
-
|
|
88
|
-
if (pieSettings == null || displayedData == null) {
|
|
89
|
-
return undefined
|
|
90
|
-
}
|
|
91
|
-
return computePieSectors({
|
|
92
|
-
cells: (cells?.length === 0 ? emptyArray : cells) as ReadonlyArray<JSX.Element> | undefined,
|
|
93
|
-
displayedData,
|
|
94
|
-
offset,
|
|
95
|
-
pieSettings,
|
|
96
|
-
})
|
|
97
|
-
})
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { ChartState } from "../store"
|
|
3
|
-
import type { AxisId } from "../cartesianAxisSlice"
|
|
4
|
-
import type { AngleAxisSettings, RadiusAxisSettings } from "../polarAxisSlice"
|
|
5
|
-
import type { PolarChartOptions } from "../polarOptionsSlice"
|
|
6
|
-
import { selectChartHeight, selectChartWidth } from "./containerSelectors"
|
|
7
|
-
import { selectChartOffsetInternal } from "./selectChartOffsetInternal"
|
|
8
|
-
import { getMaxRadius } from "../../util/PolarUtils"
|
|
9
|
-
import { getPercentValue } from "../../util/DataUtils"
|
|
10
|
-
import type { AxisDomainTypeInput, LayoutType, PolarViewBoxRequired } from "../../util/types"
|
|
11
|
-
import { defaultPolarAngleAxisProps } from "../../polar/defaultPolarAngleAxisProps"
|
|
12
|
-
import { defaultPolarRadiusAxisProps } from "../../polar/defaultPolarRadiusAxisProps"
|
|
13
|
-
import type { AxisRange } from "./axisSelectors"
|
|
14
|
-
import { combineAxisRangeWithReverse } from "./combiners/combineAxisRangeWithReverse"
|
|
15
|
-
import { selectChartLayout, selectPolarChartLayout } from "../../context/chartLayoutContext"
|
|
16
|
-
import { getAxisTypeBasedOnLayout } from "../../util/getAxisTypeBasedOnLayout"
|
|
17
|
-
import { chartSelector } from "./chartSelector"
|
|
18
|
-
import { readChartState } from "../chartState"
|
|
19
|
-
|
|
20
|
-
export const implicitAngleAxis: Omit<AngleAxisSettings, "type"> & { type: AxisDomainTypeInput } = {
|
|
21
|
-
allowDataOverflow: defaultPolarAngleAxisProps.allowDataOverflow,
|
|
22
|
-
allowDecimals: defaultPolarAngleAxisProps.allowDecimals,
|
|
23
|
-
allowDuplicatedCategory: false,
|
|
24
|
-
dataKey: undefined,
|
|
25
|
-
domain: undefined,
|
|
26
|
-
id: defaultPolarAngleAxisProps.angleAxisId,
|
|
27
|
-
includeHidden: false,
|
|
28
|
-
name: undefined,
|
|
29
|
-
niceTicks: defaultPolarAngleAxisProps.niceTicks,
|
|
30
|
-
reversed: defaultPolarAngleAxisProps.reversed,
|
|
31
|
-
scale: defaultPolarAngleAxisProps.scale,
|
|
32
|
-
tick: defaultPolarAngleAxisProps.tick,
|
|
33
|
-
tickCount: undefined,
|
|
34
|
-
ticks: undefined,
|
|
35
|
-
type: defaultPolarAngleAxisProps.type,
|
|
36
|
-
unit: undefined,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const implicitRadiusAxis: Omit<RadiusAxisSettings, "type"> & { type: AxisDomainTypeInput } =
|
|
40
|
-
{
|
|
41
|
-
allowDataOverflow: defaultPolarRadiusAxisProps.allowDataOverflow,
|
|
42
|
-
allowDecimals: defaultPolarRadiusAxisProps.allowDecimals,
|
|
43
|
-
allowDuplicatedCategory: defaultPolarRadiusAxisProps.allowDuplicatedCategory,
|
|
44
|
-
dataKey: undefined,
|
|
45
|
-
domain: undefined,
|
|
46
|
-
id: defaultPolarRadiusAxisProps.radiusAxisId,
|
|
47
|
-
includeHidden: defaultPolarRadiusAxisProps.includeHidden,
|
|
48
|
-
name: undefined,
|
|
49
|
-
niceTicks: defaultPolarRadiusAxisProps.niceTicks,
|
|
50
|
-
reversed: defaultPolarRadiusAxisProps.reversed,
|
|
51
|
-
scale: defaultPolarRadiusAxisProps.scale,
|
|
52
|
-
tick: defaultPolarRadiusAxisProps.tick,
|
|
53
|
-
tickCount: defaultPolarRadiusAxisProps.tickCount,
|
|
54
|
-
ticks: undefined,
|
|
55
|
-
type: defaultPolarRadiusAxisProps.type,
|
|
56
|
-
unit: undefined,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const selectAngleAxisNoDefaults = chartSelector((
|
|
60
|
-
state: ChartState,
|
|
61
|
-
angleAxisId: AxisId | undefined,
|
|
62
|
-
): AngleAxisSettings | undefined => {
|
|
63
|
-
if (angleAxisId == null) {
|
|
64
|
-
return undefined
|
|
65
|
-
}
|
|
66
|
-
return readChartState(state).polarAxes.angleAxis?.[String(angleAxisId)]?.settings
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
export const selectAngleAxis = chartSelector(function selectAngleAxis(state: ChartState, angleAxisId: AxisId | undefined, override?: AngleAxisSettings): AngleAxisSettings {
|
|
70
|
-
if (override != null) {
|
|
71
|
-
return override
|
|
72
|
-
}
|
|
73
|
-
const angleAxisSettings = selectAngleAxisNoDefaults(state, angleAxisId)
|
|
74
|
-
const layout = selectPolarChartLayout(state)
|
|
75
|
-
if (angleAxisSettings != null) {
|
|
76
|
-
return angleAxisSettings
|
|
77
|
-
}
|
|
78
|
-
const evaluatedType =
|
|
79
|
-
getAxisTypeBasedOnLayout(layout, "angleAxis", implicitAngleAxis.type) ?? "category"
|
|
80
|
-
return {
|
|
81
|
-
...implicitAngleAxis,
|
|
82
|
-
type: evaluatedType,
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const selectRadiusAxisNoDefaults = chartSelector((
|
|
87
|
-
state: ChartState,
|
|
88
|
-
radiusAxisId: AxisId,
|
|
89
|
-
): RadiusAxisSettings | undefined => {
|
|
90
|
-
return readChartState(state).polarAxes.radiusAxis?.[String(radiusAxisId)]?.settings
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
export const selectRadiusAxis = chartSelector(function selectRadiusAxis(state: ChartState, radiusAxisId: AxisId, override?: RadiusAxisSettings): RadiusAxisSettings {
|
|
94
|
-
if (override != null) {
|
|
95
|
-
return override
|
|
96
|
-
}
|
|
97
|
-
const radiusAxisSettings = selectRadiusAxisNoDefaults(state, radiusAxisId)
|
|
98
|
-
const layout = selectPolarChartLayout(state)
|
|
99
|
-
if (radiusAxisSettings != null) {
|
|
100
|
-
return radiusAxisSettings
|
|
101
|
-
}
|
|
102
|
-
const evaluatedType =
|
|
103
|
-
getAxisTypeBasedOnLayout(layout, "radiusAxis", implicitRadiusAxis.type) ?? "category"
|
|
104
|
-
return {
|
|
105
|
-
...implicitRadiusAxis,
|
|
106
|
-
type: evaluatedType,
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
export const selectPolarOptions = (state: ChartState): PolarChartOptions | null =>
|
|
111
|
-
state.polarOptions
|
|
112
|
-
|
|
113
|
-
export const selectMaxRadius = chartSelector(function selectMaxRadius(state: ChartState): number {
|
|
114
|
-
return getMaxRadius(
|
|
115
|
-
selectChartWidth(state),
|
|
116
|
-
selectChartHeight(state),
|
|
117
|
-
selectChartOffsetInternal(state),
|
|
118
|
-
)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
const selectInnerRadius = chartSelector(function selectInnerRadius(state: ChartState): number | undefined {
|
|
122
|
-
const polarChartOptions = selectPolarOptions(state)
|
|
123
|
-
const maxRadius = selectMaxRadius(state)
|
|
124
|
-
if (polarChartOptions == null) {
|
|
125
|
-
return undefined
|
|
126
|
-
}
|
|
127
|
-
return getPercentValue(polarChartOptions.innerRadius, maxRadius, 0)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
export const selectOuterRadius = chartSelector(function selectOuterRadius(state: ChartState): number | undefined {
|
|
131
|
-
const polarChartOptions = selectPolarOptions(state)
|
|
132
|
-
const maxRadius = selectMaxRadius(state)
|
|
133
|
-
if (polarChartOptions == null) {
|
|
134
|
-
return undefined
|
|
135
|
-
}
|
|
136
|
-
return getPercentValue(polarChartOptions.outerRadius, maxRadius, maxRadius * 0.8)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const combineAngleAxisRange = (polarOptions: PolarChartOptions | null): AxisRange => {
|
|
140
|
-
if (polarOptions == null) {
|
|
141
|
-
return [0, 0]
|
|
142
|
-
}
|
|
143
|
-
const { startAngle, endAngle } = polarOptions
|
|
144
|
-
return [startAngle, endAngle]
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export const selectAngleAxisRange = chartSelector(function selectAngleAxisRange(state: ChartState): AxisRange {
|
|
148
|
-
return combineAngleAxisRange(selectPolarOptions(state))
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
export const selectAngleAxisRangeWithReversed = chartSelector(function selectAngleAxisRangeWithReversed(state: ChartState, angleAxisId: AxisId): AxisRange | undefined {
|
|
152
|
-
return combineAxisRangeWithReverse(
|
|
153
|
-
selectAngleAxis(state, angleAxisId),
|
|
154
|
-
selectAngleAxisRange(state),
|
|
155
|
-
)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
export const selectRadiusAxisRange = chartSelector(function selectRadiusAxisRange(state: ChartState, _radiusAxisId: AxisId): AxisRange | undefined {
|
|
159
|
-
const maxRadius = selectMaxRadius(state)
|
|
160
|
-
const innerRadius = selectInnerRadius(state)
|
|
161
|
-
const outerRadius = selectOuterRadius(state)
|
|
162
|
-
if (maxRadius == null || innerRadius == null || outerRadius == null) {
|
|
163
|
-
return undefined
|
|
164
|
-
}
|
|
165
|
-
return [innerRadius, outerRadius]
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
export const selectRadiusAxisRangeWithReversed = chartSelector(function selectRadiusAxisRangeWithReversed(state: ChartState, radiusAxisId: AxisId): AxisRange | undefined {
|
|
169
|
-
return combineAxisRangeWithReverse(
|
|
170
|
-
selectRadiusAxis(state, radiusAxisId),
|
|
171
|
-
selectRadiusAxisRange(state, radiusAxisId),
|
|
172
|
-
)
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
export const selectPolarViewBox: (state: ChartState) => PolarViewBoxRequired | undefined = chartSelector(function selectPolarViewBox(state: ChartState): PolarViewBoxRequired | undefined {
|
|
176
|
-
const layout: LayoutType = selectChartLayout(state)
|
|
177
|
-
const polarOptions = selectPolarOptions(state)
|
|
178
|
-
const innerRadius = selectInnerRadius(state)
|
|
179
|
-
const outerRadius = selectOuterRadius(state)
|
|
180
|
-
const width = selectChartWidth(state)
|
|
181
|
-
const height = selectChartHeight(state)
|
|
182
|
-
|
|
183
|
-
if (
|
|
184
|
-
(layout !== "centric" && layout !== "radial") ||
|
|
185
|
-
polarOptions == null ||
|
|
186
|
-
innerRadius == null ||
|
|
187
|
-
outerRadius == null
|
|
188
|
-
) {
|
|
189
|
-
return undefined
|
|
190
|
-
}
|
|
191
|
-
const { cx, cy, startAngle, endAngle } = polarOptions
|
|
192
|
-
return {
|
|
193
|
-
clockWise: false,
|
|
194
|
-
cx: getPercentValue(cx, width, width / 2),
|
|
195
|
-
cy: getPercentValue(cy, height, height / 2),
|
|
196
|
-
endAngle,
|
|
197
|
-
innerRadius,
|
|
198
|
-
outerRadius,
|
|
199
|
-
startAngle,
|
|
200
|
-
}
|
|
201
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import { ChartState } from "../store"
|
|
3
|
-
import { AxisId } from "../cartesianAxisSlice"
|
|
4
|
-
import { chartSelector } from "./chartSelector"
|
|
5
|
-
import { selectPolarAxisTicks } from "./polarScaleSelectors"
|
|
6
|
-
|
|
7
|
-
export type PolarAngles = Array<number>
|
|
8
|
-
|
|
9
|
-
export type PolarRadius = Array<number>
|
|
10
|
-
|
|
11
|
-
/* reselect's createSelector short-circuits on input-reference equality, which
|
|
12
|
-
breaks Solid's fine-grained tracking (GOTCHA-003). chartSelector memoizes per
|
|
13
|
-
chart instead, and each memo tracks its own proxy reads. */
|
|
14
|
-
export const selectPolarGridAngles = chartSelector(function selectPolarGridAngles(state: ChartState, angleAxisId: AxisId): PolarAngles | undefined {
|
|
15
|
-
const ticks = selectPolarAxisTicks(state, "angleAxis", angleAxisId, false)
|
|
16
|
-
if (!ticks) {
|
|
17
|
-
return undefined
|
|
18
|
-
}
|
|
19
|
-
return ticks.map((tick) => tick.coordinate)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export const selectPolarGridRadii = chartSelector(function selectPolarGridRadii(state: ChartState, radiusAxisId: AxisId): PolarRadius | undefined {
|
|
23
|
-
const ticks = selectPolarAxisTicks(state, "radiusAxis", radiusAxisId, false)
|
|
24
|
-
if (!ticks) {
|
|
25
|
-
return undefined
|
|
26
|
-
}
|
|
27
|
-
return ticks.map((tick) => tick.coordinate)
|
|
28
|
-
})
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { ChartState } from "../store"
|
|
3
|
-
import type { AxisId } from "../cartesianAxisSlice"
|
|
4
|
-
import {
|
|
5
|
-
combineAxisTicks,
|
|
6
|
-
combineCategoricalDomain,
|
|
7
|
-
combineGraphicalItemTicks,
|
|
8
|
-
selectDuplicateDomain,
|
|
9
|
-
selectRealScaleType,
|
|
10
|
-
selectRenderableAxisSettings,
|
|
11
|
-
} from "./axisSelectors"
|
|
12
|
-
import {
|
|
13
|
-
selectAngleAxis,
|
|
14
|
-
selectAngleAxisRangeWithReversed,
|
|
15
|
-
selectRadiusAxis,
|
|
16
|
-
selectRadiusAxisRangeWithReversed,
|
|
17
|
-
} from "./polarAxisSelectors"
|
|
18
|
-
import type { CartesianTickItem } from "../../util/types"
|
|
19
|
-
import { selectChartLayout } from "../../context/chartLayoutContext"
|
|
20
|
-
import {
|
|
21
|
-
selectPolarAppliedValues,
|
|
22
|
-
selectPolarAxisCheckedDomain,
|
|
23
|
-
selectPolarNiceTicks,
|
|
24
|
-
} from "./polarSelectors"
|
|
25
|
-
import { type RechartsScale, rechartsScaleFactory } from "../../util/scale/RechartsScale"
|
|
26
|
-
import type { CustomScaleDefinition } from "../../util/scale/CustomScaleDefinition"
|
|
27
|
-
import { chartSelector } from "./chartSelector"
|
|
28
|
-
import { combineConfiguredScale } from "./combiners/combineConfiguredScale"
|
|
29
|
-
|
|
30
|
-
export const selectPolarAxis = chartSelector((
|
|
31
|
-
state: ChartState,
|
|
32
|
-
axisType: "angleAxis" | "radiusAxis",
|
|
33
|
-
axisId: AxisId,
|
|
34
|
-
) => {
|
|
35
|
-
switch (axisType) {
|
|
36
|
-
case "angleAxis": {
|
|
37
|
-
return selectAngleAxis(state, axisId)
|
|
38
|
-
}
|
|
39
|
-
case "radiusAxis": {
|
|
40
|
-
return selectRadiusAxis(state, axisId)
|
|
41
|
-
}
|
|
42
|
-
default: {
|
|
43
|
-
throw new Error(`Unexpected axis type: ${axisType}`)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const selectPolarAxisRangeWithReversed = chartSelector((
|
|
49
|
-
state: ChartState,
|
|
50
|
-
axisType: "angleAxis" | "radiusAxis",
|
|
51
|
-
axisId: AxisId,
|
|
52
|
-
) => {
|
|
53
|
-
switch (axisType) {
|
|
54
|
-
case "angleAxis": {
|
|
55
|
-
return selectAngleAxisRangeWithReversed(state, axisId)
|
|
56
|
-
}
|
|
57
|
-
case "radiusAxis": {
|
|
58
|
-
return selectRadiusAxisRangeWithReversed(state, axisId)
|
|
59
|
-
}
|
|
60
|
-
default: {
|
|
61
|
-
throw new Error(`Unexpected axis type: ${axisType}`)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const selectPolarConfiguredScale = chartSelector(function selectPolarConfiguredScale(state: ChartState, axisType: "angleAxis" | "radiusAxis", polarAxisId: AxisId): CustomScaleDefinition | undefined {
|
|
67
|
-
return combineConfiguredScale(
|
|
68
|
-
selectPolarAxis(state, axisType, polarAxisId),
|
|
69
|
-
selectRealScaleType(state, axisType, polarAxisId),
|
|
70
|
-
selectPolarAxisCheckedDomain(state, axisType, polarAxisId),
|
|
71
|
-
selectPolarAxisRangeWithReversed(state, axisType, polarAxisId),
|
|
72
|
-
)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
export const selectPolarAxisScale = chartSelector(function selectPolarAxisScale(state: ChartState, axisType: "angleAxis" | "radiusAxis", polarAxisId: AxisId): RechartsScale | undefined {
|
|
76
|
-
return rechartsScaleFactory(selectPolarConfiguredScale(state, axisType, polarAxisId))
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
export const selectPolarCategoricalDomain = chartSelector(function selectPolarCategoricalDomain(state: ChartState, axisType: "angleAxis" | "radiusAxis", polarAxisId: AxisId): ReadonlyArray<unknown> | undefined {
|
|
80
|
-
return combineCategoricalDomain(
|
|
81
|
-
selectChartLayout(state),
|
|
82
|
-
selectPolarAppliedValues(state, axisType, polarAxisId),
|
|
83
|
-
selectRenderableAxisSettings(state, axisType, polarAxisId),
|
|
84
|
-
axisType,
|
|
85
|
-
)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
export const selectPolarAxisTicks = chartSelector(function selectPolarAxisTicks(state: ChartState, axisType: "angleAxis" | "radiusAxis", polarAxisId: AxisId, isPanorama: boolean): ReadonlyArray<CartesianTickItem> | undefined {
|
|
89
|
-
return combineAxisTicks(
|
|
90
|
-
selectChartLayout(state),
|
|
91
|
-
selectPolarAxis(state, axisType, polarAxisId),
|
|
92
|
-
selectRealScaleType(state, axisType, polarAxisId),
|
|
93
|
-
selectPolarAxisScale(state, axisType, polarAxisId),
|
|
94
|
-
selectPolarNiceTicks(state, axisType, polarAxisId),
|
|
95
|
-
selectPolarAxisRangeWithReversed(state, axisType, polarAxisId),
|
|
96
|
-
selectDuplicateDomain(state, axisType, polarAxisId, isPanorama),
|
|
97
|
-
selectPolarCategoricalDomain(state, axisType, polarAxisId),
|
|
98
|
-
axisType,
|
|
99
|
-
)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
export const selectPolarAngleAxisTicks = chartSelector(function selectPolarAngleAxisTicks(state: ChartState, axisType: "angleAxis", polarAxisId: AxisId, isPanorama: boolean): ReadonlyArray<CartesianTickItem> | undefined {
|
|
103
|
-
const ticks = selectPolarAxisTicks(state, axisType, polarAxisId, isPanorama)
|
|
104
|
-
/*
|
|
105
|
-
* Angle axis is circular; so here we need to look for ticks that overlap (i.e., 0 and 360 degrees)
|
|
106
|
-
* and remove the duplicate tick to avoid rendering issues.
|
|
107
|
-
*/
|
|
108
|
-
if (!ticks) {
|
|
109
|
-
return undefined
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const uniqueTicksMap = new Map<number, CartesianTickItem>()
|
|
113
|
-
ticks.forEach((tick) => {
|
|
114
|
-
const normalizedCoordinate = (tick.coordinate + 360) % 360
|
|
115
|
-
if (!uniqueTicksMap.has(normalizedCoordinate)) {
|
|
116
|
-
uniqueTicksMap.set(normalizedCoordinate, tick)
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
return Array.from(uniqueTicksMap.values())
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
export const selectPolarGraphicalItemAxisTicks = chartSelector(function selectPolarGraphicalItemAxisTicks(state: ChartState, axisType: "angleAxis" | "radiusAxis", polarAxisId: AxisId, isPanorama: boolean): ReadonlyArray<CartesianTickItem> | undefined {
|
|
124
|
-
return combineGraphicalItemTicks(
|
|
125
|
-
selectChartLayout(state),
|
|
126
|
-
selectPolarAxis(state, axisType, polarAxisId),
|
|
127
|
-
selectPolarAxisScale(state, axisType, polarAxisId),
|
|
128
|
-
selectPolarAxisRangeWithReversed(state, axisType, polarAxisId),
|
|
129
|
-
selectDuplicateDomain(state, axisType, polarAxisId, isPanorama),
|
|
130
|
-
selectPolarCategoricalDomain(state, axisType, polarAxisId),
|
|
131
|
-
axisType,
|
|
132
|
-
)
|
|
133
|
-
})
|