react-native-wagmi-charts 2.9.0 → 2.10.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.
Files changed (218) hide show
  1. package/README.md +143 -66
  2. package/lib/commonjs/charts/candle/Candle.js +92 -177
  3. package/lib/commonjs/charts/candle/Candles.js +39 -66
  4. package/lib/commonjs/charts/candle/Chart.js +26 -37
  5. package/lib/commonjs/charts/candle/Context.js +49 -69
  6. package/lib/commonjs/charts/candle/Crosshair.js +82 -183
  7. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  8. package/lib/commonjs/charts/candle/CrosshairTooltip.js +61 -140
  9. package/lib/commonjs/charts/candle/DatetimeText.js +14 -19
  10. package/lib/commonjs/charts/candle/Line.js +27 -73
  11. package/lib/commonjs/charts/candle/PriceText.js +14 -19
  12. package/lib/commonjs/charts/candle/index.js +64 -67
  13. package/lib/commonjs/charts/candle/types.js +4 -4
  14. package/lib/commonjs/charts/candle/useCandleData.js +12 -9
  15. package/lib/commonjs/charts/candle/useCandlestickChart.js +7 -9
  16. package/lib/commonjs/charts/candle/useDatetime.js +18 -16
  17. package/lib/commonjs/charts/candle/usePrice.js +22 -21
  18. package/lib/commonjs/charts/candle/utils/getDomain.js +9 -5
  19. package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
  20. package/lib/commonjs/charts/candle/utils/getHeight.js +11 -12
  21. package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
  22. package/lib/commonjs/charts/candle/utils/getPrice.js +11 -12
  23. package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
  24. package/lib/commonjs/charts/candle/utils/getY.js +11 -12
  25. package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
  26. package/lib/commonjs/charts/candle/utils/index.js +16 -16
  27. package/lib/commonjs/charts/line/Axis.js +148 -268
  28. package/lib/commonjs/charts/line/Chart.js +62 -129
  29. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  30. package/lib/commonjs/charts/line/ChartPath.js +105 -285
  31. package/lib/commonjs/charts/line/Context.js +37 -95
  32. package/lib/commonjs/charts/line/Cursor.js +74 -125
  33. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  34. package/lib/commonjs/charts/line/CursorCrosshair.js +56 -134
  35. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  36. package/lib/commonjs/charts/line/CursorLine.js +67 -152
  37. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  38. package/lib/commonjs/charts/line/Data.js +34 -73
  39. package/lib/commonjs/charts/line/DatetimeText.js +15 -20
  40. package/lib/commonjs/charts/line/Dot.js +56 -149
  41. package/lib/commonjs/charts/line/Gradient.js +53 -124
  42. package/lib/commonjs/charts/line/Group.js +23 -54
  43. package/lib/commonjs/charts/line/Group.js.map +1 -1
  44. package/lib/commonjs/charts/line/Highlight.js +47 -115
  45. package/lib/commonjs/charts/line/HorizontalLine.js +39 -92
  46. package/lib/commonjs/charts/line/HoverTrap/index.js +7 -10
  47. package/lib/commonjs/charts/line/HoverTrap/index.web.js +43 -48
  48. package/lib/commonjs/charts/line/LineChartPathContext.js +11 -14
  49. package/lib/commonjs/charts/line/Path.js +32 -78
  50. package/lib/commonjs/charts/line/PriceText.js +36 -78
  51. package/lib/commonjs/charts/line/Tooltip.js +102 -188
  52. package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
  53. package/lib/commonjs/charts/line/index.js +65 -65
  54. package/lib/commonjs/charts/line/types.js +4 -4
  55. package/lib/commonjs/charts/line/useAnimatedPath.js +22 -27
  56. package/lib/commonjs/charts/line/useCurrentY.js +17 -17
  57. package/lib/commonjs/charts/line/useDatetime.js +28 -32
  58. package/lib/commonjs/charts/line/useLineChart.js +15 -20
  59. package/lib/commonjs/charts/line/usePrice.js +26 -28
  60. package/lib/commonjs/charts/line/utils/getArea.js +14 -47
  61. package/lib/commonjs/charts/line/utils/getDomain.js +8 -5
  62. package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
  63. package/lib/commonjs/charts/line/utils/getPath.js +14 -53
  64. package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +5 -8
  65. package/lib/commonjs/charts/line/utils/index.js +19 -19
  66. package/lib/commonjs/charts/line/utils/interpolatePath.js +60 -100
  67. package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
  68. package/lib/commonjs/components/AnimatedText.js +29 -67
  69. package/lib/commonjs/index.js +19 -19
  70. package/lib/commonjs/types.js +2 -2
  71. package/lib/commonjs/utils/formatDatetime.js +9 -5
  72. package/lib/commonjs/utils/formatPrice.js +6 -10
  73. package/lib/commonjs/utils/index.js +13 -13
  74. package/lib/commonjs/utils/usePrevious.js +6 -8
  75. package/lib/module/charts/candle/Candle.js +76 -126
  76. package/lib/module/charts/candle/Candles.js +30 -52
  77. package/lib/module/charts/candle/Chart.js +19 -22
  78. package/lib/module/charts/candle/Context.js +29 -47
  79. package/lib/module/charts/candle/Crosshair.js +69 -142
  80. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  81. package/lib/module/charts/candle/CrosshairTooltip.js +51 -101
  82. package/lib/module/charts/candle/DatetimeText.js +5 -5
  83. package/lib/module/charts/candle/Line.js +19 -37
  84. package/lib/module/charts/candle/PriceText.js +5 -5
  85. package/lib/module/charts/candle/index.js +2 -2
  86. package/lib/module/charts/candle/types.js +1 -1
  87. package/lib/module/charts/candle/useCandleData.js +7 -3
  88. package/lib/module/charts/candle/useCandlestickChart.js +1 -1
  89. package/lib/module/charts/candle/useDatetime.js +12 -10
  90. package/lib/module/charts/candle/usePrice.js +14 -12
  91. package/lib/module/charts/candle/utils/getDomain.js +6 -2
  92. package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
  93. package/lib/module/charts/candle/utils/getHeight.js +8 -9
  94. package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
  95. package/lib/module/charts/candle/utils/getPrice.js +8 -4
  96. package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
  97. package/lib/module/charts/candle/utils/getY.js +8 -4
  98. package/lib/module/charts/candle/utils/getY.js.map +1 -1
  99. package/lib/module/charts/candle/utils/index.js +1 -1
  100. package/lib/module/charts/line/Axis.js +113 -189
  101. package/lib/module/charts/line/Chart.js +40 -73
  102. package/lib/module/charts/line/Chart.js.map +1 -1
  103. package/lib/module/charts/line/ChartPath.js +90 -238
  104. package/lib/module/charts/line/Context.js +29 -61
  105. package/lib/module/charts/line/Cursor.js +61 -82
  106. package/lib/module/charts/line/Cursor.js.map +1 -1
  107. package/lib/module/charts/line/CursorCrosshair.js +47 -99
  108. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  109. package/lib/module/charts/line/CursorLine.js +52 -107
  110. package/lib/module/charts/line/CursorLine.js.map +1 -1
  111. package/lib/module/charts/line/Data.js +28 -41
  112. package/lib/module/charts/line/DatetimeText.js +5 -5
  113. package/lib/module/charts/line/Dot.js +39 -93
  114. package/lib/module/charts/line/Gradient.js +41 -79
  115. package/lib/module/charts/line/Group.js +14 -15
  116. package/lib/module/charts/line/Group.js.map +1 -1
  117. package/lib/module/charts/line/Highlight.js +32 -61
  118. package/lib/module/charts/line/HorizontalLine.js +27 -49
  119. package/lib/module/charts/line/HoverTrap/index.js +2 -3
  120. package/lib/module/charts/line/HoverTrap/index.web.js +34 -34
  121. package/lib/module/charts/line/LineChartPathContext.js +3 -3
  122. package/lib/module/charts/line/Path.js +20 -33
  123. package/lib/module/charts/line/PriceText.js +25 -42
  124. package/lib/module/charts/line/Tooltip.js +89 -151
  125. package/lib/module/charts/line/Tooltip.js.map +1 -1
  126. package/lib/module/charts/line/index.js +2 -2
  127. package/lib/module/charts/line/types.js +1 -1
  128. package/lib/module/charts/line/useAnimatedPath.js +16 -22
  129. package/lib/module/charts/line/useCurrentY.js +9 -4
  130. package/lib/module/charts/line/useDatetime.js +22 -26
  131. package/lib/module/charts/line/useLineChart.js +7 -10
  132. package/lib/module/charts/line/usePrice.js +20 -22
  133. package/lib/module/charts/line/utils/getArea.js +8 -15
  134. package/lib/module/charts/line/utils/getDomain.js +5 -2
  135. package/lib/module/charts/line/utils/getDomain.js.map +1 -1
  136. package/lib/module/charts/line/utils/getPath.js +8 -21
  137. package/lib/module/charts/line/utils/getXPositionForCurve.js +2 -5
  138. package/lib/module/charts/line/utils/index.js +1 -1
  139. package/lib/module/charts/line/utils/interpolatePath.js +57 -97
  140. package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
  141. package/lib/module/components/AnimatedText.js +21 -25
  142. package/lib/module/index.js +1 -1
  143. package/lib/module/types.js +2 -1
  144. package/lib/module/utils/formatDatetime.js +6 -2
  145. package/lib/module/utils/formatPrice.js +3 -7
  146. package/lib/module/utils/index.js +1 -1
  147. package/lib/module/utils/usePrevious.js +1 -1
  148. package/lib/typescript/src/charts/candle/Candle.d.ts +31 -45
  149. package/lib/typescript/src/charts/candle/Candles.d.ts +13 -24
  150. package/lib/typescript/src/charts/candle/Chart.d.ts +7 -12
  151. package/lib/typescript/src/charts/candle/Context.d.ts +7 -12
  152. package/lib/typescript/src/charts/candle/Crosshair.d.ts +9 -17
  153. package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +8 -15
  154. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +9 -15
  155. package/lib/typescript/src/charts/candle/Line.d.ts +5 -10
  156. package/lib/typescript/src/charts/candle/PriceText.d.ts +7 -13
  157. package/lib/typescript/src/charts/candle/index.d.ts +13 -32
  158. package/lib/typescript/src/charts/candle/types.d.ts +16 -16
  159. package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
  160. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
  161. package/lib/typescript/src/charts/candle/useDatetime.d.ts +9 -13
  162. package/lib/typescript/src/charts/candle/usePrice.d.ts +7 -11
  163. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
  164. package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -1
  165. package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +5 -9
  166. package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +5 -9
  167. package/lib/typescript/src/charts/candle/utils/getY.d.ts +5 -9
  168. package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
  169. package/lib/typescript/src/charts/line/Axis.d.ts +14 -27
  170. package/lib/typescript/src/charts/line/Chart.d.ts +23 -33
  171. package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
  172. package/lib/typescript/src/charts/line/ChartPath.d.ts +15 -28
  173. package/lib/typescript/src/charts/line/Context.d.ts +9 -16
  174. package/lib/typescript/src/charts/line/Cursor.d.ts +14 -22
  175. package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
  176. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +11 -23
  177. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
  178. package/lib/typescript/src/charts/line/CursorLine.d.ts +9 -15
  179. package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
  180. package/lib/typescript/src/charts/line/Data.d.ts +13 -17
  181. package/lib/typescript/src/charts/line/DatetimeText.d.ts +8 -14
  182. package/lib/typescript/src/charts/line/Dot.d.ts +25 -38
  183. package/lib/typescript/src/charts/line/Gradient.d.ts +5 -9
  184. package/lib/typescript/src/charts/line/Group.d.ts +3 -6
  185. package/lib/typescript/src/charts/line/Group.d.ts.map +1 -1
  186. package/lib/typescript/src/charts/line/Highlight.d.ts +9 -17
  187. package/lib/typescript/src/charts/line/HorizontalLine.d.ts +22 -30
  188. package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
  189. package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +1 -1
  190. package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
  191. package/lib/typescript/src/charts/line/Path.d.ts +23 -28
  192. package/lib/typescript/src/charts/line/PriceText.d.ts +20 -28
  193. package/lib/typescript/src/charts/line/Tooltip.d.ts +20 -32
  194. package/lib/typescript/src/charts/line/index.d.ts +20 -33
  195. package/lib/typescript/src/charts/line/types.d.ts +17 -19
  196. package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +7 -10
  197. package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
  198. package/lib/typescript/src/charts/line/useDatetime.d.ts +7 -11
  199. package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
  200. package/lib/typescript/src/charts/line/usePrice.d.ts +7 -11
  201. package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -17
  202. package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
  203. package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -1
  204. package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -21
  205. package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
  206. package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
  207. package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +5 -17
  208. package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -4
  209. package/lib/typescript/src/components/AnimatedText.d.ts +4 -7
  210. package/lib/typescript/src/index.d.ts +1 -1
  211. package/lib/typescript/src/types.d.ts +4 -7
  212. package/lib/typescript/src/utils/formatDatetime.d.ts +5 -9
  213. package/lib/typescript/src/utils/formatPrice.d.ts +5 -9
  214. package/lib/typescript/src/utils/index.d.ts +1 -1
  215. package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
  216. package/package.json +1 -1
  217. package/src/charts/line/CursorLine.tsx +6 -2
  218. package/src/charts/line/HorizontalLine.tsx +5 -1
