@coinbase/cds-mobile-visualization 3.8.1 → 4.0.0
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/CHANGELOG.md +8 -0
- package/dts/chart/index.d.ts +1 -15
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -5
- package/dts/sparkline/index.d.ts.map +1 -1
- package/esm/chart/index.js +1 -17
- package/esm/index.js +1 -3
- package/esm/sparkline/index.js +1 -5
- package/package.json +26 -20
- package/dts/chart/CartesianChart.d.ts +0 -206
- package/dts/chart/CartesianChart.d.ts.map +0 -1
- package/dts/chart/ChartContextBridge.d.ts +0 -28
- package/dts/chart/ChartContextBridge.d.ts.map +0 -1
- package/dts/chart/ChartProvider.d.ts +0 -9
- package/dts/chart/ChartProvider.d.ts.map +0 -1
- package/dts/chart/Path.d.ts +0 -121
- package/dts/chart/Path.d.ts.map +0 -1
- package/dts/chart/PeriodSelector.d.ts +0 -100
- package/dts/chart/PeriodSelector.d.ts.map +0 -1
- package/dts/chart/area/Area.d.ts +0 -83
- package/dts/chart/area/Area.d.ts.map +0 -1
- package/dts/chart/area/AreaChart.d.ts +0 -155
- package/dts/chart/area/AreaChart.d.ts.map +0 -1
- package/dts/chart/area/DottedArea.d.ts +0 -46
- package/dts/chart/area/DottedArea.d.ts.map +0 -1
- package/dts/chart/area/GradientArea.d.ts +0 -36
- package/dts/chart/area/GradientArea.d.ts.map +0 -1
- package/dts/chart/area/SolidArea.d.ts +0 -23
- package/dts/chart/area/SolidArea.d.ts.map +0 -1
- package/dts/chart/area/index.d.ts +0 -6
- package/dts/chart/area/index.d.ts.map +0 -1
- package/dts/chart/axis/Axis.d.ts +0 -174
- package/dts/chart/axis/Axis.d.ts.map +0 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +0 -8
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +0 -1
- package/dts/chart/axis/XAxis.d.ts +0 -22
- package/dts/chart/axis/XAxis.d.ts.map +0 -1
- package/dts/chart/axis/YAxis.d.ts +0 -22
- package/dts/chart/axis/YAxis.d.ts.map +0 -1
- package/dts/chart/axis/index.d.ts +0 -5
- package/dts/chart/axis/index.d.ts.map +0 -1
- package/dts/chart/bar/Bar.d.ts +0 -100
- package/dts/chart/bar/Bar.d.ts.map +0 -1
- package/dts/chart/bar/BarChart.d.ts +0 -158
- package/dts/chart/bar/BarChart.d.ts.map +0 -1
- package/dts/chart/bar/BarPlot.d.ts +0 -31
- package/dts/chart/bar/BarPlot.d.ts.map +0 -1
- package/dts/chart/bar/BarStack.d.ts +0 -127
- package/dts/chart/bar/BarStack.d.ts.map +0 -1
- package/dts/chart/bar/BarStackGroup.d.ts +0 -37
- package/dts/chart/bar/BarStackGroup.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBar.d.ts +0 -7
- package/dts/chart/bar/DefaultBar.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBarStack.d.ts +0 -7
- package/dts/chart/bar/DefaultBarStack.d.ts.map +0 -1
- package/dts/chart/bar/PercentageBarChart.d.ts +0 -106
- package/dts/chart/bar/PercentageBarChart.d.ts.map +0 -1
- package/dts/chart/bar/index.d.ts +0 -9
- package/dts/chart/bar/index.d.ts.map +0 -1
- package/dts/chart/gradient/Gradient.d.ts +0 -41
- package/dts/chart/gradient/Gradient.d.ts.map +0 -1
- package/dts/chart/gradient/index.d.ts +0 -2
- package/dts/chart/gradient/index.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendShape.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +0 -1
- package/dts/chart/legend/Legend.d.ts +0 -168
- package/dts/chart/legend/Legend.d.ts.map +0 -1
- package/dts/chart/legend/index.d.ts +0 -4
- package/dts/chart/legend/index.d.ts.map +0 -1
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +0 -9
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +0 -1
- package/dts/chart/line/DottedLine.d.ts +0 -20
- package/dts/chart/line/DottedLine.d.ts.map +0 -1
- package/dts/chart/line/Line.d.ts +0 -122
- package/dts/chart/line/Line.d.ts.map +0 -1
- package/dts/chart/line/LineChart.d.ts +0 -135
- package/dts/chart/line/LineChart.d.ts.map +0 -1
- package/dts/chart/line/ReferenceLine.d.ts +0 -140
- package/dts/chart/line/ReferenceLine.d.ts.map +0 -1
- package/dts/chart/line/SolidLine.d.ts +0 -15
- package/dts/chart/line/SolidLine.d.ts.map +0 -1
- package/dts/chart/line/index.d.ts +0 -7
- package/dts/chart/line/index.d.ts.map +0 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +0 -10
- package/dts/chart/point/DefaultPointLabel.d.ts.map +0 -1
- package/dts/chart/point/Point.d.ts +0 -144
- package/dts/chart/point/Point.d.ts.map +0 -1
- package/dts/chart/point/index.d.ts +0 -3
- package/dts/chart/point/index.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +0 -38
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/Scrubber.d.ts +0 -302
- package/dts/chart/scrubber/Scrubber.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +0 -12
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +0 -54
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +0 -46
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts +0 -20
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +0 -1
- package/dts/chart/scrubber/index.d.ts +0 -5
- package/dts/chart/scrubber/index.d.ts.map +0 -1
- package/dts/chart/text/ChartText.d.ts +0 -164
- package/dts/chart/text/ChartText.d.ts.map +0 -1
- package/dts/chart/text/ChartTextGroup.d.ts +0 -61
- package/dts/chart/text/ChartTextGroup.d.ts.map +0 -1
- package/dts/chart/text/index.d.ts +0 -3
- package/dts/chart/text/index.d.ts.map +0 -1
- package/dts/chart/utils/axis.d.ts +0 -387
- package/dts/chart/utils/axis.d.ts.map +0 -1
- package/dts/chart/utils/bar.d.ts +0 -225
- package/dts/chart/utils/bar.d.ts.map +0 -1
- package/dts/chart/utils/chart.d.ts +0 -165
- package/dts/chart/utils/chart.d.ts.map +0 -1
- package/dts/chart/utils/context.d.ts +0 -131
- package/dts/chart/utils/context.d.ts.map +0 -1
- package/dts/chart/utils/gradient.d.ts +0 -129
- package/dts/chart/utils/gradient.d.ts.map +0 -1
- package/dts/chart/utils/index.d.ts +0 -11
- package/dts/chart/utils/index.d.ts.map +0 -1
- package/dts/chart/utils/path.d.ts +0 -186
- package/dts/chart/utils/path.d.ts.map +0 -1
- package/dts/chart/utils/point.d.ts +0 -146
- package/dts/chart/utils/point.d.ts.map +0 -1
- package/dts/chart/utils/scale.d.ts +0 -145
- package/dts/chart/utils/scale.d.ts.map +0 -1
- package/dts/chart/utils/scrubber.d.ts +0 -40
- package/dts/chart/utils/scrubber.d.ts.map +0 -1
- package/dts/chart/utils/transition.d.ts +0 -181
- package/dts/chart/utils/transition.d.ts.map +0 -1
- package/dts/sparkline/Counter.d.ts +0 -8
- package/dts/sparkline/Counter.d.ts.map +0 -1
- package/dts/sparkline/Sparkline.d.ts +0 -74
- package/dts/sparkline/Sparkline.d.ts.map +0 -1
- package/dts/sparkline/SparklineArea.d.ts +0 -15
- package/dts/sparkline/SparklineArea.d.ts.map +0 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +0 -14
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +0 -1
- package/dts/sparkline/SparklineGradient.d.ts +0 -24
- package/dts/sparkline/SparklineGradient.d.ts.map +0 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +0 -2
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +0 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +0 -11
- package/dts/sparkline/generateSparklineWithId.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +0 -23
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +0 -185
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +0 -28
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +0 -17
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +0 -11
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +0 -26
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +0 -39
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +0 -31
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +0 -16
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +0 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +0 -22
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +0 -34
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +0 -118
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +0 -29
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +0 -1
- package/esm/chart/CartesianChart.js +0 -431
- package/esm/chart/ChartContextBridge.js +0 -159
- package/esm/chart/ChartProvider.js +0 -10
- package/esm/chart/Path.js +0 -255
- package/esm/chart/PeriodSelector.js +0 -139
- package/esm/chart/__stories__/CartesianChart.stories.js +0 -659
- package/esm/chart/__stories__/ChartAccessibility.stories.js +0 -721
- package/esm/chart/__stories__/ChartTransitions.stories.js +0 -693
- package/esm/chart/__stories__/PeriodSelector.stories.js +0 -420
- package/esm/chart/area/Area.js +0 -85
- package/esm/chart/area/AreaChart.js +0 -152
- package/esm/chart/area/DottedArea.js +0 -92
- package/esm/chart/area/GradientArea.js +0 -63
- package/esm/chart/area/SolidArea.js +0 -45
- package/esm/chart/area/__stories__/AreaChart.stories.js +0 -370
- package/esm/chart/area/index.js +0 -7
- package/esm/chart/axis/Axis.js +0 -9
- package/esm/chart/axis/DefaultAxisTickLabel.js +0 -11
- package/esm/chart/axis/XAxis.js +0 -256
- package/esm/chart/axis/YAxis.js +0 -255
- package/esm/chart/axis/__stories__/Axis.stories.js +0 -552
- package/esm/chart/axis/index.js +0 -6
- package/esm/chart/bar/Bar.js +0 -71
- package/esm/chart/bar/BarChart.js +0 -122
- package/esm/chart/bar/BarPlot.js +0 -106
- package/esm/chart/bar/BarStack.js +0 -173
- package/esm/chart/bar/BarStackGroup.js +0 -89
- package/esm/chart/bar/DefaultBar.js +0 -79
- package/esm/chart/bar/DefaultBarStack.js +0 -68
- package/esm/chart/bar/PercentageBarChart.js +0 -99
- package/esm/chart/bar/__stories__/BarChart.stories.js +0 -1417
- package/esm/chart/bar/__stories__/PercentageBarChart.stories.js +0 -833
- package/esm/chart/bar/index.js +0 -10
- package/esm/chart/gradient/Gradient.js +0 -156
- package/esm/chart/gradient/index.js +0 -1
- package/esm/chart/legend/DefaultLegendEntry.js +0 -42
- package/esm/chart/legend/DefaultLegendShape.js +0 -64
- package/esm/chart/legend/Legend.js +0 -59
- package/esm/chart/legend/__stories__/Legend.stories.js +0 -574
- package/esm/chart/legend/index.js +0 -3
- package/esm/chart/line/DefaultReferenceLineLabel.js +0 -66
- package/esm/chart/line/DottedLine.js +0 -57
- package/esm/chart/line/Line.js +0 -180
- package/esm/chart/line/LineChart.js +0 -149
- package/esm/chart/line/ReferenceLine.js +0 -132
- package/esm/chart/line/SolidLine.js +0 -53
- package/esm/chart/line/__stories__/LineChart.stories.js +0 -2018
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +0 -226
- package/esm/chart/line/index.js +0 -8
- package/esm/chart/point/DefaultPointLabel.js +0 -39
- package/esm/chart/point/Point.js +0 -187
- package/esm/chart/point/index.js +0 -2
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +0 -182
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +0 -43
- package/esm/chart/scrubber/DefaultScrubberLabel.js +0 -44
- package/esm/chart/scrubber/Scrubber.js +0 -198
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +0 -177
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +0 -169
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +0 -212
- package/esm/chart/scrubber/ScrubberProvider.js +0 -140
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +0 -946
- package/esm/chart/scrubber/index.js +0 -4
- package/esm/chart/text/ChartText.js +0 -305
- package/esm/chart/text/ChartTextGroup.js +0 -211
- package/esm/chart/text/index.js +0 -4
- package/esm/chart/utils/axis.js +0 -664
- package/esm/chart/utils/bar.js +0 -906
- package/esm/chart/utils/chart.js +0 -329
- package/esm/chart/utils/context.js +0 -22
- package/esm/chart/utils/gradient.js +0 -319
- package/esm/chart/utils/index.js +0 -12
- package/esm/chart/utils/path.js +0 -304
- package/esm/chart/utils/point.js +0 -282
- package/esm/chart/utils/scale.js +0 -288
- package/esm/chart/utils/scrubber.js +0 -146
- package/esm/chart/utils/transition.js +0 -241
- package/esm/sparkline/Counter.js +0 -45
- package/esm/sparkline/Sparkline.js +0 -165
- package/esm/sparkline/SparklineArea.js +0 -20
- package/esm/sparkline/SparklineAreaPattern.js +0 -38
- package/esm/sparkline/SparklineGradient.js +0 -77
- package/esm/sparkline/__figma__/Sparkline.figma.js +0 -22
- package/esm/sparkline/__stories__/Sparkline.stories.js +0 -124
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +0 -126
- package/esm/sparkline/generateSparklineWithId.js +0 -7
- package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +0 -75
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +0 -308
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +0 -116
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +0 -131
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +0 -99
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +0 -82
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +0 -103
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +0 -104
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +0 -57
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +0 -124
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +0 -80
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +0 -109
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +0 -85
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +0 -526
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +0 -58
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +0 -37
- package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +0 -56
- package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +0 -23
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +0 -47
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +0 -34
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +0 -233
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +0 -104
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +0 -565
- package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +0 -117
package/esm/chart/axis/XAxis.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
2
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
3
|
-
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
-
import { Group } from '@shopify/react-native-skia';
|
|
6
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
-
import { DottedLine } from '../line/DottedLine';
|
|
8
|
-
import { SolidLine } from '../line/SolidLine';
|
|
9
|
-
import { ChartText } from '../text/ChartText';
|
|
10
|
-
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
11
|
-
import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
|
|
12
|
-
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const AXIS_HEIGHT = 32;
|
|
15
|
-
const LABEL_SIZE = 20;
|
|
16
|
-
export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
17
|
-
let {
|
|
18
|
-
axisId,
|
|
19
|
-
position = 'bottom',
|
|
20
|
-
showGrid,
|
|
21
|
-
requestedTickCount,
|
|
22
|
-
ticks,
|
|
23
|
-
tickLabelFormatter,
|
|
24
|
-
TickLabelComponent = DefaultAxisTickLabel,
|
|
25
|
-
GridLineComponent = DottedLine,
|
|
26
|
-
LineComponent = SolidLine,
|
|
27
|
-
TickMarkLineComponent = SolidLine,
|
|
28
|
-
tickMarkLabelGap = 2,
|
|
29
|
-
minTickLabelGap = 4,
|
|
30
|
-
showTickMarks,
|
|
31
|
-
showLine,
|
|
32
|
-
tickMarkSize = 4,
|
|
33
|
-
tickInterval = 32,
|
|
34
|
-
tickMinStep = 1,
|
|
35
|
-
tickMaxStep,
|
|
36
|
-
label,
|
|
37
|
-
labelGap = 4,
|
|
38
|
-
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT,
|
|
39
|
-
bandGridLinePlacement = 'edges',
|
|
40
|
-
bandTickMarkPlacement = 'middle'
|
|
41
|
-
} = _ref,
|
|
42
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
43
|
-
const theme = useTheme();
|
|
44
|
-
const registrationId = useId();
|
|
45
|
-
const {
|
|
46
|
-
animate,
|
|
47
|
-
drawingArea,
|
|
48
|
-
layout,
|
|
49
|
-
getXScale,
|
|
50
|
-
getXAxis,
|
|
51
|
-
registerAxis,
|
|
52
|
-
unregisterAxis,
|
|
53
|
-
getAxisBounds
|
|
54
|
-
} = useCartesianChartContext();
|
|
55
|
-
const xScale = getXScale(axisId);
|
|
56
|
-
const xAxis = getXAxis(axisId);
|
|
57
|
-
const axisBounds = getAxisBounds(registrationId);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
registerAxis(registrationId, position, height);
|
|
60
|
-
return () => unregisterAxis(registrationId);
|
|
61
|
-
}, [registrationId, registerAxis, unregisterAxis, position, height]);
|
|
62
|
-
const formatTick = useCallback(value => {
|
|
63
|
-
var _tickLabelFormatter;
|
|
64
|
-
// If we have string labels and no custom formatter, use the labels
|
|
65
|
-
const axisData = xAxis == null ? void 0 : xAxis.data;
|
|
66
|
-
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
67
|
-
if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
|
|
68
|
-
return axisData[value];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Otherwise passes raw index to formatter
|
|
72
|
-
return (_tickLabelFormatter = tickLabelFormatter == null ? void 0 : tickLabelFormatter(value)) != null ? _tickLabelFormatter : value;
|
|
73
|
-
}, [xAxis == null ? void 0 : xAxis.data, tickLabelFormatter]);
|
|
74
|
-
const ticksData = useMemo(() => {
|
|
75
|
-
if (!xScale) return [];
|
|
76
|
-
|
|
77
|
-
// Check if we have string labels
|
|
78
|
-
const axisData = xAxis == null ? void 0 : xAxis.data;
|
|
79
|
-
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
80
|
-
|
|
81
|
-
// For band scales, we need categories
|
|
82
|
-
let categories;
|
|
83
|
-
if (hasStringLabels) {
|
|
84
|
-
categories = axisData;
|
|
85
|
-
} else if (isCategoricalScale(xScale)) {
|
|
86
|
-
// For band scales without explicit string data, generate numeric categories
|
|
87
|
-
// based on the domain of the scale
|
|
88
|
-
const domain = xScale.domain();
|
|
89
|
-
categories = domain.map(String);
|
|
90
|
-
}
|
|
91
|
-
return getAxisTicksData({
|
|
92
|
-
scaleFunction: xScale,
|
|
93
|
-
ticks,
|
|
94
|
-
requestedTickCount: requestedTickCount != null ? requestedTickCount : layout === 'horizontal' ? 5 : undefined,
|
|
95
|
-
categories,
|
|
96
|
-
possibleTickValues: axisData && Array.isArray(axisData) && typeof axisData[0] === 'string' ? Array.from({
|
|
97
|
-
length: axisData.length
|
|
98
|
-
}, (_, i) => i) : undefined,
|
|
99
|
-
tickInterval: tickInterval,
|
|
100
|
-
options: {
|
|
101
|
-
minStep: tickMinStep,
|
|
102
|
-
maxStep: tickMaxStep
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis == null ? void 0 : xAxis.data, layout]);
|
|
106
|
-
const isBandScale = useMemo(() => {
|
|
107
|
-
if (!xScale) return false;
|
|
108
|
-
return isCategoricalScale(xScale);
|
|
109
|
-
}, [xScale]);
|
|
110
|
-
|
|
111
|
-
// Compute grid line positions (including bounds closing line for band scales)
|
|
112
|
-
const gridLinePositions = useMemo(() => {
|
|
113
|
-
if (!xScale) return [];
|
|
114
|
-
return ticksData.flatMap((tick, index) => {
|
|
115
|
-
if (!isBandScale) {
|
|
116
|
-
return [{
|
|
117
|
-
x: tick.position,
|
|
118
|
-
key: "grid-" + tick.tick + "-" + index
|
|
119
|
-
}];
|
|
120
|
-
}
|
|
121
|
-
const bandScale = xScale;
|
|
122
|
-
const isLastTick = index === ticksData.length - 1;
|
|
123
|
-
const isEdges = bandGridLinePlacement === 'edges';
|
|
124
|
-
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
|
|
125
|
-
const positions = [{
|
|
126
|
-
x: startX,
|
|
127
|
-
key: "grid-" + tick.tick + "-" + index
|
|
128
|
-
}];
|
|
129
|
-
|
|
130
|
-
// For edges on last tick, add the closing line at stepEnd
|
|
131
|
-
if (isLastTick && isEdges) {
|
|
132
|
-
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
133
|
-
positions.push({
|
|
134
|
-
x: endX,
|
|
135
|
-
key: "grid-" + tick.tick + "-" + index + "-end"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return positions;
|
|
139
|
-
});
|
|
140
|
-
}, [ticksData, xScale, isBandScale, bandGridLinePlacement]);
|
|
141
|
-
|
|
142
|
-
// Compute tick mark positions (including bounds closing tick for band scales)
|
|
143
|
-
const tickMarkPositions = useMemo(() => {
|
|
144
|
-
if (!xScale) return [];
|
|
145
|
-
return ticksData.flatMap((tick, index) => {
|
|
146
|
-
if (!isBandScale) {
|
|
147
|
-
return [{
|
|
148
|
-
x: tick.position,
|
|
149
|
-
key: "tick-mark-" + tick.tick + "-" + index
|
|
150
|
-
}];
|
|
151
|
-
}
|
|
152
|
-
const bandScale = xScale;
|
|
153
|
-
const isLastTick = index === ticksData.length - 1;
|
|
154
|
-
const isEdges = bandTickMarkPlacement === 'edges';
|
|
155
|
-
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
|
|
156
|
-
const positions = [{
|
|
157
|
-
x: startX,
|
|
158
|
-
key: "tick-mark-" + tick.tick + "-" + index
|
|
159
|
-
}];
|
|
160
|
-
|
|
161
|
-
// For edges on last tick, add the closing tick mark at stepEnd
|
|
162
|
-
if (isLastTick && isEdges) {
|
|
163
|
-
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
164
|
-
positions.push({
|
|
165
|
-
x: endX,
|
|
166
|
-
key: "tick-mark-" + tick.tick + "-" + index + "-end"
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
return positions;
|
|
170
|
-
});
|
|
171
|
-
}, [ticksData, xScale, isBandScale, bandTickMarkPlacement]);
|
|
172
|
-
const chartTextData = useMemo(() => {
|
|
173
|
-
if (!axisBounds) return null;
|
|
174
|
-
return ticksData.map(tick => {
|
|
175
|
-
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
176
|
-
|
|
177
|
-
// Use AXIS_HEIGHT for centering, not full axisBounds.height
|
|
178
|
-
// This ensures tick labels are centered in the axis area, not including label space
|
|
179
|
-
const availableSpace = AXIS_HEIGHT - tickOffset;
|
|
180
|
-
const labelOffset = availableSpace / 2;
|
|
181
|
-
const labelY = position === 'top' ? axisBounds.y + axisBounds.height - tickOffset - labelOffset : axisBounds.y + labelOffset + tickOffset;
|
|
182
|
-
return {
|
|
183
|
-
x: tick.position,
|
|
184
|
-
y: labelY,
|
|
185
|
-
label: String(formatTick(tick.tick)),
|
|
186
|
-
chartTextProps: {
|
|
187
|
-
color: theme.color.fgMuted,
|
|
188
|
-
verticalAlignment: 'middle',
|
|
189
|
-
horizontalAlignment: 'center'
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
});
|
|
193
|
-
}, [axisBounds, ticksData, theme.color.fgMuted, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick]);
|
|
194
|
-
if (!xScale || !axisBounds) return;
|
|
195
|
-
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
196
|
-
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
197
|
-
|
|
198
|
-
// Pre-compute tick mark Y coordinates
|
|
199
|
-
const tickYTop = axisBounds.y;
|
|
200
|
-
const tickYBottom = axisBounds.y + axisBounds.height;
|
|
201
|
-
const tickYStart = position === 'bottom' ? tickYTop : tickYBottom;
|
|
202
|
-
const tickYEnd = position === 'bottom' ? tickYTop + tickMarkSize : tickYBottom - tickMarkSize;
|
|
203
|
-
|
|
204
|
-
// Note: Unlike web, mobile renders grid lines and tick marks immediately without fade animation.
|
|
205
|
-
// This is because Skia can measure text dimensions synchronously, so there's no need to hide
|
|
206
|
-
// elements while waiting for measurements (web uses async ResizeObserver).
|
|
207
|
-
return /*#__PURE__*/_jsxs(Group, {
|
|
208
|
-
children: [showGrid && /*#__PURE__*/_jsx(Group, {
|
|
209
|
-
children: gridLinePositions.map(_ref2 => {
|
|
210
|
-
let {
|
|
211
|
-
x,
|
|
212
|
-
key
|
|
213
|
-
} = _ref2;
|
|
214
|
-
return /*#__PURE__*/_jsx(GridLineComponent, {
|
|
215
|
-
animate: false,
|
|
216
|
-
clipPath: null,
|
|
217
|
-
d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
|
|
218
|
-
stroke: theme.color.bgLine
|
|
219
|
-
}, key);
|
|
220
|
-
})
|
|
221
|
-
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
222
|
-
prioritizeEndLabels: true,
|
|
223
|
-
LabelComponent: TickLabelComponent,
|
|
224
|
-
labels: chartTextData,
|
|
225
|
-
minGap: minTickLabelGap
|
|
226
|
-
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
227
|
-
children: tickMarkPositions.map(_ref3 => {
|
|
228
|
-
let {
|
|
229
|
-
x,
|
|
230
|
-
key
|
|
231
|
-
} = _ref3;
|
|
232
|
-
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
233
|
-
animate: false,
|
|
234
|
-
clipPath: null,
|
|
235
|
-
d: lineToPath(x, tickYStart, x, tickYEnd),
|
|
236
|
-
stroke: theme.color.fg,
|
|
237
|
-
strokeCap: "square",
|
|
238
|
-
strokeWidth: 1
|
|
239
|
-
}, key);
|
|
240
|
-
})
|
|
241
|
-
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
242
|
-
animate: false,
|
|
243
|
-
clipPath: null,
|
|
244
|
-
d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
|
|
245
|
-
stroke: theme.color.fg,
|
|
246
|
-
strokeCap: "square",
|
|
247
|
-
strokeWidth: 1
|
|
248
|
-
}), label && /*#__PURE__*/_jsx(ChartText, {
|
|
249
|
-
horizontalAlignment: "center",
|
|
250
|
-
verticalAlignment: "middle",
|
|
251
|
-
x: labelX,
|
|
252
|
-
y: labelY,
|
|
253
|
-
children: label
|
|
254
|
-
})]
|
|
255
|
-
});
|
|
256
|
-
});
|
package/esm/chart/axis/YAxis.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
2
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
3
|
-
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
-
import { Group, vec } from '@shopify/react-native-skia';
|
|
6
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
-
import { DottedLine } from '../line/DottedLine';
|
|
8
|
-
import { SolidLine } from '../line/SolidLine';
|
|
9
|
-
import { ChartText } from '../text/ChartText';
|
|
10
|
-
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
11
|
-
import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
|
|
12
|
-
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const AXIS_WIDTH = 44;
|
|
15
|
-
const LABEL_SIZE = 20;
|
|
16
|
-
export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
17
|
-
let {
|
|
18
|
-
axisId,
|
|
19
|
-
position = 'right',
|
|
20
|
-
showGrid,
|
|
21
|
-
requestedTickCount,
|
|
22
|
-
ticks,
|
|
23
|
-
tickLabelFormatter,
|
|
24
|
-
TickLabelComponent = DefaultAxisTickLabel,
|
|
25
|
-
GridLineComponent = DottedLine,
|
|
26
|
-
LineComponent = SolidLine,
|
|
27
|
-
TickMarkLineComponent = SolidLine,
|
|
28
|
-
tickMarkLabelGap = 8,
|
|
29
|
-
minTickLabelGap = 0,
|
|
30
|
-
showTickMarks,
|
|
31
|
-
showLine,
|
|
32
|
-
tickMarkSize = 4,
|
|
33
|
-
tickInterval,
|
|
34
|
-
label,
|
|
35
|
-
labelGap = 4,
|
|
36
|
-
width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH,
|
|
37
|
-
bandGridLinePlacement = 'edges',
|
|
38
|
-
bandTickMarkPlacement = 'middle'
|
|
39
|
-
} = _ref,
|
|
40
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
41
|
-
const theme = useTheme();
|
|
42
|
-
const registrationId = useId();
|
|
43
|
-
const {
|
|
44
|
-
animate,
|
|
45
|
-
drawingArea,
|
|
46
|
-
layout,
|
|
47
|
-
getYScale,
|
|
48
|
-
getYAxis,
|
|
49
|
-
registerAxis,
|
|
50
|
-
unregisterAxis,
|
|
51
|
-
getAxisBounds
|
|
52
|
-
} = useCartesianChartContext();
|
|
53
|
-
const yScale = getYScale(axisId);
|
|
54
|
-
const yAxis = getYAxis(axisId);
|
|
55
|
-
const axisBounds = getAxisBounds(registrationId);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
registerAxis(registrationId, position, width);
|
|
58
|
-
return () => unregisterAxis(registrationId);
|
|
59
|
-
}, [registrationId, registerAxis, unregisterAxis, position, width]);
|
|
60
|
-
const formatTick = useCallback(value => {
|
|
61
|
-
var _tickLabelFormatter;
|
|
62
|
-
// If we have string labels and no custom formatter, use the labels
|
|
63
|
-
const axisData = yAxis == null ? void 0 : yAxis.data;
|
|
64
|
-
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
65
|
-
if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
|
|
66
|
-
// Use the string label from the data array
|
|
67
|
-
return axisData[value];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Otherwise use the formatter (if provided) or the value itself
|
|
71
|
-
return (_tickLabelFormatter = tickLabelFormatter == null ? void 0 : tickLabelFormatter(value)) != null ? _tickLabelFormatter : value;
|
|
72
|
-
}, [yAxis == null ? void 0 : yAxis.data, tickLabelFormatter]);
|
|
73
|
-
|
|
74
|
-
// Use D3 to get the ticks data
|
|
75
|
-
// Result contains each tick value and its axis position
|
|
76
|
-
const ticksData = useMemo(() => {
|
|
77
|
-
if (!yScale) return [];
|
|
78
|
-
|
|
79
|
-
// Check if we have string labels
|
|
80
|
-
const axisData = yAxis == null ? void 0 : yAxis.data;
|
|
81
|
-
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
82
|
-
|
|
83
|
-
// For band scales, we need categories
|
|
84
|
-
let categories;
|
|
85
|
-
if (hasStringLabels) {
|
|
86
|
-
categories = axisData;
|
|
87
|
-
} else if (isCategoricalScale(yScale)) {
|
|
88
|
-
// For band scales without explicit string data, generate numeric categories
|
|
89
|
-
// based on the domain of the scale
|
|
90
|
-
const domain = yScale.domain();
|
|
91
|
-
categories = domain.map(String);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// For numeric data or no explicit data, use default tick generation
|
|
95
|
-
return getAxisTicksData({
|
|
96
|
-
scaleFunction: yScale,
|
|
97
|
-
ticks,
|
|
98
|
-
requestedTickCount: tickInterval !== undefined ? undefined : requestedTickCount != null ? requestedTickCount : layout === 'horizontal' ? undefined : 5,
|
|
99
|
-
categories,
|
|
100
|
-
possibleTickValues: axisData && Array.isArray(axisData) && typeof axisData[0] === 'number' ? axisData : undefined,
|
|
101
|
-
tickInterval: tickInterval
|
|
102
|
-
});
|
|
103
|
-
}, [ticks, yScale, requestedTickCount, tickInterval, yAxis == null ? void 0 : yAxis.data, layout]);
|
|
104
|
-
const isBandScale = useMemo(() => {
|
|
105
|
-
if (!yScale) return false;
|
|
106
|
-
return isCategoricalScale(yScale);
|
|
107
|
-
}, [yScale]);
|
|
108
|
-
|
|
109
|
-
// Compute grid line positions (including bounds closing line for band scales)
|
|
110
|
-
const gridLinePositions = useMemo(() => {
|
|
111
|
-
if (!yScale) return [];
|
|
112
|
-
return ticksData.flatMap((tick, index) => {
|
|
113
|
-
if (!isBandScale) {
|
|
114
|
-
return [{
|
|
115
|
-
y: tick.position,
|
|
116
|
-
key: "grid-" + tick.tick + "-" + index
|
|
117
|
-
}];
|
|
118
|
-
}
|
|
119
|
-
const bandScale = yScale;
|
|
120
|
-
const isLastTick = index === ticksData.length - 1;
|
|
121
|
-
const isEdges = bandGridLinePlacement === 'edges';
|
|
122
|
-
const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
|
|
123
|
-
const positions = [{
|
|
124
|
-
y: startY,
|
|
125
|
-
key: "grid-" + tick.tick + "-" + index
|
|
126
|
-
}];
|
|
127
|
-
|
|
128
|
-
// For edges on last tick, add the closing line at stepEnd
|
|
129
|
-
if (isLastTick && isEdges) {
|
|
130
|
-
const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
131
|
-
positions.push({
|
|
132
|
-
y: endY,
|
|
133
|
-
key: "grid-" + tick.tick + "-" + index + "-end"
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return positions;
|
|
137
|
-
});
|
|
138
|
-
}, [ticksData, yScale, isBandScale, bandGridLinePlacement]);
|
|
139
|
-
|
|
140
|
-
// Compute tick mark positions (including bounds closing tick for band scales)
|
|
141
|
-
const tickMarkPositions = useMemo(() => {
|
|
142
|
-
if (!yScale) return [];
|
|
143
|
-
return ticksData.flatMap((tick, index) => {
|
|
144
|
-
if (!isBandScale) {
|
|
145
|
-
return [{
|
|
146
|
-
y: tick.position,
|
|
147
|
-
key: "tick-mark-" + tick.tick + "-" + index
|
|
148
|
-
}];
|
|
149
|
-
}
|
|
150
|
-
const bandScale = yScale;
|
|
151
|
-
const isLastTick = index === ticksData.length - 1;
|
|
152
|
-
const isEdges = bandTickMarkPlacement === 'edges';
|
|
153
|
-
const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
|
|
154
|
-
const positions = [{
|
|
155
|
-
y: startY,
|
|
156
|
-
key: "tick-mark-" + tick.tick + "-" + index
|
|
157
|
-
}];
|
|
158
|
-
|
|
159
|
-
// For edges on last tick, add the closing tick mark at stepEnd
|
|
160
|
-
if (isLastTick && isEdges) {
|
|
161
|
-
const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
162
|
-
positions.push({
|
|
163
|
-
y: endY,
|
|
164
|
-
key: "tick-mark-" + tick.tick + "-" + index + "-end"
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return positions;
|
|
168
|
-
});
|
|
169
|
-
}, [ticksData, yScale, isBandScale, bandTickMarkPlacement]);
|
|
170
|
-
const chartTextData = useMemo(() => {
|
|
171
|
-
if (!axisBounds) return null;
|
|
172
|
-
return ticksData.map(tick => {
|
|
173
|
-
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
174
|
-
const labelX = position === 'left' ? axisBounds.x + axisBounds.width - tickOffset : axisBounds.x + tickOffset;
|
|
175
|
-
return {
|
|
176
|
-
x: labelX,
|
|
177
|
-
y: tick.position,
|
|
178
|
-
label: String(formatTick(tick.tick)),
|
|
179
|
-
chartTextProps: {
|
|
180
|
-
color: theme.color.fgMuted,
|
|
181
|
-
verticalAlignment: 'middle',
|
|
182
|
-
horizontalAlignment: position === 'left' ? 'right' : 'left'
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, theme.color.fgMuted]);
|
|
187
|
-
if (!yScale || !axisBounds) return;
|
|
188
|
-
const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
|
|
189
|
-
const labelY = axisBounds.y + axisBounds.height / 2;
|
|
190
|
-
|
|
191
|
-
// Pre-compute tick mark X coordinates
|
|
192
|
-
const tickXLeft = axisBounds.x;
|
|
193
|
-
const tickXRight = axisBounds.x + axisBounds.width;
|
|
194
|
-
const tickXStart = position === 'left' ? tickXRight : tickXLeft;
|
|
195
|
-
const tickXEnd = position === 'left' ? tickXRight - tickMarkSize : tickXLeft + tickMarkSize;
|
|
196
|
-
|
|
197
|
-
// Note: Unlike web, mobile renders grid lines and tick marks immediately without fade animation.
|
|
198
|
-
// This is because Skia can measure text dimensions synchronously, so there's no need to hide
|
|
199
|
-
// elements while waiting for measurements (web uses async ResizeObserver).
|
|
200
|
-
return /*#__PURE__*/_jsxs(Group, {
|
|
201
|
-
children: [showGrid && /*#__PURE__*/_jsx(Group, {
|
|
202
|
-
children: gridLinePositions.map(_ref2 => {
|
|
203
|
-
let {
|
|
204
|
-
y,
|
|
205
|
-
key
|
|
206
|
-
} = _ref2;
|
|
207
|
-
return /*#__PURE__*/_jsx(GridLineComponent, {
|
|
208
|
-
animate: false,
|
|
209
|
-
clipPath: null,
|
|
210
|
-
d: lineToPath(drawingArea.x, y, drawingArea.x + drawingArea.width, y),
|
|
211
|
-
stroke: theme.color.bgLine
|
|
212
|
-
}, key);
|
|
213
|
-
})
|
|
214
|
-
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
215
|
-
prioritizeEndLabels: true,
|
|
216
|
-
LabelComponent: TickLabelComponent,
|
|
217
|
-
labels: chartTextData,
|
|
218
|
-
minGap: minTickLabelGap
|
|
219
|
-
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx(Group, {
|
|
220
|
-
children: tickMarkPositions.map(_ref3 => {
|
|
221
|
-
let {
|
|
222
|
-
y,
|
|
223
|
-
key
|
|
224
|
-
} = _ref3;
|
|
225
|
-
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
226
|
-
animate: false,
|
|
227
|
-
clipPath: null,
|
|
228
|
-
d: lineToPath(tickXStart, y, tickXEnd, y),
|
|
229
|
-
stroke: theme.color.fg,
|
|
230
|
-
strokeCap: "square",
|
|
231
|
-
strokeWidth: 1
|
|
232
|
-
}, key);
|
|
233
|
-
})
|
|
234
|
-
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
235
|
-
animate: false,
|
|
236
|
-
clipPath: null,
|
|
237
|
-
d: lineToPath(position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y, position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y + axisBounds.height),
|
|
238
|
-
stroke: theme.color.fg,
|
|
239
|
-
strokeCap: "square",
|
|
240
|
-
strokeWidth: 1
|
|
241
|
-
}), label && /*#__PURE__*/_jsx(Group, {
|
|
242
|
-
origin: vec(labelX, labelY),
|
|
243
|
-
transform: [{
|
|
244
|
-
rotate: position === 'left' ? -Math.PI / 2 : Math.PI / 2
|
|
245
|
-
}],
|
|
246
|
-
children: /*#__PURE__*/_jsx(ChartText, {
|
|
247
|
-
horizontalAlignment: "center",
|
|
248
|
-
verticalAlignment: "middle",
|
|
249
|
-
x: labelX,
|
|
250
|
-
y: labelY,
|
|
251
|
-
children: label
|
|
252
|
-
})
|
|
253
|
-
})]
|
|
254
|
-
});
|
|
255
|
-
});
|