@obitrain/charts 0.10.3 → 0.11.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 +4 -2
- package/lib/commonjs/Charts/BottomAxis/BottomAxis.js +53 -13
- package/lib/commonjs/Charts/BottomAxis/BottomAxis.js.map +1 -1
- package/lib/commonjs/Charts/BottomAxis/Tick.js +27 -11
- package/lib/commonjs/Charts/BottomAxis/Tick.js.map +1 -1
- package/lib/commonjs/Charts/BottomAxis/index.js.map +1 -1
- package/lib/commonjs/Charts/Cursor.js +18 -6
- package/lib/commonjs/Charts/Cursor.js.map +1 -1
- package/lib/commonjs/Charts/Dot.js +51 -0
- package/lib/commonjs/Charts/Dot.js.map +1 -0
- package/lib/commonjs/Charts/Dots.js +74 -0
- package/lib/commonjs/Charts/Dots.js.map +1 -0
- package/lib/commonjs/Charts/YAxis.js +64 -0
- package/lib/commonjs/Charts/YAxis.js.map +1 -0
- package/lib/commonjs/Charts/gesture.js +67 -24
- package/lib/commonjs/Charts/gesture.js.map +1 -1
- package/lib/commonjs/Charts/graphUtils.js +4 -1
- package/lib/commonjs/Charts/graphUtils.js.map +1 -1
- package/lib/commonjs/Charts/index.js +33 -0
- package/lib/commonjs/Charts/index.js.map +1 -1
- package/lib/module/Charts/BottomAxis/BottomAxis.js +55 -14
- package/lib/module/Charts/BottomAxis/BottomAxis.js.map +1 -1
- package/lib/module/Charts/BottomAxis/Tick.js +28 -10
- package/lib/module/Charts/BottomAxis/Tick.js.map +1 -1
- package/lib/module/Charts/BottomAxis/index.js.map +1 -1
- package/lib/module/Charts/Cursor.js +19 -7
- package/lib/module/Charts/Cursor.js.map +1 -1
- package/lib/module/Charts/Dot.js +47 -0
- package/lib/module/Charts/Dot.js.map +1 -0
- package/lib/module/Charts/Dots.js +70 -0
- package/lib/module/Charts/Dots.js.map +1 -0
- package/lib/module/Charts/YAxis.js +59 -0
- package/lib/module/Charts/YAxis.js.map +1 -0
- package/lib/module/Charts/gesture.js +67 -25
- package/lib/module/Charts/gesture.js.map +1 -1
- package/lib/module/Charts/graphUtils.js +4 -1
- package/lib/module/Charts/graphUtils.js.map +1 -1
- package/lib/module/Charts/index.js +4 -1
- package/lib/module/Charts/index.js.map +1 -1
- package/lib/typescript/commonjs/src/Charts/BottomAxis/BottomAxis.d.ts +26 -3
- package/lib/typescript/commonjs/src/Charts/BottomAxis/BottomAxis.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/BottomAxis/Tick.d.ts +16 -3
- package/lib/typescript/commonjs/src/Charts/BottomAxis/Tick.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/BottomAxis/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/Charts/BottomAxis/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/Cursor.d.ts +3 -0
- package/lib/typescript/commonjs/src/Charts/Cursor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/Dot.d.ts +22 -0
- package/lib/typescript/commonjs/src/Charts/Dot.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Charts/Dots.d.ts +28 -0
- package/lib/typescript/commonjs/src/Charts/Dots.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Charts/YAxis.d.ts +22 -0
- package/lib/typescript/commonjs/src/Charts/YAxis.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Charts/ZoomableLinechart/ScalablePath.d.ts +1 -1
- package/lib/typescript/commonjs/src/Charts/ZoomableLinechart/ScalablePath.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/gesture.d.ts +6 -0
- package/lib/typescript/commonjs/src/Charts/gesture.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/graphUtils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Charts/index.d.ts +8 -2
- package/lib/typescript/commonjs/src/Charts/index.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/BottomAxis/BottomAxis.d.ts +26 -3
- package/lib/typescript/module/src/Charts/BottomAxis/BottomAxis.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/BottomAxis/Tick.d.ts +16 -3
- package/lib/typescript/module/src/Charts/BottomAxis/Tick.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/BottomAxis/index.d.ts +1 -1
- package/lib/typescript/module/src/Charts/BottomAxis/index.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/Cursor.d.ts +3 -0
- package/lib/typescript/module/src/Charts/Cursor.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/Dot.d.ts +22 -0
- package/lib/typescript/module/src/Charts/Dot.d.ts.map +1 -0
- package/lib/typescript/module/src/Charts/Dots.d.ts +28 -0
- package/lib/typescript/module/src/Charts/Dots.d.ts.map +1 -0
- package/lib/typescript/module/src/Charts/YAxis.d.ts +22 -0
- package/lib/typescript/module/src/Charts/YAxis.d.ts.map +1 -0
- package/lib/typescript/module/src/Charts/ZoomableLinechart/ScalablePath.d.ts +1 -1
- package/lib/typescript/module/src/Charts/ZoomableLinechart/ScalablePath.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/gesture.d.ts +6 -0
- package/lib/typescript/module/src/Charts/gesture.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/graphUtils.d.ts.map +1 -1
- package/lib/typescript/module/src/Charts/index.d.ts +8 -2
- package/lib/typescript/module/src/Charts/index.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/Charts/BottomAxis/BottomAxis.tsx +100 -19
- package/src/Charts/BottomAxis/Tick.tsx +55 -11
- package/src/Charts/BottomAxis/index.tsx +5 -1
- package/src/Charts/Cursor.tsx +21 -1
- package/src/Charts/Dot.tsx +64 -0
- package/src/Charts/Dots.tsx +96 -0
- package/src/Charts/YAxis.tsx +96 -0
- package/src/Charts/ZoomableLinechart/ScalablePath.tsx +1 -1
- package/src/Charts/gesture.ts +109 -51
- package/src/Charts/graphUtils.ts +4 -1
- package/src/Charts/index.tsx +8 -0
package/README.md
CHANGED
|
@@ -155,8 +155,10 @@ From `example/src/screens/DotsScreen`.
|
|
|
155
155
|
|
|
156
156
|