@@ -1,47 +1,17 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
5
  });
6
6
  exports.LineChartAxis = void 0;
7
- var _react = _interopRequireDefault(require('react'));
8
- var _reactNative = require('react-native');
9
- var _reactNativeSvg = require('react-native-svg');
10
- var _reactNativeReanimated = _interopRequireWildcard(
11
- require('react-native-reanimated')
12
- );
13
- var _Chart = require('./Chart');
14
- var _useLineChart = require('./useLineChart');
15
- function _interopRequireWildcard(e, t) {
16
- if ('function' == typeof WeakMap)
17
- var r = new WeakMap(),
18
- n = new WeakMap();
19
- return (_interopRequireWildcard = function (e, t) {
20
- if (!t && e && e.__esModule) return e;
21
- var o,
22
- i,
23
- f = { __proto__: null, default: e };
24
- if (null === e || ('object' != typeof e && 'function' != typeof e))
25
- return f;
26
- if ((o = t ? n : r)) {
27
- if (o.has(e)) return o.get(e);
28
- o.set(e, f);
29
- }
30
- for (const t in e)
31
- 'default' !== t &&
32
- {}.hasOwnProperty.call(e, t) &&
33
- ((i =
34
- (o = Object.defineProperty) &&
35
- Object.getOwnPropertyDescriptor(e, t)) &&
36
- (i.get || i.set)
37
- ? o(f, t, i)
38
- : (f[t] = e[t]));
39
- return f;
40
- })(e, t);
41
- }
42
- function _interopRequireDefault(e) {
43
- return e && e.__esModule ? e : { default: e };
44
- }
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeSvg = require("react-native-svg");
10
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
+ var _Chart = require("./Chart");
12
+ var _useLineChart = require("./useLineChart");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
45
15
  const LineChartAxis = ({
46
16
  position,
47
17
  orientation,
@@ -50,31 +20,33 @@ const LineChartAxis = ({
50
20
  tickCount = 5,
51
21
  domain = [0, 100],
52
22
  hideOnInteraction = false,
53
- format = (value) => value,
23
+ format = value => value,
54
24
  textStyle,
55
25
  labelPadding = 3,
56
26
  containerStyle,
57
27
  ...props
58
28
  }) => {
59
- const { width, height } = _react.default.useContext(
60
- _Chart.LineChartDimensionsContext
61
- );
62
- const { isActive } = (0, _useLineChart.useLineChart)();
29
+ const {
30
+ width,
31
+ height
32
+ } = _react.default.useContext(_Chart.LineChartDimensionsContext);
33
+ const {
34
+ isActive
35
+ } = (0, _useLineChart.useLineChart)();
63
36
 
64
37
  // Reserve space at the bottom for x-axis cursor labels
65
38
  const X_AXIS_LABEL_RESERVED_HEIGHT = 40;
66
39
  // For vertical axes, don't extend into the reserved cursor label space
67
- const effectiveHeight =
68
- orientation === 'vertical' ? height - X_AXIS_LABEL_RESERVED_HEIGHT : height;
40
+ const effectiveHeight = orientation === 'vertical' ? height - X_AXIS_LABEL_RESERVED_HEIGHT : height;
69
41
  const padding = {
70
42
  left: 5,
71
43
  right: 5,
72
44
  top: 20,
73
- bottom: 20,
45
+ bottom: 20
74
46
  };
75
47
  const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
76
48
  return {
77
- opacity: hideOnInteraction && isActive.value ? 0 : 1,
49
+ opacity: hideOnInteraction && isActive.value ? 0 : 1
78
50
  };
79
51
  }, [hideOnInteraction, isActive]);
80
52
  const renderTicks = () => {
@@ -98,15 +70,12 @@ const LineChartAxis = ({
98
70
  }
99
71
 
100
72
  // Dynamic width allocation - ensure we don't exceed available space
101
- const maxAllowableWidth =
102
- position === 'left' || position === 'right'
103
- ? Math.max(width * 0.3, 60) // Allow up to 30% of chart width for y-axis labels, minimum 60px
104
- : width * 0.9; // For horizontal labels, use most of the width
73
+ const maxAllowableWidth = position === 'left' || position === 'right' ? Math.max(width * 0.3, 60) // Allow up to 30% of chart width for y-axis labels, minimum 60px
74
+ : width * 0.9; // For horizontal labels, use most of the width
105
75
 
106
- const dynamicLabelWidth = Math.min(
107
- Math.max(maxLabelWidth + 16, 40),
108
- // Minimum 40px, add 16px padding
109
- maxAllowableWidth // Don't exceed the calculated max
76
+ const dynamicLabelWidth = Math.min(Math.max(maxLabelWidth + 16, 40),
77
+ // Minimum 40px, add 16px padding
78
+ maxAllowableWidth // Don't exceed the calculated max
110
79
  );
111
80
  for (let i = 0; i <= tickCount; i++) {
112
81
  const value = min + (max - min) * (i / tickCount);
@@ -121,234 +90,145 @@ const LineChartAxis = ({
121
90
  const y = topPadding + availableHeight * (1 - tickPosition);
122
91
  const x = position === 'left' ? padding.left : width - padding.right;
123
92
  if (strokeWidth) {
124
- ticks.push(
125
- /*#__PURE__*/ _react.default.createElement(_reactNativeSvg.Line, {
126
- key: `tick-${i}`,
127
- x1: x,
128
- y1: y,
129
- x2: position === 'left' ? x - tickLength : x + tickLength,
130
- y2: y,
131
- stroke: color,
132
- strokeWidth: strokeWidth,
133
- })
134
- );
93
+ ticks.push(/*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
94
+ key: `tick-${i}`,
95
+ x1: x,
96
+ y1: y,
97
+ x2: position === 'left' ? x - tickLength : x + tickLength,
98
+ y2: y,
99
+ stroke: color,
100
+ strokeWidth: strokeWidth
101
+ }));
135
102
  }
136
- labels.push(
137
- /*#__PURE__*/ _react.default.createElement(
138
- _reactNativeReanimated.default.View,
139
- {
140
- key: `label-${i}`,
141
- style: [
142
- styles.verticalLabel,
143
- {
144
- width: dynamicLabelWidth,
145
- // Use calculated width
146
- left:
147
- position === 'left'
148
- ? Math.max(0, x - labelOffset - dynamicLabelWidth) // Keep labels within left boundary
149
- : Math.min(
150
- width - dynamicLabelWidth - 5,
151
- x + labelOffset
152
- ),
153
- // Keep labels within right boundary with 5px margin
154
- top: y - 10, // Center the label vertically on the tick mark
155
- },
156
- position === 'left' ? styles.alignEnd : styles.alignStart,
157
- ],
158
- },
159
- /*#__PURE__*/ _react.default.createElement(
160
- _reactNative.Text,
161
- {
162
- numberOfLines: 1,
163
- ellipsizeMode: 'tail',
164
- style: [
165
- styles.labelText,
166
- {
167
- color: color,
168
- },
169
- position === 'left' ? styles.textRight : styles.textLeft,
170
- textStyle,
171
- ],
172
- adjustsFontSizeToFit: true,
173
- minimumFontScale: 0.7,
174
- },
175
- String(format(value))
176
- )
177
- )
178
- );
103
+ labels.push(/*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
104
+ key: `label-${i}`,
105
+ style: [styles.verticalLabel, {
106
+ width: dynamicLabelWidth,
107
+ // Use calculated width
108
+ left: position === 'left' ? Math.max(0, x - labelOffset - dynamicLabelWidth) // Keep labels within left boundary
109
+ : Math.min(width - dynamicLabelWidth - 5, x + labelOffset),
110
+ // Keep labels within right boundary with 5px margin
111
+ top: y - 10 // Center the label vertically on the tick mark
112
+ }, position === 'left' ? styles.alignEnd : styles.alignStart]
113
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
114
+ numberOfLines: 1,
115
+ ellipsizeMode: "tail",
116
+ style: [styles.labelText, {
117
+ color: color
118
+ }, position === 'left' ? styles.textRight : styles.textLeft, textStyle],
119
+ adjustsFontSizeToFit: true,
120
+ minimumFontScale: 0.7
121
+ }, String(format(value)))));
179
122
  } else {
180
123
  const x = width * tickPosition;
181
124
  const y = position === 'top' ? 15 : height - padding.bottom;
182
125
  if (strokeWidth) {
183
- ticks.push(
184
- /*#__PURE__*/ _react.default.createElement(_reactNativeSvg.Line, {
185
- key: `tick-${i}`,
186
- x1: x,
187
- y1: y,
188
- x2: x,
189
- y2: position === 'top' ? y - tickLength : height - 15,
190
- stroke: color,
191
- strokeWidth: strokeWidth,
192
- })
193
- );
126
+ ticks.push(/*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
127
+ key: `tick-${i}`,
128
+ x1: x,
129
+ y1: y,
130
+ x2: x,
131
+ y2: position === 'top' ? y - tickLength : height - 15,
132
+ stroke: color,
133
+ strokeWidth: strokeWidth
134
+ }));
194
135
  }
195
- const alignmentStyle =
196
- i === 0
197
- ? styles.alignStart
198
- : i === tickCount
199
- ? styles.alignEnd
200
- : styles.alignCenter;
201
- const textAlignStyle =
202
- i === 0
203
- ? styles.textLeft
204
- : i === tickCount
205
- ? styles.textRight
206
- : styles.textCenter;
207
- labels.push(
208
- /*#__PURE__*/ _react.default.createElement(
209
- _reactNativeReanimated.default.View,
210
- {
211
- key: `label-${i}`,
212
- style: [
213
- styles.horizontalLabel,
214
- {
215
- width: dynamicLabelWidth,
216
- // Use dynamic width for horizontal labels too
217
- left: Math.max(
218
- 0,
219
- Math.min(
220
- width - dynamicLabelWidth,
221
- i === 0
222
- ? x + labelOffset
223
- : i === tickCount
224
- ? x - dynamicLabelWidth - labelOffset
225
- : x - dynamicLabelWidth / 2
226
- )
227
- ),
228
- top:
229
- position === 'top'
230
- ? Math.max(0, y - labelOffset - 15)
231
- : Math.max(0, height - 35),
232
- },
233
- alignmentStyle,
234
- ],
235
- },
236
- /*#__PURE__*/ _react.default.createElement(
237
- _reactNative.Text,
238
- {
239
- numberOfLines: 1,
240
- ellipsizeMode: 'tail',
241
- style: [
242
- styles.labelText,
243
- {
244
- color: color,
245
- },
246
- textAlignStyle,
247
- textStyle,
248
- ],
249
- adjustsFontSizeToFit: true,
250
- minimumFontScale: 0.7,
251
- },
252
- String(format(value))
253
- )
254
- )
255
- );
136
+ const alignmentStyle = i === 0 ? styles.alignStart : i === tickCount ? styles.alignEnd : styles.alignCenter;
137
+ const textAlignStyle = i === 0 ? styles.textLeft : i === tickCount ? styles.textRight : styles.textCenter;
138
+ labels.push(/*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
139
+ key: `label-${i}`,
140
+ style: [styles.horizontalLabel, {
141
+ width: dynamicLabelWidth,
142
+ // Use dynamic width for horizontal labels too
143
+ left: Math.max(0, Math.min(width - dynamicLabelWidth, i === 0 ? x + labelOffset : i === tickCount ? x - dynamicLabelWidth - labelOffset : x - dynamicLabelWidth / 2)),
144
+ top: position === 'top' ? Math.max(0, y - labelOffset - 15) : Math.max(0, height - 35)
145
+ }, alignmentStyle]
146
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
147
+ numberOfLines: 1,
148
+ ellipsizeMode: "tail",
149
+ style: [styles.labelText, {
150
+ color: color
151
+ }, textAlignStyle, textStyle],
152
+ adjustsFontSizeToFit: true,
153
+ minimumFontScale: 0.7
154
+ }, String(format(value)))));
256
155
  }
257
156
  }
258
157
  return {
259
158
  ticks,
260
- labels,
159
+ labels
261
160
  };
262
161
  };
263
162
  const renderAxis = () => {
264
- const { ticks, labels } = renderTicks();
163
+ const {
164
+ ticks,
165
+ labels
166
+ } = renderTicks();
265
167
  let axisLine = null;
266
168
  if (strokeWidth) {
267
169
  switch (position) {
268
170
  case 'left':
269
- axisLine = /*#__PURE__*/ _react.default.createElement(
270
- _reactNativeSvg.Line,
271
- {
272
- x1: padding.left,
273
- y1: 0,
274
- x2: padding.left,
275
- y2: effectiveHeight,
276
- stroke: color,
277
- strokeWidth: strokeWidth,
278
- }
279
- );
171
+ axisLine = /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
172
+ x1: padding.left,
173
+ y1: 0,
174
+ x2: padding.left,
175
+ y2: effectiveHeight,
176
+ stroke: color,
177
+ strokeWidth: strokeWidth
178
+ });
280
179
  break;
281
180
  case 'right':
282
- axisLine = /*#__PURE__*/ _react.default.createElement(
283
- _reactNativeSvg.Line,
284
- {
285
- x1: width - padding.right,
286
- y1: 0,
287
- x2: width - padding.right,
288
- y2: effectiveHeight,
289
- stroke: color,
290
- strokeWidth: strokeWidth,
291
- }
292
- );
181
+ axisLine = /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
182
+ x1: width - padding.right,
183
+ y1: 0,
184
+ x2: width - padding.right,
185
+ y2: effectiveHeight,
186
+ stroke: color,
187
+ strokeWidth: strokeWidth
188
+ });
293
189
  break;
294
190
  case 'top':
295
- axisLine = /*#__PURE__*/ _react.default.createElement(
296
- _reactNativeSvg.Line,
297
- {
298
- x1: 0,
299
- y1: 20,
300
- x2: width,
301
- y2: 20,
302
- stroke: color,
303
- strokeWidth: strokeWidth,
304
- }
305
- );
191
+ axisLine = /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
192
+ x1: 0,
193
+ y1: 20,
194
+ x2: width,
195
+ y2: 20,
196
+ stroke: color,
197
+ strokeWidth: strokeWidth
198
+ });
306
199
  break;
307
200
  case 'bottom':
308
- axisLine = /*#__PURE__*/ _react.default.createElement(
309
- _reactNativeSvg.Line,
310
- {
311
- x1: 0,
312
- y1: height - 20,
313
- x2: width,
314
- y2: height - 20,
315
- stroke: color,
316
- strokeWidth: strokeWidth,
317
- }
318
- );
201
+ axisLine = /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Line, {
202
+ x1: 0,
203
+ y1: height - 20,
204
+ x2: width,
205
+ y2: height - 20,
206
+ stroke: color,
207
+ strokeWidth: strokeWidth
208
+ });
319
209
  break;
320
210
  }
321
211
  }
