@obitrain/charts 0.9.2
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/LICENSE +21 -0
- package/README.md +125 -0
- package/lib/commonjs/Charts/BottomAxis/AxisLine.js +38 -0
- package/lib/commonjs/Charts/BottomAxis/AxisLine.js.map +1 -0
- package/lib/commonjs/Charts/BottomAxis/BottomAxis.js +45 -0
- package/lib/commonjs/Charts/BottomAxis/BottomAxis.js.map +1 -0
- package/lib/commonjs/Charts/BottomAxis/Tick.js +43 -0
- package/lib/commonjs/Charts/BottomAxis/Tick.js.map +1 -0
- package/lib/commonjs/Charts/BottomAxis/index.js +27 -0
- package/lib/commonjs/Charts/BottomAxis/index.js.map +1 -0
- package/lib/commonjs/Charts/Cursor.js +50 -0
- package/lib/commonjs/Charts/Cursor.js.map +1 -0
- package/lib/commonjs/Charts/Linechart/index.js +55 -0
- package/lib/commonjs/Charts/Linechart/index.js.map +1 -0
- package/lib/commonjs/Charts/ZoomableLinechart/ScalablePath.js +43 -0
- package/lib/commonjs/Charts/ZoomableLinechart/ScalablePath.js.map +1 -0
- package/lib/commonjs/Charts/ZoomableLinechart/index.js +43 -0
- package/lib/commonjs/Charts/ZoomableLinechart/index.js.map +1 -0
- package/lib/commonjs/Charts/gesture.js +185 -0
- package/lib/commonjs/Charts/gesture.js.map +1 -0
- package/lib/commonjs/Charts/graphUtils.js +131 -0
- package/lib/commonjs/Charts/graphUtils.js.map +1 -0
- package/lib/commonjs/Charts/index.js +151 -0
- package/lib/commonjs/Charts/index.js.map +1 -0
- package/lib/commonjs/Charts/maths.js +195 -0
- package/lib/commonjs/Charts/maths.js.map +1 -0
- package/lib/commonjs/Charts/types.js +6 -0
- package/lib/commonjs/Charts/types.js.map +1 -0
- package/lib/commonjs/dateUtils.js +151 -0
- package/lib/commonjs/dateUtils.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/textUtils.js +21 -0
- package/lib/commonjs/textUtils.js.map +1 -0
- package/lib/module/Charts/BottomAxis/AxisLine.js +34 -0
- package/lib/module/Charts/BottomAxis/AxisLine.js.map +1 -0
- package/lib/module/Charts/BottomAxis/BottomAxis.js +40 -0
- package/lib/module/Charts/BottomAxis/BottomAxis.js.map +1 -0
- package/lib/module/Charts/BottomAxis/Tick.js +37 -0
- package/lib/module/Charts/BottomAxis/Tick.js.map +1 -0
- package/lib/module/Charts/BottomAxis/index.js +6 -0
- package/lib/module/Charts/BottomAxis/index.js.map +1 -0
- package/lib/module/Charts/Cursor.js +46 -0
- package/lib/module/Charts/Cursor.js.map +1 -0
- package/lib/module/Charts/Linechart/index.js +50 -0
- package/lib/module/Charts/Linechart/index.js.map +1 -0
- package/lib/module/Charts/ZoomableLinechart/ScalablePath.js +39 -0
- package/lib/module/Charts/ZoomableLinechart/ScalablePath.js.map +1 -0
- package/lib/module/Charts/ZoomableLinechart/index.js +33 -0
- package/lib/module/Charts/ZoomableLinechart/index.js.map +1 -0
- package/lib/module/Charts/gesture.js +176 -0
- package/lib/module/Charts/gesture.js.map +1 -0
- package/lib/module/Charts/graphUtils.js +121 -0
- package/lib/module/Charts/graphUtils.js.map +1 -0
- package/lib/module/Charts/index.js +10 -0
- package/lib/module/Charts/index.js.map +1 -0
- package/lib/module/Charts/maths.js +187 -0
- package/lib/module/Charts/maths.js.map +1 -0
- package/lib/module/Charts/types.js +4 -0
- package/lib/module/Charts/types.js.map +1 -0
- package/lib/module/dateUtils.js +142 -0
- package/lib/module/dateUtils.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/textUtils.js +16 -0
- package/lib/module/textUtils.js.map +1 -0
- package/lib/typescript/src/Charts/BottomAxis/AxisLine.d.ts +15 -0
- package/lib/typescript/src/Charts/BottomAxis/AxisLine.d.ts.map +1 -0
- package/lib/typescript/src/Charts/BottomAxis/BottomAxis.d.ts +17 -0
- package/lib/typescript/src/Charts/BottomAxis/BottomAxis.d.ts.map +1 -0
- package/lib/typescript/src/Charts/BottomAxis/Tick.d.ts +14 -0
- package/lib/typescript/src/Charts/BottomAxis/Tick.d.ts.map +1 -0
- package/lib/typescript/src/Charts/BottomAxis/index.d.ts +4 -0
- package/lib/typescript/src/Charts/BottomAxis/index.d.ts.map +1 -0
- package/lib/typescript/src/Charts/Cursor.d.ts +14 -0
- package/lib/typescript/src/Charts/Cursor.d.ts.map +1 -0
- package/lib/typescript/src/Charts/Linechart/index.d.ts +25 -0
- package/lib/typescript/src/Charts/Linechart/index.d.ts.map +1 -0
- package/lib/typescript/src/Charts/ZoomableLinechart/ScalablePath.d.ts +14 -0
- package/lib/typescript/src/Charts/ZoomableLinechart/ScalablePath.d.ts.map +1 -0
- package/lib/typescript/src/Charts/ZoomableLinechart/index.d.ts +23 -0
- package/lib/typescript/src/Charts/ZoomableLinechart/index.d.ts.map +1 -0
- package/lib/typescript/src/Charts/gesture.d.ts +54 -0
- package/lib/typescript/src/Charts/gesture.d.ts.map +1 -0
- package/lib/typescript/src/Charts/graphUtils.d.ts +43 -0
- package/lib/typescript/src/Charts/graphUtils.d.ts.map +1 -0
- package/lib/typescript/src/Charts/index.d.ts +14 -0
- package/lib/typescript/src/Charts/index.d.ts.map +1 -0
- package/lib/typescript/src/Charts/maths.d.ts +19 -0
- package/lib/typescript/src/Charts/maths.d.ts.map +1 -0
- package/lib/typescript/src/Charts/types.d.ts +14 -0
- package/lib/typescript/src/Charts/types.d.ts.map +1 -0
- package/lib/typescript/src/dateUtils.d.ts +37 -0
- package/lib/typescript/src/dateUtils.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/textUtils.d.ts +3 -0
- package/lib/typescript/src/textUtils.d.ts.map +1 -0
- package/package.json +226 -0
- package/src/Charts/BottomAxis/AxisLine.tsx +40 -0
- package/src/Charts/BottomAxis/BottomAxis.tsx +41 -0
- package/src/Charts/BottomAxis/Tick.tsx +54 -0
- package/src/Charts/BottomAxis/index.tsx +3 -0
- package/src/Charts/Cursor.tsx +51 -0
- package/src/Charts/Linechart/index.tsx +79 -0
- package/src/Charts/ZoomableLinechart/ScalablePath.tsx +49 -0
- package/src/Charts/ZoomableLinechart/index.tsx +47 -0
- package/src/Charts/gesture.ts +254 -0
- package/src/Charts/graphUtils.ts +198 -0
- package/src/Charts/index.tsx +32 -0
- package/src/Charts/maths.ts +245 -0
- package/src/Charts/types.ts +16 -0
- package/src/dateUtils.ts +163 -0
- package/src/index.tsx +4 -0
- package/src/textUtils.ts +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Julien Brayere
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @obitrain/charts
|
|
2
|
+
|
|
3
|
+
React Native charting primitives built on [React Native Skia](https://shopify.github.io/react-native-skia/),
|
|
4
|
+
[Reanimated](https://docs.swmansion.com/react-native-reanimated/) and
|
|
5
|
+
[Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/): animated line charts, a
|
|
6
|
+
zoomable/pannable variant, a scalable bottom axis and a cursor, all driven from the UI thread.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
yarn add @obitrain/charts
|
|
12
|
+
yarn add @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler d3-scale d3-shape
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`react-native-worklets` is only needed with Reanimated 4 (it is an optional peer dependency).
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
| Peer dependency | Supported versions |
|
|
20
|
+
| ---------------------------- | ----------------------------------------------------- |
|
|
21
|
+
| `@shopify/react-native-skia` | `>=2.0.0 <3.0.0` |
|
|
22
|
+
| `react-native-reanimated` | 3.x or 4.x |
|
|
23
|
+
| `react-native-worklets` | `>=0.10.0` (optional, required with Reanimated 4) |
|
|
24
|
+
| `react-native-gesture-handler` | 2.x or 3.x |
|
|
25
|
+
| `d3-scale` | `>=4.0.2 <5.0.0` |
|
|
26
|
+
| `d3-shape` | `>=3.2.0 <4.0.0` |
|
|
27
|
+
| `react` | 18.x or 19.x |
|
|
28
|
+
| `react-native` | 0.61.5 up to 0.87 |
|
|
29
|
+
|
|
30
|
+
The exact ranges live in the `peerDependencies` of `package.json`. Development and tests run on
|
|
31
|
+
Expo SDK 57 / React Native 0.86 / Node `>= 20.19.4`.
|
|
32
|
+
|
|
33
|
+
## What's inside
|
|
34
|
+
|
|
35
|
+
**Components** — `BottomAxis`, `AxisLine`, `Tick`, `Cursor`, `LineChart`, `ZoomableLineChart`,
|
|
36
|
+
`ScalablePath`.
|
|
37
|
+
|
|
38
|
+
**Hooks** — `useScalableGesture` (pinch/pan into a shared `scale`/`focalX`/`offsetX`),
|
|
39
|
+
`useCursorGesture` (continuous or discrete cursor), `useUpdateAxis` (swap axis labels on scale
|
|
40
|
+
thresholds), `useDotsTransition` (animate dots along a path), `useSharedNumberToStr`.
|
|
41
|
+
|
|
42
|
+
**Graph helpers** — `buildGraph`, `scaleCommands`, `getClosestPoint`, `getPositionWl`,
|
|
43
|
+
`defaultOpacityTransitionWl`, `defaultTranslateTransitionWl`.
|
|
44
|
+
|
|
45
|
+
**Math helpers** — `commandsToBezier`, `cubicBezierYForX`, `getYForX`, `magnitude`, `normalize`,
|
|
46
|
+
`selectCurve`.
|
|
47
|
+
|
|
48
|
+
**Date helpers** — `getMonthInterval`, `getDateInterval`, `getDateBoundaries`, `sampleDates`,
|
|
49
|
+
`sampleDatesByRange`.
|
|
50
|
+
|
|
51
|
+
**Types** — `AnimatedDot`, `DataPoint`, `LineGraphType`, `GraphData`, `Config`, `LinePath`,
|
|
52
|
+
`DateRange`, plus the component/hook prop types (`CursorProps`, `LineChartProps`,
|
|
53
|
+
`ZoomableLineChartProps`, `UseCursorGestureProps`, `UseDotAnimationProps`).
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### Bottom axis
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
`BottomAxis` with `useScalableGesture` and `useUpdateAxis`: zooming swaps the label set to match the
|
|
62
|
+
current scale. From `example/src/screens/BottomAxisScreen.tsx`.
|
|
63
|
+
|
|
64
|
+
### Line chart
|
|
65
|
+
|
|
66
|
+

|
|
67
|
+
|
|
68
|
+
`LineChart` interpolating between three paths, with animated dots and a `Cursor` — single path, then
|
|
69
|
+
several paths at once. From `example/src/screens/LineChartScreen`.
|
|
70
|
+
|
|
71
|
+
### Zoomable line chart
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
`ZoomableLineChart` with pinch/pan and a programmatic zoom onto a period between two data points.
|
|
76
|
+
From `example/src/screens/ZoomableLineChartScreen`.
|
|
77
|
+
|
|
78
|
+
### Dots
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
Dot transitions between data sets of different lengths, the primitive behind `useDotsTransition`.
|
|
83
|
+
From `example/src/screens/DotsScreen`.
|
|
84
|
+
|
|
85
|
+
### Advanced chart
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
`AxisLine` + `Tick` + a Y axis and dots composed in a single Skia canvas, with a shared scale driven
|
|
90
|
+
by gestures or sliders. From `example/src/screens/AdvancedChartScreen`.
|
|
91
|
+
|
|
92
|
+
## Example app
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
yarn
|
|
96
|
+
yarn example ios # or: yarn example android
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Every demo screen is reachable through the `obichart://` scheme. Appending `?demo=1` replays a
|
|
100
|
+
scripted sequence of interactions on that screen (used to record the GIFs above):
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
xcrun simctl openurl booted "obichart://line-chart?demo=1"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Slugs: `bottom-axis`, `line-chart`, `zoomable-line-chart`, `dots`, `advanced-chart`.
|
|
107
|
+
|
|
108
|
+
## Regenerating the GIFs
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
yarn gifs # all screens, builds the app in Release
|
|
112
|
+
yarn gifs --skip-build dots line-chart # reuse the installed app, only these screens
|
|
113
|
+
yarn gifs --device "iPhone 17 Pro"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Requires Xcode with an iOS simulator, `ffmpeg` and `jq`. The script boots the simulator, freezes the
|
|
117
|
+
status bar, drives each screen through its deep link and writes `static/<slug>.gif`.
|
|
118
|
+
|
|
119
|
+
## Contributing
|
|
120
|
+
|
|
121
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AxisLine = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
|
+
var _gesture = require("../gesture");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
const AxisLine = function (props) {
|
|
13
|
+
const {
|
|
14
|
+
width,
|
|
15
|
+
focalX,
|
|
16
|
+
scale,
|
|
17
|
+
offsetX,
|
|
18
|
+
offsetY = 0,
|
|
19
|
+
strokeWidth = _reactNative.StyleSheet.hairlineWidth,
|
|
20
|
+
color = 'black'
|
|
21
|
+
} = props;
|
|
22
|
+
const p1 = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
23
|
+
const p1X = (0, _gesture.getPositionWl)(0, focalX.value, scale.value, offsetX.value);
|
|
24
|
+
return (0, _reactNativeSkia.vec)(p1X, offsetY);
|
|
25
|
+
}, []);
|
|
26
|
+
const p2 = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
27
|
+
const p1X = (0, _gesture.getPositionWl)(width, focalX.value, scale.value, offsetX.value);
|
|
28
|
+
return (0, _reactNativeSkia.vec)(p1X, offsetY);
|
|
29
|
+
}, [width]);
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Line, {
|
|
31
|
+
p1,
|
|
32
|
+
p2,
|
|
33
|
+
color,
|
|
34
|
+
strokeWidth
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.AxisLine = AxisLine;
|
|
38
|
+
//# sourceMappingURL=AxisLine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNative","_reactNativeReanimated","_gesture","_jsxRuntime","AxisLine","props","width","focalX","scale","offsetX","offsetY","strokeWidth","StyleSheet","hairlineWidth","color","p1","useDerivedValue","p1X","getPositionWl","value","vec","p2","jsx","Line","exports"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/AxisLine.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAY3C,MAAMK,QAA2B,GAAG,SAAAA,CAAUC,KAAK,EAAE;EACnD,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,KAAK;IACLC,OAAO;IACPC,OAAO,GAAG,CAAC;IACXC,WAAW,GAAGC,uBAAU,CAACC,aAAa;IACtCC,KAAK,GAAG;EACV,CAAC,GAAGT,KAAK;EACT,MAAMU,EAAE,GAAG,IAAAC,sCAAe,EAAC,MAAM;IAC/B,MAAMC,GAAG,GAAG,IAAAC,sBAAa,EAAC,CAAC,EAAEX,MAAM,CAACY,KAAK,EAAEX,KAAK,CAACW,KAAK,EAAEV,OAAO,CAACU,KAAK,CAAC;IACtE,OAAO,IAAAC,oBAAG,EAACH,GAAG,EAAEP,OAAO,CAAC;EAC1B,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMW,EAAE,GAAG,IAAAL,sCAAe,EAAC,MAAM;IAC/B,MAAMC,GAAG,GAAG,IAAAC,sBAAa,EAACZ,KAAK,EAAEC,MAAM,CAACY,KAAK,EAAEX,KAAK,CAACW,KAAK,EAAEV,OAAO,CAACU,KAAK,CAAC;IAC1E,OAAO,IAAAC,oBAAG,EAACH,GAAG,EAAEP,OAAO,CAAC;EAC1B,CAAC,EAAE,CAACJ,KAAK,CAAC,CAAC;EAEX,oBAAO,IAAAH,WAAA,CAAAmB,GAAA,EAACxB,gBAAA,CAAAyB,IAAI;IAAOR,EAAE;IAAEM,EAAE;IAAEP,KAAK;IAAEH;EAAW,CAAK,CAAC;AACrD,CAAC;AAACa,OAAA,CAAApB,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BottomAxis = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _AxisLine = require("./AxisLine");
|
|
9
|
+
var _Tick = require("./Tick");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
// ChartUtilsScreen.tsx
|
|
12
|
+
|
|
13
|
+
const BottomAxis = function (props) {
|
|
14
|
+
const {
|
|
15
|
+
labels,
|
|
16
|
+
scale,
|
|
17
|
+
focalX,
|
|
18
|
+
offsetX,
|
|
19
|
+
style,
|
|
20
|
+
width,
|
|
21
|
+
font
|
|
22
|
+
} = props;
|
|
23
|
+
const offsetY = props.offsetY ?? 0;
|
|
24
|
+
const tickInterval = width / (labels.length - 1);
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Canvas, {
|
|
26
|
+
style: style,
|
|
27
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AxisLine.AxisLine, {
|
|
28
|
+
width,
|
|
29
|
+
offsetY,
|
|
30
|
+
focalX,
|
|
31
|
+
scale,
|
|
32
|
+
offsetX
|
|
33
|
+
}), labels.map((_label, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tick.Tick, {
|
|
34
|
+
label: _label,
|
|
35
|
+
initPosition: tickInterval * i,
|
|
36
|
+
offsetX,
|
|
37
|
+
offsetY,
|
|
38
|
+
focalX,
|
|
39
|
+
scale,
|
|
40
|
+
font
|
|
41
|
+
}, i))]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.BottomAxis = BottomAxis;
|
|
45
|
+
//# sourceMappingURL=BottomAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_AxisLine","_Tick","_jsxRuntime","BottomAxis","props","labels","scale","focalX","offsetX","style","width","font","offsetY","tickInterval","length","jsxs","Canvas","children","jsx","AxisLine","map","_label","i","Tick","label","initPosition","exports"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/BottomAxis.tsx"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAA8B,IAAAG,WAAA,GAAAH,OAAA;AAN9B;;AAoBA,MAAMI,UAA+B,GAAG,SAAAA,CAAUC,KAAK,EAAE;EACvD,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAK,CAAC,GAAGP,KAAK;EACpE,MAAMQ,OAAO,GAAGR,KAAK,CAACQ,OAAO,IAAI,CAAC;EAClC,MAAMC,YAAY,GAAGH,KAAK,IAAIL,MAAM,CAACS,MAAM,GAAG,CAAC,CAAC;EAEhD,oBACE,IAAAZ,WAAA,CAAAa,IAAA,EAACjB,gBAAA,CAAAkB,MAAM;IAACP,KAAK,EAAEA,KAAM;IAAAQ,QAAA,gBACnB,IAAAf,WAAA,CAAAgB,GAAA,EAAClB,SAAA,CAAAmB,QAAQ;MAAOT,KAAK;MAAEE,OAAO;MAAEL,MAAM;MAAED,KAAK;MAAEE;IAAO,CAAK,CAAC,EAC3DH,MAAM,CAACe,GAAG,CAAC,CAACC,MAAM,EAAEC,CAAC,kBACpB,IAAApB,WAAA,CAAAgB,GAAA,EAACjB,KAAA,CAAAsB,IAAI;MAEHC,KAAK,EAAEH,MAAO;MACdI,YAAY,EAAEZ,YAAY,GAAGS,CAAE;MACzBd,OAAO;MAAEI,OAAO;MAAEL,MAAM;MAAED,KAAK;MAAEK;IAAI,GAHtCW,CAIN,CACF,CAAC;EAAA,CACI,CAAC;AAEb,CAAC;AAACI,OAAA,CAAAvB,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Tick = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
|
+
var _gesture = require("../gesture");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const Tick = props => {
|
|
14
|
+
const {
|
|
15
|
+
label,
|
|
16
|
+
scale,
|
|
17
|
+
focalX,
|
|
18
|
+
offsetX,
|
|
19
|
+
initPosition,
|
|
20
|
+
font
|
|
21
|
+
} = props;
|
|
22
|
+
const offsetY = props.offsetY ?? 0;
|
|
23
|
+
const transform = (0, _reactNativeReanimated.useDerivedValue)(() => [{
|
|
24
|
+
translateX: (0, _gesture.getPositionWl)(initPosition, focalX.value, scale.value, offsetX.value)
|
|
25
|
+
}], [initPosition, offsetX]);
|
|
26
|
+
const width = font.getGlyphWidths(font.getGlyphIDs(label)).reduce((a, b) => a + b, 0);
|
|
27
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
28
|
+
transform: transform,
|
|
29
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Line, {
|
|
30
|
+
color: "black",
|
|
31
|
+
p1: (0, _reactNativeSkia.vec)(0, offsetY),
|
|
32
|
+
p2: (0, _reactNativeSkia.vec)(0, offsetY + 10)
|
|
33
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Text, {
|
|
34
|
+
text: label,
|
|
35
|
+
color: "black",
|
|
36
|
+
x: -width / 2,
|
|
37
|
+
y: offsetY + 23,
|
|
38
|
+
font: font
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.Tick = Tick;
|
|
43
|
+
//# sourceMappingURL=Tick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_interopRequireDefault","_reactNativeReanimated","_gesture","_jsxRuntime","e","__esModule","default","Tick","props","label","scale","focalX","offsetX","initPosition","font","offsetY","transform","useDerivedValue","translateX","getPositionWl","value","width","getGlyphWidths","getGlyphIDs","reduce","a","b","jsxs","Group","children","jsx","Line","color","p1","vec","p2","Text","text","x","y","exports"],"sourceRoot":"../../../../src","sources":["Charts/BottomAxis/Tick.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAA2C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAYpC,MAAMG,IAAyB,GAAIC,KAAK,IAAK;EAClD,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC;EAAK,CAAC,GAAGN,KAAK;EACnE,MAAMO,OAAO,GAAGP,KAAK,CAACO,OAAO,IAAI,CAAC;EAClC,MAAMC,SAAS,GAAG,IAAAC,sCAAe,EAC/B,MAAM,CACJ;IACEC,UAAU,EAAE,IAAAC,sBAAa,EACvBN,YAAY,EACZF,MAAM,CAACS,KAAK,EACZV,KAAK,CAACU,KAAK,EACXR,OAAO,CAACQ,KACV;EACF,CAAC,CACF,EACD,CAACP,YAAY,EAAED,OAAO,CACxB,CAAC;EACD,MAAMS,KAAK,GAAGP,IAAI,CACfQ,cAAc,CAACR,IAAI,CAACS,WAAW,CAACd,KAAK,CAAC,CAAC,CACvCe,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,EAAE,CAAC,CAAC;EAE7B,oBACE,IAAAvB,WAAA,CAAAwB,IAAA,EAAC9B,gBAAA,CAAA+B,KAAK;IAACZ,SAAS,EAAEA,SAAU;IAAAa,QAAA,gBAC1B,IAAA1B,WAAA,CAAA2B,GAAA,EAACjC,gBAAA,CAAAkC,IAAI;MAACC,KAAK,EAAC,OAAO;MAACC,EAAE,EAAE,IAAAC,oBAAG,EAAC,CAAC,EAAEnB,OAAO,CAAE;MAACoB,EAAE,EAAE,IAAAD,oBAAG,EAAC,CAAC,EAAEnB,OAAO,GAAG,EAAE;IAAE,CAAE,CAAC,eACrE,IAAAZ,WAAA,CAAA2B,GAAA,EAACjC,gBAAA,CAAAuC,IAAI;MACHC,IAAI,EAAE5B,KAAM;MACZuB,KAAK,EAAC,OAAO;MACbM,CAAC,EAAE,CAACjB,KAAK,GAAG,CAAE;MACdkB,CAAC,EAAExB,OAAO,GAAG,EAAG;MAChBD,IAAI,EAAEA;IAAK,CACZ,CAAC;EAAA,CACG,CAAC;AAEZ,CAAC;AAAC0B,OAAA,CAAAjC,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AxisLine", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AxisLine.AxisLine;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "BottomAxis", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _BottomAxis.BottomAxis;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Tick", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Tick.Tick;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _AxisLine = require("./AxisLine");
|
|
25
|
+
var _BottomAxis = require("./BottomAxis");
|
|
26
|
+
var _Tick = require("./Tick");
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AACA,IAAAE,KAAA,GAAAF,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Cursor = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
var _maths = require("./maths");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const CURSOR_SIZE = 10;
|
|
12
|
+
const Cursor = function ({
|
|
13
|
+
commands,
|
|
14
|
+
positionX,
|
|
15
|
+
color,
|
|
16
|
+
currentValue,
|
|
17
|
+
translateY,
|
|
18
|
+
size = CURSOR_SIZE
|
|
19
|
+
}) {
|
|
20
|
+
if (currentValue !== undefined && translateY !== undefined) {
|
|
21
|
+
console.warn('Current value as no effect when translateY is set');
|
|
22
|
+
}
|
|
23
|
+
const _translateY = translateY ? translateY :
|
|
24
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
25
|
+
(0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
26
|
+
const _commands = commands?.value;
|
|
27
|
+
if (_commands === undefined) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
const _value = (0, _maths.getYForX)(_commands, positionX.value) ?? 0;
|
|
31
|
+
if (currentValue !== undefined) {
|
|
32
|
+
currentValue.value = _value;
|
|
33
|
+
}
|
|
34
|
+
return _value;
|
|
35
|
+
});
|
|
36
|
+
const transform = (0, _reactNativeReanimated.useDerivedValue)(() => [{
|
|
37
|
+
translateX: positionX.value
|
|
38
|
+
}, {
|
|
39
|
+
translateY: _translateY.value ?? 0
|
|
40
|
+
}]);
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
42
|
+
transform: transform,
|
|
43
|
+
cx: 0,
|
|
44
|
+
cy: 0,
|
|
45
|
+
r: size,
|
|
46
|
+
color: color
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.Cursor = Cursor;
|
|
50
|
+
//# sourceMappingURL=Cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNativeReanimated","_maths","_jsxRuntime","CURSOR_SIZE","Cursor","commands","positionX","color","currentValue","translateY","size","undefined","console","warn","_translateY","useDerivedValue","_commands","value","_value","getYForX","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;AAWtB,MAAMC,MAAuB,GAAG,SAAAA,CAAU;EACxCC,QAAQ;EACRC,SAAS;EACTC,KAAK;EACLC,YAAY;EACZC,UAAU;EACVC,IAAI,GAAGP;AACT,CAAC,EAAE;EACD,IAAIK,YAAY,KAAKG,SAAS,IAAIF,UAAU,KAAKE,SAAS,EAAE;IAC1DC,OAAO,CAACC,IAAI,CAAC,mDAAmD,CAAC;EACnE;EAEA,MAAMC,WAAW,GAAGL,UAAU,GAC1BA,UAAU;EACV;EACA,IAAAM,sCAAe,EAAC,MAAM;IACpB,MAAMC,SAAS,GAAGX,QAAQ,EAAEY,KAAK;IACjC,IAAID,SAAS,KAAKL,SAAS,EAAE;MAC3B,OAAO,CAAC;IACV;IACA,MAAMO,MAAM,GAAG,IAAAC,eAAQ,EAACH,SAAS,EAAEV,SAAS,CAACW,KAAK,CAAC,IAAI,CAAC;IACxD,IAAIT,YAAY,KAAKG,SAAS,EAAE;MAC9BH,YAAY,CAACS,KAAK,GAAGC,MAAM;IAC7B;IACA,OAAOA,MAAM;EACf,CAAC,CAAC;EAEN,MAAME,SAAS,GAAG,IAAAL,sCAAe,EAAC,MAAM,CACtC;IAAEM,UAAU,EAAEf,SAAS,CAACW;EAAM,CAAC,EAC/B;IAAER,UAAU,EAAEK,WAAW,CAACG,KAAK,IAAI;EAAE,CAAC,CACvC,CAAC;EACF,oBAAO,IAAAf,WAAA,CAAAoB,GAAA,EAACxB,gBAAA,CAAAyB,MAAM;IAACH,SAAS,EAAEA,SAAU;IAACI,EAAE,EAAE,CAAE;IAACC,EAAE,EAAE,CAAE;IAACC,CAAC,EAAEhB,IAAK;IAACH,KAAK,EAAEA;EAAM,CAAE,CAAC;AAC9E,CAAC;AAACoB,OAAA,CAAAvB,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LineChart = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const LineChart = function (props) {
|
|
12
|
+
const {
|
|
13
|
+
width,
|
|
14
|
+
height,
|
|
15
|
+
style,
|
|
16
|
+
path,
|
|
17
|
+
children,
|
|
18
|
+
color,
|
|
19
|
+
paths,
|
|
20
|
+
background,
|
|
21
|
+
offsetX = 0,
|
|
22
|
+
offsetY = 0
|
|
23
|
+
} = props;
|
|
24
|
+
const _paths = paths !== undefined ? paths : path !== undefined ? [{
|
|
25
|
+
path: path,
|
|
26
|
+
color: color ?? 'red'
|
|
27
|
+
}] : [];
|
|
28
|
+
if (_paths.length === 0) {
|
|
29
|
+
console.warn('Specify either a path or multiple paths.');
|
|
30
|
+
return null;
|
|
31
|
+
// throw new Error('Specify either a path or multiple paths.');
|
|
32
|
+
}
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Canvas, {
|
|
34
|
+
style: [{
|
|
35
|
+
width,
|
|
36
|
+
height
|
|
37
|
+
}, style],
|
|
38
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
39
|
+
transform: [{
|
|
40
|
+
translateY: offsetY
|
|
41
|
+
}, {
|
|
42
|
+
translateX: offsetX
|
|
43
|
+
}],
|
|
44
|
+
children: [background, _paths.map((_path, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Path, {
|
|
45
|
+
style: "stroke",
|
|
46
|
+
..._path,
|
|
47
|
+
strokeWidth: 2,
|
|
48
|
+
strokeJoin: "round",
|
|
49
|
+
strokeCap: "round"
|
|
50
|
+
}, `${_path.id ?? i}`)), children]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.LineChart = LineChart;
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_interopRequireDefault","_jsxRuntime","e","__esModule","default","LineChart","props","width","height","style","path","children","color","paths","background","offsetX","offsetY","_paths","undefined","length","console","warn","jsx","Canvas","jsxs","Group","transform","translateY","translateX","map","_path","i","Path","strokeWidth","strokeJoin","strokeCap","id","exports"],"sourceRoot":"../../../../src","sources":["Charts/Linechart/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0B,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAuB1B,MAAMG,SAA6B,GAAG,SAAAA,CAAUC,KAAK,EAAE;EACrD,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,QAAQ;IACRC,KAAK;IACLC,KAAK;IACLC,UAAU;IACVC,OAAO,GAAG,CAAC;IACXC,OAAO,GAAG;EACZ,CAAC,GAAGV,KAAK;EAET,MAAMW,MAAkB,GACtBJ,KAAK,KAAKK,SAAS,GACfL,KAAK,GACLH,IAAI,KAAKQ,SAAS,GAClB,CAAC;IAAER,IAAI,EAAEA,IAAI;IAAEE,KAAK,EAAEA,KAAK,IAAI;EAAM,CAAC,CAAC,GACvC,EAAE;EACR,IAAIK,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACvBC,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;IACxD,OAAO,IAAI;IACX;EACF;EACA,oBACE,IAAApB,WAAA,CAAAqB,GAAA,EAACzB,gBAAA,CAAA0B,MAAM;IACLd,KAAK,EAAE,CACL;MACEF,KAAK;MACLC;IACF,CAAC,EACDC,KAAK,CACL;IAAAE,QAAA,eAEF,IAAAV,WAAA,CAAAuB,IAAA,EAAC3B,gBAAA,CAAA4B,KAAK;MAACC,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEX;MAAQ,CAAC,EAAE;QAAEY,UAAU,EAAEb;MAAQ,CAAC,CAAE;MAAAJ,QAAA,GAClEG,UAAU,EACVG,MAAM,CAACY,GAAG,CAAC,CAACC,KAAK,EAAEC,CAAC,kBACnB,IAAA9B,WAAA,CAAAqB,GAAA,EAACzB,gBAAA,CAAAmC,IAAI;QAEHvB,KAAK,EAAC,QAAQ;QAAA,GACVqB,KAAK;QACTG,WAAW,EAAE,CAAE;QACfC,UAAU,EAAC,OAAO;QAClBC,SAAS,EAAC;MAAO,GALZ,GAAGL,KAAK,CAACM,EAAE,IAAIL,CAAC,EAMtB,CACF,CAAC,EACDpB,QAAQ;IAAA,CACJ;EAAC,CACF,CAAC;AAEb,CAAC;AAAC0B,OAAA,CAAAhC,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScalablePath = void 0;
|
|
7
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
8
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
|
+
var _graphUtils = require("../graphUtils");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
const ScalablePath = function (props) {
|
|
12
|
+
const {
|
|
13
|
+
path,
|
|
14
|
+
scale,
|
|
15
|
+
focalX,
|
|
16
|
+
offsetX,
|
|
17
|
+
pathProps,
|
|
18
|
+
color = 'red'
|
|
19
|
+
} = props;
|
|
20
|
+
const animatedPath = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
21
|
+
let _cmds = [];
|
|
22
|
+
try {
|
|
23
|
+
_cmds = (0, _graphUtils.scaleCommands)(path.value?.toCmds() ?? [], scale, focalX, offsetX);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
console.error('Got error while scaling path: ', typeof e);
|
|
26
|
+
_cmds = [];
|
|
27
|
+
}
|
|
28
|
+
const _path = _reactNativeSkia.Skia.Path.MakeFromCmds(_cmds);
|
|
29
|
+
if (!_path) throw new Error('Path is null');
|
|
30
|
+
return _path;
|
|
31
|
+
}, [scale]);
|
|
32
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Path, {
|
|
33
|
+
style: "stroke",
|
|
34
|
+
path: animatedPath,
|
|
35
|
+
strokeWidth: 2,
|
|
36
|
+
strokeJoin: "round",
|
|
37
|
+
strokeCap: "round",
|
|
38
|
+
color: color,
|
|
39
|
+
...pathProps
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.ScalablePath = ScalablePath;
|
|
43
|
+
//# sourceMappingURL=ScalablePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_reactNativeReanimated","_graphUtils","_jsxRuntime","ScalablePath","props","path","scale","focalX","offsetX","pathProps","color","animatedPath","useDerivedValue","_cmds","scaleCommands","value","toCmds","e","console","error","_path","Skia","Path","MakeFromCmds","Error","jsx","style","strokeWidth","strokeJoin","strokeCap","exports"],"sourceRoot":"../../../../src","sources":["Charts/ZoomableLinechart/ScalablePath.tsx"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAOA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAA8C,IAAAG,WAAA,GAAAH,OAAA;AAW9C,MAAMI,YAAmC,GAAG,SAAAA,CAAUC,KAAK,EAAE;EAC3D,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC,MAAM;IAAEC,OAAO;IAAEC,SAAS;IAAEC,KAAK,GAAG;EAAM,CAAC,GAAGN,KAAK;EAExE,MAAMO,YAAY,GAAG,IAAAC,sCAAe,EAAC,MAAM;IACzC,IAAIC,KAAoB,GAAG,EAAE;IAC7B,IAAI;MACFA,KAAK,GAAG,IAAAC,yBAAa,EAACT,IAAI,CAACU,KAAK,EAAEC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAEV,KAAK,EAAEC,MAAM,EAAEC,OAAO,CAAC;IAC3E,CAAC,CAAC,OAAOS,CAAC,EAAE;MACVC,OAAO,CAACC,KAAK,CAAC,gCAAgC,EAAE,OAAOF,CAAC,CAAC;MACzDJ,KAAK,GAAG,EAAE;IACZ;IACA,MAAMO,KAAK,GAAGC,qBAAI,CAACC,IAAI,CAACC,YAAY,CAACV,KAAK,CAAC;IAC3C,IAAI,CAACO,KAAK,EAAE,MAAM,IAAII,KAAK,CAAC,cAAc,CAAC;IAC3C,OAAOJ,KAAK;EACd,CAAC,EAAE,CAACd,KAAK,CAAC,CAAC;EAEX,oBACE,IAAAJ,WAAA,CAAAuB,GAAA,EAAC3B,gBAAA,CAAAwB,IAAI;IACHI,KAAK,EAAC,QAAQ;IACdrB,IAAI,EAAEM,YAAa;IACnBgB,WAAW,EAAE,CAAE;IACfC,UAAU,EAAC,OAAO;IAClBC,SAAS,EAAC,OAAO;IACjBnB,KAAK,EAAEA,KAAM;IAAA,GACTD;EAAS,CACd,CAAC;AAEN,CAAC;AAACqB,OAAA,CAAA3B,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ScalablePath", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ScalablePath.ScalablePath;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.ZoomableLineChart = void 0;
|
|
13
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _ScalablePath = require("./ScalablePath");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
const ZoomableLineChart = function (props) {
|
|
19
|
+
const {
|
|
20
|
+
width,
|
|
21
|
+
height,
|
|
22
|
+
style,
|
|
23
|
+
children,
|
|
24
|
+
offsetY = 0,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
27
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Canvas, {
|
|
28
|
+
style: [{
|
|
29
|
+
width,
|
|
30
|
+
height
|
|
31
|
+
}, style],
|
|
32
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSkia.Group, {
|
|
33
|
+
transform: [{
|
|
34
|
+
translateY: offsetY
|
|
35
|
+
}],
|
|
36
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ScalablePath.ScalablePath, {
|
|
37
|
+
...rest
|
|
38
|
+
}), children]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.ZoomableLineChart = ZoomableLineChart;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeSkia","require","_react","_interopRequireDefault","_ScalablePath","_jsxRuntime","e","__esModule","default","ZoomableLineChart","props","width","height","style","children","offsetY","rest","jsx","Canvas","jsxs","Group","transform","translateY","ScalablePath","exports"],"sourceRoot":"../../../../src","sources":["Charts/ZoomableLinechart/index.tsx"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAIA,IAAAG,aAAA,GAAAH,OAAA;AAAsE,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAmBtE,MAAMG,iBAA6C,GAAG,SAAAA,CAAUC,KAAK,EAAE;EACrE,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,OAAO,GAAG,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGN,KAAK;EAEtE,oBACE,IAAAL,WAAA,CAAAY,GAAA,EAACjB,gBAAA,CAAAkB,MAAM;IACLL,KAAK,EAAE,CACL;MACEF,KAAK;MACLC;IACF,CAAC,EACDC,KAAK,CACL;IAAAC,QAAA,eAEF,IAAAT,WAAA,CAAAc,IAAA,EAACnB,gBAAA,CAAAoB,KAAK;MAACC,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEP;MAAQ,CAAC,CAAE;MAAAD,QAAA,gBAC1C,IAAAT,WAAA,CAAAY,GAAA,EAACb,aAAA,CAAAmB,YAAY;QAAA,GAAKP;MAAI,CAAG,CAAC,EACzBF,QAAQ;IAAA,CACJ;EAAC,CACF,CAAC;AAEb,CAAC;AAACU,OAAA,CAAAf,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|