@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/theme/lightTheme.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { RechartsTheme } from "./RechartsTheme"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Light mode theme
|
|
5
|
-
*
|
|
6
|
-
* @experimental - this is still in active development, assume that the API will change in a minor/patch version
|
|
7
|
-
*/
|
|
8
|
-
export const lightTheme: RechartsTheme = {
|
|
9
|
-
grid: {
|
|
10
|
-
stroke: "#d6d3d1",
|
|
11
|
-
fill: "none",
|
|
12
|
-
},
|
|
13
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines the blank space between the chart and the plot area.
|
|
3
|
-
* This blank space is occupied by supporting elements like axes, legends, and brushes.
|
|
4
|
-
* This also includes any margins that might be applied to the chart.
|
|
5
|
-
*/
|
|
6
|
-
export type ChartOffset = {
|
|
7
|
-
/**
|
|
8
|
-
* Distance from the top edge of the chart to the top edge of the plot area.
|
|
9
|
-
*/
|
|
10
|
-
readonly top: number
|
|
11
|
-
/**
|
|
12
|
-
* Distance from the bottom edge of the chart to the bottom edge of the plot area.
|
|
13
|
-
* Note that this is not a coordinate, this is a distance.
|
|
14
|
-
* Meaning, `offset.bottom` could be 0 in a perfectly fine big chart.
|
|
15
|
-
*/
|
|
16
|
-
readonly bottom: number
|
|
17
|
-
/**
|
|
18
|
-
* Distance from the left edge of the chart to the left edge of the plot area.
|
|
19
|
-
*/
|
|
20
|
-
readonly left: number
|
|
21
|
-
/**
|
|
22
|
-
* Distance from the right edge of the chart to the right edge of the plot area.
|
|
23
|
-
* Note that this is not a coordinate, this is a distance.
|
|
24
|
-
* Meaning, `offset.right` could be 0 in a perfectly fine big chart.
|
|
25
|
-
*/
|
|
26
|
-
readonly right: number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Plot area is the area where the actual chart data is rendered.
|
|
31
|
-
* This means: bars, lines, scatter points, etc.
|
|
32
|
-
*/
|
|
33
|
-
export type PlotArea = {
|
|
34
|
-
/**
|
|
35
|
-
* The width of the plot area.
|
|
36
|
-
* This will be the same as `chartWidth - offset.left - offset.right`
|
|
37
|
-
*/
|
|
38
|
-
readonly width: number
|
|
39
|
-
/**
|
|
40
|
-
* The height of the plot area.
|
|
41
|
-
* This will be the same as `chartHeight - offset.top - offset.bottom`
|
|
42
|
-
*/
|
|
43
|
-
readonly height: number
|
|
44
|
-
/**
|
|
45
|
-
* The x coordinate of the top-left corner of the plot area.
|
|
46
|
-
* This will be the same as `offset.left`
|
|
47
|
-
*/
|
|
48
|
-
readonly x: number
|
|
49
|
-
/**
|
|
50
|
-
* The y coordinate of the top-left corner of the plot area.
|
|
51
|
-
* This will be the same as `offset.top`
|
|
52
|
-
*/
|
|
53
|
-
readonly y: number
|
|
54
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import { Dynamic } from '@solidjs/web';
|
|
4
|
-
import { createMemo, Show } from 'solid-js';
|
|
5
|
-
import isPlainObject from "es-toolkit/compat/isPlainObject"
|
|
6
|
-
|
|
7
|
-
import { Rectangle } from "../shape/Rectangle"
|
|
8
|
-
import { Trapezoid } from "../shape/Trapezoid"
|
|
9
|
-
import { Sector } from "../shape/Sector"
|
|
10
|
-
import { Layer } from "../container/Layer"
|
|
11
|
-
import { Symbols, SymbolsProps } from "../shape/Symbols"
|
|
12
|
-
import { Curve } from "../shape/Curve"
|
|
13
|
-
import { cloneJsxNodeWithProps, isJsxNode } from "./ReactUtils"
|
|
14
|
-
import {
|
|
15
|
-
armShapeElementProps,
|
|
16
|
-
createShapeElementPropsSlot,
|
|
17
|
-
disarmShapeElementProps,
|
|
18
|
-
ShapeElementPropsProvider,
|
|
19
|
-
} from "./ShapeElementProps"
|
|
20
|
-
|
|
21
|
-
import { splitProps } from './solid-1-compat';
|
|
22
|
-
/**
|
|
23
|
-
* This is an abstraction for rendering a user defined prop for a customized shape in several forms.
|
|
24
|
-
*
|
|
25
|
-
* <Shape /> is the root and will handle taking in:
|
|
26
|
-
* - an object of svg properties
|
|
27
|
-
* - a boolean
|
|
28
|
-
* - a render prop (inline function that returns jsx)
|
|
29
|
-
* - a JSX element
|
|
30
|
-
*
|
|
31
|
-
* <ShapeSelector /> is a subcomponent of <Shape /> and used to match a component
|
|
32
|
-
* to the value of props.shapeType that is passed to the root.
|
|
33
|
-
*/
|
|
34
|
-
type ShapeType = "trapezoid" | "rectangle" | "sector" | "symbols" | "curve"
|
|
35
|
-
|
|
36
|
-
export type ShapeProps<OptionType, ExtraProps> = {
|
|
37
|
-
shapeType: ShapeType
|
|
38
|
-
option: OptionType
|
|
39
|
-
/**
|
|
40
|
-
* Component rendered when `option` is empty, an object of props, or this same component.
|
|
41
|
-
* Overrides the `shapeType` lookup, like upstream's `DefaultShape`.
|
|
42
|
-
*/
|
|
43
|
-
DefaultShape?: (props: never) => JSX.Element
|
|
44
|
-
isActive?: boolean
|
|
45
|
-
index?: string | number
|
|
46
|
-
activeClassName?: string
|
|
47
|
-
inActiveClassName?: string
|
|
48
|
-
} & ExtraProps
|
|
49
|
-
|
|
50
|
-
function defaultPropTransformer(
|
|
51
|
-
option: Record<string, unknown>,
|
|
52
|
-
props: Record<string, unknown>,
|
|
53
|
-
): Record<string, unknown> {
|
|
54
|
-
return {
|
|
55
|
-
...props,
|
|
56
|
-
...option,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function isSymbolsProps(
|
|
61
|
-
shapeType: ShapeType,
|
|
62
|
-
_elementProps: unknown,
|
|
63
|
-
): _elementProps is SymbolsProps {
|
|
64
|
-
return shapeType === "symbols"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
type ShapeComponent = (props: Record<string, unknown>) => JSX.Element
|
|
68
|
-
|
|
69
|
-
const SHAPE_MAP: Record<ShapeType, ShapeComponent> = {
|
|
70
|
-
curve: Curve as ShapeComponent,
|
|
71
|
-
rectangle: Rectangle as ShapeComponent,
|
|
72
|
-
sector: Sector as ShapeComponent,
|
|
73
|
-
symbols: Symbols as ShapeComponent,
|
|
74
|
-
trapezoid: Trapezoid as ShapeComponent,
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function ShapeSelector(props: {
|
|
78
|
-
shapeType: ShapeType
|
|
79
|
-
elementProps: Record<string, unknown>
|
|
80
|
-
}): JSX.Element {
|
|
81
|
-
const component = createMemo(() => SHAPE_MAP[props.shapeType])
|
|
82
|
-
const isSymbols = createMemo(
|
|
83
|
-
() => props.shapeType === "symbols" && isSymbolsProps(props.shapeType, props.elementProps),
|
|
84
|
-
)
|
|
85
|
-
return (
|
|
86
|
-
<Show when={component()}>
|
|
87
|
-
<Dynamic component={isSymbols() ? Symbols : component()} {...props.elementProps} />
|
|
88
|
-
</Show>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function getPropsFromShapeOption<T>(option: T): T {
|
|
93
|
-
return option
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function Shape<OptionType, ExtraProps>(
|
|
97
|
-
allProps: ShapeProps<OptionType, ExtraProps>,
|
|
98
|
-
): JSX.Element {
|
|
99
|
-
/* mirror upstream: keep `isActive` on the forwarded props so function-options and
|
|
100
|
-
downstream rectangles receive it (tests assert it on the received props). */
|
|
101
|
-
const [local, props] = splitProps(allProps as Record<string, unknown>, [
|
|
102
|
-
"option",
|
|
103
|
-
"shapeType",
|
|
104
|
-
"DefaultShape",
|
|
105
|
-
"activeClassName",
|
|
106
|
-
"inActiveClassName",
|
|
107
|
-
])
|
|
108
|
-
const activeClassName = () => (local.activeClassName as string) ?? "recharts-active-shape"
|
|
109
|
-
const inActiveClassName = () => (local.inActiveClassName as string) ?? "recharts-shape"
|
|
110
|
-
|
|
111
|
-
const renderDefault = (elementProps: Record<string, unknown>): JSX.Element => {
|
|
112
|
-
const DefaultShape = local.DefaultShape as ShapeComponent | undefined
|
|
113
|
-
if (DefaultShape != null) {
|
|
114
|
-
return <Dynamic component={DefaultShape} {...elementProps} />
|
|
115
|
-
}
|
|
116
|
-
return <ShapeSelector shapeType={local.shapeType as ShapeType} elementProps={elementProps} />
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Element options are evaluated inside the provider so built-in shapes pick up the
|
|
120
|
-
props upstream would inject with cloneElement (see ShapeElementProps). */
|
|
121
|
-
const slot = createShapeElementPropsSlot()
|
|
122
|
-
|
|
123
|
-
const renderShape = (): JSX.Element => {
|
|
124
|
-
const token = armShapeElementProps(slot, props)
|
|
125
|
-
/* read once: an element option is a getter that mints a new shape per read */
|
|
126
|
-
const option = local.option
|
|
127
|
-
/* Only an element option may take the injected props; it already has while being
|
|
128
|
-
read. Disarm so shapes rendered by the remaining branches (and their nested
|
|
129
|
-
shapes) keep exactly the props they are given. */
|
|
130
|
-
disarmShapeElementProps(slot)
|
|
131
|
-
|
|
132
|
-
if (option != null && option === local.DefaultShape) {
|
|
133
|
-
return renderDefault(props)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (typeof option === "function") {
|
|
137
|
-
return (option as (p: Record<string, unknown>, i: unknown) => JSX.Element)(props, props.index)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (isPlainObject(option) && typeof option !== "boolean") {
|
|
141
|
-
const nextProps = defaultPropTransformer(option as Record<string, unknown>, props)
|
|
142
|
-
return renderDefault(nextProps)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/* A built-in shape passed as an element took the injected props while it was
|
|
146
|
-
evaluated. Anything else (a custom component) is cloned with the props applied. */
|
|
147
|
-
if (isJsxNode(option)) {
|
|
148
|
-
if (token.consumed) {
|
|
149
|
-
return option as unknown as JSX.Element
|
|
150
|
-
}
|
|
151
|
-
return <>{cloneJsxNodeWithProps(option, props as Record<string, unknown>) as unknown as JSX.Element}</>
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return renderDefault(props)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Layer class={props.isActive ? activeClassName() : inActiveClassName()}>
|
|
159
|
-
<ShapeElementPropsProvider slot={slot}>{renderShape()}</ShapeElementPropsProvider>
|
|
160
|
-
</Layer>
|
|
161
|
-
)
|
|
162
|
-
}
|
package/src/util/BarUtils.tsx
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import type { JSX } from '@solidjs/web';
|
|
3
|
-
import invariant from "tiny-invariant"
|
|
4
|
-
import { ActiveShape, DataKey } from "./types"
|
|
5
|
-
import { Rectangle, Props as RectangleProps } from "../shape/Rectangle"
|
|
6
|
-
import { BarShapeProps } from "../cartesian/Bar"
|
|
7
|
-
import { Shape } from "./ActiveShapeUtils"
|
|
8
|
-
import { isNullish, isNumber } from "./DataUtils"
|
|
9
|
-
|
|
10
|
-
export const defaultBarShape = Rectangle
|
|
11
|
-
|
|
12
|
-
export type BarRectangleProps = {
|
|
13
|
-
option: ActiveShape<BarShapeProps, SVGPathElement> | undefined
|
|
14
|
-
isActive: boolean
|
|
15
|
-
onMouseEnter?: (e: MouseEvent & { currentTarget: SVGPathElement }) => void
|
|
16
|
-
onMouseLeave?: (e: MouseEvent & { currentTarget: SVGPathElement }) => void
|
|
17
|
-
onClick?: (e: MouseEvent & { currentTarget: SVGPathElement }) => void
|
|
18
|
-
width?: number
|
|
19
|
-
height?: number
|
|
20
|
-
index: number
|
|
21
|
-
dataKey: DataKey<unknown> | undefined
|
|
22
|
-
/* React-style alias forwarded through Shape to function options that read className. */
|
|
23
|
-
className?: string
|
|
24
|
-
animationElapsedTime?: number
|
|
25
|
-
isAnimating?: boolean
|
|
26
|
-
isEntrance?: boolean
|
|
27
|
-
} & Omit<RectangleProps, "onAnimationStart" | "onAnimationEnd">
|
|
28
|
-
|
|
29
|
-
export function BarRectangle(props: BarRectangleProps): JSX.Element {
|
|
30
|
-
return (
|
|
31
|
-
<Shape
|
|
32
|
-
shapeType="rectangle"
|
|
33
|
-
activeClassName="recharts-active-bar"
|
|
34
|
-
inActiveClassName="recharts-inactive-bar"
|
|
35
|
-
{...props}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type MinPointSize = number | ((value: number | undefined | null, index: number) => number)
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Safely gets minPointSize from the minPointSize prop if it is a function
|
|
44
|
-
* @param minPointSize minPointSize as passed to the Bar component
|
|
45
|
-
* @param defaultValue default minPointSize
|
|
46
|
-
* @returns minPointSize
|
|
47
|
-
*/
|
|
48
|
-
export const minPointSizeCallback =
|
|
49
|
-
(minPointSize: MinPointSize, defaultValue = 0) =>
|
|
50
|
-
(value: unknown, index: number): number => {
|
|
51
|
-
if (isNumber(minPointSize)) return minPointSize
|
|
52
|
-
const isValueNumberOrNil = isNumber(value) || isNullish(value)
|
|
53
|
-
if (isValueNumberOrNil) {
|
|
54
|
-
return minPointSize(value, index)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
invariant(
|
|
58
|
-
isValueNumberOrNil,
|
|
59
|
-
`minPointSize callback function received a value with type of ${typeof value}. Currently only numbers or null/undefined are supported.`,
|
|
60
|
-
)
|
|
61
|
-
return defaultValue
|
|
62
|
-
}
|
package/src/util/BarePortal.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createEffect,
|
|
3
|
-
createMemo,
|
|
4
|
-
createRoot,
|
|
5
|
-
getOwner,
|
|
6
|
-
runWithOwner,
|
|
7
|
-
} from 'solid-js';
|
|
8
|
-
import type { JSX } from '@solidjs/web';
|
|
9
|
-
import { insert } from '@solidjs/web';
|
|
10
|
-
/* Wrapper-less alternative to `solid-js/web::Portal`. Solid's Portal mounts a
|
|
11
|
-
* `<div>` inside `mount` and inserts children there — that extra div breaks
|
|
12
|
-
* upstream tests that assert `.recharts-wrapper > .recharts-tooltip-wrapper`
|
|
13
|
-
* direct-child selectors. BarePortal inserts directly on `mount` so children
|
|
14
|
-
* land at the requested level. */
|
|
15
|
-
export function BarePortal(props: {
|
|
16
|
-
mount: HTMLElement | undefined
|
|
17
|
-
children: JSX.Element
|
|
18
|
-
}): null {
|
|
19
|
-
const owner = getOwner()
|
|
20
|
-
createEffect(
|
|
21
|
-
() => props.mount,
|
|
22
|
-
(target) => {
|
|
23
|
-
if (target == null) return
|
|
24
|
-
/* Children land between two markers so teardown can remove exactly what was inserted;
|
|
25
|
-
disposing the root alone leaves the inserted nodes in the mount. */
|
|
26
|
-
const start = document.createTextNode("")
|
|
27
|
-
const marker = document.createTextNode("")
|
|
28
|
-
target.appendChild(start)
|
|
29
|
-
target.appendChild(marker)
|
|
30
|
-
const dispose = createRoot((d) => {
|
|
31
|
-
/* eslint-disable-next-line solid/reactivity -- createMemo inside runWithOwner must be assigned inline; owner-tree placement is the invariant */
|
|
32
|
-
const content = runWithOwner(owner, () => createMemo(() => props.children))
|
|
33
|
-
insert(target, content, marker)
|
|
34
|
-
return d
|
|
35
|
-
})
|
|
36
|
-
return () => {
|
|
37
|
-
dispose()
|
|
38
|
-
let node = start.nextSibling
|
|
39
|
-
while (node != null && node !== marker) {
|
|
40
|
-
const next = node.nextSibling
|
|
41
|
-
node.remove()
|
|
42
|
-
node = next
|
|
43
|
-
}
|
|
44
|
-
start.remove()
|
|
45
|
-
marker.remove()
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
)
|
|
49
|
-
return null
|
|
50
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Solid uses kebab-case for SVG attributes, React uses camelCase.
|
|
3
|
-
* This type adds camelCase aliases for the most commonly-used SVG presentation attributes
|
|
4
|
-
* so ported React code can continue to use props.strokeWidth, props.fillOpacity, etc.
|
|
5
|
-
*/
|
|
6
|
-
export type CamelCaseSVGAttrs = {
|
|
7
|
-
alignmentBaseline?: string
|
|
8
|
-
capHeight?: number | string
|
|
9
|
-
className?: string
|
|
10
|
-
clipPath?: string
|
|
11
|
-
clipRule?: "nonzero" | "evenodd" | "inherit"
|
|
12
|
-
dominantBaseline?: string
|
|
13
|
-
fillOpacity?: number | string
|
|
14
|
-
fillRule?: "nonzero" | "evenodd" | "inherit"
|
|
15
|
-
fontFamily?: string
|
|
16
|
-
fontSize?: number | string
|
|
17
|
-
fontStyle?: string
|
|
18
|
-
fontWeight?: number | string
|
|
19
|
-
letterSpacing?: number | string
|
|
20
|
-
pointerEvents?: string
|
|
21
|
-
stopColor?: string
|
|
22
|
-
stopOpacity?: number | string
|
|
23
|
-
strokeDasharray?: string
|
|
24
|
-
strokeDashoffset?: number | string
|
|
25
|
-
strokeLinecap?: "butt" | "round" | "square" | "inherit"
|
|
26
|
-
strokeLinejoin?: "miter" | "round" | "bevel" | "inherit"
|
|
27
|
-
strokeMiterlimit?: number | string
|
|
28
|
-
strokeOpacity?: number | string
|
|
29
|
-
strokeWidth?: number | string
|
|
30
|
-
textAnchor?: "start" | "middle" | "end" | "inherit"
|
|
31
|
-
textDecoration?: string
|
|
32
|
-
wordSpacing?: number | string
|
|
33
|
-
writingMode?: string
|
|
34
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-cycle */
|
|
2
|
-
import { Coordinate, RectangleCoordinate, RectanglePosition, Size } from "./types"
|
|
3
|
-
|
|
4
|
-
export const rectWithPoints = (
|
|
5
|
-
{ x: x1, y: y1 }: Coordinate,
|
|
6
|
-
{ x: x2, y: y2 }: Coordinate,
|
|
7
|
-
): RectanglePosition => ({
|
|
8
|
-
height: Math.abs(y2 - y1),
|
|
9
|
-
width: Math.abs(x2 - x1),
|
|
10
|
-
x: Math.min(x1, x2),
|
|
11
|
-
y: Math.min(y1, y2),
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Compute the x, y, width, and height of a box from two reference points.
|
|
16
|
-
* @param {Object} coords x1, x2, y1, and y2
|
|
17
|
-
* @return {Object} object
|
|
18
|
-
*/
|
|
19
|
-
export const rectWithCoords = ({ x1, y1, x2, y2 }: RectangleCoordinate): RectanglePosition =>
|
|
20
|
-
rectWithPoints({ x: x1, y: y1 }, { x: x2, y: y2 })
|
|
21
|
-
|
|
22
|
-
/** Normalizes the angle so that 0 <= angle < 180.
|
|
23
|
-
* @param {number} angle Angle in degrees.
|
|
24
|
-
* @return {number} the normalized angle with a value of at least 0 and never greater or equal to 180. */
|
|
25
|
-
export function normalizeAngle(angle: number) {
|
|
26
|
-
return ((angle % 180) + 180) % 180
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Calculates the width of the largest horizontal line that fits inside a rectangle that is displayed at an angle.
|
|
30
|
-
* @param {Object} size Width and height of the text in a horizontal position.
|
|
31
|
-
* @param {number} angle Angle in degrees in which the text is displayed.
|
|
32
|
-
* @return {number} The width of the largest horizontal line that fits inside a rectangle that is displayed at an angle.
|
|
33
|
-
*/
|
|
34
|
-
export const getAngledRectangleWidth = ({ width, height }: Size, angle: number | undefined = 0) => {
|
|
35
|
-
const normalizedAngle = normalizeAngle(angle)
|
|
36
|
-
const angleRadians = (normalizedAngle * Math.PI) / 180
|
|
37
|
-
|
|
38
|
-
/* Depending on the height and width of the rectangle, we may need to use different formulas to calculate the angled
|
|
39
|
-
* width. This threshold defines when each formula should kick in. */
|
|
40
|
-
const angleThreshold = Math.atan(height / width)
|
|
41
|
-
|
|
42
|
-
const angledWidth =
|
|
43
|
-
angleRadians > angleThreshold && angleRadians < Math.PI - angleThreshold
|
|
44
|
-
? height / Math.sin(angleRadians)
|
|
45
|
-
: width / Math.cos(angleRadians)
|
|
46
|
-
|
|
47
|
-
return Math.abs(angledWidth)
|
|
48
|
-
}
|