322
212
  return {
323
213
  axisLine,
324
214
  ticks,
325
- labels,
215
+ labels
326
216
  };
327
217
  };
328
- const { axisLine, ticks, labels } = renderAxis();
329
- return /*#__PURE__*/ _react.default.createElement(
330
- _reactNativeReanimated.default.View,
331
- {
332
- style: [styles.container, containerStyle, props.style, animatedStyle],
333
- },
334
- /*#__PURE__*/ _react.default.createElement(
335
- _reactNativeSvg.Svg,
336
- {
337
- width: width,
338
- height: height,
339
- style: _reactNative.StyleSheet.absoluteFill,
340
- },
341
- axisLine,
342
- ticks
343
- ),
344
- /*#__PURE__*/ _react.default.createElement(
345
- _reactNativeReanimated.default.View,
346
- {
347
- style: [_reactNative.StyleSheet.absoluteFill, styles.labelsContainer],
348
- },
349
- labels
350
- )
351
- );
218
+ const {
219
+ axisLine,
220
+ ticks,
221
+ labels
222
+ } = renderAxis();
223
+ return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
224
+ style: [styles.container, containerStyle, props.style, animatedStyle]
225
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeSvg.Svg, {
226
+ width: width,
227
+ height: height,
228
+ style: _reactNative.StyleSheet.absoluteFill
229
+ }, axisLine, ticks), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
230
+ style: [_reactNative.StyleSheet.absoluteFill, styles.labelsContainer]
231
+ }, labels));
352
232
  };
