@coinbase/cds-mobile-visualization 3.4.0-beta.1 → 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.
Files changed (184) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dts/chart/CartesianChart.d.ts +57 -33
  3. package/dts/chart/CartesianChart.d.ts.map +1 -1
  4. package/dts/chart/ChartContextBridge.d.ts +28 -0
  5. package/dts/chart/ChartContextBridge.d.ts.map +1 -0
  6. package/dts/chart/Path.d.ts +77 -34
  7. package/dts/chart/Path.d.ts.map +1 -1
  8. package/dts/chart/PeriodSelector.d.ts +2 -2
  9. package/dts/chart/PeriodSelector.d.ts.map +1 -1
  10. package/dts/chart/area/Area.d.ts +42 -27
  11. package/dts/chart/area/Area.d.ts.map +1 -1
  12. package/dts/chart/area/AreaChart.d.ts +51 -10
  13. package/dts/chart/area/AreaChart.d.ts.map +1 -1
  14. package/dts/chart/area/DottedArea.d.ts +21 -2
  15. package/dts/chart/area/DottedArea.d.ts.map +1 -1
  16. package/dts/chart/area/GradientArea.d.ts +19 -13
  17. package/dts/chart/area/GradientArea.d.ts.map +1 -1
  18. package/dts/chart/area/SolidArea.d.ts +17 -2
  19. package/dts/chart/area/SolidArea.d.ts.map +1 -1
  20. package/dts/chart/axis/Axis.d.ts +68 -78
  21. package/dts/chart/axis/Axis.d.ts.map +1 -1
  22. package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
  23. package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
  24. package/dts/chart/axis/XAxis.d.ts +1 -1
  25. package/dts/chart/axis/XAxis.d.ts.map +1 -1
  26. package/dts/chart/axis/YAxis.d.ts +2 -2
  27. package/dts/chart/axis/YAxis.d.ts.map +1 -1
  28. package/dts/chart/axis/index.d.ts +1 -0
  29. package/dts/chart/axis/index.d.ts.map +1 -1
  30. package/dts/chart/bar/Bar.d.ts +16 -13
  31. package/dts/chart/bar/Bar.d.ts.map +1 -1
  32. package/dts/chart/bar/BarChart.d.ts +36 -20
  33. package/dts/chart/bar/BarChart.d.ts.map +1 -1
  34. package/dts/chart/bar/BarPlot.d.ts +2 -1
  35. package/dts/chart/bar/BarPlot.d.ts.map +1 -1
  36. package/dts/chart/bar/BarStack.d.ts +39 -48
  37. package/dts/chart/bar/BarStack.d.ts.map +1 -1
  38. package/dts/chart/bar/BarStackGroup.d.ts +1 -0
  39. package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
  40. package/dts/chart/bar/DefaultBar.d.ts +1 -1
  41. package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
  42. package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
  43. package/dts/chart/gradient/Gradient.d.ts +25 -0
  44. package/dts/chart/gradient/Gradient.d.ts.map +1 -0
  45. package/dts/chart/gradient/index.d.ts +2 -0
  46. package/dts/chart/gradient/index.d.ts.map +1 -0
  47. package/dts/chart/index.d.ts +3 -1
  48. package/dts/chart/index.d.ts.map +1 -1
  49. package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
  50. package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
  51. package/dts/chart/line/DottedLine.d.ts +13 -5
  52. package/dts/chart/line/DottedLine.d.ts.map +1 -1
  53. package/dts/chart/line/Line.d.ts +62 -25
  54. package/dts/chart/line/Line.d.ts.map +1 -1
  55. package/dts/chart/line/LineChart.d.ts +43 -9
  56. package/dts/chart/line/LineChart.d.ts.map +1 -1
  57. package/dts/chart/line/ReferenceLine.d.ts +68 -20
  58. package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
  59. package/dts/chart/line/SolidLine.d.ts +8 -5
  60. package/dts/chart/line/SolidLine.d.ts.map +1 -1
  61. package/dts/chart/line/index.d.ts +1 -1
  62. package/dts/chart/line/index.d.ts.map +1 -1
  63. package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
  64. package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
  65. package/dts/chart/point/Point.d.ts +120 -0
  66. package/dts/chart/point/Point.d.ts.map +1 -0
  67. package/dts/chart/point/index.d.ts +3 -0
  68. package/dts/chart/point/index.d.ts.map +1 -0
  69. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +8 -0
  70. package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
  71. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
  72. package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
  73. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +11 -0
  74. package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
  75. package/dts/chart/scrubber/Scrubber.d.ts +172 -43
  76. package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
  77. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +44 -0
  78. package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
  79. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +31 -0
  80. package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
  81. package/dts/chart/scrubber/ScrubberProvider.d.ts +6 -3
  82. package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
  83. package/dts/chart/scrubber/index.d.ts +3 -0
  84. package/dts/chart/scrubber/index.d.ts.map +1 -1
  85. package/dts/chart/text/ChartText.d.ts +151 -77
  86. package/dts/chart/text/ChartText.d.ts.map +1 -1
  87. package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
  88. package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
  89. package/dts/chart/text/index.d.ts +1 -1
  90. package/dts/chart/text/index.d.ts.map +1 -1
  91. package/dts/chart/utils/chart.d.ts +34 -7
  92. package/dts/chart/utils/chart.d.ts.map +1 -1
  93. package/dts/chart/utils/context.d.ts +28 -7
  94. package/dts/chart/utils/context.d.ts.map +1 -1
  95. package/dts/chart/utils/gradient.d.ts +117 -0
  96. package/dts/chart/utils/gradient.d.ts.map +1 -0
  97. package/dts/chart/utils/index.d.ts +3 -0
  98. package/dts/chart/utils/index.d.ts.map +1 -1
  99. package/dts/chart/utils/path.d.ts +53 -0
  100. package/dts/chart/utils/path.d.ts.map +1 -1
  101. package/dts/chart/utils/point.d.ts +60 -1
  102. package/dts/chart/utils/point.d.ts.map +1 -1
  103. package/dts/chart/utils/scale.d.ts +91 -0
  104. package/dts/chart/utils/scale.d.ts.map +1 -1
  105. package/dts/chart/utils/scrubber.d.ts +39 -0
  106. package/dts/chart/utils/scrubber.d.ts.map +1 -0
  107. package/dts/chart/utils/transition.d.ts +140 -0
  108. package/dts/chart/utils/transition.d.ts.map +1 -0
  109. package/esm/chart/CartesianChart.js +164 -70
  110. package/esm/chart/ChartContextBridge.js +148 -0
  111. package/esm/chart/Path.js +198 -113
  112. package/esm/chart/PeriodSelector.js +2 -2
  113. package/esm/chart/__stories__/CartesianChart.stories.js +378 -131
  114. package/esm/chart/__stories__/Chart.stories.js +2 -4
  115. package/esm/chart/__stories__/PeriodSelector.stories.js +103 -75
  116. package/esm/chart/area/Area.js +25 -35
  117. package/esm/chart/area/AreaChart.js +17 -12
  118. package/esm/chart/area/DottedArea.js +61 -109
  119. package/esm/chart/area/GradientArea.js +35 -91
  120. package/esm/chart/area/SolidArea.js +22 -8
  121. package/esm/chart/area/__stories__/AreaChart.stories.js +1 -1
  122. package/esm/chart/axis/Axis.js +2 -0
  123. package/esm/chart/axis/DefaultAxisTickLabel.js +11 -0
  124. package/esm/chart/axis/XAxis.js +63 -56
  125. package/esm/chart/axis/YAxis.js +59 -52
  126. package/esm/chart/axis/__stories__/Axis.stories.js +0 -1
  127. package/esm/chart/axis/index.js +1 -0
  128. package/esm/chart/bar/Bar.js +3 -1
  129. package/esm/chart/bar/BarChart.js +15 -37
  130. package/esm/chart/bar/BarPlot.js +41 -35
  131. package/esm/chart/bar/BarStack.js +75 -38
  132. package/esm/chart/bar/BarStackGroup.js +6 -16
  133. package/esm/chart/bar/DefaultBar.js +26 -48
  134. package/esm/chart/bar/DefaultBarStack.js +23 -58
  135. package/esm/chart/bar/__stories__/BarChart.stories.js +463 -77
  136. package/esm/chart/gradient/Gradient.js +53 -0
  137. package/esm/chart/gradient/index.js +1 -0
  138. package/esm/chart/index.js +3 -1
  139. package/esm/chart/line/DefaultReferenceLineLabel.js +66 -0
  140. package/esm/chart/line/DottedLine.js +29 -14
  141. package/esm/chart/line/Line.js +106 -67
  142. package/esm/chart/line/LineChart.js +20 -14
  143. package/esm/chart/line/ReferenceLine.js +80 -63
  144. package/esm/chart/line/SolidLine.js +25 -10
  145. package/esm/chart/line/__stories__/LineChart.stories.js +2101 -1977
  146. package/esm/chart/line/__stories__/ReferenceLine.stories.js +83 -28
  147. package/esm/chart/line/index.js +1 -1
  148. package/esm/chart/point/DefaultPointLabel.js +39 -0
  149. package/esm/chart/point/Point.js +188 -0
  150. package/esm/chart/point/index.js +2 -0
  151. package/esm/chart/scrubber/DefaultScrubberBeacon.js +179 -0
  152. package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +43 -0
  153. package/esm/chart/scrubber/DefaultScrubberLabel.js +28 -0
  154. package/esm/chart/scrubber/Scrubber.js +126 -146
  155. package/esm/chart/scrubber/ScrubberBeaconGroup.js +161 -0
  156. package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +185 -0
  157. package/esm/chart/scrubber/ScrubberProvider.js +46 -54
  158. package/esm/chart/scrubber/index.js +3 -1
  159. package/esm/chart/text/ChartText.js +242 -174
  160. package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +6 -5
  161. package/esm/chart/text/index.js +1 -1
  162. package/esm/chart/utils/chart.js +44 -3
  163. package/esm/chart/utils/gradient.js +305 -0
  164. package/esm/chart/utils/index.js +3 -0
  165. package/esm/chart/utils/path.js +76 -8
  166. package/esm/chart/utils/point.js +116 -5
  167. package/esm/chart/utils/scale.js +230 -1
  168. package/esm/chart/utils/scrubber.js +139 -0
  169. package/esm/chart/utils/transition.js +185 -0
  170. package/esm/sparkline/__stories__/Sparkline.stories.js +11 -7
  171. package/esm/sparkline/__stories__/SparklineGradient.stories.js +7 -4
  172. package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +51 -26
  173. package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +17 -9
  174. package/package.json +15 -9
  175. package/dts/chart/Point.d.ts +0 -103
  176. package/dts/chart/Point.d.ts.map +0 -1
  177. package/dts/chart/line/GradientLine.d.ts +0 -45
  178. package/dts/chart/line/GradientLine.d.ts.map +0 -1
  179. package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -75
  180. package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
  181. package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
  182. package/esm/chart/Point.js +0 -111
  183. package/esm/chart/line/GradientLine.js +0 -62
  184. package/esm/chart/scrubber/ScrubberBeacon.js +0 -199
