@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/util/Constants.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export const COLOR_PANEL = [
|
|
2
|
-
"#1890FF",
|
|
3
|
-
"#66B5FF",
|
|
4
|
-
"#41D9C7",
|
|
5
|
-
"#2FC25B",
|
|
6
|
-
"#6EDB8F",
|
|
7
|
-
"#9AE65C",
|
|
8
|
-
"#FACC14",
|
|
9
|
-
"#E6965C",
|
|
10
|
-
"#57AD71",
|
|
11
|
-
"#223273",
|
|
12
|
-
"#738AE6",
|
|
13
|
-
"#7564CC",
|
|
14
|
-
"#8543E0",
|
|
15
|
-
"#A877ED",
|
|
16
|
-
"#5C8EE6",
|
|
17
|
-
"#13C2C2",
|
|
18
|
-
"#70E0E0",
|
|
19
|
-
"#5CA3E6",
|
|
20
|
-
"#3436C7",
|
|
21
|
-
"#8082FF",
|
|
22
|
-
"#DD81E6",
|
|
23
|
-
"#F04864",
|
|
24
|
-
"#FA7D92",
|
|
25
|
-
"#D598D9",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* We use this attribute to identify which element is the one that the user is touching.
|
|
30
|
-
* The index is the position of the element in the data array.
|
|
31
|
-
* This can be either a number (for array-based charts) or a string (for the charts that have a matrix-shaped data).
|
|
32
|
-
*/
|
|
33
|
-
export const DATA_ITEM_INDEX_ATTRIBUTE_NAME = "data-recharts-item-index"
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* We use this attribute to identify which element is the one that the user is touching.
|
|
37
|
-
* Unlike dataKey, or name, it is always unique.
|
|
38
|
-
*/
|
|
39
|
-
export const DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME = "data-recharts-item-id"
|
|
40
|
-
|
|
41
|
-
export const DEFAULT_Y_AXIS_WIDTH = 60
|
|
42
|
-
export const DEFAULT_X_AXIS_HEIGHT = 30
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const PREFIX_LIST = ["Webkit", "Moz", "O", "ms"]
|
|
2
|
-
|
|
3
|
-
export const generatePrefixStyle = (name: string, value: string) => {
|
|
4
|
-
if (!name) {
|
|
5
|
-
return undefined
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const camelName = name.replace(/(\w)/, (v) => v.toUpperCase())
|
|
9
|
-
const result: Record<string, string> = PREFIX_LIST.reduce(
|
|
10
|
-
(res: Record<string, string>, entry) => {
|
|
11
|
-
res[entry + camelName] = value
|
|
12
|
-
return res
|
|
13
|
-
},
|
|
14
|
-
{},
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
result[name] = value
|
|
18
|
-
|
|
19
|
-
return result
|
|
20
|
-
}
|
package/src/util/DOMUtils.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { Global } from "./Global"
|
|
4
|
-
import { Size } from "./types"
|
|
5
|
-
import { LRUCache } from "./LRUCache"
|
|
6
|
-
|
|
7
|
-
export interface TextMeasurementConfig {
|
|
8
|
-
/** Maximum number of items to cache */
|
|
9
|
-
cacheSize: number
|
|
10
|
-
/** Whether to enable caching */
|
|
11
|
-
enableCache: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const defaultConfig: TextMeasurementConfig = {
|
|
15
|
-
cacheSize: 2000,
|
|
16
|
-
enableCache: true,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let currentConfig = { ...defaultConfig }
|
|
20
|
-
|
|
21
|
-
let stringCache = new LRUCache<string, Size>(currentConfig.cacheSize)
|
|
22
|
-
const SPAN_STYLE = {
|
|
23
|
-
border: "none",
|
|
24
|
-
left: 0,
|
|
25
|
-
margin: 0,
|
|
26
|
-
padding: 0,
|
|
27
|
-
position: "absolute",
|
|
28
|
-
top: "-20000px",
|
|
29
|
-
whiteSpace: "pre",
|
|
30
|
-
}
|
|
31
|
-
const MEASUREMENT_SPAN_ID = "recharts_measurement_span"
|
|
32
|
-
|
|
33
|
-
function createCacheKey(text: string | number, style: JSX.CSSProperties): string {
|
|
34
|
-
const fontSize = style["font-size"] || ""
|
|
35
|
-
const fontFamily = style["font-family"] || ""
|
|
36
|
-
const fontWeight = style["font-weight"] || ""
|
|
37
|
-
const fontStyle = style["font-style"] || ""
|
|
38
|
-
const letterSpacing = style["letter-spacing"] || ""
|
|
39
|
-
const textTransform = style["text-transform"] || ""
|
|
40
|
-
|
|
41
|
-
return `${text}|${fontSize}|${fontFamily}|${fontWeight}|${fontStyle}|${letterSpacing}|${textTransform}`
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Measure text using DOM (accurate but slower)
|
|
46
|
-
* @param text - The text to measure
|
|
47
|
-
* @param style - CSS style properties to apply
|
|
48
|
-
* @returns The size of the text
|
|
49
|
-
*/
|
|
50
|
-
const measureTextWithDOM = (text: string | number, style: JSX.CSSProperties): Size => {
|
|
51
|
-
try {
|
|
52
|
-
let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID)
|
|
53
|
-
if (!measurementSpan) {
|
|
54
|
-
measurementSpan = document.createElement("span")
|
|
55
|
-
measurementSpan.setAttribute("id", MEASUREMENT_SPAN_ID)
|
|
56
|
-
measurementSpan.setAttribute("aria-hidden", "true")
|
|
57
|
-
document.body.appendChild(measurementSpan)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
Object.assign(measurementSpan.style, SPAN_STYLE, style)
|
|
61
|
-
measurementSpan.textContent = `${text}`
|
|
62
|
-
|
|
63
|
-
const rect = measurementSpan.getBoundingClientRect()
|
|
64
|
-
return { height: rect.height, width: rect.width }
|
|
65
|
-
} catch {
|
|
66
|
-
return { height: 0, width: 0 }
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const getStringSize = (text: string | number, style: JSX.CSSProperties = {}): Size => {
|
|
71
|
-
if (text === undefined || text === null || Global.isSsr) {
|
|
72
|
-
return { height: 0, width: 0 }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (!currentConfig.enableCache) {
|
|
76
|
-
return measureTextWithDOM(text, style)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const cacheKey = createCacheKey(text, style)
|
|
80
|
-
const cachedResult = stringCache.get(cacheKey)
|
|
81
|
-
|
|
82
|
-
if (cachedResult) {
|
|
83
|
-
return cachedResult
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const result = measureTextWithDOM(text, style)
|
|
87
|
-
|
|
88
|
-
stringCache.set(cacheKey, result)
|
|
89
|
-
|
|
90
|
-
return result
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Configure text measurement behavior
|
|
95
|
-
* @param config - Partial configuration to apply
|
|
96
|
-
* @returns void
|
|
97
|
-
*/
|
|
98
|
-
export const configureTextMeasurement = (config: Partial<TextMeasurementConfig>): void => {
|
|
99
|
-
const newConfig = { ...currentConfig, ...config }
|
|
100
|
-
|
|
101
|
-
if (newConfig.cacheSize !== currentConfig.cacheSize) {
|
|
102
|
-
stringCache = new LRUCache<string, Size>(newConfig.cacheSize)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
currentConfig = newConfig
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get current text measurement configuration
|
|
110
|
-
* @returns Current configuration
|
|
111
|
-
*/
|
|
112
|
-
export const getTextMeasurementConfig = (): TextMeasurementConfig => ({ ...currentConfig })
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Clear the string size cache. Useful for testing or memory management.
|
|
116
|
-
* @returns void
|
|
117
|
-
*/
|
|
118
|
-
export const clearStringCache = (): void => {
|
|
119
|
-
stringCache.clear()
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Get cache statistics for debugging purposes.
|
|
124
|
-
* @returns Cache statistics including size and max size
|
|
125
|
-
*/
|
|
126
|
-
export const getStringCacheStats = () => ({
|
|
127
|
-
maxSize: currentConfig.cacheSize,
|
|
128
|
-
size: stringCache.size(),
|
|
129
|
-
})
|
package/src/util/DataUtils.ts
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import get from "es-toolkit/compat/get"
|
|
3
|
-
import { NonEmptyArray, Percent } from "./types"
|
|
4
|
-
import { round } from "./round"
|
|
5
|
-
|
|
6
|
-
export const mathSign = (value: number) => {
|
|
7
|
-
if (value === 0) {
|
|
8
|
-
return 0
|
|
9
|
-
}
|
|
10
|
-
if (value > 0) {
|
|
11
|
-
return 1
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return -1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const isNan = (value: unknown): value is number => {
|
|
18
|
-
return typeof value === "number" && value !== +value
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const isPercent = (value: string | number | undefined): value is Percent =>
|
|
22
|
-
typeof value === "string" && value.indexOf("%") === value.length - 1
|
|
23
|
-
|
|
24
|
-
export const isNumber = (value: unknown): value is number =>
|
|
25
|
-
(typeof value === "number" || (typeof value === "object" && value !== null && Object.prototype.toString.call(value) === "[object Number]")) && !isNan(value)
|
|
26
|
-
|
|
27
|
-
export const isNumOrStr = (value: unknown): value is number | string =>
|
|
28
|
-
isNumber(value) || typeof value === "string"
|
|
29
|
-
|
|
30
|
-
let idCounter = 0
|
|
31
|
-
export const uniqueId = (prefix?: string) => {
|
|
32
|
-
const id = ++idCounter
|
|
33
|
-
|
|
34
|
-
return `${prefix || ""}${id}`
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Calculates the numeric value represented by a percent string or number, based on a total value.
|
|
39
|
-
*
|
|
40
|
-
* - If `percent` is not a number or string, returns `defaultValue`.
|
|
41
|
-
* - If `percent` is a percent string but `totalValue` is null/undefined, returns `defaultValue`.
|
|
42
|
-
* - If the result is NaN, returns `defaultValue`.
|
|
43
|
-
* - If `validate` is true and the result exceeds `totalValue`, returns `totalValue`.
|
|
44
|
-
*
|
|
45
|
-
* @param percent - The percent value to convert. Can be a number (e.g. 25) or a string ending with '%' (e.g. '25%').
|
|
46
|
-
* If a string, it must end with '%' to be treated as a percent; otherwise, it is parsed as a number.
|
|
47
|
-
* @param totalValue - The total value to calculate the percent of. Required if `percent` is a percent string.
|
|
48
|
-
* @param defaultValue - The value returned if `percent` is undefined, invalid, or cannot be converted to a number.
|
|
49
|
-
* @param validate - If true, ensures the result does not exceed `totalValue` (when provided).
|
|
50
|
-
* @returns The calculated value, or `defaultValue` for invalid input.
|
|
51
|
-
*/
|
|
52
|
-
export const getPercentValue = (
|
|
53
|
-
percent: number | string | undefined,
|
|
54
|
-
totalValue: number | undefined,
|
|
55
|
-
defaultValue = 0,
|
|
56
|
-
validate = false,
|
|
57
|
-
) => {
|
|
58
|
-
if (!isNumber(percent) && typeof percent !== "string") {
|
|
59
|
-
return defaultValue
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let value: number
|
|
63
|
-
|
|
64
|
-
if (isPercent(percent)) {
|
|
65
|
-
if (totalValue == null) {
|
|
66
|
-
return defaultValue
|
|
67
|
-
}
|
|
68
|
-
const index = percent.indexOf("%")
|
|
69
|
-
value = (totalValue * parseFloat((percent as string).slice(0, index))) / 100
|
|
70
|
-
} else {
|
|
71
|
-
value = +percent
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isNan(value)) {
|
|
75
|
-
value = defaultValue
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (validate && totalValue != null && value > totalValue) {
|
|
79
|
-
value = totalValue
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return value
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const hasDuplicate = (ary: ReadonlyArray<unknown>): boolean => {
|
|
86
|
-
if (!Array.isArray(ary)) {
|
|
87
|
-
return false
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const len = ary.length
|
|
91
|
-
const cache: Record<string, boolean> = {}
|
|
92
|
-
|
|
93
|
-
for (let i = 0; i < len; i++) {
|
|
94
|
-
if (!cache[String(ary[i])]) {
|
|
95
|
-
cache[String(ary[i])] = true
|
|
96
|
-
} else {
|
|
97
|
-
return true
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return false
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function interpolate(start: unknown, end: number, t: number): number
|
|
105
|
-
export function interpolate(start: unknown, end: null, t: number): null
|
|
106
|
-
export function interpolate(start: unknown, end: number | null, t: number): number | null
|
|
107
|
-
export function interpolate(start: unknown, end: number | null, t: number): number | null {
|
|
108
|
-
if (isNumber(start) && isNumber(end)) {
|
|
109
|
-
return round(start + t * (end - start))
|
|
110
|
-
}
|
|
111
|
-
return end
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function findEntryInArray<T>(
|
|
115
|
-
ary: ReadonlyArray<T>,
|
|
116
|
-
specifiedKey: number | string | ((entry: T) => unknown),
|
|
117
|
-
specifiedValue: unknown,
|
|
118
|
-
): T | undefined {
|
|
119
|
-
if (!ary || !ary.length) {
|
|
120
|
-
return undefined
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return ary.find(
|
|
124
|
-
(entry) =>
|
|
125
|
-
entry &&
|
|
126
|
-
(typeof specifiedKey === "function" ? specifiedKey(entry) : get(entry, specifiedKey)) ===
|
|
127
|
-
specifiedValue,
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
type LinearRegressionResult = {
|
|
132
|
-
xmin: number
|
|
133
|
-
xmax: number
|
|
134
|
-
a: number
|
|
135
|
-
b: number
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The least square linear regression
|
|
140
|
-
* @param {Array} data The array of points
|
|
141
|
-
* @returns {Object} The domain of x, and the parameter of linear function
|
|
142
|
-
*/
|
|
143
|
-
export const getLinearRegression = (
|
|
144
|
-
data: NonEmptyArray<{ cx?: number; cy?: number }>,
|
|
145
|
-
): LinearRegressionResult => {
|
|
146
|
-
const len = data.length
|
|
147
|
-
let xsum = 0
|
|
148
|
-
let ysum = 0
|
|
149
|
-
let xysum = 0
|
|
150
|
-
let xxsum = 0
|
|
151
|
-
let xmin = Infinity
|
|
152
|
-
let xmax = -Infinity
|
|
153
|
-
let xcurrent = 0
|
|
154
|
-
let ycurrent = 0
|
|
155
|
-
|
|
156
|
-
for (let i = 0; i < len; i++) {
|
|
157
|
-
xcurrent = data[i]?.cx || 0
|
|
158
|
-
ycurrent = data[i]?.cy || 0
|
|
159
|
-
|
|
160
|
-
xsum += xcurrent
|
|
161
|
-
ysum += ycurrent
|
|
162
|
-
xysum += xcurrent * ycurrent
|
|
163
|
-
xxsum += xcurrent * xcurrent
|
|
164
|
-
xmin = Math.min(xmin, xcurrent)
|
|
165
|
-
xmax = Math.max(xmax, xcurrent)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const a =
|
|
169
|
-
len * xxsum !== xsum * xsum ? (len * xysum - xsum * ysum) / (len * xxsum - xsum * xsum) : 0
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
a,
|
|
173
|
-
b: (ysum - a * xsum) / len,
|
|
174
|
-
xmax,
|
|
175
|
-
xmin,
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
type Nullish = null | undefined
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Checks if the value is null or undefined
|
|
183
|
-
* @param value The value to check
|
|
184
|
-
* @returns true if the value is null or undefined
|
|
185
|
-
*/
|
|
186
|
-
export const isNullish = (value: unknown): value is Nullish => {
|
|
187
|
-
return value === null || typeof value === "undefined"
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Uppercase the first letter of a string
|
|
192
|
-
* @param {string} value The string to uppercase
|
|
193
|
-
* @returns {string} The uppercased string
|
|
194
|
-
*/
|
|
195
|
-
export const upperFirst = (value: string): string => {
|
|
196
|
-
if (isNullish(value)) {
|
|
197
|
-
return value
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Checks if the value is not null nor undefined.
|
|
205
|
-
* @param value The value to check
|
|
206
|
-
* @returns true if the value is not null nor undefined
|
|
207
|
-
*/
|
|
208
|
-
export function isNotNil<T>(value: T): value is NonNullable<T> {
|
|
209
|
-
return value != null
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* No-operation function that does nothing.
|
|
214
|
-
* Useful as a placeholder or default callback function.
|
|
215
|
-
*/
|
|
216
|
-
export function noop(): undefined {}
|
package/src/util/Events.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "eventemitter3"
|
|
2
|
-
import type { BrushStartEndIndex } from "../context/brushUpdateContext"
|
|
3
|
-
import type { TooltipSyncState } from "../state/tooltipSlice"
|
|
4
|
-
|
|
5
|
-
const eventCenter: EventEmitter<EventTypes> = new EventEmitter()
|
|
6
|
-
|
|
7
|
-
export { eventCenter }
|
|
8
|
-
|
|
9
|
-
export const TOOLTIP_SYNC_EVENT = "recharts.syncEvent.tooltip"
|
|
10
|
-
|
|
11
|
-
export const BRUSH_SYNC_EVENT = "recharts.syncEvent.brush"
|
|
12
|
-
|
|
13
|
-
interface EventTypes {
|
|
14
|
-
[TOOLTIP_SYNC_EVENT](syncId: number | string, data: TooltipSyncState, emitter: symbol): void
|
|
15
|
-
[BRUSH_SYNC_EVENT](syncId: number | string, data: BrushStartEndIndex, emitter: symbol): void
|
|
16
|
-
}
|
package/src/util/FunnelUtils.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { Props as FunnelProps, FunnelTrapezoidItem } from "../cartesian/Funnel"
|
|
4
|
-
import { Shape } from "./ActiveShapeUtils"
|
|
5
|
-
import type { ShapeAnimationProps } from "./types"
|
|
6
|
-
|
|
7
|
-
export type FunnelTrapezoidProps = {
|
|
8
|
-
option: FunnelProps["activeShape"]
|
|
9
|
-
isActive: boolean
|
|
10
|
-
} & ShapeAnimationProps &
|
|
11
|
-
FunnelTrapezoidItem
|
|
12
|
-
|
|
13
|
-
export function FunnelTrapezoid(props: FunnelTrapezoidProps): JSX.Element {
|
|
14
|
-
return <Shape shapeType="trapezoid" {...props} />
|
|
15
|
-
}
|
package/src/util/Global.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const parseIsSsrByDefault = (): boolean =>
|
|
2
|
-
!(
|
|
3
|
-
typeof window !== "undefined" &&
|
|
4
|
-
window.document &&
|
|
5
|
-
Boolean(window.document.createElement) &&
|
|
6
|
-
window.setTimeout
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
export const Global = {
|
|
10
|
-
devToolsEnabled: process.env.NODE_ENV !== "production",
|
|
11
|
-
isSsr: parseIsSsrByDefault(),
|
|
12
|
-
}
|
package/src/util/IfOverflow.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type IfOverflow = "hidden" | "visible" | "discard" | "extendDomain"
|
|
2
|
-
|
|
3
|
-
export interface Overflowable {
|
|
4
|
-
/**
|
|
5
|
-
* Defines how to draw this component if it falls partly outside the canvas:
|
|
6
|
-
*
|
|
7
|
-
* - `discard`: the whole component will not be drawn at all
|
|
8
|
-
* - `hidden`: the component will be clipped to the chart plot area
|
|
9
|
-
* - `visible`: the component will be drawn completely
|
|
10
|
-
* - `extendDomain`: the domain of the overflown axis will be extended such that the whole component fits into the plot area
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue discard
|
|
13
|
-
*/
|
|
14
|
-
ifOverflow?: IfOverflow
|
|
15
|
-
}
|
package/src/util/LRUCache.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple LRU (Least Recently Used) cache implementation
|
|
3
|
-
*/
|
|
4
|
-
export class LRUCache<K, V> {
|
|
5
|
-
private cache = new Map<K, V>()
|
|
6
|
-
|
|
7
|
-
private maxSize: number
|
|
8
|
-
|
|
9
|
-
constructor(maxSize: number) {
|
|
10
|
-
this.maxSize = maxSize
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
get(key: K): V | undefined {
|
|
14
|
-
const value = this.cache.get(key)
|
|
15
|
-
if (value !== undefined) {
|
|
16
|
-
this.cache.delete(key)
|
|
17
|
-
this.cache.set(key, value)
|
|
18
|
-
}
|
|
19
|
-
return value
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
set(key: K, value: V): void {
|
|
23
|
-
if (this.cache.has(key)) {
|
|
24
|
-
this.cache.delete(key)
|
|
25
|
-
} else if (this.cache.size >= this.maxSize) {
|
|
26
|
-
const firstKey = this.cache.keys().next().value
|
|
27
|
-
if (firstKey != null) {
|
|
28
|
-
this.cache.delete(firstKey)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
this.cache.set(key, value)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
clear(): void {
|
|
35
|
-
this.cache.clear()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
size(): number {
|
|
39
|
-
return this.cache.size
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/util/LogUtils.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const isDev = process.env.NODE_ENV !== "production"
|
|
2
|
-
|
|
3
|
-
export const warn = (condition: boolean, format: string, ...args: Array<unknown>) => {
|
|
4
|
-
if (isDev && typeof console !== "undefined" && console.warn) {
|
|
5
|
-
if (format === undefined) {
|
|
6
|
-
console.warn("LogUtils requires an error message argument")
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (!condition) {
|
|
10
|
-
if (format === undefined) {
|
|
11
|
-
console.warn(
|
|
12
|
-
"Minified exception occurred; use the non-minified dev environment " +
|
|
13
|
-
"for the full error message and additional helpful warnings.",
|
|
14
|
-
)
|
|
15
|
-
} else {
|
|
16
|
-
let argIndex = 0
|
|
17
|
-
|
|
18
|
-
console.warn(format.replace(/%s/g, () => String(args[argIndex++])))
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
package/src/util/PolarUtils.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import {
|
|
3
|
-
ChartOffsetInternal,
|
|
4
|
-
RelativePointer,
|
|
5
|
-
Coordinate,
|
|
6
|
-
PolarViewBoxRequired,
|
|
7
|
-
RangeObj,
|
|
8
|
-
} from "./types"
|
|
9
|
-
|
|
10
|
-
export const RADIAN = Math.PI / 180
|
|
11
|
-
|
|
12
|
-
export const degreeToRadian = (angle: number) => (angle * Math.PI) / 180
|
|
13
|
-
|
|
14
|
-
export const radianToDegree = (angleInRadian: number) => (angleInRadian * 180) / Math.PI
|
|
15
|
-
|
|
16
|
-
export const polarToCartesian = (
|
|
17
|
-
cx: number,
|
|
18
|
-
cy: number,
|
|
19
|
-
radius: number,
|
|
20
|
-
angle: number,
|
|
21
|
-
): Coordinate => ({
|
|
22
|
-
x: cx + Math.cos(-RADIAN * angle) * radius,
|
|
23
|
-
y: cy + Math.sin(-RADIAN * angle) * radius,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export const getMaxRadius = (
|
|
27
|
-
width: number,
|
|
28
|
-
height: number,
|
|
29
|
-
offset: ChartOffsetInternal = {
|
|
30
|
-
bottom: 0,
|
|
31
|
-
brushBottom: 0,
|
|
32
|
-
height: 0,
|
|
33
|
-
left: 0,
|
|
34
|
-
right: 0,
|
|
35
|
-
top: 0,
|
|
36
|
-
width: 0,
|
|
37
|
-
},
|
|
38
|
-
) =>
|
|
39
|
-
Math.min(
|
|
40
|
-
Math.abs(width - (offset.left || 0) - (offset.right || 0)),
|
|
41
|
-
Math.abs(height - (offset.top || 0) - (offset.bottom || 0)),
|
|
42
|
-
) / 2
|
|
43
|
-
|
|
44
|
-
const distanceBetweenPoints = (point: Coordinate, anotherPoint: Coordinate) => {
|
|
45
|
-
const { x: x1, y: y1 } = point
|
|
46
|
-
const { x: x2, y: y2 } = anotherPoint
|
|
47
|
-
|
|
48
|
-
return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const getAngleOfPoint = ({ x, y }: Coordinate, { cx, cy }: PolarViewBoxRequired) => {
|
|
52
|
-
const radius = distanceBetweenPoints({ x, y }, { x: cx, y: cy })
|
|
53
|
-
|
|
54
|
-
if (radius <= 0) {
|
|
55
|
-
return { angle: 0, radius }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const cos = (x - cx) / radius
|
|
59
|
-
let angleInRadian = Math.acos(cos)
|
|
60
|
-
|
|
61
|
-
if (y > cy) {
|
|
62
|
-
angleInRadian = 2 * Math.PI - angleInRadian
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return { angle: radianToDegree(angleInRadian), angleInRadian, radius }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const formatAngleOfSector = ({ startAngle, endAngle }: PolarViewBoxRequired) => {
|
|
69
|
-
const startCnt = Math.floor(startAngle / 360)
|
|
70
|
-
const endCnt = Math.floor(endAngle / 360)
|
|
71
|
-
const min = Math.min(startCnt, endCnt)
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
endAngle: endAngle - min * 360,
|
|
75
|
-
startAngle: startAngle - min * 360,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const reverseFormatAngleOfSector = (
|
|
80
|
-
angle: number,
|
|
81
|
-
{ startAngle, endAngle }: PolarViewBoxRequired,
|
|
82
|
-
): number => {
|
|
83
|
-
const startCnt = Math.floor(startAngle / 360)
|
|
84
|
-
const endCnt = Math.floor(endAngle / 360)
|
|
85
|
-
const min = Math.min(startCnt, endCnt)
|
|
86
|
-
|
|
87
|
-
return angle + min * 360
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const inRangeOfSector = (
|
|
91
|
-
{ relativeX: x, relativeY: y }: RelativePointer,
|
|
92
|
-
viewBox: PolarViewBoxRequired,
|
|
93
|
-
): RangeObj | null => {
|
|
94
|
-
const { radius, angle } = getAngleOfPoint({ x, y }, viewBox)
|
|
95
|
-
const { innerRadius, outerRadius } = viewBox
|
|
96
|
-
|
|
97
|
-
if (radius < innerRadius || radius > outerRadius) {
|
|
98
|
-
return null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (radius === 0) {
|
|
102
|
-
return null
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const { startAngle, endAngle } = formatAngleOfSector(viewBox)
|
|
106
|
-
let formatAngle = angle
|
|
107
|
-
let inRange
|
|
108
|
-
|
|
109
|
-
if (startAngle <= endAngle) {
|
|
110
|
-
while (formatAngle > endAngle) {
|
|
111
|
-
formatAngle -= 360
|
|
112
|
-
}
|
|
113
|
-
while (formatAngle < startAngle) {
|
|
114
|
-
formatAngle += 360
|
|
115
|
-
}
|
|
116
|
-
inRange = formatAngle >= startAngle && formatAngle <= endAngle
|
|
117
|
-
} else {
|
|
118
|
-
while (formatAngle > startAngle) {
|
|
119
|
-
formatAngle -= 360
|
|
120
|
-
}
|
|
121
|
-
while (formatAngle < endAngle) {
|
|
122
|
-
formatAngle += 360
|
|
123
|
-
}
|
|
124
|
-
inRange = formatAngle >= endAngle && formatAngle <= startAngle
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (inRange) {
|
|
128
|
-
return { ...viewBox, angle: reverseFormatAngleOfSector(formatAngle, viewBox), radius }
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return null
|
|
132
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { RadialBarDataItem, RadialBarProps } from "../polar/RadialBar"
|
|
4
|
-
import { Shape } from "./ActiveShapeUtils"
|
|
5
|
-
import type { ShapeAnimationProps } from "./types"
|
|
6
|
-
|
|
7
|
-
export function parseCornerRadius(cornerRadius: string | number | undefined): number | undefined {
|
|
8
|
-
if (typeof cornerRadius === "string") {
|
|
9
|
-
return parseInt(cornerRadius, 10)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return cornerRadius
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface RadialBarSectorProps extends RadialBarDataItem, ShapeAnimationProps {
|
|
16
|
-
index: number
|
|
17
|
-
option: RadialBarProps["activeShape"]
|
|
18
|
-
isActive: boolean
|
|
19
|
-
className?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function RadialBarSector(props: RadialBarSectorProps): JSX.Element {
|
|
23
|
-
return <Shape shapeType="sector" {...props} />
|
|
24
|
-
}
|