353
233
  exports.LineChartAxis = LineChartAxis;
354
234
  const styles = _reactNative.StyleSheet.create({
@@ -358,45 +238,45 @@ const styles = _reactNative.StyleSheet.create({
358
238
  left: 0,
359
239
  right: 0,
360
240
  bottom: 0,
361
- pointerEvents: 'none',
241
+ pointerEvents: 'none'
362
242
  },
363
243
  verticalLabel: {
364
244
  position: 'absolute',
365
245
  minHeight: 20,
366
246
  zIndex: 1000,
367
247
  overflow: 'visible',
368
- justifyContent: 'center',
248
+ justifyContent: 'center'
369
249
  },
370
250
  horizontalLabel: {
371
251
  position: 'absolute',
372
252
  minHeight: 20,
373
253
  zIndex: 1000,
374
254
  overflow: 'hidden',
375
- justifyContent: 'center',
255
+ justifyContent: 'center'
376
256
  },
377
257
  labelText: {
378
- fontSize: 10,
258
+ fontSize: 10
379
259
  },
380
260
  labelsContainer: {
381
- zIndex: 1000,
261
+ zIndex: 1000
382
262
  },
383
263
  alignStart: {
384
- alignItems: 'flex-start',
264
+ alignItems: 'flex-start'
385
265
  },
386
266
  alignEnd: {
387
- alignItems: 'flex-end',
267
+ alignItems: 'flex-end'
388
268
  },
389
269
  alignCenter: {
390
- alignItems: 'center',
270
+ alignItems: 'center'
391
271
  },
392
272
  textLeft: {
393
- textAlign: 'left',
273
+ textAlign: 'left'
394
274
  },
395
275
  textRight: {
396
- textAlign: 'right',
276
+ textAlign: 'right'
397
277
  },
398
278
  textCenter: {
399
- textAlign: 'center',
400
- },
279
+ textAlign: 'center'
280
+ }
401
281
  });
402
- //# sourceMappingURL=Axis.js.map
282
+ //# sourceMappingURL=Axis.js.map