@coinbase/cds-mobile-visualization 3.3.0 → 3.4.0-beta.10
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 +80 -0
- package/dts/chart/CartesianChart.d.ts +125 -0
- package/dts/chart/CartesianChart.d.ts.map +1 -0
- package/dts/chart/ChartContextBridge.d.ts +28 -0
- package/dts/chart/ChartContextBridge.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +6 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +91 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +85 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +77 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +131 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +46 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +36 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +23 -0
- package/dts/chart/area/SolidArea.d.ts.map +1 -0
- package/dts/chart/area/index.d.ts +6 -0
- package/dts/chart/area/index.d.ts.map +1 -0
- package/dts/chart/axis/Axis.d.ts +194 -0
- package/dts/chart/axis/Axis.d.ts.map +1 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +16 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -0
- package/dts/chart/axis/YAxis.d.ts +21 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -0
- package/dts/chart/axis/index.d.ts +5 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +92 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +113 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +30 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +102 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +36 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBar.d.ts +7 -0
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBarStack.d.ts +7 -0
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
- package/dts/chart/bar/index.d.ts +8 -0
- package/dts/chart/bar/index.d.ts.map +1 -0
- package/dts/chart/gradient/Gradient.d.ts +25 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +15 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +20 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +115 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +118 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +139 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +15 -0
- package/dts/chart/line/SolidLine.d.ts.map +1 -0
- package/dts/chart/line/index.d.ts +7 -0
- package/dts/chart/line/index.d.ts.map +1 -0
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +120 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +233 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts +20 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +5 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +164 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/ChartTextGroup.d.ts +61 -0
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +3 -0
- package/dts/chart/text/index.d.ts.map +1 -0
- package/dts/chart/utils/axis.d.ts +342 -0
- package/dts/chart/utils/axis.d.ts.map +1 -0
- package/dts/chart/utils/bar.d.ts +20 -0
- package/dts/chart/utils/bar.d.ts.map +1 -0
- package/dts/chart/utils/chart.d.ts +124 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +116 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/gradient.d.ts +117 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +11 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +160 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +134 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +134 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +140 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/dts/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Counter.d.ts +7 -2
- package/dts/sparkline/Sparkline.d.ts +67 -16
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +10 -4
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +12 -4
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +21 -10
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +8 -2
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +8 -3
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +132 -110
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +22 -9
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +18 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +9 -4
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +7 -5
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +22 -10
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +21 -7
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +21 -16
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +29 -23
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +22 -14
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +9 -5
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +11 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +5 -2
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +17 -17
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +16 -13
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +106 -98
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +1 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +22 -19
- package/esm/chart/CartesianChart.js +335 -0
- package/esm/chart/ChartContextBridge.js +148 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +218 -0
- package/esm/chart/PeriodSelector.js +136 -0
- package/esm/chart/__stories__/CartesianChart.stories.js +723 -0
- package/esm/chart/__stories__/Chart.stories.js +77 -0
- package/esm/chart/__stories__/PeriodSelector.stories.js +322 -0
- package/esm/chart/area/Area.js +75 -0
- package/esm/chart/area/AreaChart.js +151 -0
- package/esm/chart/area/DottedArea.js +80 -0
- package/esm/chart/area/GradientArea.js +54 -0
- package/esm/chart/area/SolidArea.js +38 -0
- package/esm/chart/area/__stories__/AreaChart.stories.js +100 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +45 -0
- package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
- package/esm/chart/axis/XAxis.js +188 -0
- package/esm/chart/axis/YAxis.js +177 -0
- package/esm/chart/axis/__stories__/Axis.stories.js +276 -0
- package/esm/chart/axis/index.js +6 -0
- package/esm/chart/bar/Bar.js +69 -0
- package/esm/chart/bar/BarChart.js +125 -0
- package/esm/chart/bar/BarPlot.js +102 -0
- package/esm/chart/bar/BarStack.js +551 -0
- package/esm/chart/bar/BarStackGroup.js +79 -0
- package/esm/chart/bar/DefaultBar.js +56 -0
- package/esm/chart/bar/DefaultBarStack.js +47 -0
- package/esm/chart/bar/__stories__/BarChart.stories.js +668 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/gradient/Gradient.js +53 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +16 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
- package/esm/chart/line/DottedLine.js +50 -0
- package/esm/chart/line/Line.js +178 -0
- package/esm/chart/line/LineChart.js +121 -0
- package/esm/chart/line/ReferenceLine.js +132 -0
- package/esm/chart/line/SolidLine.js +46 -0
- package/esm/chart/line/__stories__/LineChart.stories.js +2372 -0
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +132 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/point/DefaultPointLabel.js +39 -0
- package/esm/chart/point/Point.js +188 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
- package/esm/chart/scrubber/Scrubber.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
- package/esm/chart/scrubber/ScrubberProvider.js +135 -0
- package/esm/chart/scrubber/index.js +4 -0
- package/esm/chart/text/ChartText.js +305 -0
- package/esm/chart/text/ChartTextGroup.js +211 -0
- package/esm/chart/text/index.js +4 -0
- package/esm/chart/utils/axis.js +592 -0
- package/esm/chart/utils/bar.js +24 -0
- package/esm/chart/utils/chart.js +270 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/gradient.js +305 -0
- package/esm/chart/utils/index.js +12 -0
- package/esm/chart/utils/path.js +274 -0
- package/esm/chart/utils/point.js +229 -0
- package/esm/chart/utils/scale.js +277 -0
- package/esm/chart/utils/scrubber.js +139 -0
- package/esm/chart/utils/transition.js +185 -0
- package/esm/index.js +4 -1
- package/esm/sparkline/Sparkline.js +129 -16
- package/esm/sparkline/SparklineArea.js +7 -2
- package/esm/sparkline/SparklineAreaPattern.js +4 -2
- package/esm/sparkline/SparklineGradient.js +4 -0
- package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
- package/esm/sparkline/generateSparklineWithId.js +3 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +76 -24
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
- package/package.json +17 -11
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/Sparkline.stories.d.ts.map +0 -1
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts +0 -3
- package/dts/sparkline/__stories__/SparklineGradient.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts +0 -3
- package/dts/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractive.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveHoverDate.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePanGestureHandler.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractivePeriodSelector.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/SparklineInteractiveTimeseriesPaths.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__tests__/useMinMaxTransform.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts +0 -4
- package/dts/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/SparklineInteractiveHeader.test.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__tests__/useSparklineInteractiveHeaderStyles.test.d.ts.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { AnimatedProp } from '@shopify/react-native-skia';
|
|
2
|
+
import type { GradientDefinition } from './gradient';
|
|
3
|
+
export declare const defaultStackId = 'DEFAULT_STACK_ID';
|
|
4
|
+
export type AxisBounds = {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if bounds are complete with both min and max values.
|
|
10
|
+
* @param bounds - The bounds to validate
|
|
11
|
+
* @returns True if bounds has both min and max defined
|
|
12
|
+
*/
|
|
13
|
+
export declare const isValidBounds: (bounds: Partial<AxisBounds>) => bounds is AxisBounds;
|
|
14
|
+
export type Series = {
|
|
15
|
+
/**
|
|
16
|
+
* Id of the series.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Data array for this series. Use null values to create gaps in the visualization.
|
|
21
|
+
*
|
|
22
|
+
* Can be either:
|
|
23
|
+
* - Array of numbers: `[10, -5, 20]`
|
|
24
|
+
* - Array of tuples: `[[0, 10], [0, -5], [0, 20]]` [baseline, value] pairs
|
|
25
|
+
*/
|
|
26
|
+
data?: Array<number | null> | Array<[number, number] | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Label of the series.
|
|
29
|
+
* Used for scrubber beacon labels.
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Color for the series.
|
|
34
|
+
* If gradient is provided, that will be used for chart components
|
|
35
|
+
* Color will still be used by scrubber beacon labels
|
|
36
|
+
*/
|
|
37
|
+
color?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Color gradient configuration.
|
|
40
|
+
* Takes precedence over color except for scrubber beacon labels.
|
|
41
|
+
*/
|
|
42
|
+
gradient?: GradientDefinition;
|
|
43
|
+
/**
|
|
44
|
+
* Id of the y-axis this series uses.
|
|
45
|
+
* Defaults to defaultAxisId if not specified.
|
|
46
|
+
*/
|
|
47
|
+
yAxisId?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Id of the stack group this series belongs to.
|
|
50
|
+
* Series with the same stackId value will be stacked together.
|
|
51
|
+
* If not specified, the series will not be stacked.
|
|
52
|
+
*/
|
|
53
|
+
stackId?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Calculates the domain of a chart from series data.
|
|
57
|
+
* Domain represents the range of x-values from the data.
|
|
58
|
+
*/
|
|
59
|
+
export declare const getChartDomain: (
|
|
60
|
+
series: Series[],
|
|
61
|
+
min?: number,
|
|
62
|
+
max?: number,
|
|
63
|
+
) => Partial<AxisBounds>;
|
|
64
|
+
/**
|
|
65
|
+
* Transforms series data into stacked data using D3's stack algorithm.
|
|
66
|
+
* Returns a map of series ID to transformed [baseline, value] tuples.
|
|
67
|
+
*
|
|
68
|
+
* @param series - Array of series with potential stack properties
|
|
69
|
+
* @returns Map of series ID to stacked data arrays
|
|
70
|
+
*/
|
|
71
|
+
export declare const getStackedSeriesData: (
|
|
72
|
+
series: Series[],
|
|
73
|
+
) => Map<string, Array<[number, number] | null>>;
|
|
74
|
+
/**
|
|
75
|
+
* Extracts line data values from series data that may contain tuples.
|
|
76
|
+
* For tuple data [[baseline, value]], extracts the last value.
|
|
77
|
+
* For numeric data [value], returns as-is.
|
|
78
|
+
*
|
|
79
|
+
* @param data - Array of numbers, tuples, or null values
|
|
80
|
+
* @returns Array of numbers or null values
|
|
81
|
+
*/
|
|
82
|
+
export declare const getLineData: (
|
|
83
|
+
data?: Array<number | null> | Array<[number, number] | null>,
|
|
84
|
+
) => Array<number | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Calculates the range of a chart from series data.
|
|
87
|
+
* Range represents the range of y-values from the data.
|
|
88
|
+
* Handles stacking by transforming data when series have stack properties.
|
|
89
|
+
*/
|
|
90
|
+
export declare const getChartRange: (
|
|
91
|
+
series: Series[],
|
|
92
|
+
min?: number,
|
|
93
|
+
max?: number,
|
|
94
|
+
) => Partial<AxisBounds>;
|
|
95
|
+
export type ChartInset = {
|
|
96
|
+
top: number;
|
|
97
|
+
left: number;
|
|
98
|
+
bottom: number;
|
|
99
|
+
right: number;
|
|
100
|
+
};
|
|
101
|
+
export declare const defaultChartInset: ChartInset;
|
|
102
|
+
/**
|
|
103
|
+
* Normalize padding to include all sides with a value.
|
|
104
|
+
* @param padding - The padding to get.
|
|
105
|
+
* @param defaults - Optional complete default values to use instead of 0.
|
|
106
|
+
* @returns The calculated padding.
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Normalize inset to include all sides with a value.
|
|
110
|
+
* @param inset - The inset to get.
|
|
111
|
+
* @param defaults - Optional complete default values to use instead of 0.
|
|
112
|
+
* @returns The calculated inset.
|
|
113
|
+
*/
|
|
114
|
+
export declare const getChartInset: (
|
|
115
|
+
inset?: number | Partial<ChartInset>,
|
|
116
|
+
defaults?: ChartInset,
|
|
117
|
+
) => ChartInset;
|
|
118
|
+
/**
|
|
119
|
+
* Unwraps an optionally animated value to get the raw value.
|
|
120
|
+
* @param value - The value to unwrap.
|
|
121
|
+
* @returns The raw value.
|
|
122
|
+
*/
|
|
123
|
+
export declare const unwrapAnimatedValue: <T>(value: AnimatedProp<T>) => T;
|
|
124
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/chart.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,CAAC,UAAU,CAAC,KAAG,MAAM,IAAI,UAChB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7D;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CAoBpB,CAAC;AAcF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EAAE,KACf,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CA0E5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAC3D,KAAK,CAAC,MAAM,GAAG,IAAI,CAerB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EAAE,EAChB,MAAM,MAAM,EACZ,MAAM,MAAM,KACX,OAAO,CAAC,UAAU,CA2EpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF;;;;;GAKG;AACH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,EACpC,WAAW,UAAU,KACpB,UAuBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,OAAO,YAAY,CAAC,CAAC,CAAC,KAAG,CAM/D,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { Rect } from '@coinbase/cds-common/types';
|
|
3
|
+
import type { SkTypefaceFontProvider } from '@shopify/react-native-skia';
|
|
4
|
+
import type { AxisConfig } from './axis';
|
|
5
|
+
import type { Series } from './chart';
|
|
6
|
+
import type { ChartScaleFunction, SerializableScale } from './scale';
|
|
7
|
+
/**
|
|
8
|
+
* Context value for Cartesian (X/Y) coordinate charts.
|
|
9
|
+
* Contains axis-specific methods and properties for rectangular coordinate systems.
|
|
10
|
+
*/
|
|
11
|
+
export type CartesianChartContextValue = {
|
|
12
|
+
/**
|
|
13
|
+
* The series data for the chart.
|
|
14
|
+
*/
|
|
15
|
+
series: Series[];
|
|
16
|
+
/**
|
|
17
|
+
* Returns the series which matches the seriesId or undefined.
|
|
18
|
+
* @param seriesId - A series' id
|
|
19
|
+
*/
|
|
20
|
+
getSeries: (seriesId?: string) => Series | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the data for a series
|
|
23
|
+
* @param seriesId - A series' id
|
|
24
|
+
* @returns data for series, if series exists
|
|
25
|
+
*/
|
|
26
|
+
getSeriesData: (seriesId?: string) => Array<[number, number] | null> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to animate the chart.
|
|
29
|
+
*/
|
|
30
|
+
animate: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Width of the chart SVG.
|
|
33
|
+
*/
|
|
34
|
+
width: number;
|
|
35
|
+
/**
|
|
36
|
+
* Height of the chart SVG.
|
|
37
|
+
*/
|
|
38
|
+
height: number;
|
|
39
|
+
/**
|
|
40
|
+
* Default font families to use within ChartText.
|
|
41
|
+
* When not set, should use the default for the system.
|
|
42
|
+
*/
|
|
43
|
+
fontFamilies?: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Skia font provider.
|
|
46
|
+
*/
|
|
47
|
+
fontProvider: SkTypefaceFontProvider;
|
|
48
|
+
/**
|
|
49
|
+
* Get x-axis configuration.
|
|
50
|
+
*/
|
|
51
|
+
getXAxis: () => AxisConfig | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get y-axis configuration by ID.
|
|
54
|
+
* @param id - The axis ID. Defaults to defaultAxisId.
|
|
55
|
+
*/
|
|
56
|
+
getYAxis: (id?: string) => AxisConfig | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Get x-axis scale function.
|
|
59
|
+
*/
|
|
60
|
+
getXScale: () => ChartScaleFunction | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Get y-axis scale function by ID.
|
|
63
|
+
* @param id - The axis ID. Defaults to defaultAxisId.
|
|
64
|
+
*/
|
|
65
|
+
getYScale: (id?: string) => ChartScaleFunction | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Get x-axis serializable scale function that can be used in worklets.
|
|
68
|
+
*/
|
|
69
|
+
getXSerializableScale: () => SerializableScale | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get y-axis serializable scale function by ID that can be used in worklets.
|
|
72
|
+
* @param id - The axis ID. Defaults to defaultAxisId.
|
|
73
|
+
*/
|
|
74
|
+
getYSerializableScale: (id?: string) => SerializableScale | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Drawing area of the chart.
|
|
77
|
+
*/
|
|
78
|
+
drawingArea: Rect;
|
|
79
|
+
/**
|
|
80
|
+
* Length of the data domain.
|
|
81
|
+
* This is equal to the length of xAxis.data or the longest series data length
|
|
82
|
+
* This equals the number of possible scrubber positions
|
|
83
|
+
*/
|
|
84
|
+
dataLength: number;
|
|
85
|
+
/**
|
|
86
|
+
* Registers an axis.
|
|
87
|
+
* Used by axis components to reserve space in the chart, preventing overlap with the drawing area.
|
|
88
|
+
* @param id - The axis ID
|
|
89
|
+
* @param position - The axis position ('top'/'bottom' for x-axis, 'left'/'right' for y-axis)
|
|
90
|
+
* @param size - The size of the axis in pixels
|
|
91
|
+
*/
|
|
92
|
+
registerAxis: (id: string, position: 'top' | 'bottom' | 'left' | 'right', size: number) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Unregisters an axis.
|
|
95
|
+
*/
|
|
96
|
+
unregisterAxis: (id: string) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the rectangle bounds of a requested axis.
|
|
99
|
+
* Computes the bounds of the axis based on the chart's drawing area chart/axis config, and axis position.
|
|
100
|
+
*/
|
|
101
|
+
getAxisBounds: (id: string) => Rect | undefined;
|
|
102
|
+
};
|
|
103
|
+
export type ScrubberContextValue = {
|
|
104
|
+
/**
|
|
105
|
+
* Enables scrubbing interactions.
|
|
106
|
+
* When true, allows scrubbing and makes scrubber components interactive.
|
|
107
|
+
*/
|
|
108
|
+
enableScrubbing: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The current position of the scrubber.
|
|
111
|
+
*/
|
|
112
|
+
scrubberPosition: SharedValue<number | undefined>;
|
|
113
|
+
};
|
|
114
|
+
export declare const ScrubberContext: import('react').Context<ScrubberContextValue | undefined>;
|
|
115
|
+
export declare const useScrubberContext: () => ScrubberContextValue;
|
|
116
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACrD;;;;OAIG;IACH,aAAa,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACjF;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,YAAY,EAAE,sBAAsB,CAAC;IACrC;;OAEG;IACH,QAAQ,EAAE,MAAM,UAAU,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAClD;;OAEG;IACH,SAAS,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAC;IAChD;;;OAGG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,kBAAkB,GAAG,SAAS,CAAC;IAC3D;;OAEG;IACH,qBAAqB,EAAE,MAAM,iBAAiB,GAAG,SAAS,CAAC;IAC3D;;;OAGG;IACH,qBAAqB,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IACtE;;OAEG;IACH,WAAW,EAAE,IAAI,CAAC;IAClB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChG;;OAEG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,eAAe,2DAA6D,CAAC;AAE1F,eAAO,MAAM,kBAAkB,QAAO,oBAMrC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { AxisBounds } from './chart';
|
|
2
|
+
import { type ChartScaleFunction, type SerializableScale } from './scale';
|
|
3
|
+
/**
|
|
4
|
+
* Defines a color transition point in the gradient
|
|
5
|
+
*/
|
|
6
|
+
export type GradientStop = {
|
|
7
|
+
/**
|
|
8
|
+
* Position in data space.
|
|
9
|
+
* Multiple stops at the same offset create hard color transitions.
|
|
10
|
+
*/
|
|
11
|
+
offset: number;
|
|
12
|
+
/** Color at the stop (any valid Skia color) */
|
|
13
|
+
color: string;
|
|
14
|
+
/** Optional opacity (0-1). Defaults to 1. */
|
|
15
|
+
opacity?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Defines a gradient.
|
|
19
|
+
*/
|
|
20
|
+
export type GradientDefinition = {
|
|
21
|
+
/**
|
|
22
|
+
* Axis that the gradient maps to.
|
|
23
|
+
* @default 'y'
|
|
24
|
+
*/
|
|
25
|
+
axis?: 'x' | 'y';
|
|
26
|
+
/**
|
|
27
|
+
* Gradient stops with colors and positions.
|
|
28
|
+
* Can be an array of stop objects or a function that receives domain bounds.
|
|
29
|
+
*/
|
|
30
|
+
stops: GradientStop[] | ((domain: AxisBounds) => GradientStop[]);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolves gradient stops, handling both static arrays and function forms.
|
|
34
|
+
* When stops is a function, calls it with the domain bounds.
|
|
35
|
+
*/
|
|
36
|
+
export declare const getGradientStops: (
|
|
37
|
+
stops: GradientStop[] | ((domain: AxisBounds) => GradientStop[]),
|
|
38
|
+
domain: AxisBounds,
|
|
39
|
+
) => GradientStop[];
|
|
40
|
+
/**
|
|
41
|
+
* Adds an opacity to a color
|
|
42
|
+
* Returns an rgba string.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getColorWithOpacity: (color1: string, opacity: number) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a gradient configuration for SVG components.
|
|
47
|
+
* Processes a GradientDefinition into a renderable GradientConfig.
|
|
48
|
+
* Supports both numeric scales (linear, log) and categorical scales (band).
|
|
49
|
+
*
|
|
50
|
+
* @param gradient - GradientDefinition configuration (required)
|
|
51
|
+
* @param xScale - X-axis scale (required)
|
|
52
|
+
* @param yScale - Y-axis scale (required)
|
|
53
|
+
* @returns GradientConfig or null if gradient processing fails
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const gradientConfig = useMemo(() => {
|
|
57
|
+
* if (!gradient || !xScale || !yScale) return;
|
|
58
|
+
* return getGradientConfig(gradient, xScale, yScale);
|
|
59
|
+
* }, [gradient, xScale, yScale]);
|
|
60
|
+
*
|
|
61
|
+
* if (gradientConfig) {
|
|
62
|
+
* return (
|
|
63
|
+
* <defs>
|
|
64
|
+
* <Gradient
|
|
65
|
+
* config={gradientConfig}
|
|
66
|
+
* direction={gradient.axis === 'x' ? 'horizontal' : 'vertical'}
|
|
67
|
+
* id={gradientId}
|
|
68
|
+
* />
|
|
69
|
+
* </defs>
|
|
70
|
+
* );
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
export declare const getGradientConfig: (
|
|
74
|
+
gradient: GradientDefinition,
|
|
75
|
+
xScale: ChartScaleFunction,
|
|
76
|
+
yScale: ChartScaleFunction,
|
|
77
|
+
) => GradientStop[] | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Evaluates the color at a specific data value based on the gradient stops, ignoring opacity.
|
|
80
|
+
* @param stops - The gradient stops configuration
|
|
81
|
+
* @param dataValue - The data value to evaluate (for band scales, this is the index)
|
|
82
|
+
* @param scale - The scale to use for value mapping (handles log scales correctly)
|
|
83
|
+
* @returns The color string at this data value, or undefined if invalid
|
|
84
|
+
*/
|
|
85
|
+
export declare const evaluateGradientAtValue: (
|
|
86
|
+
stops: GradientStop[],
|
|
87
|
+
dataValue: number,
|
|
88
|
+
scale: SerializableScale | ChartScaleFunction,
|
|
89
|
+
) => string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Determines the baseline value for the gradient area by finding the value
|
|
92
|
+
* within the axis bounds that is closest to the target baseline.
|
|
93
|
+
*
|
|
94
|
+
* @param axisBounds - The min and max bounds of the axis
|
|
95
|
+
* @param baseline - The target baseline value (defaults to 0)
|
|
96
|
+
* @returns The value within bounds closest to the baseline
|
|
97
|
+
*/
|
|
98
|
+
export declare const getBaseline: (axisBounds: AxisBounds, baseline?: number) => number;
|
|
99
|
+
/**
|
|
100
|
+
* Generates a gradient definition for the area chart based on the axis bounds
|
|
101
|
+
* and styling parameters. Ensures gradient stops are in ascending order.
|
|
102
|
+
*
|
|
103
|
+
* @param axisBounds - The min and max bounds of the axis
|
|
104
|
+
* @param baselineValue - The baseline value for the gradient
|
|
105
|
+
* @param fill - The color to use for the gradient
|
|
106
|
+
* @param peakOpacity - Opacity at the peak of the gradient
|
|
107
|
+
* @param baselineOpacity - Opacity at the baseline
|
|
108
|
+
* @returns A gradient definition with y-axis stops in ascending order
|
|
109
|
+
*/
|
|
110
|
+
export declare const createGradient: (
|
|
111
|
+
axisBounds: AxisBounds,
|
|
112
|
+
baselineValue: number,
|
|
113
|
+
fill: string,
|
|
114
|
+
peakOpacity: number,
|
|
115
|
+
baselineOpacity: number,
|
|
116
|
+
) => GradientDefinition;
|
|
117
|
+
//# sourceMappingURL=gradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gradient.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/gradient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAEL,KAAK,kBAAkB,EAGvB,KAAK,iBAAiB,EACvB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,YAAY,EAAE,CAAC,CAAC;CAClE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,YAAY,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,YAAY,EAAE,CAAC,EAChE,QAAQ,UAAU,KACjB,YAAY,EAKd,CAAC;AAiEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,MAGrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,kBAAkB,EAC5B,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB,YAAY,EAAE,GAAG,SAqBnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,YAAY,EAAE,EACrB,WAAW,MAAM,EACjB,OAAO,iBAAiB,GAAG,kBAAkB,KAC5C,MAAM,GAAG,SAyFX,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,YAAY,UAAU,EAAE,WAAU,MAAU,KAAG,MAc1E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,UAAU,EACtB,eAAe,MAAM,EACrB,MAAM,MAAM,EACZ,aAAa,MAAM,EACnB,iBAAiB,MAAM,KACtB,kBA0BF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './axis';
|
|
2
|
+
export * from './bar';
|
|
3
|
+
export * from './chart';
|
|
4
|
+
export * from './context';
|
|
5
|
+
export * from './gradient';
|
|
6
|
+
export * from './path';
|
|
7
|
+
export * from './point';
|
|
8
|
+
export * from './scale';
|
|
9
|
+
export * from './scrubber';
|
|
10
|
+
export * from './transition';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { type ChartScaleFunction } from './scale';
|
|
2
|
+
export type ChartPathCurveType =
|
|
3
|
+
| 'bump'
|
|
4
|
+
| 'catmullRom'
|
|
5
|
+
| 'linear'
|
|
6
|
+
| 'linearClosed'
|
|
7
|
+
| 'monotone'
|
|
8
|
+
| 'natural'
|
|
9
|
+
| 'step'
|
|
10
|
+
| 'stepBefore'
|
|
11
|
+
| 'stepAfter';
|
|
12
|
+
/**
|
|
13
|
+
* Get the d3 curve function for a path.
|
|
14
|
+
* See https://d3js.org/d3-shape/curve
|
|
15
|
+
* @param curve - The curve type. Defaults to 'linear'.
|
|
16
|
+
* @returns The d3 curve function.
|
|
17
|
+
*/
|
|
18
|
+
export declare const getPathCurveFunction: (
|
|
19
|
+
curve?: ChartPathCurveType,
|
|
20
|
+
) => import('d3-shape').CurveFactory;
|
|
21
|
+
/**
|
|
22
|
+
* Generates an SVG line path string from data using chart scale functions.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
|
|
27
|
+
* const path = getLinePath({ data: [1, 2, 3], chartScale, curve: 'linear' });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const getLinePath: ({
|
|
31
|
+
data,
|
|
32
|
+
curve,
|
|
33
|
+
xScale,
|
|
34
|
+
yScale,
|
|
35
|
+
xData,
|
|
36
|
+
connectNulls,
|
|
37
|
+
}: {
|
|
38
|
+
data: (
|
|
39
|
+
| number
|
|
40
|
+
| null
|
|
41
|
+
| {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}
|
|
45
|
+
)[];
|
|
46
|
+
curve?: ChartPathCurveType;
|
|
47
|
+
xScale: ChartScaleFunction;
|
|
48
|
+
yScale: ChartScaleFunction;
|
|
49
|
+
xData?: number[];
|
|
50
|
+
/**
|
|
51
|
+
* When true, null values are skipped and the line connects across gaps.
|
|
52
|
+
* When false, null values create gaps in the line.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
connectNulls?: boolean;
|
|
56
|
+
}) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Generates an SVG area path string from data using chart scale functions.
|
|
59
|
+
* Supports both single values (area from baseline to value) and tuples ([baseline, value]).
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Single values - area from baseline to value
|
|
64
|
+
* const area = getAreaPath({
|
|
65
|
+
* data: [1, 2, 3],
|
|
66
|
+
* xScale,
|
|
67
|
+
* yScale,
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Range values - area from low to high
|
|
71
|
+
* const rangeArea = getAreaPath({
|
|
72
|
+
* data: [[0, 3], [2, 4], [1, 5]],
|
|
73
|
+
* xScale,
|
|
74
|
+
* yScale,
|
|
75
|
+
* curve: 'monotone'
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const getAreaPath: ({
|
|
80
|
+
data,
|
|
81
|
+
curve,
|
|
82
|
+
xScale,
|
|
83
|
+
yScale,
|
|
84
|
+
xData,
|
|
85
|
+
connectNulls,
|
|
86
|
+
}: {
|
|
87
|
+
data: (number | null)[] | Array<[number, number] | null>;
|
|
88
|
+
xScale: ChartScaleFunction;
|
|
89
|
+
yScale: ChartScaleFunction;
|
|
90
|
+
curve: ChartPathCurveType;
|
|
91
|
+
xData?: number[];
|
|
92
|
+
/**
|
|
93
|
+
* When true, null values are skipped and the area connects across gaps.
|
|
94
|
+
* When false, null values create gaps in the area.
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
connectNulls?: boolean;
|
|
98
|
+
}) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Converts line coordinates to an SVG path string.
|
|
101
|
+
* Useful for rendering axis lines and tick marks.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const path = lineToPath(0, 0, 100, 100);
|
|
106
|
+
* // Returns: "M 0 0 L 100 100"
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare const lineToPath: (x1: number, y1: number, x2: number, y2: number) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Creates an SVG path string for a rectangle with selective corner rounding.
|
|
112
|
+
* Useful for creating bars in charts with optional rounded corners.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Simple rectangle bar
|
|
117
|
+
* const barPath = getBarPath(10, 20, 50, 100, 0, false, false);
|
|
118
|
+
*
|
|
119
|
+
* // Bar with rounded top corners
|
|
120
|
+
* const roundedPath = getBarPath(10, 20, 50, 100, 8, true, false);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare const getBarPath: (
|
|
124
|
+
x: number,
|
|
125
|
+
y: number,
|
|
126
|
+
width: number,
|
|
127
|
+
height: number,
|
|
128
|
+
radius: number,
|
|
129
|
+
roundTop: boolean,
|
|
130
|
+
roundBottom: boolean,
|
|
131
|
+
) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Generates an SVG path string with circles arranged in a dotted pattern within a bounding area.
|
|
134
|
+
* Creates circles at regular intervals based on the pattern size and dot size parameters.
|
|
135
|
+
*
|
|
136
|
+
* @param bounds - The bounding rectangle to fill with dots
|
|
137
|
+
* @param patternSize - Size of the pattern unit (spacing between dots)
|
|
138
|
+
* @param dotSize - Radius of each dot
|
|
139
|
+
* @returns SVG path string containing all the circles
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const dotsPath = getDottedAreaPath(
|
|
144
|
+
* { x: 0, y: 0, width: 100, height: 50 },
|
|
145
|
+
* 8, // 8px spacing
|
|
146
|
+
* 2 // 2px radius dots
|
|
147
|
+
* );
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const getDottedAreaPath: (
|
|
151
|
+
bounds: {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
width: number;
|
|
155
|
+
height: number;
|
|
156
|
+
},
|
|
157
|
+
patternSize: number,
|
|
158
|
+
dotSize: number,
|
|
159
|
+
) => string;
|
|
160
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/chart/utils/path.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,SAAS,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,UAAU,GACV,SAAS,GACT,MAAM,GACN,YAAY,GACZ,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAO,kBAA6B,oCAsBxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,uDAOzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,MAoBH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,uDAOzB;IACD,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACzD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,KAAG,MAoFH,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,MAE3E,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GACrB,GAAG,MAAM,EACT,GAAG,MAAM,EACT,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,UAAU,OAAO,EACjB,aAAa,OAAO,KACnB,MA0BF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/D,aAAa,MAAM,EACnB,SAAS,MAAM,KACd,MAgCF,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { TextHorizontalAlignment, TextVerticalAlignment } from '../text';
|
|
2
|
+
import { type ChartScaleFunction, type SerializableScale } from './scale';
|
|
3
|
+
/**
|
|
4
|
+
* Position a label should be placed relative to the point
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* 'top' would have the label be located above the point itself,
|
|
8
|
+
* and thus the vertical alignment of that text would be bottom.
|
|
9
|
+
*/
|
|
10
|
+
export type PointLabelPosition = 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
11
|
+
/**
|
|
12
|
+
* Get a point from a data value and a scale.
|
|
13
|
+
* @note for categorical scales, the point will be centered within the band.
|
|
14
|
+
* @note for log scales, zero and negative values are clamped to a small positive value.
|
|
15
|
+
* @param data - the data value.
|
|
16
|
+
* @param scale - the scale function.
|
|
17
|
+
* @returns the pixel value (defaulting to 0 if data value is not defined in scale).
|
|
18
|
+
*/
|
|
19
|
+
export declare const getPointOnScale: (dataValue: number, scale: ChartScaleFunction) => number;
|
|
20
|
+
/**
|
|
21
|
+
* Get a point from a data value and a serializable scale (worklet-compatible).
|
|
22
|
+
* @note for categorical scales, the point will be centered within the band.
|
|
23
|
+
* @note for log scales, zero and negative values are clamped to a small positive value.
|
|
24
|
+
* @param dataValue - the data value.
|
|
25
|
+
* @param scale - the serializable scale object.
|
|
26
|
+
* @returns the pixel value (defaulting to 0 if data value is not defined in scale).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPointOnSerializableScale(
|
|
29
|
+
dataValue: number,
|
|
30
|
+
scale: SerializableScale,
|
|
31
|
+
): number;
|
|
32
|
+
/**
|
|
33
|
+
* Projects a single data point to pixel coordinates using serializable scales.
|
|
34
|
+
* This is the worklet-compatible version for use in react-native-reanimated.
|
|
35
|
+
*/
|
|
36
|
+
export declare function projectPointWithSerializableScale({
|
|
37
|
+
x,
|
|
38
|
+
y,
|
|
39
|
+
xScale,
|
|
40
|
+
yScale,
|
|
41
|
+
}: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
xScale: SerializableScale;
|
|
45
|
+
yScale: SerializableScale;
|
|
46
|
+
}): {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Projects a data point to pixel coordinates using the chart scale.
|
|
52
|
+
* Automatically handles log scale transformations for zero/negative values.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
|
|
57
|
+
* const pixelCoord = projectPoint({ x: 5, y: 10, chartScale });
|
|
58
|
+
* ```
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
|
|
62
|
+
* const pixelCoord = projectPoint({ x: 2, y: 10, chartScale, xData: ['Jan', 'Feb', 'Mar'] });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare const projectPoint: ({
|
|
66
|
+
x,
|
|
67
|
+
y,
|
|
68
|
+
xScale,
|
|
69
|
+
yScale,
|
|
70
|
+
}: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
xScale: ChartScaleFunction;
|
|
74
|
+
yScale: ChartScaleFunction;
|
|
75
|
+
}) => {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Projects multiple data points to pixel coordinates using chart scale functions.
|
|
81
|
+
* Handles both numeric and band scales automatically.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const chartScale = getChartScale({ chartRect, domain, range, xScale, yScale });
|
|
86
|
+
* const pixelPoints = projectPoints({ data, chartScale });
|
|
87
|
+
* // For mixed scales
|
|
88
|
+
* const pixelPoints = projectPoints({ data, chartScale, xData: ['Jan', 'Feb', 'Mar'] });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare const projectPoints: ({
|
|
92
|
+
data,
|
|
93
|
+
xScale,
|
|
94
|
+
yScale,
|
|
95
|
+
xData,
|
|
96
|
+
yData,
|
|
97
|
+
}: {
|
|
98
|
+
data: (
|
|
99
|
+
| number
|
|
100
|
+
| null
|
|
101
|
+
| {
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
}
|
|
105
|
+
)[];
|
|
106
|
+
xData?: number[];
|
|
107
|
+
yData?: number[];
|
|
108
|
+
xScale: ChartScaleFunction;
|
|
109
|
+
yScale: ChartScaleFunction;
|
|
110
|
+
}) => Array<{
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
} | null>;
|
|
114
|
+
/**
|
|
115
|
+
* Determines text alignment based on label position.
|
|
116
|
+
* For example, a 'top' position needs the text aligned to the 'bottom' so it appears above the point.
|
|
117
|
+
*/
|
|
118
|
+
export declare const getAlignmentFromPosition: (position: PointLabelPosition) => {
|
|
119
|
+
horizontalAlignment: TextHorizontalAlignment;
|
|
120
|
+
verticalAlignment: TextVerticalAlignment;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Calculates the final label coordinates by applying offset based on position.
|
|
124
|
+
*/
|
|
125
|
+
export declare const getLabelCoordinates: (
|
|
126
|
+
x: number,
|
|
127
|
+
y: number,
|
|
128
|
+
position: PointLabelPosition,
|
|
129
|
+
offset: number,
|
|
130
|
+
) => {
|
|
131
|
+
x: number;
|
|
132
|
+
y: number;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=point.d.ts.map
|