react-native-wagmi-charts 1.0.4 → 1.2.1
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/.DS_Store +0 -0
- package/.prettierrc.js +5 -0
- package/README.md +171 -121
- package/example/.DS_Store +0 -0
- package/example/README.md +32 -0
- package/example/package.json +1 -1
- package/example/src/App.tsx +32 -7
- package/example/src/CandlestickChart.tsx +23 -11
- package/example/src/LineChart.tsx +51 -20
- package/example/src/{candlestick-data.json → data/candlestick-data.json} +0 -0
- package/example/src/{candlestick-data2.json → data/candlestick-data2.json} +0 -0
- package/example/src/{line-data.json → data/line-data.json} +0 -0
- package/example/src/{line-data2.json → data/line-data2.json} +0 -0
- package/example/yarn.lock +5 -5
- package/lib/commonjs/charts/candle/Crosshair.js +6 -17
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +12 -8
- package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/commonjs/charts/candle/DatetimeText.js +7 -8
- package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/candle/Line.js.map +1 -1
- package/lib/commonjs/charts/candle/PriceText.js +7 -8
- package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils.js.map +1 -1
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +4 -3
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +8 -1
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/DatetimeText.js +7 -8
- package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/line/Path.js +13 -16
- package/lib/commonjs/charts/line/Path.js.map +1 -1
- package/lib/commonjs/charts/line/PriceText.js +7 -8
- package/lib/commonjs/charts/line/PriceText.js.map +1 -1
- package/lib/commonjs/charts/line/interpolatePath.js +600 -0
- package/lib/commonjs/charts/line/interpolatePath.js.map +1 -0
- package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/line/usePrice.js.map +1 -1
- package/lib/commonjs/charts/line/utils.js +1 -70
- package/lib/commonjs/charts/line/utils.js.map +1 -1
- package/lib/commonjs/components/AnimatedText.js +63 -0
- package/lib/commonjs/components/AnimatedText.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/charts/candle/Crosshair.js +7 -16
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +10 -8
- package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/module/charts/candle/DatetimeText.js +6 -7
- package/lib/module/charts/candle/DatetimeText.js.map +1 -1
- package/lib/module/charts/candle/Line.js.map +1 -1
- package/lib/module/charts/candle/PriceText.js +6 -7
- package/lib/module/charts/candle/PriceText.js.map +1 -1
- package/lib/module/charts/candle/useCandleData.js.map +1 -1
- package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/module/charts/candle/useDatetime.js.map +1 -1
- package/lib/module/charts/candle/usePrice.js.map +1 -1
- package/lib/module/charts/candle/utils.js.map +1 -1
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +4 -3
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +7 -1
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/DatetimeText.js +6 -7
- package/lib/module/charts/line/DatetimeText.js.map +1 -1
- package/lib/module/charts/line/Path.js +11 -15
- package/lib/module/charts/line/Path.js.map +1 -1
- package/lib/module/charts/line/PriceText.js +6 -7
- package/lib/module/charts/line/PriceText.js.map +1 -1
- package/lib/module/charts/line/interpolatePath.js +587 -0
- package/lib/module/charts/line/interpolatePath.js.map +1 -0
- package/lib/module/charts/line/useDatetime.js.map +1 -1
- package/lib/module/charts/line/usePrice.js.map +1 -1
- package/lib/module/charts/line/utils.js +1 -66
- package/lib/module/charts/line/utils.js.map +1 -1
- package/lib/module/components/AnimatedText.js +43 -0
- package/lib/module/components/AnimatedText.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +4 -4
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Line.d.ts +1 -1
- package/lib/typescript/src/charts/candle/PriceText.d.ts +3 -3
- package/lib/typescript/src/charts/candle/types.d.ts +8 -3
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +3 -3
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +2 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +5 -7
- package/lib/typescript/src/charts/candle/usePrice.d.ts +5 -8
- package/lib/typescript/src/charts/candle/utils.d.ts +1 -1
- package/lib/typescript/src/charts/line/Chart.d.ts +1 -1
- package/lib/typescript/src/charts/line/Cursor.d.ts +1 -2
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +5 -6
- package/lib/typescript/src/charts/line/Path.d.ts +17 -1
- package/lib/typescript/src/charts/line/PriceText.d.ts +3 -2
- package/lib/typescript/src/charts/line/interpolatePath.d.ts +50 -0
- package/lib/typescript/src/charts/line/useDatetime.d.ts +4 -5
- package/lib/typescript/src/charts/line/usePrice.d.ts +3 -2
- package/lib/typescript/src/charts/line/utils.d.ts +0 -13
- package/lib/typescript/src/components/AnimatedText.d.ts +9 -0
- package/lib/typescript/src/utils.d.ts +2 -4
- package/package.json +4 -4
- package/src/charts/candle/Crosshair.tsx +20 -20
- package/src/charts/candle/CrosshairTooltip.tsx +11 -4
- package/src/charts/candle/DatetimeText.tsx +5 -4
- package/src/charts/candle/Line.tsx +1 -1
- package/src/charts/candle/PriceText.tsx +5 -5
- package/src/charts/candle/types.ts +11 -3
- package/src/charts/candle/useCandleData.ts +3 -2
- package/src/charts/candle/useCandlestickChart.ts +2 -1
- package/src/charts/candle/useDatetime.ts +7 -3
- package/src/charts/candle/usePrice.ts +10 -3
- package/src/charts/candle/utils.ts +1 -1
- package/src/charts/line/Chart.tsx +1 -1
- package/src/charts/line/Cursor.tsx +7 -3
- package/src/charts/line/CursorCrosshair.tsx +4 -3
- package/src/charts/line/CursorLine.tsx +9 -1
- package/src/charts/line/DatetimeText.tsx +8 -7
- package/src/charts/line/Path.tsx +25 -21
- package/src/charts/line/PriceText.tsx +5 -4
- package/src/charts/line/interpolatePath.ts +650 -0
- package/src/charts/line/useDatetime.ts +3 -2
- package/src/charts/line/usePrice.ts +2 -1
- package/src/charts/line/utils.ts +2 -79
- package/src/components/AnimatedText.tsx +53 -0
- package/src/utils.ts +3 -3
- package/yarn.lock +5 -5
package/.DS_Store
CHANGED
|
Binary file
|
package/.prettierrc.js
ADDED
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ A sweet & simple chart library for React Native that will make us feel like **W*
|
|
|
35
35
|
- [Interactive cursors](#interactive-cursors)
|
|
36
36
|
- [Interactive labels](#interactive-labels)
|
|
37
37
|
- [Interactive tooltips](#interactive-tooltips)
|
|
38
|
+
- [Haptic feedback](#haptic-feedback)
|
|
38
39
|
- [Colors](#colors)
|
|
39
40
|
- [Customizing size](#customizing-size)
|
|
40
41
|
- [Customizing labels](#customizing-labels)
|
|
@@ -63,6 +64,9 @@ A sweet & simple chart library for React Native that will make us feel like **W*
|
|
|
63
64
|
- [CandlestickChart.useCandleData](#candlestickchartusecandledata)
|
|
64
65
|
- [CandlestickChart.useDatetime](#candlestickchartusedatetime)
|
|
65
66
|
- [CandlestickChart.usePrice](#candlestickchartuseprice)
|
|
67
|
+
- [Web Support (Experimental)](#web-support)
|
|
68
|
+
- [Disable Transitions](#disable-transitions)
|
|
69
|
+
- [Reanimated Version](#reanimated-version)
|
|
66
70
|
- [Credits](#credits)
|
|
67
71
|
|
|
68
72
|
## Install
|
|
@@ -92,26 +96,26 @@ The `LineChart.Provider` component sets up the context of your chart, `LineChart
|
|
|
92
96
|
> Note: This chart does not include an interactive cursor like in the animated example above. If you want one, [check out the "Interactive Cursors" guide](#interactive-cursors)
|
|
93
97
|
|
|
94
98
|
```jsx
|
|
95
|
-
import { LineChart } from 'react-native-wagmi-charts';
|
|
99
|
+
import { LineChart } from 'react-native-wagmi-charts';
|
|
96
100
|
|
|
97
101
|
const data = [
|
|
98
102
|
{
|
|
99
103
|
timestamp: 1625945400000,
|
|
100
|
-
value: 33575.25
|
|
104
|
+
value: 33575.25,
|
|
101
105
|
},
|
|
102
106
|
{
|
|
103
107
|
timestamp: 1625946300000,
|
|
104
|
-
value: 33545.25
|
|
108
|
+
value: 33545.25,
|
|
105
109
|
},
|
|
106
110
|
{
|
|
107
111
|
timestamp: 1625947200000,
|
|
108
|
-
value: 33510.25
|
|
112
|
+
value: 33510.25,
|
|
109
113
|
},
|
|
110
114
|
{
|
|
111
115
|
timestamp: 1625948100000,
|
|
112
|
-
value: 33215.25
|
|
113
|
-
}
|
|
114
|
-
]
|
|
116
|
+
value: 33215.25,
|
|
117
|
+
},
|
|
118
|
+
];
|
|
115
119
|
|
|
116
120
|
function Example() {
|
|
117
121
|
return (
|
|
@@ -120,7 +124,7 @@ function Example() {
|
|
|
120
124
|
<LineChart.Path />
|
|
121
125
|
</LineChart>
|
|
122
126
|
</LineChart.Provider>
|
|
123
|
-
)
|
|
127
|
+
);
|
|
124
128
|
}
|
|
125
129
|
```
|
|
126
130
|
|
|
@@ -133,7 +137,7 @@ The `CandlestickChart.Provider` component sets up the context of your chart, `Ca
|
|
|
133
137
|
> Note: This chart does not include an interactive cursor like in the animated example above. If you want one, [check out the "Interactive Cursors" guide](#interactive-cursors)
|
|
134
138
|
|
|
135
139
|
```jsx
|
|
136
|
-
import { CandlestickChart } from 'react-native-wagmi-charts';
|
|
140
|
+
import { CandlestickChart } from 'react-native-wagmi-charts';
|
|
137
141
|
|
|
138
142
|
const data = [
|
|
139
143
|
{
|
|
@@ -141,30 +145,30 @@ const data = [
|
|
|
141
145
|
open: 33575.25,
|
|
142
146
|
high: 33600.52,
|
|
143
147
|
low: 33475.12,
|
|
144
|
-
close: 33520.11
|
|
148
|
+
close: 33520.11,
|
|
145
149
|
},
|
|
146
150
|
{
|
|
147
151
|
timestamp: 1625946300000,
|
|
148
152
|
open: 33545.25,
|
|
149
153
|
high: 33560.52,
|
|
150
154
|
low: 33510.12,
|
|
151
|
-
close: 33520.11
|
|
155
|
+
close: 33520.11,
|
|
152
156
|
},
|
|
153
157
|
{
|
|
154
158
|
timestamp: 1625947200000,
|
|
155
159
|
open: 33510.25,
|
|
156
160
|
high: 33515.52,
|
|
157
161
|
low: 33250.12,
|
|
158
|
-
close: 33250.11
|
|
162
|
+
close: 33250.11,
|
|
159
163
|
},
|
|
160
164
|
{
|
|
161
165
|
timestamp: 1625948100000,
|
|
162
166
|
open: 33215.25,
|
|
163
167
|
high: 33430.52,
|
|
164
168
|
low: 33215.12,
|
|
165
|
-
close: 33420.11
|
|
166
|
-
}
|
|
167
|
-
]
|
|
169
|
+
close: 33420.11,
|
|
170
|
+
},
|
|
171
|
+
];
|
|
168
172
|
|
|
169
173
|
function Example() {
|
|
170
174
|
return (
|
|
@@ -173,7 +177,7 @@ function Example() {
|
|
|
173
177
|
<CandlestickChart.Candles />
|
|
174
178
|
</CandlestickChart>
|
|
175
179
|
</CandlestickChart.Provider>
|
|
176
|
-
)
|
|
180
|
+
);
|
|
177
181
|
}
|
|
178
182
|
```
|
|
179
183
|
|
|
@@ -213,7 +217,6 @@ To render an interactive cursor on your line chart, you can include either the `
|
|
|
213
217
|
|
|
214
218
|
<img src="https://user-images.githubusercontent.com/7336481/133027471-1c620ece-a95e-46b7-bd92-50f33757ce92.gif" width="200px" />
|
|
215
219
|
|
|
216
|
-
|
|
217
220
|
#### Candlestick chart
|
|
218
221
|
|
|
219
222
|
To render an interactive cursor on your candlestick chart, you can include the `CandlestickChart.Crosshair` component:
|
|
@@ -328,6 +331,64 @@ To render an interactive tooltip that follows your crosshair, you can use the `T
|
|
|
328
331
|
|
|
329
332
|
<img src="https://user-images.githubusercontent.com/7336481/133036451-e1f2f12b-9e96-4a0f-8c69-4f630bb8ded3.gif" width="200px" />
|
|
330
333
|
|
|
334
|
+
### Haptic feedback
|
|
335
|
+
|
|
336
|
+
By making use of the chart event handlers, you are able to integrate haptic feedback into your charts.
|
|
337
|
+
|
|
338
|
+
#### Line charts
|
|
339
|
+
|
|
340
|
+
We can utilise the `onActivated` and `onEnded` events to create haptic feedback on our line chart.
|
|
341
|
+
|
|
342
|
+
```jsx
|
|
343
|
+
import * as haptics from 'expo-haptics';
|
|
344
|
+
|
|
345
|
+
const data = [...];
|
|
346
|
+
|
|
347
|
+
function invokeHaptic() {
|
|
348
|
+
haptics.impactAsync(haptics.ImpactFeedbackStyle.Light);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function Example() {
|
|
352
|
+
return (
|
|
353
|
+
<LineChart.Provider data={data}>
|
|
354
|
+
<LineChart>
|
|
355
|
+
<LineChart.Path />
|
|
356
|
+
<LineChart.CursorCrosshair onActivated={invokeHaptic} onEnded={invokeHaptic}>
|
|
357
|
+
<LineChart.Tooltip />
|
|
358
|
+
</LineChart.CursorCrosshair>
|
|
359
|
+
</LineChart>
|
|
360
|
+
</LineChart.Provider>
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### Candlestick charts
|
|
366
|
+
|
|
367
|
+
We can utilise the `onCurrentXChange` event to create haptic feedback on our candlestick chart.
|
|
368
|
+
|
|
369
|
+
```jsx
|
|
370
|
+
import * as haptics from 'expo-haptics';
|
|
371
|
+
|
|
372
|
+
const data = [...];
|
|
373
|
+
|
|
374
|
+
function invokeHaptic() {
|
|
375
|
+
haptics.impactAsync(haptics.ImpactFeedbackStyle.Light);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function Example() {
|
|
379
|
+
return (
|
|
380
|
+
<CandlestickChart.Provider data={data}>
|
|
381
|
+
<CandlestickChart>
|
|
382
|
+
<CandlestickChart.Candles />
|
|
383
|
+
<CandlestickChart.Crosshair onCurrentXChange={invokeHaptic}>
|
|
384
|
+
<CandlestickChart.Tooltip />
|
|
385
|
+
</CandlestickChart.Crosshair>
|
|
386
|
+
</CandlestickChart>
|
|
387
|
+
</CandlestickChart.Provider>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
331
392
|
### Colors
|
|
332
393
|
|
|
333
394
|
By default, the charts come with default colors out-of-the-box... But you probably will want to change these to suit your brand.
|
|
@@ -348,7 +409,6 @@ To customise the color of the line chart path, supply a `color` prop to `LineCha
|
|
|
348
409
|
|
|
349
410
|
<img src="https://user-images.githubusercontent.com/7336481/133037040-ce13ba5b-6ee5-45a2-ba14-18bf12e13746.png" width="200px" />
|
|
350
411
|
|
|
351
|
-
|
|
352
412
|
##### Coloring the cursor
|
|
353
413
|
|
|
354
414
|
To customise the color of the line chart cursor, supply a `color` prop to `LineChart.CursorCrosshair`. This can be any valid React Native `StyleSheet` compatible color.
|
|
@@ -382,7 +442,6 @@ To customise the color of the candlestick chart candles, supply a `negativeColor
|
|
|
382
442
|
|
|
383
443
|
<img width="200px" alt="Screen Shot 2021-09-13 at 4 58 52 pm" src="https://user-images.githubusercontent.com/7336481/133037949-aba76daa-20bb-4d4e-b05e-b0cff42b69a6.png">
|
|
384
444
|
|
|
385
|
-
|
|
386
445
|
##### Coloring the crosshair
|
|
387
446
|
|
|
388
447
|
To customise the color of the line chart cursor, supply a `color` prop to `CandlestickChart.Crosshair`. This can be any valid React Native `StyleSheet` compatible color.
|
|
@@ -504,11 +563,7 @@ You can customize the gutters of the tooltip by providing `cursorGutter`, `xGutt
|
|
|
504
563
|
`xGutter` and `yGutter` is the gutter on the x & y axis of the chart (the tooltip can't pass the gutter).
|
|
505
564
|
|
|
506
565
|
```jsx
|
|
507
|
-
<LineChart.Tooltip
|
|
508
|
-
cursorGutter={60}
|
|
509
|
-
xGutter={16}
|
|
510
|
-
yGutter={16}
|
|
511
|
-
/>
|
|
566
|
+
<LineChart.Tooltip cursorGutter={60} xGutter={16} yGutter={16} />
|
|
512
567
|
```
|
|
513
568
|
|
|
514
569
|
<img src="https://user-images.githubusercontent.com/7336481/133054393-28d542c1-c9fc-4ba6-b4a0-86cf096ebcda.gif" width="200px" />
|
|
@@ -533,22 +588,23 @@ You can customize the gutters of the tooltip by providing `cursorGutter`, `xGutt
|
|
|
533
588
|
|
|
534
589
|
### LineChart.Path
|
|
535
590
|
|
|
536
|
-
| Prop
|
|
537
|
-
|
|
|
538
|
-
| `color`
|
|
539
|
-
| `width`
|
|
540
|
-
|
|
|
591
|
+
| Prop | Type | Default | Description |
|
|
592
|
+
| ----------- | ----------- | --------- | -------------------------------- |
|
|
593
|
+
| `color` | `string` | `"black"` | Color of the line path |
|
|
594
|
+
| `width` | `number` | `3` | Width of the line path |
|
|
595
|
+
| `pathProps` | `PathProps` | `{}` | React Native SVG's `Path` props. |
|
|
541
596
|
|
|
542
597
|
### LineChart.CursorCrosshair
|
|
543
598
|
|
|
544
|
-
| Prop | Type
|
|
545
|
-
| ----------------------- |
|
|
546
|
-
| `color` | `string`
|
|
547
|
-
| `size` | `number`
|
|
548
|
-
| `outerSize` | `number`
|
|
549
|
-
| `crosshairWrapperProps` | `ViewProps`
|
|
550
|
-
| `crosshairProps` | `ViewProps`
|
|
551
|
-
| `crosshairOuterProps` | `ViewProps`
|
|
599
|
+
| Prop | Type | Default | Description |
|
|
600
|
+
| ----------------------- | ------------------------------ | --------- | ----------------------------------------------- |
|
|
601
|
+
| `color` | `string` | `"black"` | Color of the crosshair dot |
|
|
602
|
+
| `size` | `number` | `8` | Size of the crosshair dot |
|
|
603
|
+
| `outerSize` | `number` | `32` | Size of the outer crosshair dot (faded dot) |
|
|
604
|
+
| `crosshairWrapperProps` | `ViewProps` | | Props of the wrapper component of the crosshair |
|
|
605
|
+
| `crosshairProps` | `ViewProps` | | Props of the crosshair dot |
|
|
606
|
+
| `crosshairOuterProps` | `ViewProps` | | Props of the crosshair outer dot |
|
|
607
|
+
| `...props` | `LongPressGestureHandlerProps` | | |
|
|
552
608
|
|
|
553
609
|
### LineChart.CursorLine
|
|
554
610
|
|
|
@@ -559,31 +615,31 @@ You can customize the gutters of the tooltip by providing `cursorGutter`, `xGutt
|
|
|
559
615
|
|
|
560
616
|
### LineChart.Tooltip
|
|
561
617
|
|
|
562
|
-
| Prop | Type
|
|
563
|
-
| -------------- |
|
|
564
|
-
| `xGutter` | `number`
|
|
565
|
-
| `yGutter` | `number`
|
|
566
|
-
| `cursorGutter` | `number`
|
|
567
|
-
| `position` | `"top"
|
|
618
|
+
| Prop | Type | Default | Description |
|
|
619
|
+
| -------------- | -------- | --------- | ---------------------------------------------------- | ----------------------------------------------- |
|
|
620
|
+
| `xGutter` | `number` | `8` | X axis gutter in which the tooltip will not pass. |
|
|
621
|
+
| `yGutter` | `number` | `8` | Y axis gutter in which the tooltip will not pass. |
|
|
622
|
+
| `cursorGutter` | `number` | `48` | Gutter (spacing) between the cursor and the tooltip. |
|
|
623
|
+
| `position` | `"top" | "bottom"` | `"top"` | Position of the tooltip relative to the cursor. |
|
|
568
624
|
|
|
569
625
|
### LineChart.PriceText
|
|
570
626
|
|
|
571
|
-
| Prop | Type | Default
|
|
572
|
-
| ----------- | ---------------------------------- |
|
|
573
|
-
| `format` | `({ value, formatted }) => string` |
|
|
574
|
-
| `precision` | `number` | `2`
|
|
575
|
-
| `variant` | `"formatted"
|
|
576
|
-
| `...props` | `TextProps` |
|
|
627
|
+
| Prop | Type | Default | Description |
|
|
628
|
+
| ----------- | ---------------------------------- | -------- | ------------------------------------ | ------------------------------------------ |
|
|
629
|
+
| `format` | `({ value, formatted }) => string` | | Custom format function of the price. |
|
|
630
|
+
| `precision` | `number` | `2` | Default precision of the price. |
|
|
631
|
+
| `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the price value. |
|
|
632
|
+
| `...props` | `TextProps` | | Inherits React Native's `Text` props |
|
|
577
633
|
|
|
578
634
|
### LineChart.DatetimeText
|
|
579
635
|
|
|
580
|
-
| Prop | Type | Default
|
|
581
|
-
| --------- | ---------------------------------- |
|
|
582
|
-
| `format` | `({ value, formatted }) => string` |
|
|
583
|
-
| `locale` | `string` | `"en-US"`
|
|
584
|
-
| `options` | `{}` |
|
|
585
|
-
| `style` | `{}` |
|
|
586
|
-
| `variant` | `"formatted"
|
|
636
|
+
| Prop | Type | Default | Description |
|
|
637
|
+
| --------- | ---------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
638
|
+
| `format` | `({ value, formatted }) => string` | | Custom format function of the timestamp. |
|
|
639
|
+
| `locale` | `string` | `"en-US"` | Locale of the timestamp. |
|
|
640
|
+
| `options` | `{}` | | Options to pass to `toLocaleString()`. [Available options are here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) |
|
|
641
|
+
| `style` | `{}` | | Style of the price text |
|
|
642
|
+
| `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the timestamp value. |
|
|
587
643
|
|
|
588
644
|
### CandlestickChart.Provider
|
|
589
645
|
|
|
@@ -613,9 +669,11 @@ You can customize the gutters of the tooltip by providing `cursorGutter`, `xGutt
|
|
|
613
669
|
|
|
614
670
|
### CandlestickChart.Crosshair
|
|
615
671
|
|
|
616
|
-
| Prop
|
|
617
|
-
|
|
|
618
|
-
| `color`
|
|
672
|
+
| Prop | Type | Default | Description |
|
|
673
|
+
| ------------------ | ------------------------------ | --------- | ------------------------------------------------ | --- |
|
|
674
|
+
| `color` | `string` | `"black"` | Color of the crosshair | |
|
|
675
|
+
| `onCurrentXChange` | `(xValue: number) => void` | | Callback to invoke when the x coordinate changes |
|
|
676
|
+
| `...props` | `LongPressGestureHandlerProps` | | |
|
|
619
677
|
|
|
620
678
|
### CandlestickChart.Tooltip
|
|
621
679
|
|
|
@@ -625,41 +683,37 @@ You can customize the gutters of the tooltip by providing `cursorGutter`, `xGutt
|
|
|
625
683
|
| `yGutter` | `number` | `8` | Y axis gutter in which the tooltip will not pass. |
|
|
626
684
|
| `tooltipTextProps` | `PriceTextProps` | | Props of the tooltip (price) text. |
|
|
627
685
|
| `textStyle` | `{}` | | Style of the tooltip text |
|
|
686
|
+
|
|
628
687
|
### CandlestickChart.PriceText
|
|
629
688
|
|
|
630
|
-
| Prop | Type | Default
|
|
631
|
-
| ----------- | ---------------------------------- |
|
|
632
|
-
| `format` | `({ value, formatted }) => string` |
|
|
633
|
-
| `precision` | `number` | `2`
|
|
634
|
-
| `variant` | `"formatted"
|
|
635
|
-
| `...props` | `TextProps` |
|
|
689
|
+
| Prop | Type | Default | Description |
|
|
690
|
+
| ----------- | ---------------------------------- | -------- | ------------------------------------ | ------------------------------------------ |
|
|
691
|
+
| `format` | `({ value, formatted }) => string` | | Custom format function of the price. |
|
|
692
|
+
| `precision` | `number` | `2` | Default precision of the price. |
|
|
693
|
+
| `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the price value. |
|
|
694
|
+
| `...props` | `TextProps` | | Inherits React Native's `Text` props |
|
|
636
695
|
|
|
637
696
|
### CandlestickChart.DatetimeText
|
|
638
697
|
|
|
639
|
-
| Prop | Type | Default
|
|
640
|
-
| --------- | ---------------------------------- |
|
|
641
|
-
| `format` | `({ value, formatted }) => string` |
|
|
642
|
-
| `locale` | `string` | `"en-US"`
|
|
643
|
-
| `options` | `{}` |
|
|
644
|
-
| `style` | `{}` |
|
|
645
|
-
| `variant` | `"formatted"
|
|
698
|
+
| Prop | Type | Default | Description |
|
|
699
|
+
| --------- | ---------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
|
700
|
+
| `format` | `({ value, formatted }) => string` | | Custom format function of the timestamp. |
|
|
701
|
+
| `locale` | `string` | `"en-US"` | Locale of the timestamp. |
|
|
702
|
+
| `options` | `{}` | | Options to pass to `toLocaleString()`. [Available options are here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) |
|
|
703
|
+
| `style` | `{}` | | Style of the price text |
|
|
704
|
+
| `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the timestamp value. |
|
|
646
705
|
|
|
647
706
|
## Hooks
|
|
648
707
|
|
|
649
708
|
The following hooks are only accessible inside the `LineChart.Provider` or `CandlestickChart.Provider`.
|
|
709
|
+
|
|
650
710
|
### LineChart.useChart
|
|
651
711
|
|
|
652
712
|
The `LineChart.useChart` hook returns the current state of the chart.
|
|
653
713
|
|
|
654
714
|
```jsx
|
|
655
|
-
const {
|
|
656
|
-
|
|
657
|
-
currentY,
|
|
658
|
-
currentIndex,
|
|
659
|
-
data,
|
|
660
|
-
domain,
|
|
661
|
-
isActive
|
|
662
|
-
} = LineChart.useChart();
|
|
715
|
+
const { currentX, currentY, currentIndex, data, domain, isActive } =
|
|
716
|
+
LineChart.useChart();
|
|
663
717
|
```
|
|
664
718
|
|
|
665
719
|
#### Reference
|
|
@@ -678,14 +732,11 @@ const {
|
|
|
678
732
|
### LineChart.useDatetime
|
|
679
733
|
|
|
680
734
|
```jsx
|
|
681
|
-
const {
|
|
682
|
-
value,
|
|
683
|
-
formatted
|
|
684
|
-
} = LineChart.useDatetime({
|
|
735
|
+
const { value, formatted } = LineChart.useDatetime({
|
|
685
736
|
format,
|
|
686
737
|
locale,
|
|
687
|
-
options
|
|
688
|
-
})
|
|
738
|
+
options,
|
|
739
|
+
});
|
|
689
740
|
```
|
|
690
741
|
|
|
691
742
|
#### Reference
|
|
@@ -708,13 +759,10 @@ const {
|
|
|
708
759
|
### LineChart.usePrice
|
|
709
760
|
|
|
710
761
|
```jsx
|
|
711
|
-
const {
|
|
712
|
-
value,
|
|
713
|
-
formatted
|
|
714
|
-
} = LineChart.usePrice({
|
|
762
|
+
const { value, formatted } = LineChart.usePrice({
|
|
715
763
|
format,
|
|
716
|
-
precision
|
|
717
|
-
})
|
|
764
|
+
precision,
|
|
765
|
+
});
|
|
718
766
|
```
|
|
719
767
|
|
|
720
768
|
**Arguments**
|
|
@@ -734,13 +782,7 @@ const {
|
|
|
734
782
|
### CandlestickChart.useChart
|
|
735
783
|
|
|
736
784
|
```jsx
|
|
737
|
-
const {
|
|
738
|
-
currentX,
|
|
739
|
-
currentY,
|
|
740
|
-
data,
|
|
741
|
-
domain,
|
|
742
|
-
step
|
|
743
|
-
} = CandlestickChart.useChart();
|
|
785
|
+
const { currentX, currentY, data, domain, step } = CandlestickChart.useChart();
|
|
744
786
|
```
|
|
745
787
|
|
|
746
788
|
#### Reference
|
|
@@ -760,13 +802,7 @@ const {
|
|
|
760
802
|
The `useCandleData` hook returns the current candle data.
|
|
761
803
|
|
|
762
804
|
```jsx
|
|
763
|
-
const {
|
|
764
|
-
timestamp,
|
|
765
|
-
open,
|
|
766
|
-
high,
|
|
767
|
-
low,
|
|
768
|
-
close
|
|
769
|
-
} = CandlestickChart.useCandleData();
|
|
805
|
+
const { timestamp, open, high, low, close } = CandlestickChart.useCandleData();
|
|
770
806
|
```
|
|
771
807
|
|
|
772
808
|
#### Reference
|
|
@@ -781,18 +817,14 @@ const {
|
|
|
781
817
|
| `low` | `number` | | |
|
|
782
818
|
| `close` | `number` | | |
|
|
783
819
|
|
|
784
|
-
|
|
785
820
|
### CandlestickChart.useDatetime
|
|
786
821
|
|
|
787
822
|
```jsx
|
|
788
|
-
const {
|
|
789
|
-
value,
|
|
790
|
-
formatted
|
|
791
|
-
} = CandlestickChart.useDatetime({
|
|
823
|
+
const { value, formatted } = CandlestickChart.useDatetime({
|
|
792
824
|
format,
|
|
793
825
|
locale,
|
|
794
|
-
options
|
|
795
|
-
})
|
|
826
|
+
options,
|
|
827
|
+
});
|
|
796
828
|
```
|
|
797
829
|
|
|
798
830
|
#### Reference
|
|
@@ -812,17 +844,13 @@ const {
|
|
|
812
844
|
| `value` | `string` | | Timestamp value in ms. |
|
|
813
845
|
| `formatted` | `string` | | Formatted timestamp value |
|
|
814
846
|
|
|
815
|
-
|
|
816
847
|
### CandlestickChart.usePrice
|
|
817
848
|
|
|
818
849
|
```jsx
|
|
819
|
-
const {
|
|
820
|
-
value,
|
|
821
|
-
formatted
|
|
822
|
-
} = CandlestickChart.usePrice({
|
|
850
|
+
const { value, formatted } = CandlestickChart.usePrice({
|
|
823
851
|
format,
|
|
824
|
-
precision
|
|
825
|
-
})
|
|
852
|
+
precision,
|
|
853
|
+
});
|
|
826
854
|
```
|
|
827
855
|
|
|
828
856
|
**Arguments**
|
|
@@ -839,11 +867,33 @@ const {
|
|
|
839
867
|
| `value` | `string` | | Price value |
|
|
840
868
|
| `formatted` | `string` | | Formatted price value |
|
|
841
869
|
|
|
870
|
+
## Web Support
|
|
871
|
+
|
|
872
|
+
Web support is currently experimental.
|
|
873
|
+
|
|
874
|
+
Currently, transitions for a line chart's path flicker a little. You can disable them on Web with the `isTransitionEnabled` prop.
|
|
875
|
+
|
|
876
|
+
### Disable Transitions
|
|
877
|
+
|
|
878
|
+
```tsx
|
|
879
|
+
import { Platform } from 'react-native';
|
|
880
|
+
|
|
881
|
+
const isWeb = Platform.OS === 'web'
|
|
882
|
+
|
|
883
|
+
<LineChart.Path
|
|
884
|
+
pathProps={{
|
|
885
|
+
isTransitionEnabled: !isWeb,
|
|
886
|
+
}}
|
|
887
|
+
/>;
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
### Reanimated Version
|
|
842
891
|
|
|
892
|
+
In order to support SVG animations on Web, you'll need at least Reanimated version `2.3.0-beta.2`. Or, you can use the patch from [Issue #8](https://github.com/coinjar/react-native-wagmi-charts/issues/8#issuecomment-938097099).
|
|
843
893
|
|
|
844
894
|
## Credits
|
|
845
895
|
|
|
846
896
|
This library wouldn't be possible if it weren't for:
|
|
847
897
|
|
|
848
898
|
- [Rainbow's Animated Charts](https://github.com/rainbow-me/react-native-animated-charts)
|
|
849
|
-
- @wcandillon and his [Can It Be Done In React Native](www.youtube.com/wcandillon) series 💪😍
|
|
899
|
+
- @wcandillon and his [Can It Be Done In React Native](www.youtube.com/wcandillon) series 💪😍
|
package/example/.DS_Store
CHANGED
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# react-native-wagmi-charts Example Project 🧑🏫
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First install project dependencies in this directory:
|
|
6
|
+
|
|
7
|
+
`npm install`
|
|
8
|
+
|
|
9
|
+
After dependencies are installed, you can go ahead and run the project on either a simulator, or a real device using the following commands
|
|
10
|
+
|
|
11
|
+
For iOS:
|
|
12
|
+
|
|
13
|
+
`npm run ios`
|
|
14
|
+
|
|
15
|
+
For Android:
|
|
16
|
+
|
|
17
|
+
`npm run android`
|
|
18
|
+
|
|
19
|
+
For Web:
|
|
20
|
+
|
|
21
|
+
`npm run web`
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Example Charts
|
|
25
|
+
|
|
26
|
+
The following charts are included:
|
|
27
|
+
|
|
28
|
+
- Candlestick Chart
|
|
29
|
+
- Line Chart
|
|
30
|
+
|
|
31
|
+
### Sample Data
|
|
32
|
+
The charts in this example use hardcoded data, which is stored in the `src/data` directory
|
package/example/package.json
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"bumbag": "^2.2.1",
|
|
16
16
|
"bumbag-native": "^2.3.0",
|
|
17
17
|
"expo": "42.0.1",
|
|
18
|
+
"expo-haptics": "^10.1.0",
|
|
18
19
|
"expo-splash-screen": "~0.11.2",
|
|
19
20
|
"react": "16.13.1",
|
|
20
21
|
"react-dom": "16.13.1",
|
|
21
22
|
"react-native": "0.63.4",
|
|
22
23
|
"react-native-gesture-handler": "~1.10.2",
|
|
23
|
-
"react-native-haptic-feedback": "^1.11.0",
|
|
24
24
|
"react-native-reanimated": "~2.2.0",
|
|
25
25
|
"react-native-unimodules": "~0.14.5",
|
|
26
26
|
"react-native-web": "~0.13.12"
|
package/example/src/App.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import 'react-native-gesture-handler';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
Text,
|
|
7
|
+
Heading,
|
|
8
|
+
Level,
|
|
9
|
+
Provider as BumbagNativeProvider,
|
|
10
|
+
} from 'bumbag-native';
|
|
4
11
|
|
|
5
12
|
import CandlestickChart from './CandlestickChart';
|
|
6
13
|
import LineChart from './LineChart';
|
|
@@ -10,19 +17,37 @@ export default function App() {
|
|
|
10
17
|
return (
|
|
11
18
|
<BumbagNativeProvider>
|
|
12
19
|
<Box.Safe flex="1">
|
|
20
|
+
<Level
|
|
21
|
+
verticalBelow=""
|
|
22
|
+
paddingX="major-2"
|
|
23
|
+
paddingY="major-2"
|
|
24
|
+
alignY="center"
|
|
25
|
+
>
|
|
26
|
+
<Heading.H5 key={'heading'}>React Native WAGMI Charts 💸</Heading.H5>
|
|
27
|
+
{selected ? (
|
|
28
|
+
<Button size="small" onPress={() => setSelected('')}>
|
|
29
|
+
Back
|
|
30
|
+
</Button>
|
|
31
|
+
) : null}
|
|
32
|
+
</Level>
|
|
13
33
|
<Box.Scroll>
|
|
14
34
|
{!selected && (
|
|
15
35
|
<Box paddingX="major-2" marginTop="major-6">
|
|
16
|
-
<
|
|
36
|
+
<Heading.H6 marginBottom="major-2">
|
|
37
|
+
Click a chart below to get started
|
|
38
|
+
</Heading.H6>
|
|
39
|
+
<Button onPress={() => setSelected('candlestick')}>
|
|
17
40
|
<Text>Candlestick</Text>
|
|
18
|
-
</
|
|
19
|
-
<
|
|
41
|
+
</Button>
|
|
42
|
+
<Button onPress={() => setSelected('line')}>
|
|
20
43
|
<Text>Line</Text>
|
|
21
|
-
</
|
|
44
|
+
</Button>
|
|
22
45
|
</Box>
|
|
23
46
|
)}
|
|
24
|
-
|
|
25
|
-
|
|
47
|
+
<Box marginTop="major-2">
|
|
48
|
+
{selected === 'candlestick' && <CandlestickChart />}
|
|
49
|
+
{selected === 'line' && <LineChart />}
|
|
50
|
+
</Box>
|
|
26
51
|
</Box.Scroll>
|
|
27
52
|
</Box.Safe>
|
|
28
53
|
</BumbagNativeProvider>
|