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.
- package/README.md +143 -66
- package/lib/commonjs/charts/candle/Candle.js +92 -177
- package/lib/commonjs/charts/candle/Candles.js +39 -66
- package/lib/commonjs/charts/candle/Chart.js +26 -37
- package/lib/commonjs/charts/candle/Context.js +49 -69
- package/lib/commonjs/charts/candle/Crosshair.js +82 -183
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +61 -140
- package/lib/commonjs/charts/candle/DatetimeText.js +14 -19
- package/lib/commonjs/charts/candle/Line.js +27 -73
- package/lib/commonjs/charts/candle/PriceText.js +14 -19
- package/lib/commonjs/charts/candle/index.js +64 -67
- package/lib/commonjs/charts/candle/types.js +4 -4
- package/lib/commonjs/charts/candle/useCandleData.js +12 -9
- package/lib/commonjs/charts/candle/useCandlestickChart.js +7 -9
- package/lib/commonjs/charts/candle/useDatetime.js +18 -16
- package/lib/commonjs/charts/candle/usePrice.js +22 -21
- package/lib/commonjs/charts/candle/utils/getDomain.js +9 -5
- package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getHeight.js +11 -12
- package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getPrice.js +11 -12
- package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getY.js +11 -12
- package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/index.js +16 -16
- package/lib/commonjs/charts/line/Axis.js +148 -268
- package/lib/commonjs/charts/line/Chart.js +62 -129
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/ChartPath.js +105 -285
- package/lib/commonjs/charts/line/Context.js +37 -95
- package/lib/commonjs/charts/line/Cursor.js +74 -125
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +56 -134
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +67 -152
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/Data.js +34 -73
- package/lib/commonjs/charts/line/DatetimeText.js +15 -20
- package/lib/commonjs/charts/line/Dot.js +56 -149
- package/lib/commonjs/charts/line/Gradient.js +53 -124
- package/lib/commonjs/charts/line/Group.js +23 -54
- package/lib/commonjs/charts/line/Group.js.map +1 -1
- package/lib/commonjs/charts/line/Highlight.js +47 -115
- package/lib/commonjs/charts/line/HorizontalLine.js +39 -92
- package/lib/commonjs/charts/line/HoverTrap/index.js +7 -10
- package/lib/commonjs/charts/line/HoverTrap/index.web.js +43 -48
- package/lib/commonjs/charts/line/LineChartPathContext.js +11 -14
- package/lib/commonjs/charts/line/Path.js +32 -78
- package/lib/commonjs/charts/line/PriceText.js +36 -78
- package/lib/commonjs/charts/line/Tooltip.js +102 -188
- package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
- package/lib/commonjs/charts/line/index.js +65 -65
- package/lib/commonjs/charts/line/types.js +4 -4
- package/lib/commonjs/charts/line/useAnimatedPath.js +22 -27
- package/lib/commonjs/charts/line/useCurrentY.js +17 -17
- package/lib/commonjs/charts/line/useDatetime.js +28 -32
- package/lib/commonjs/charts/line/useLineChart.js +15 -20
- package/lib/commonjs/charts/line/usePrice.js +26 -28
- package/lib/commonjs/charts/line/utils/getArea.js +14 -47
- package/lib/commonjs/charts/line/utils/getDomain.js +8 -5
- package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getPath.js +14 -53
- package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +5 -8
- package/lib/commonjs/charts/line/utils/index.js +19 -19
- package/lib/commonjs/charts/line/utils/interpolatePath.js +60 -100
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
- package/lib/commonjs/components/AnimatedText.js +29 -67
- package/lib/commonjs/index.js +19 -19
- package/lib/commonjs/types.js +2 -2
- package/lib/commonjs/utils/formatDatetime.js +9 -5
- package/lib/commonjs/utils/formatPrice.js +6 -10
- package/lib/commonjs/utils/index.js +13 -13
- package/lib/commonjs/utils/usePrevious.js +6 -8
- package/lib/module/charts/candle/Candle.js +76 -126
- package/lib/module/charts/candle/Candles.js +30 -52
- package/lib/module/charts/candle/Chart.js +19 -22
- package/lib/module/charts/candle/Context.js +29 -47
- package/lib/module/charts/candle/Crosshair.js +69 -142
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +51 -101
- package/lib/module/charts/candle/DatetimeText.js +5 -5
- package/lib/module/charts/candle/Line.js +19 -37
- package/lib/module/charts/candle/PriceText.js +5 -5
- package/lib/module/charts/candle/index.js +2 -2
- package/lib/module/charts/candle/types.js +1 -1
- package/lib/module/charts/candle/useCandleData.js +7 -3
- package/lib/module/charts/candle/useCandlestickChart.js +1 -1
- package/lib/module/charts/candle/useDatetime.js +12 -10
- package/lib/module/charts/candle/usePrice.js +14 -12
- package/lib/module/charts/candle/utils/getDomain.js +6 -2
- package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/module/charts/candle/utils/getHeight.js +8 -9
- package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/module/charts/candle/utils/getPrice.js +8 -4
- package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/module/charts/candle/utils/getY.js +8 -4
- package/lib/module/charts/candle/utils/getY.js.map +1 -1
- package/lib/module/charts/candle/utils/index.js +1 -1
- package/lib/module/charts/line/Axis.js +113 -189
- package/lib/module/charts/line/Chart.js +40 -73
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/ChartPath.js +90 -238
- package/lib/module/charts/line/Context.js +29 -61
- package/lib/module/charts/line/Cursor.js +61 -82
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +47 -99
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +52 -107
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/Data.js +28 -41
- package/lib/module/charts/line/DatetimeText.js +5 -5
- package/lib/module/charts/line/Dot.js +39 -93
- package/lib/module/charts/line/Gradient.js +41 -79
- package/lib/module/charts/line/Group.js +14 -15
- package/lib/module/charts/line/Group.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +32 -61
- package/lib/module/charts/line/HorizontalLine.js +27 -49
- package/lib/module/charts/line/HoverTrap/index.js +2 -3
- package/lib/module/charts/line/HoverTrap/index.web.js +34 -34
- package/lib/module/charts/line/LineChartPathContext.js +3 -3
- package/lib/module/charts/line/Path.js +20 -33
- package/lib/module/charts/line/PriceText.js +25 -42
- package/lib/module/charts/line/Tooltip.js +89 -151
- package/lib/module/charts/line/Tooltip.js.map +1 -1
- package/lib/module/charts/line/index.js +2 -2
- package/lib/module/charts/line/types.js +1 -1
- package/lib/module/charts/line/useAnimatedPath.js +16 -22
- package/lib/module/charts/line/useCurrentY.js +9 -4
- package/lib/module/charts/line/useDatetime.js +22 -26
- package/lib/module/charts/line/useLineChart.js +7 -10
- package/lib/module/charts/line/usePrice.js +20 -22
- package/lib/module/charts/line/utils/getArea.js +8 -15
- package/lib/module/charts/line/utils/getDomain.js +5 -2
- package/lib/module/charts/line/utils/getDomain.js.map +1 -1
- package/lib/module/charts/line/utils/getPath.js +8 -21
- package/lib/module/charts/line/utils/getXPositionForCurve.js +2 -5
- package/lib/module/charts/line/utils/index.js +1 -1
- package/lib/module/charts/line/utils/interpolatePath.js +57 -97
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
- package/lib/module/components/AnimatedText.js +21 -25
- package/lib/module/index.js +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/utils/formatDatetime.js +6 -2
- package/lib/module/utils/formatPrice.js +3 -7
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/usePrevious.js +1 -1
- package/lib/typescript/src/charts/candle/Candle.d.ts +31 -45
- package/lib/typescript/src/charts/candle/Candles.d.ts +13 -24
- package/lib/typescript/src/charts/candle/Chart.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Context.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +9 -17
- package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +8 -15
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +9 -15
- package/lib/typescript/src/charts/candle/Line.d.ts +5 -10
- package/lib/typescript/src/charts/candle/PriceText.d.ts +7 -13
- package/lib/typescript/src/charts/candle/index.d.ts +13 -32
- package/lib/typescript/src/charts/candle/types.d.ts +16 -16
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +9 -13
- package/lib/typescript/src/charts/candle/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getY.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/Axis.d.ts +14 -27
- package/lib/typescript/src/charts/line/Chart.d.ts +23 -33
- package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/ChartPath.d.ts +15 -28
- package/lib/typescript/src/charts/line/Context.d.ts +9 -16
- package/lib/typescript/src/charts/line/Cursor.d.ts +14 -22
- package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +11 -23
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorLine.d.ts +9 -15
- package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Data.d.ts +13 -17
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +8 -14
- package/lib/typescript/src/charts/line/Dot.d.ts +25 -38
- package/lib/typescript/src/charts/line/Gradient.d.ts +5 -9
- package/lib/typescript/src/charts/line/Group.d.ts +3 -6
- package/lib/typescript/src/charts/line/Group.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Highlight.d.ts +9 -17
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts +22 -30
- package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +1 -1
- package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
- package/lib/typescript/src/charts/line/Path.d.ts +23 -28
- package/lib/typescript/src/charts/line/PriceText.d.ts +20 -28
- package/lib/typescript/src/charts/line/Tooltip.d.ts +20 -32
- package/lib/typescript/src/charts/line/index.d.ts +20 -33
- package/lib/typescript/src/charts/line/types.d.ts +17 -19
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +7 -10
- package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
- package/lib/typescript/src/charts/line/useDatetime.d.ts +7 -11
- package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
- package/lib/typescript/src/charts/line/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -17
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -21
- package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +5 -17
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -4
- package/lib/typescript/src/components/AnimatedText.d.ts +4 -7
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +4 -7
- package/lib/typescript/src/utils/formatDatetime.d.ts +5 -9
- package/lib/typescript/src/utils/formatPrice.d.ts +5 -9
- package/lib/typescript/src/utils/index.d.ts +1 -1
- package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
- package/package.json +1 -1
- package/src/charts/line/CursorLine.tsx +6 -2
- package/src/charts/line/HorizontalLine.tsx +5 -1
|
@@ -1,47 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
value: true
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.LineChartAxis = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require(
|
|
8
|
-
var _reactNative = require(
|
|
9
|
-
var _reactNativeSvg = require(
|
|
10
|
-
var _reactNativeReanimated = _interopRequireWildcard(
|
|
11
|
-
|
|
12
|
-
);
|
|
13
|
-
var
|
|
14
|
-
|
|
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 =
|
|
23
|
+
format = value => value,
|
|
54
24
|
textStyle,
|
|
55
25
|
labelPadding = 3,
|
|
56
26
|
containerStyle,
|
|
57
27
|
...props
|
|
58
28
|
}) => {
|
|
59
|
-
const {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
?
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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 {
|
|
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__*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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__*/
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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__*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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__*/
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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 {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|