@@ -1,103 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- import type { ChartTextChildren } from './text/ChartText';
3
- import { type ChartTextProps } from './text';
4
- /**
5
- * Parameters passed to renderPoints callback function.
6
- */
7
- export type RenderPointsParams = {
8
- /**
9
- * X coordinate in SVG pixel space.
10
- */
11
- x: number;
12
- /**
13
- * Y coordinate in SVG pixel space.
14
- */
15
- y: number;
16
- /**
17
- * X coordinate in data space (usually same as index).
18
- */
19
- dataX: number;
20
- /**
21
- * Y coordinate in data space (same as value).
22
- */
23
- dataY: number;
24
- };
25
- /**
26
- * Shared configuration for point appearance and behavior.
27
- * Used by line-associated points rendered via Line/LineChart components.
28
- */
29
- export type PointConfig = {
30
- /**
31
- * The fill color of the point.
32
- */
33
- fill?: string;
34
- /**
35
- * Optional Y-axis id to specify which axis to plot along.
36
- * Defaults to the first y-axis
37
- */
38
- yAxisId?: string;
39
- /**
40
- * Radius of the point.
41
- * @default 4
42
- */
43
- radius?: number;
44
- /**
45
- * Opacity of the point.
46
- */
47
- opacity?: number;
48
- /**
49
- * Handler for when the point is clicked.
50
- */
51
- onPress?: (point: { x: number; y: number; dataX: number; dataY: number }) => void;
52
- /**
53
- * Handler for when the scrubber enters this point.
54
- */
55
- onScrubberEnter?: (point: { x: number; y: number }) => void;
56
- /**
57
- * Color of the outer stroke around the point.
58
- * @default theme.color.bg
59
- */
60
- stroke?: string;
61
- /**
62
- * Outer stroke width of the point.
63
- * Set to 0 to remove the stroke.
64
- * @default 2
65
- */
66
- strokeWidth?: number;
67
- /**
68
- * Simple text label to display at the point position.
69
- * If provided, a ChartText will be automatically rendered.
70
- */
71
- label?: ChartTextChildren;
72
- /**
73
- * Configuration for the automatically rendered label.
74
- * Only used when `label` prop is provided.
75
- */
76
- labelProps?: Omit<ChartTextProps, 'x' | 'y' | 'children'>;
77
- /**
78
- * Accessibility label for screen readers to describe the point.
79
- * If not provided, a default label will be generated using the data coordinates.
80
- */
81
- accessibilityLabel?: string;
82
- };
83
- export type PointProps = SharedProps &
84
- PointConfig & {
85
- /**
86
- * X coordinate in data space (not pixel coordinates).
87
- */
88
- dataX: number;
89
- /**
90
- * Y coordinate in data space (not pixel coordinates).
91
- */
92
- dataY: number;
93
- /**
94
- * Optional pixel coordinates to use instead of calculating from dataX/dataY.
95
- * Useful for performance when coordinates are already calculated.
96
- */
97
- pixelCoordinates?: {
98
- x: number;
99
- y: number;
100
- };
101
- };
102
- export declare const Point: import('react').NamedExoticComponent<PointProps>;
103
- //# sourceMappingURL=Point.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Point.d.ts","sourceRoot":"","sources":["../../src/chart/Point.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAClF;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,GAAG,GAAG,UAAU,CAAC,CAAC;IAC1D;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAClC,WAAW,GAAG;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,gBAAgB,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEJ,eAAO,MAAM,KAAK,kDAyFjB,CAAC"}
@@ -1,45 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- import { type PathProps } from '../Path';
3
- export type GradientLineProps = SharedProps &
4
- Omit<PathProps, 'stroke' | 'strokeOpacity' | 'strokeWidth'> & {
5
- /**
6
- * The color of the line.
7
- * @default theme.color.bgLine
8
- */
9
- stroke?: string;
10
- /**
11
- * Opacity of the line.
12
- * @default 1
13
- */
14
- strokeOpacity?: number;
15
- /**
16
- * Path stroke width
17
- * @default 2
18
- */
19
- strokeWidth?: number;
20
- /**
21
- * The color of the start of the gradient.
22
- * @default stroke or theme.color.bgLine
23
- */
24
- startColor?: string;
25
- /**
26
- * The color of the end of the gradient.
27
- * @default stroke or theme.color.bgLine
28
- */
29
- endColor?: string;
30
- /**
31
- * Opacity of the start color.
32
- * @default strokeOpacity
33
- */
34
- startOpacity?: number;
35
- /**
36
- * Opacity of the end color.
37
- * @default strokeOpacity
38
- */
39
- endOpacity?: number;
40
- };
41
- /**
42
- * A gradient line component which uses path element.
43
- */
44
- export declare const GradientLine: import('react').NamedExoticComponent<GradientLineProps>;
45
- //# sourceMappingURL=GradientLine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GradientLine.d.ts","sourceRoot":"","sources":["../../../src/chart/line/GradientLine.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,WAAW,GACzC,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,eAAe,GAAG,aAAa,CAAC,GAAG;IAC5D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,YAAY,yDAmDxB,CAAC"}
@@ -1,75 +0,0 @@
1
- import type { SharedProps } from '@coinbase/cds-common/types';
2
- export type ScrubberBeaconRef = {
3
- /**
4
- * Triggers a single pulse animation.
5
- */
6
- pulse: () => void;
7
- };
8
- export type ScrubberBeaconProps = SharedProps & {
9
- /**
10
- * Optional data X coordinate to position the beacon.
11
- * If not provided, uses the scrubber position from context.
12
- */
13
- dataX?: number;
14
- /**
15
- * Optional data Y coordinate to position the beacon.
16
- * If not provided, looks up the Y value from series data at scrubber position.
17
- */
18
- dataY?: number;
19
- /**
20
- * Filter to only show dot for specific series (used for hover-based positioning).
21
- */
22
- seriesId?: string;
23
- /**
24
- * Color of the beacon point.
25
- * If not provided, uses the series color.
26
- */
27
- color?: string;
28
- /**
29
- * Opacity of the beacon.
30
- * @default 1
31
- */
32
- opacity?: number;
33
- /**
34
- * Pulse the scrubber beacon while it is at rest.
35
- */
36
- idlePulse?: boolean;
37
- };
38
- /**
39
- * The ScrubberBeacon is a special instance of a Point used to mark the scrubber's position on a specific series.
40
- */
41
- export declare const ScrubberBeacon: import('react').MemoExoticComponent<
42
- import('react').ForwardRefExoticComponent<
43
- SharedProps & {
44
- /**
45
- * Optional data X coordinate to position the beacon.
46
- * If not provided, uses the scrubber position from context.
47
- */
48
- dataX?: number;
49
- /**
50
- * Optional data Y coordinate to position the beacon.
51
- * If not provided, looks up the Y value from series data at scrubber position.
52
- */
53
- dataY?: number;
54
- /**
55
- * Filter to only show dot for specific series (used for hover-based positioning).
56
- */
57
- seriesId?: string;
58
- /**
59
- * Color of the beacon point.
60
- * If not provided, uses the series color.
61
- */
62
- color?: string;
63
- /**
64
- * Opacity of the beacon.
65
- * @default 1
66
- */
67
- opacity?: number;
68
- /**
69
- * Pulse the scrubber beacon while it is at rest.
70
- */
71
- idlePulse?: boolean;
72
- } & import('react').RefAttributes<ScrubberBeaconRef>
73
- >
74
- >;
75
- //# sourceMappingURL=ScrubberBeacon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScrubberBeacon.d.ts","sourceRoot":"","sources":["../../../src/chart/scrubber/ScrubberBeacon.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAe9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;IAjCzB;;;OAGG;YACK,MAAM;IACd;;;OAGG;YACK,MAAM;IACd;;OAEG;eACQ,MAAM;IACjB;;;OAGG;YACK,MAAM;IACd;;;OAGG;cACO,MAAM;IAChB;;OAEG;gBACS,OAAO;sDAgMpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SmartChartTextGroup.d.ts","sourceRoot":"","sources":["../../../src/chart/text/SmartChartTextGroup.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CAC1C,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,gEAwL/B,CAAC"}
@@ -1,111 +0,0 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import { memo, useEffect, useMemo } from 'react';
3
- import { Circle, G } from 'react-native-svg';
4
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
5
- import { useCartesianChartContext } from './ChartProvider';
6
- import { ChartText } from './text';
7
- import { projectPoint, useScrubberContext } from './utils';
8
-
9
- /**
10
- * Parameters passed to renderPoints callback function.
11
- */
12
-
13
- /**
14
- * Shared configuration for point appearance and behavior.
15
- * Used by line-associated points rendered via Line/LineChart components.
16
- */
17
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
18
- export const Point = /*#__PURE__*/memo(_ref => {
19
- let {
20
- dataX,
21
- dataY,
22
- yAxisId,
23
- fill,
24
- radius = 4,
25
- opacity,
26
- onPress,
27
- onScrubberEnter,
28
- stroke,
29
- strokeWidth = 2,
30
- accessibilityLabel,
31
- label,
32
- labelProps,
33
- pixelCoordinates,
34
- testID
35
- } = _ref;
36
- const theme = useTheme();
37
- const effectiveStroke = stroke != null ? stroke : theme.color.bg;
38
- const {
39
- getXScale,
40
- getYScale
41
- } = useCartesianChartContext();
42
- const {
43
- scrubberPosition
44
- } = useScrubberContext();
45
- const xScale = getXScale();
46
- const yScale = getYScale(yAxisId);
47
-
48
- // Scrubber detection: check if this point is highlighted by the scrubber
49
- const isScrubberHighlighted = scrubberPosition !== undefined && scrubberPosition === dataX;
50
-
51
- // Use provided pixelCoordinates or calculate from data coordinates
52
- const pixelCoordinate = useMemo(() => {
53
- if (pixelCoordinates) {
54
- return pixelCoordinates;
55
- }
56
- if (!xScale || !yScale) {
57
- return {
58
- x: 0,
59
- y: 0
60
- };
61
- }
62
- return projectPoint({
63
- x: dataX,
64
- y: dataY,
65
- xScale,
66
- yScale
67
- });
68
- }, [pixelCoordinates, xScale, yScale, dataX, dataY]);
69
- useEffect(() => {
70
- if (isScrubberHighlighted && onScrubberEnter) {
71
- onScrubberEnter({
72
- x: pixelCoordinate.x,
73
- y: pixelCoordinate.y
74
- });
75
- }
76
- }, [isScrubberHighlighted, onScrubberEnter, pixelCoordinate.x, pixelCoordinate.y]);
77
- if (!xScale || !yScale) {
78
- return null;
79
- }
80
- return /*#__PURE__*/_jsxs(_Fragment, {
81
- children: [/*#__PURE__*/_jsx(G, {
82
- opacity: opacity,
83
- testID: testID,
84
- transform: [{
85
- translateX: pixelCoordinate.x
86
- }, {
87
- translateY: pixelCoordinate.y
88
- }],
89
- children: /*#__PURE__*/_jsx(Circle, {
90
- accessibilityLabel: accessibilityLabel,
91
- cx: 0,
92
- cy: 0,
93
- fill: fill != null ? fill : theme.color.fgPrimary,
94
- onPress: onPress ? event => onPress({
95
- dataX,
96
- dataY,
97
- x: pixelCoordinate.x,
98
- y: pixelCoordinate.y
99
- }) : undefined,
100
- r: radius,
101
- stroke: effectiveStroke,
102
- strokeWidth: strokeWidth
103
- })
104
- }), label && /*#__PURE__*/_jsx(ChartText, _extends({
105
- x: pixelCoordinate.x,
106
- y: pixelCoordinate.y
107
- }, labelProps, {
108
- children: label
109
- }))]
110
- });
111
- });
@@ -1,62 +0,0 @@
1
- const _excluded = ["fill", "stroke", "startColor", "endColor", "strokeOpacity", "startOpacity", "endOpacity", "strokeLinecap", "strokeLinejoin", "strokeWidth", "animate"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- 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; }
4
- import { memo, useId } from 'react';
5
- import { Defs, LinearGradient, Stop } from 'react-native-svg';
6
- import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
7
- import { useCartesianChartContext } from '../ChartProvider';
8
- import { Path } from '../Path';
9
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
10
- /**
11
- * A gradient line component which uses path element.
12
- */
13
- export const GradientLine = /*#__PURE__*/memo(_ref => {
14
- var _ref2, _ref3;
15
- let {
16
- fill = 'none',
17
- stroke,
18
- startColor,
19
- endColor,
20
- strokeOpacity = 1,
21
- startOpacity = strokeOpacity,
22
- endOpacity = strokeOpacity,
23
- strokeLinecap = 'round',
24
- strokeLinejoin = 'round',
25
- strokeWidth = 2,
26
- animate
27
- } = _ref,
28
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
29
- const context = useCartesianChartContext();
30
- const theme = useTheme();
31
- const patternId = useId();
32
- const shouldAnimate = animate != null ? animate : context.animate;
33
- return /*#__PURE__*/_jsxs(_Fragment, {
34
- children: [/*#__PURE__*/_jsx(Defs, {
35
- children: /*#__PURE__*/_jsxs(LinearGradient, {
36
- id: patternId,
37
- x1: "0%",
38
- x2: "0%",
39
- y1: "0%",
40
- y2: "100%",
41
- children: [/*#__PURE__*/_jsx(Stop, {
42
- offset: "0%",
43
- stopColor: (_ref2 = startColor != null ? startColor : stroke) != null ? _ref2 : theme.color.bgLine,
44
- stopOpacity: startOpacity
45
- }), /*#__PURE__*/_jsx(Stop, {
46
- offset: "100%",
47
- stopColor: (_ref3 = endColor != null ? endColor : stroke) != null ? _ref3 : theme.color.bgLine,
48
- stopOpacity: endOpacity
49
- })]
50
- })
51
- }), /*#__PURE__*/_jsx(Path, _extends({
52
- animate: shouldAnimate,
53
- clipOffset: strokeWidth,
54
- fill: fill,
55
- stroke: "url(#" + patternId + ")",
56
- strokeLinecap: strokeLinecap,
57
- strokeLinejoin: strokeLinejoin,
58
- strokeOpacity: strokeOpacity,
59
- strokeWidth: strokeWidth
60
- }, props))]
61
- });
62
- });
@@ -1,199 +0,0 @@
1
- import { forwardRef, memo, useEffect, useImperativeHandle, useMemo } from 'react';
2
- import Reanimated, { cancelAnimation, useAnimatedProps, useSharedValue, withRepeat, withSequence, withTiming } from 'react-native-reanimated';
3
- import { Circle, G } from 'react-native-svg';
4
- import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue';
5
- import { useTheme } from '@coinbase/cds-mobile';
6
- import { useCartesianChartContext } from '../ChartProvider';
7
- import { projectPoint, useScrubberContext } from '../utils';
8
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
- const AnimatedCircle = Reanimated.createAnimatedComponent(Circle);
10
- const radius = 5;
11
- const glowRadius = 10;
12
- const pulseRadius = 15;
13
- const pulseDuration = 2000; // 2 seconds
14
- const singlePulseDuration = 1000; // 1 second
15
-
16
- /**
17
- * The ScrubberBeacon is a special instance of a Point used to mark the scrubber's position on a specific series.
18
- */
19
- export const ScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
20
- var _pixelCoordinate$x, _pixelCoordinate$y, _ref2;
21
- let {
22
- seriesId,
23
- dataX: dataXProp,
24
- dataY: dataYProp,
25
- color,
26
- testID,
27
- idlePulse,
28
- opacity = 1
29
- } = _ref;
30
- const theme = useTheme();
31
- const {
32
- getSeries,
33
- getXScale,
34
- getYScale,
35
- getSeriesData,
36
- animate
37
- } = useCartesianChartContext();
38
- const {
39
- scrubberPosition
40
- } = useScrubberContext();
41
- const targetSeries = getSeries(seriesId);
42
- const sourceData = getSeriesData(seriesId);
43
- const xScale = getXScale();
44
- const yScale = getYScale(targetSeries == null ? void 0 : targetSeries.yAxisId);
45
- const isIdleState = scrubberPosition === undefined;
46
- const {
47
- dataX,
48
- dataY
49
- } = useMemo(() => {
50
- let x;
51
- let y;
52
- if (xScale && yScale) {
53
- if (dataXProp !== undefined && dataYProp !== undefined && !isNaN(dataYProp) && !isNaN(dataXProp)) {
54
- // Use direct coordinates if provided
55
- x = dataXProp;
56
- y = dataYProp;
57
- } else if (sourceData && scrubberPosition != null && scrubberPosition >= 0 && scrubberPosition < sourceData.length) {
58
- // Use series data at highlight index
59
- x = scrubberPosition;
60
- const dataValue = sourceData[scrubberPosition];
61
- if (typeof dataValue === 'number') {
62
- y = dataValue;
63
- } else if (Array.isArray(dataValue)) {
64
- const validValues = dataValue.filter(val => val !== null);
65
- if (validValues.length >= 2) {
66
- y = validValues[1];
67
- }
68
- }
69
- }
70
- }
71
- return {
72
- dataX: x,
73
- dataY: y
74
- };
75
- }, [dataXProp, dataYProp, sourceData, scrubberPosition, xScale, yScale]);
76
- const previousIdleState = usePreviousValue(!!isIdleState);
77
- const pixelCoordinate = useMemo(() => {
78
- if (!xScale || !yScale || dataX === undefined || dataY === undefined) return undefined;
79
- const point = projectPoint({
80
- x: dataX,
81
- y: dataY,
82
- xScale,
83
- yScale
84
- });
85
-
86
- // Return undefined if coordinates are invalid
87
- if (!point || isNaN(point.x) || isNaN(point.y)) return undefined;
88
- return point;
89
- }, [xScale, yScale, dataX, dataY]);
90
- const animatedX = useSharedValue((_pixelCoordinate$x = pixelCoordinate == null ? void 0 : pixelCoordinate.x) != null ? _pixelCoordinate$x : 0);
91
- const animatedY = useSharedValue((_pixelCoordinate$y = pixelCoordinate == null ? void 0 : pixelCoordinate.y) != null ? _pixelCoordinate$y : 0);
92
- const pulseOpacity = useSharedValue(0);
93
- useImperativeHandle(ref, () => ({
94
- pulse: () => {
95
- if (isIdleState && animate) {
96
- pulseOpacity.value = 0.1;
97
- pulseOpacity.value = withTiming(0, {
98
- duration: singlePulseDuration
99
- });
100
- }
101
- }
102
- }));
103
- useEffect(() => {
104
- const shouldPulse = animate && isIdleState && idlePulse;
105
- if (shouldPulse) {
106
- pulseOpacity.value = withRepeat(withSequence(withTiming(0.1, {
107
- duration: pulseDuration / 2
108
- }), withTiming(0, {
109
- duration: pulseDuration / 2
110
- })), -1,
111
- // loop
112
- false);
113
- } else {
114
- cancelAnimation(pulseOpacity);
115
- pulseOpacity.value = withTiming(0, {
116
- duration: 200
117
- });
118
- }
119
- }, [animate, isIdleState, idlePulse, pulseOpacity]);
120
-
121
- // Update position when data coordinates change
122
- useEffect(() => {
123
- if (!pixelCoordinate) return;
124
-
125
- // When scrubbing or animations disabled: snap immediately
126
- if (!isIdleState || !animate || !previousIdleState) {
127
- // Cancel any ongoing animations before snapping
128
- cancelAnimation(animatedX);
129
- cancelAnimation(animatedY);
130
- animatedX.value = pixelCoordinate.x;
131
- animatedY.value = pixelCoordinate.y;
132
- } else {
133
- // When idle with animations enabled: animate smoothly
134
- animatedX.value = withTiming(pixelCoordinate.x, {
135
- duration: 300
136
- });
137
- animatedY.value = withTiming(pixelCoordinate.y, {
138
- duration: 300
139
- });
140
- }
141
- }, [pixelCoordinate, isIdleState, animate, previousIdleState, animatedX, animatedY]);
142
-
143
- // Animated props for all circles in idle state
144
- const glowAnimatedProps = useAnimatedProps(() => ({
145
- cx: animatedX.value,
146
- cy: animatedY.value
147
- }));
148
- const pointAnimatedProps = useAnimatedProps(() => ({
149
- cx: animatedX.value,
150
- cy: animatedY.value
151
- }));
152
- const pulseAnimatedProps = useAnimatedProps(() => ({
153
- cx: animatedX.value,
154
- cy: animatedY.value,
155
- opacity: pulseOpacity.value
156
- }));
157
- if (!pixelCoordinate) return;
158
- const pointColor = (_ref2 = color != null ? color : targetSeries == null ? void 0 : targetSeries.color) != null ? _ref2 : theme.color.fgPrimary;
159
- if (!isIdleState) {
160
- return /*#__PURE__*/_jsxs(G, {
161
- opacity: opacity,
162
- testID: testID,
163
- children: [/*#__PURE__*/_jsx(Circle, {
164
- cx: pixelCoordinate.x,
165
- cy: pixelCoordinate.y,
166
- fill: pointColor,
167
- opacity: 0.15,
168
- r: glowRadius
169
- }), /*#__PURE__*/_jsx(Circle, {
170
- cx: pixelCoordinate.x,
171
- cy: pixelCoordinate.y,
172
- fill: pointColor,
173
- r: radius,
174
- stroke: theme.color.bg,
175
- strokeWidth: 2
176
- })]
177
- });
178
- }
179
- return /*#__PURE__*/_jsxs(G, {
180
- opacity: opacity,
181
- testID: testID,
182
- children: [/*#__PURE__*/_jsx(AnimatedCircle, {
183
- animatedProps: glowAnimatedProps,
184
- fill: pointColor,
185
- opacity: 0.15,
186
- r: glowRadius
187
- }), /*#__PURE__*/_jsx(AnimatedCircle, {
188
- animatedProps: pulseAnimatedProps,
189
- fill: pointColor,
190
- r: pulseRadius
191
- }), /*#__PURE__*/_jsx(AnimatedCircle, {
192
- animatedProps: pointAnimatedProps,
193
- fill: pointColor,
194
- r: radius,
195
- stroke: theme.color.bg,
196
- strokeWidth: 2
197
- })]
198
- });
199
- }));