|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
Two series with hollow markers (ring and diamond), pinch-to-zoom with live-clamped panning, period
|
|
159
|
+
presets, and a light/dark themed time axis whose bucketing and labels adapt to the visible window
|
|
160
|
+
(years → months → weeks → days). See the [implementation notes](./docs/advanced-chart.md).
|
|
161
|
+
From `example/src/screens/AdvancedChartScreen`.
|
|
160
162
|
|
|
161
163
|
## Example app
|
|
162
164
|
|
|
@@ -5,40 +5,80 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.BottomAxis = void 0;
|
|
7
7
|
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _react = require("react");
|
|
8
9
|
var _AxisLine = require("./AxisLine.js");
|
|
9
10
|
var _Tick = require("./Tick.js");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
|
|
12
|
+
/** A tick at an explicit position in graph space, as returned by a d3 scale. */
|
|
12
13
|
|
|
13
14
|
const BottomAxis = function (props) {
|
|
14
15
|
const {
|
|
15
16
|
labels,
|
|
17
|
+
ticks,
|
|
16
18
|
scale,
|
|
17
19
|
focalX,
|
|
18
20
|
offsetX,
|
|
19
21
|
style,
|
|
20
22
|
width,
|
|
21
|
-
font
|
|
23
|
+
font,
|
|
24
|
+
offsetY = 0,
|
|
25
|
+
standalone = true,
|
|
26
|
+
showAxisLine = true,
|
|
27
|
+
color,
|
|
28
|
+
labelColor,
|
|
29
|
+
tickLength,
|
|
30
|
+
strokeWidth,
|
|
31
|
+
dash,
|
|
32
|
+
labelAlign,
|
|
33
|
+
labelGap,
|
|
34
|
+
showLabels
|
|
22
35
|
} = props;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
const items = (0, _react.useMemo)(() => {
|
|
37
|
+
if (ticks !== undefined) return ticks;
|
|
38
|
+
if (labels === undefined) return [];
|
|
39
|
+
const interval = labels.length > 1 ? width / (labels.length - 1) : 0;
|
|
40
|
+
return labels.map((label, i) => ({
|
|
41
|
+
x: interval * i,
|
|
42
|
+
label
|
|
43
|
+
}));
|
|
44
|
+
}, [ticks, labels, width]);
|
|
45
|
+
|
|
46
|
+
// Callers naturally write `dash={[3, 4]}`; keying the memo on the values
|
|
47
|
+
// keeps one reference so the memoized Ticks are not rebuilt every render
|
|
48
|
+
const dashStart = dash?.[0];
|
|
49
|
+
const dashEnd = dash?.[1];
|
|
50
|
+
const dashIntervals = (0, _react.useMemo)(() => dashStart === undefined || dashEnd === undefined ? undefined : [dashStart, dashEnd], [dashStart, dashEnd]);
|
|
51
|
+
const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
52
|
+
children: [showAxisLine ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_AxisLine.AxisLine, {
|
|
28
53
|
width,
|
|
29
54
|
offsetY,
|
|
30
55
|
focalX,
|
|
31
56
|
scale,
|
|
32
|
-
offsetX
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
offsetX,
|
|
58
|
+
color,
|
|
59
|
+
strokeWidth
|
|
60
|
+
}) : null, items.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tick.Tick, {
|
|
61
|
+
initPosition: tick.x,
|
|
62
|
+
label: tick.label,
|
|
63
|
+
dash: dashIntervals,
|
|
36
64
|
offsetX,
|
|
37
65
|
offsetY,
|
|
38
66
|
focalX,
|
|
39
67
|
scale,
|
|
40
|
-
font
|
|
41
|
-
|
|
68
|
+
font,
|
|
69
|
+
color,
|
|
70
|
+
labelColor,
|
|
71
|
+
tickLength,
|
|
72
|
+
strokeWidth,
|
|
73
|
+
labelAlign,
|
|
74
|
+
labelGap,
|
|
75
|
+
showLabel: showLabels
|
|
76
|
+
}, `${tick.x}:${tick.label}`))]
|
|
77
|
+
});
|
|
78
|
+
if (!standalone) return content;
|
|
79
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Canvas, {
|
|
80
|
+
style: style,
|
|
81
|
+
children: content
|
|
42
82
|
});
|
|
43
83
|
};
|
|
44
84
|
exports.BottomAxis = BottomAxis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeSkia","require","_AxisLine","_Tick","_jsxRuntime","BottomAxis","props","labels","scale","focalX","offsetX","style","width","font","offsetY","
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_AxisLine","_Tick","_jsxRuntime","BottomAxis","props","labels","ticks","scale","focalX","offsetX","style","width","font","offsetY","standalone","showAxisLine","color","labelColor","tickLength","strokeWidth","dash","labelAlign","labelGap","showLabels","items","useMemo","undefined","interval","length","map","label","i","x","dashStart","dashEnd","dashIntervals","content","jsxs","Fragment","children","jsx","AxisLine","tick","Tick","initPosition","showLabel","Canvas","exports"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/BottomAxis.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAA8B,IAAAI,WAAA,GAAAJ,OAAA;AAE9B;;AAgCA,MAAMK,UAA+B,GAAG,SAAAA,CAAUC,KAAK,EAAE;EACvD,MAAM;IACJC,MAAM;IACNC,KAAK;IACLC,KAAK;IACLC,MAAM;IACNC,OAAO;IACPC,KAAK;IACLC,KAAK;IACLC,IAAI;IACJC,OAAO,GAAG,CAAC;IACXC,UAAU,GAAG,IAAI;IACjBC,YAAY,GAAG,IAAI;IACnBC,KAAK;IACLC,UAAU;IACVC,UAAU;IACVC,WAAW;IACXC,IAAI;IACJC,UAAU;IACVC,QAAQ;IACRC;EACF,CAAC,GAAGnB,KAAK;EAET,MAAMoB,KAAK,GAAG,IAAAC,cAAO,EAAa,MAAM;IACtC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Ee,aAAc;MAElB1B,OAAO;MACPI,OAAO;MACPL,MAAM;MACND,KAAK;MACLK,IAAI;MACJI,KAAK;MACLC,UAAU;MACVC,UAAU;MACVC,WAAW;MACXE,UAAU;MACVC,QAAQ;MAEVuB,SAAS,EAAEtB;IAAW,GAjBjB,GAAGmB,IAAI,CAACV,CAAC,IAAIU,IAAI,CAACZ,KAAK,EAkB7B,CACF,CAAC;EAAA,CACF,CACH;EAED,IAAI,CAAChB,UAAU,EAAE,OAAOsB,OAAO;EAC/B,oBAAO,IAAAlC,WAAA,CAAAsC,GAAA,EAAC3C,gBAAA,CAAAiD,MAAM;IAACpC,KAAK,EAAEA,KAAM;IAAA6B,QAAA,EAAEH;EAAO,CAAS,CAAC;AACjD,CAAC;AAACW,OAAA,CAAA5C,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -5,39 +5,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Tick = void 0;
|
|
7
7
|
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = require("react");
|
|
9
9
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
10
|
var _gesture = require("../gesture.js");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function
|
|
13
|
-
const Tick = props => {
|
|
12
|
+
const TickComponent = function (props) {
|
|
14
13
|
const {
|
|
15
14
|
label,
|
|
16
15
|
scale,
|
|
17
16
|
focalX,
|
|
18
17
|
offsetX,
|
|
19
18
|
initPosition,
|
|
20
|
-
font
|
|
19
|
+
font,
|
|
20
|
+
color = 'black',
|
|
21
|
+
labelColor,
|
|
22
|
+
tickLength = 10,
|
|
23
|
+
strokeWidth,
|
|
24
|
+
dash,
|
|
25
|
+
showLabel = true,
|
|
26
|
+
labelAlign = 'center',
|
|
27
|
+
labelGap = 6
|
|
21
28
|
} = props;
|
|
22
29
|
const offsetY = props.offsetY ?? 0;
|
|
23
30
|
const transform = (0, _reactNativeReanimated.useDerivedValue)(() => [{
|
|
24
31
|
translateX: (0, _gesture.getPositionWl)(initPosition, focalX.value, scale.value, offsetX.value)
|
|
25
32
|
}]);
|
|
26
33
|
const width = font.getGlyphWidths(font.getGlyphIDs(label)).reduce((a, b) => a + b, 0);
|
|
34
|
+
const labelX = labelAlign === 'left' ? labelGap : -width / 2;
|
|
27
35
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
28
36
|
transform: transform,
|
|
29
37
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Line, {
|
|
30
|
-
color:
|
|
38
|
+
color: color,
|
|
39
|
+
strokeWidth: strokeWidth,
|
|
31
40
|
p1: (0, _reactNativeSkia.vec)(0, offsetY),
|
|
32
|
-
p2: (0, _reactNativeSkia.vec)(0, offsetY +
|
|
33
|
-
|
|
41
|
+
p2: (0, _reactNativeSkia.vec)(0, offsetY + tickLength),
|
|
42
|
+
children: dash !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.DashPathEffect, {
|
|
43
|
+
intervals: dash
|
|
44
|
+
}) : null
|
|
45
|
+
}), showLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Text, {
|
|
34
46
|
text: label,
|
|
35
|
-
color:
|
|
36
|
-
x:
|
|
47
|
+
color: labelColor ?? color,
|
|
48
|
+
x: labelX,
|
|
37
49
|
y: offsetY + 23,
|
|
38
50
|
font: font
|
|
39
|
-
})]
|
|
51
|
+
}) : null]
|
|
40
52
|
});
|
|
41
53
|
};
|
|
42
|
-
|
|
54
|
+
|
|
55
|
+
// Memoized: zoom/pan flows through shared values, so a Tick only needs to
|
|
56
|
+
// re-render when its label or base position changes
|
|
57
|
+
const Tick = exports.Tick = /*#__PURE__*/(0, _react.memo)(TickComponent);
|
|
58
|
+
Tick.displayName = 'Tick';
|
|
43
59
|
//# sourceMappingURL=Tick.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeSkia","require","_react","
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_reactNativeReanimated","_gesture","_jsxRuntime","TickComponent","props","label","scale","focalX","offsetX","initPosition","font","color","labelColor","tickLength","strokeWidth","dash","showLabel","labelAlign","labelGap","offsetY","transform","useDerivedValue","translateX","getPositionWl","value","width","getGlyphWidths","getGlyphIDs","reduce","a","b","labelX","jsxs","Group","children","jsx","Line","p1","vec","p2","undefined","DashPathEffect","intervals","Text","text","x","y","Tick","exports","memo","displayName"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/Tick.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAwB3C,MAAMK,aAAa,GAAG,SAAAA,CAAUC,KAAgB,EAAE;EAChD,MAAM;IACJC,KAAK;IACLC,KAAK;IACLC,MAAM;IACNC,OAAO;IACPC,YAAY;IACZC,IAAI;IACJC,KAAK,GAAG,OAAO;IACfC,UAAU;IACVC,UAAU,GAAG,EAAE;IACfC,WAAW;IACXC,IAAI;IACJC,SAAS,GAAG,IAAI;IAChBC,UAAU,GAAG,QAAQ;IACrBC,QAAQ,GAAG;EACb,CAAC,GAAGd,KAAK;EACT,MAAMe,OAAO,GAAGf,KAAK,CAACe,OAAO,IAAI,CAAC;EAClC,MAAMC,SAAS,GAAG,IAAAC,sCAAe,EAAC,MAAM,CACtC;IACEC,UAAU,EAAE,IAAAC,sBAAa,EACvBd,YAAY,EACZF,MAAM,CAACiB,KAAK,EACZlB,KAAK,CAACkB,KAAK,EACXhB,OAAO,CAACgB,KACV;EACF,CAAC,CACF,CAAC;EACF,MAAMC,KAAK,GAAGf,IAAI,CACfgB,cAAc,CAAChB,IAAI,CAACiB,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3,"names":["_AxisLine","require","_BottomAxis","_Tick"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;
|
|
1
|
+
{"version":3,"names":["_AxisLine","require","_BottomAxis","_Tick"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAF,OAAA","ignoreList":[]}
|
|
@@ -13,6 +13,8 @@ const Cursor = function ({
|
|
|
13
13
|
commands,
|
|
14
14
|
positionX,
|
|
15
15
|
color,
|
|
16
|
+
strokeColor,
|
|
17
|
+
strokeWidth = 2,
|
|
16
18
|
currentValue,
|
|
17
19
|
translateY,
|
|
18
20
|
size = CURSOR_SIZE
|
|
@@ -37,12 +39,22 @@ const Cursor = function ({
|
|
|
37
39
|
}, {
|
|
38
40
|
translateY: _translateY.value ?? 0
|
|
39
41
|
}]);
|
|
40
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
43
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
44
|
+
transform: transform,
|
|
45
|
+
cx: 0,
|
|
46
|
+
cy: 0,
|
|
47
|
+
r: size,
|
|
48
|
+
color: color
|
|
49
|
+
}), strokeColor !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
50
|
+
transform: transform,
|
|
51
|
+
cx: 0,
|
|
52
|
+
cy: 0,
|
|
53
|
+
r: size,
|
|
54
|
+
color: strokeColor,
|
|
55
|
+
style: "stroke",
|
|
56
|
+
strokeWidth: strokeWidth
|
|
57
|
+
}) : null]
|
|
46
58
|
});
|
|
47
59
|
};
|
|
48
60
|
exports.Cursor = Cursor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeSkia","require","_reactNativeReanimated","_maths","_jsxRuntime","CURSOR_SIZE","Cursor","commands","positionX","color","currentValue","translateY","size","undefined","console","warn","derivedTranslateY","useDerivedValue","_commands","value","_value","getYForX","_translateY","transform","translateX","jsx","Circle","cx","cy","r","exports"],"sourceRoot":"../../../src","sources":["Charts/Cursor.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAAmC,IAAAG,WAAA,GAAAH,OAAA;AAEnC,MAAMI,WAAW,GAAG,EAAE;
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNativeReanimated","_maths","_jsxRuntime","CURSOR_SIZE","Cursor","commands","positionX","color","strokeColor","strokeWidth","currentValue","translateY","size","undefined","console","warn","derivedTranslateY","useDerivedValue","_commands","value","_value","getYForX","_translateY","transform","translateX","jsxs","Fragment","children","jsx","Circle","cx","cy","r","style","exports"],"sourceRoot":"../../../src","sources":["Charts/Cursor.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAAmC,IAAAG,WAAA,GAAAH,OAAA;AAEnC,MAAMI,WAAW,GAAG,EAAE;AActB,MAAMC,MAAuB,GAAG,SAAAA,CAAU;EACxCC,QAAQ;EACRC,SAAS;EACTC,KAAK;EACLC,WAAW;EACXC,WAAW,GAAG,CAAC;EACfC,YAAY;EACZC,UAAU;EACVC,IAAI,GAAGT;AACT,CAAC,EAAE;EACD,IAAIO,YAAY,KAAKG,SAAS,IAAIF,UAAU,KA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xB,WAAW,EAAEA;IAAY,CAC1B,CAAC,GACA,IAAI;EAAA,CACR,CAAC;AAEP,CAAC;AAACyB,OAAA,CAAA9B,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Dot = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
|
+
var _gesture = require("./gesture.js");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function DotComponent(props) {
|
|
13
|
+
const {
|
|
14
|
+
x,
|
|
15
|
+
y,
|
|
16
|
+
opacity = 1,
|
|
17
|
+
r = 4,
|
|
18
|
+
color = 'black',
|
|
19
|
+
fillColor,
|
|
20
|
+
strokeWidth = 2,
|
|
21
|
+
scale,
|
|
22
|
+
focalX,
|
|
23
|
+
offsetX
|
|
24
|
+
} = props;
|
|
25
|
+
const cx = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
26
|
+
const _x = typeof x === 'number' ? x : x.value;
|
|
27
|
+
if (scale === undefined || focalX === undefined || offsetX === undefined) return _x;
|
|
28
|
+
return (0, _gesture.getPositionWl)(_x, focalX.value, scale.value, offsetX.value);
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
31
|
+
opacity: opacity,
|
|
32
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
33
|
+
cx: cx,
|
|
34
|
+
cy: y,
|
|
35
|
+
r: r,
|
|
36
|
+
color: fillColor ?? color
|
|
37
|
+
}), fillColor !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
38
|
+
cx: cx,
|
|
39
|
+
cy: y,
|
|
40
|
+
r: r,
|
|
41
|
+
style: "stroke",
|
|
42
|
+
color: color,
|
|
43
|
+
strokeWidth: strokeWidth
|
|
44
|
+
}) : null]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Memoized: charts render many dots and the position updates flow through
|
|
49
|
+
// shared values, so parent re-renders don't need to reach them
|
|
50
|
+
const Dot = exports.Dot = /*#__PURE__*/(0, _react.memo)(DotComponent);
|
|
51
|
+
//# sourceMappingURL=Dot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_reactNativeReanimated","_gesture","_jsxRuntime","DotComponent","props","x","y","opacity","r","color","fillColor","strokeWidth","scale","focalX","offsetX","cx","useDerivedValue","_x","value","undefined","getPositionWl","jsxs","Group","children","jsx","Circle","cy","style","Dot","exports","memo"],"sourceRoot":"../../../src","sources":["Charts/Dot.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAA0C,IAAAI,WAAA,GAAAJ,OAAA;AAoB1C,SAASK,YAAYA,CAACC,KAAe,EAAE;EACrC,MAAM;IACJC,CAAC;IACDC,CAAC;IACDC,OAAO,GAAG,CAAC;IACXC,CAAC,GAAG,CAAC;IACLC,KAAK,GAAG,OAAO;IACfC,SAAS;IACTC,WAAW,GAAG,CAAC;IACfC,KAAK;IACLC,MAAM;IACNC;EACF,CAAC,GAAGV,KAAK;EAET,MAAMW,EAAE,GAAG,IAAAC,sCAAe,EAAC,MAAM;IAC/B,MAAMC,EAAE,GAAG,OAAOZ,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACa,KAAK;IAC9C,IAAIN,KAAK,KAAKO,SAAS,IAAIN,MAAM,KAAKM,SAAS,IAAIL,OAAO,KAAKK,SAAS,EACtE,OAAOF,EAAE;IACX,OAAO,IAAAG,sBAAa,EAACH,EAAE,EAAEJ,MAAM,CAACK,KAAK,EAAEN,KAAK,CAACM,KAAK,EAAEJ,OAAO,CAACI,KAAK,CAAC;EACpE,CAAC,CAAC;EAEF,oBACE,IAAAhB,WAAA,CAAAmB,IAAA,EAACxB,gBAAA,CAAAyB,KAAK;IAACf,OAAO,EAAEA,OAAQ;IAAAgB,QAAA,gBACtB,IAAArB,WAAA,CAAAsB,GAAA,EAAC3B,gBAAA,CAAA4B,MAAM;MAACV,EAAE,EAAEA,EAAG;MAACW,EAAE,EAAEpB,CAAE;MAACE,CAAC,EAAEA,CAAE;MAACC,KAAK,EAAEC,SAAS,IAAID;IAAM,CAAE,CAAC,EACzDC,SAAS,KAAKS,SAAS,gBACtB,IAAAjB,WAAA,CAAAsB,GAAA,EAAC3B,gBAAA,CAAA4B,MAAM;MACLV,EAAE,EAAEA,EAAG;MACPW,EAAE,EAAEpB,CAAE;MACNE,CAAC,EAAEA,CAAE;MACLmB,KAAK,EAAC,QAAQ;MACdlB,KAAK,EAAEA,KAAM;MACbE,WAAW,EAAEA;IAAY,CAC1B,CAAC,GACA,IAAI;EAAA,CACH,CAAC;AAEZ;;AAEA;AACA;AACO,MAAMiB,GAAG,GAAAC,OAAA,CAAAD,GAAA,gBAAG,IAAAE,WAAI,EAAC3B,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Dots = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
var _gesture = require("./gesture.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* Draw a whole series of dots as a single Skia path (two with `fillColor`).
|
|
13
|
+
* Unlike mapping over {@link Dot}, this runs one worklet per frame instead of
|
|
14
|
+
* one per dot, which keeps large series smooth during zoom/pan gestures.
|
|
15
|
+
* Per-dot opacity is binary here: dots below 0.5 are hidden.
|
|
16
|
+
*/
|
|
17
|
+
const Dots = function (props) {
|
|
18
|
+
const {
|
|
19
|
+
dots,
|
|
20
|
+
r = 4,
|
|
21
|
+
shape = 'circle',
|
|
22
|
+
color = 'black',
|
|
23
|
+
fillColor,
|
|
24
|
+
strokeWidth = 2,
|
|
25
|
+
width,
|
|
26
|
+
scale,
|
|
27
|
+
focalX,
|
|
28
|
+
offsetX
|
|
29
|
+
} = props;
|
|
30
|
+
const path = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
31
|
+
const p = _reactNativeSkia.Skia.Path.Make();
|
|
32
|
+
const margin = r + strokeWidth;
|
|
33
|
+
for (const dot of dots) {
|
|
34
|
+
if (dot.opacity.value < 0.5) continue;
|
|
35
|
+
const x = scale === undefined || focalX === undefined || offsetX === undefined ? dot.x.value : (0, _gesture.getPositionWl)(dot.x.value, focalX.value, scale.value, offsetX.value);
|
|
36
|
+
if (width !== undefined && (x < -margin || x > width + margin)) continue;
|
|
37
|
+
const y = dot.y.value;
|
|
38
|
+
if (shape === 'diamond') {
|
|
39
|
+
// One addPoly beats four moveTo/lineTo calls: each is a JSI hop, and
|
|
40
|
+
// this worklet rebuilds every dot on every frame of a gesture
|
|
41
|
+
p.addPoly([{
|
|
42
|
+
x,
|
|
43
|
+
y: y - r
|
|
44
|
+
}, {
|
|
45
|
+
x: x + r,
|
|
46
|
+
y
|
|
47
|
+
}, {
|
|
48
|
+
x,
|
|
49
|
+
y: y + r
|
|
50
|
+
}, {
|
|
51
|
+
x: x - r,
|
|
52
|
+
y
|
|
53
|
+
}], true);
|
|
54
|
+
} else {
|
|
55
|
+
p.addCircle(x, y, r);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return p;
|
|
59
|
+
});
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
61
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Path, {
|
|
62
|
+
path: path,
|
|
63
|
+
color: fillColor ?? color
|
|
64
|
+
}), fillColor !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Path, {
|
|
65
|
+
path: path,
|
|
66
|
+
style: "stroke",
|
|
67
|
+
color: color,
|
|
68
|
+
strokeWidth: strokeWidth,
|
|
69
|
+
strokeJoin: "round"
|
|
70
|
+
}) : null]
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
exports.Dots = Dots;
|
|
74
|
+
//# sourceMappingURL=Dots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNativeReanimated","_gesture","_jsxRuntime","Dots","props","dots","r","shape","color","fillColor","strokeWidth","width","scale","focalX","offsetX","path","useDerivedValue","p","Skia","Path","Make","margin","dot","opacity","value","x","undefined","getPositionWl","y","addPoly","addCircle","jsxs","Fragment","children","jsx","style","strokeJoin","exports"],"sourceRoot":"../../../src","sources":["Charts/Dots.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAA0C,IAAAG,WAAA,GAAAH,OAAA;AAqB1C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,IAAmB,GAAG,SAAAA,CAAUC,KAAK,EAAE;EAC3C,MAAM;IACJC,IAAI;IACJC,CAAC,GAAG,CAAC;IACLC,KAAK,GAAG,QAAQ;IAChBC,KAAK,GAAG,OAAO;IACfC,SAAS;IACTC,WAAW,GAAG,CAAC;IACfC,KAAK;IACLC,KAAK;IACLC,MAAM;IACNC;EACF,CAAC,GAAGV,KAAK;EAET,MAAMW,IAAI,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B,IAAA,EAAA7B,WAAA,CAAA8B,QAAA;IAAAC,QAAA,gBACE,IAAA/B,WAAA,CAAAgC,GAAA,EAACpC,gBAAA,CAAAqB,IAAI;MAACJ,IAAI,EAAEA,IAAK;MAACP,KAAK,EAAEC,SAAS,IAAID;IAAM,CAAE,CAAC,EAC9CC,SAAS,KAAKiB,SAAS,gBACtB,IAAAxB,WAAA,CAAAgC,GAAA,EAACpC,gBAAA,CAAAqB,IAAI;MACHJ,IAAI,EAAEA,IAAK;MACXoB,KAAK,EAAC,QAAQ;MACd3B,KAAK,EAAEA,KAAM;MACbE,WAAW,EAAEA,WAAY;MACzB0B,UAAU,EAAC;IAAO,CACnB,CAAC,GACA,IAAI;EAAA,CACR,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAlC,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPaddedTicks = exports.YAxis = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
const defaultFormatLabel = value => `${Math.round(value)}`;
|
|
11
|
+
|
|
12
|
+
/** Evenly spaced integer ticks from 0 to a padded maximum, e.g. 0, 26, 52, 78, 104. */
|
|
13
|
+
const getPaddedTicks = function (maxValue, nbTicks = 4, padding = 1.15) {
|
|
14
|
+
const step = Math.max(1, Math.ceil(maxValue * padding / nbTicks));
|
|
15
|
+
return Array.from({
|
|
16
|
+
length: nbTicks + 1
|
|
17
|
+
}, (_, i) => i * step);
|
|
18
|
+
};
|
|
19
|
+
exports.getPaddedTicks = getPaddedTicks;
|
|
20
|
+
const YAxis = function (props) {
|
|
21
|
+
const {
|
|
22
|
+
width,
|
|
23
|
+
height,
|
|
24
|
+
font,
|
|
25
|
+
minY,
|
|
26
|
+
maxY,
|
|
27
|
+
nbTicks = 4,
|
|
28
|
+
color = 'black',
|
|
29
|
+
labelColor,
|
|
30
|
+
strokeWidth = _reactNative.StyleSheet.hairlineWidth,
|
|
31
|
+
showLabels = true,
|
|
32
|
+
formatLabel = defaultFormatLabel
|
|
33
|
+
} = props;
|
|
34
|
+
const values = props.values ?? Array.from({
|
|
35
|
+
length: nbTicks
|
|
36
|
+
}, (_, i) => minY + (i + 1) * (maxY - minY) / nbTicks);
|
|
37
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Group, {
|
|
38
|
+
children: values.map((value, i) => {
|
|
39
|
+
const y = height - (value - minY) * height / (maxY - minY);
|
|
40
|
+
const label = formatLabel(value);
|
|
41
|
+
const labelWidth = font.getGlyphWidths(font.getGlyphIDs(label)).reduce((a, b) => a + b, 0);
|
|
42
|
+
const lineWidth = showLabels ? width - 10 - labelWidth : width;
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
44
|
+
transform: [{
|
|
45
|
+
translateY: y
|
|
46
|
+
}],
|
|
47
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Line, {
|
|
48
|
+
p1: (0, _reactNativeSkia.vec)(0, 0),
|
|
49
|
+
p2: (0, _reactNativeSkia.vec)(lineWidth, 0),
|
|
50
|
+
color: color,
|
|
51
|
+
strokeWidth: strokeWidth
|
|
52
|
+
}), showLabels ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Text, {
|
|
53
|
+
text: label,
|
|
54
|
+
x: width - labelWidth,
|
|
55
|
+
y: font.getSize() / 2.5,
|
|
56
|
+
font: font,
|
|
57
|
+
color: labelColor ?? color
|
|
58
|
+
}) : null]
|
|
59
|
+
}, `YTick-${i}`);
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.YAxis = YAxis;
|
|
64
|
+
//# sourceMappingURL=YAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNative","_jsxRuntime","defaultFormatLabel","value","Math","round","getPaddedTicks","maxValue","nbTicks","padding","step","max","ceil","Array","from","length","_","i","exports","YAxis","props","width","height","font","minY","maxY","color","labelColor","strokeWidth","StyleSheet","hairlineWidth","showLabels","formatLabel","values","jsx","Group","children","map","y","label","labelWidth","getGlyphWidths","getGlyphIDs","reduce","a","b","lineWidth","jsxs","transform","translateY","Line","p1","vec","p2","Text","text","x","getSize"],"sourceRoot":"../../../src","sources":["Charts/YAxis.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AAA0C,IAAAE,WAAA,GAAAF,OAAA;AAkB1C,MAAMG,kBAAkB,GAAIC,KAAa,IAAK,GAAGC,IAAI,CAACC,KAAK,CAACF,KAAK,CAAC,EAAE;;AAEpE;AACO,MAAMG,cAAc,GAAG,SAAAA,CAC5BC,QAAgB,EAChBC,OAAO,GAAG,CAAC,EACXC,OAAO,GAAG,IAAI,EACJ;EACV,MAAMC,IAAI,GAAGN,IAAI,CAACO,GAAG,CAAC,CAAC,EAAEP,IAAI,CAACQ,IAAI,CAAEL,QAAQ,GAAGE,OAAO,GAAID,OAAO,CAAC,CAAC;EACnE,OAAOK,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEP,OAAO,GAAG;EAAE,CAAC,EAAE,CAACQ,CAAC,EAAEC,CAAC,KAAKA,CAAC,GAAGP,IAAI,CAAC;AAChE,CAAC;AAACQ,OAAA,CAAAZ,cAAA,GAAAA,cAAA;AAEF,MAAMa,KAAqB,GAAG,SAAAA,CAAUC,KAAK,EAAE;EAC7C,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,IAAI;IACJC,IAAI;IACJC,IAAI;IACJjB,OAAO,GAAG,CAAC;IACXkB,KAAK,G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AAE;UACdC,EAAE,EAAE,IAAAD,oBAAG,EAACN,SAAS,EAAE,CAAC,CAAE;UACtBpB,KAAK,EAAEA,KAAM;UACbE,WAAW,EAAEA;QAAY,CAC1B,CAAC,EACDG,UAAU,gBACT,IAAA9B,WAAA,CAAAiC,GAAA,EAACpC,gBAAA,CAAAwD,IAAI;UACHC,IAAI,EAAEhB,KAAM;UACZiB,CAAC,EAAEnC,KAAK,GAAGmB,UAAW;UACtBF,CAAC,EAAEf,IAAI,CAACkC,OAAO,CAAC,CAAC,GAAG,GAAI;UACxBlC,IAAI,EAAEA,IAAK;UACXG,KAAK,EAAEC,UAAU,IAAID;QAAM,CAC5B,CAAC,GACA,IAAI;MAAA,GAfE,SAAST,CAAC,EAgBf,CAAC;IAEZ,CAAC;EAAC,CACG,CAAC;AAEZ,CAAC;AAACC,OAAA,CAAAC,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useUpdateAxis = exports.useScalableGesture = exports.useCursorGesture = exports.getPositionWl = exports.getClosestPoint = void 0;
|
|
6
|
+
exports.useUpdateAxis = exports.useScalableGesture = exports.useCursorGesture = exports.getPositionWl = exports.getOffsetBoundsWl = exports.getClosestPoint = void 0;
|
|
7
7
|
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
@@ -18,7 +18,21 @@ const getPositionWl = function (position, focalX, scale, offsetX) {
|
|
|
18
18
|
|
|
19
19
|
return (position - focalX) * scale + focalX + offsetX;
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Offset range keeping the content edges pinned to the viewport:
|
|
24
|
+
* leftBound (position 0) <= startOffset and rightBound (position width)
|
|
25
|
+
* >= width + startOffset. Collapses to [startOffset, startOffset] at scale 1.
|
|
26
|
+
*/
|
|
21
27
|
exports.getPositionWl = getPositionWl;
|
|
28
|
+
const getOffsetBoundsWl = function (width, startOffset, focalX, scale) {
|
|
29
|
+
'worklet';
|
|
30
|
+
|
|
31
|
+
const maxOffset = startOffset + focalX * (scale - 1);
|
|
32
|
+
const minOffset = startOffset + (1 - scale) * (width - focalX);
|
|
33
|
+
return [minOffset, maxOffset];
|
|
34
|
+
};
|
|
35
|
+
exports.getOffsetBoundsWl = getOffsetBoundsWl;
|
|
22
36
|
/**
|
|
23
37
|
* Return utilities for zooming and panning the axis
|
|
24
38
|
*/
|
|
@@ -37,6 +51,8 @@ const useScalableGesture = props => {
|
|
|
37
51
|
// For panning
|
|
38
52
|
const offsetX = (0, _reactNativeReanimated.useSharedValue)(startOffset);
|
|
39
53
|
const lastOffsetX = (0, _reactNativeReanimated.useSharedValue)(startOffset);
|
|
54
|
+
// Pinch pivot bookkeeping (see pinchGesture)
|
|
55
|
+
const needsPivot = (0, _reactNativeReanimated.useSharedValue)(true);
|
|
40
56
|
const reset = (0, _react.useCallback)(() => {
|
|
41
57
|
scale.value = startScale;
|
|
42
58
|
lastScale.value = startScale;
|
|
@@ -45,37 +61,56 @@ const useScalableGesture = props => {
|
|
|
45
61
|
offsetX.value = startOffset;
|
|
46
62
|
lastOffsetX.value = startOffset;
|
|
47
63
|
}, [focalX, lastFocalX, lastOffsetX, lastScale, offsetX, scale, startOffset, startScale]);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
|
|
65
|
+
// Memoized: handing a new gesture instance to GestureDetector mid-gesture
|
|
66
|
+
// resets the active pan and makes the chart jump
|
|
67
|
+
const panGesture = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pan()
|
|
68
|
+
// Single-finger only: two fingers belong to the pinch, whose focal
|
|
69
|
+
// rebase would otherwise fight the pan over offsetX
|
|
70
|
+
.maxPointers(1)
|
|
71
|
+
// Incremental deltas (changeX) with a live clamp keep the content
|
|
72
|
+
// edges pinned: no overscroll, no snap-back to interrupt
|
|
73
|
+
.onChange(event => {
|
|
74
|
+
const [minOffset, maxOffset] = getOffsetBoundsWl(width, startOffset, focalX.value, scale.value);
|
|
75
|
+
offsetX.value = (0, _reactNativeSkia.clamp)(offsetX.value + event.changeX, minOffset, maxOffset);
|
|
51
76
|
}).onEnd(() => {
|
|
52
77
|
lastScale.value = scale.value;
|
|
53
78
|
lastFocalX.value = focalX.value;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
lastOffsetX.value = offsetX.value;
|
|
80
|
+
}), [focalX, lastFocalX, lastOffsetX, lastScale, offsetX, scale, startOffset, width]);
|
|
81
|
+
const pinchGesture = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pinch().onStart(() => {
|
|
82
|
+
needsPivot.value = true;
|
|
83
|
+
}).onUpdate(event => {
|
|
84
|
+
// The pinch can keep firing in the single-finger tail of the
|
|
85
|
+
// gesture, tracking the remaining finger as its focal: ignore it
|
|
86
|
+
// (numberOfPointers is missing on web — let those through)
|
|
87
|
+
if ((event.numberOfPointers ?? 2) < 2) {
|
|
88
|
+
needsPivot.value = true;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const prevScale = scale.value;
|
|
92
|
+
const newScale = (0, _reactNativeSkia.clamp)(lastScale.value * event.scale, 1, Infinity);
|
|
93
|
+
if (needsPivot.value) {
|
|
94
|
+
// New pivot: rebase offsetX so re-anchoring under the fingers
|
|
95
|
+
// doesn't shift the content
|
|
96
|
+
const rebased = offsetX.value + (focalX.value - event.focalX) * (1 - prevScale);
|
|
97
|
+
offsetX.value = rebased * newScale / prevScale;
|
|
98
|
+
needsPivot.value = false;
|
|
61
99
|
} else {
|
|
62
|
-
|
|
100
|
+
// Keep the content glued to both fingers: the offset follows the
|
|
101
|
+
// focal translation and rescales with the zoom
|
|
102
|
+
offsetX.value = (event.focalX - focalX.value + offsetX.value / prevScale) * newScale;
|
|
63
103
|
}
|
|
64
|
-
offsetX.value = (0, _reactNativeReanimated.withTiming)(newOffset, {
|
|
65
|
-
duration: 300
|
|
66
|
-
});
|
|
67
|
-
lastOffsetX.value = newOffset;
|
|
68
|
-
});
|
|
69
|
-
const pinchGesture = _reactNativeGestureHandler.Gesture.Pinch().onUpdate(event => {
|
|
70
|
-
// Rebase offsetX so moving the focal point doesn't shift the content
|
|
71
|
-
offsetX.value += (focalX.value - event.focalX) * (1 - scale.value);
|
|
72
104
|
focalX.value = event.focalX;
|
|
73
|
-
scale.value =
|
|
105
|
+
scale.value = newScale;
|
|
106
|
+
// Zooming moves the bounds: keep the content edges pinned
|
|
107
|
+
const [minOffset, maxOffset] = getOffsetBoundsWl(width, startOffset, focalX.value, scale.value);
|
|
108
|
+
offsetX.value = (0, _reactNativeSkia.clamp)(offsetX.value, minOffset, maxOffset);
|
|
74
109
|
}).onEnd(() => {
|
|
75
110
|
lastScale.value = scale.value;
|
|
76
111
|
lastFocalX.value = focalX.value;
|
|
77
112
|
lastOffsetX.value = offsetX.value;
|
|
78
|
-
});
|
|
113
|
+
}), [focalX, lastFocalX, lastOffsetX, lastScale, needsPivot, offsetX, scale, startOffset, width]);
|
|
79
114
|
return {
|
|
80
115
|
scale,
|
|
81
116
|
focalX,
|
|
@@ -93,6 +128,14 @@ const useUpdateAxis = function (props) {
|
|
|
93
128
|
onScaleChange
|
|
94
129
|
} = props;
|
|
95
130
|
const currentIndex = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
131
|
+
|
|
132
|
+
// Stable dispatcher so an inline onScaleChange doesn't re-register the
|
|
133
|
+
// reaction (and disturb the UI thread) on every render
|
|
134
|
+
const onScaleChangeRef = (0, _react.useRef)(onScaleChange);
|
|
135
|
+
onScaleChangeRef.current = onScaleChange;
|
|
136
|
+
const dispatchScaleChange = (0, _react.useCallback)(index => {
|
|
137
|
+
onScaleChangeRef.current?.(index);
|
|
138
|
+
}, []);
|
|
96
139
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => scale.value, (currentScale, _) => {
|
|
97
140
|
for (let i = 0; i < scales.length; i++) {
|
|
98
141
|
const _prevScale = scales[i - 1] ?? 0;
|
|
@@ -100,11 +143,11 @@ const useUpdateAxis = function (props) {
|
|
|
100
143
|
if (_curScale === undefined || _prevScale === undefined) throw new Error('Got undefined scale');
|
|
101
144
|
if (currentScale >= _prevScale && currentScale < _curScale && currentIndex.value !== i) {
|
|
102
145
|
currentIndex.value = i;
|
|
103
|
-
|
|
146
|
+
(0, _reactNativeWorklets.scheduleOnRN)(dispatchScaleChange, i);
|
|
104
147
|
break;
|
|
105
148
|
}
|
|
106
149
|
}
|
|
107
|
-
});
|
|
150
|
+
}, [scales, dispatchScaleChange]);
|
|
108
151
|
return {
|
|
109
152
|
currentIndex
|
|
110
153
|
};
|