react-native-wagmi-charts 2.9.0 → 2.9.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/README.md +142 -66
- package/lib/commonjs/charts/candle/Candle.js +92 -177
- package/lib/commonjs/charts/candle/Candles.js +39 -66
- package/lib/commonjs/charts/candle/Chart.js +26 -37
- package/lib/commonjs/charts/candle/Context.js +49 -69
- package/lib/commonjs/charts/candle/Crosshair.js +82 -183
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +61 -140
- package/lib/commonjs/charts/candle/DatetimeText.js +14 -19
- package/lib/commonjs/charts/candle/Line.js +27 -73
- package/lib/commonjs/charts/candle/PriceText.js +14 -19
- package/lib/commonjs/charts/candle/index.js +64 -67
- package/lib/commonjs/charts/candle/types.js +4 -4
- package/lib/commonjs/charts/candle/useCandleData.js +12 -9
- package/lib/commonjs/charts/candle/useCandlestickChart.js +7 -9
- package/lib/commonjs/charts/candle/useDatetime.js +18 -16
- package/lib/commonjs/charts/candle/usePrice.js +22 -21
- package/lib/commonjs/charts/candle/utils/getDomain.js +9 -5
- package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getHeight.js +11 -12
- package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getPrice.js +11 -12
- package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getY.js +11 -12
- package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/index.js +16 -16
- package/lib/commonjs/charts/line/Axis.js +148 -268
- package/lib/commonjs/charts/line/Chart.js +62 -129
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/ChartPath.js +105 -285
- package/lib/commonjs/charts/line/Context.js +37 -95
- package/lib/commonjs/charts/line/Cursor.js +74 -125
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +56 -134
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +67 -152
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/Data.js +34 -73
- package/lib/commonjs/charts/line/DatetimeText.js +15 -20
- package/lib/commonjs/charts/line/Dot.js +56 -149
- package/lib/commonjs/charts/line/Gradient.js +53 -124
- package/lib/commonjs/charts/line/Group.js +23 -54
- package/lib/commonjs/charts/line/Group.js.map +1 -1
- package/lib/commonjs/charts/line/Highlight.js +47 -115
- package/lib/commonjs/charts/line/HorizontalLine.js +39 -92
- package/lib/commonjs/charts/line/HoverTrap/index.js +7 -10
- package/lib/commonjs/charts/line/HoverTrap/index.web.js +43 -48
- package/lib/commonjs/charts/line/LineChartPathContext.js +11 -14
- package/lib/commonjs/charts/line/Path.js +32 -78
- package/lib/commonjs/charts/line/PriceText.js +36 -78
- package/lib/commonjs/charts/line/Tooltip.js +102 -188
- package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
- package/lib/commonjs/charts/line/index.js +65 -65
- package/lib/commonjs/charts/line/types.js +4 -4
- package/lib/commonjs/charts/line/useAnimatedPath.js +22 -27
- package/lib/commonjs/charts/line/useCurrentY.js +17 -17
- package/lib/commonjs/charts/line/useDatetime.js +28 -32
- package/lib/commonjs/charts/line/useLineChart.js +15 -20
- package/lib/commonjs/charts/line/usePrice.js +26 -28
- package/lib/commonjs/charts/line/utils/getArea.js +14 -47
- package/lib/commonjs/charts/line/utils/getDomain.js +8 -5
- package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getPath.js +14 -53
- package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +5 -8
- package/lib/commonjs/charts/line/utils/index.js +19 -19
- package/lib/commonjs/charts/line/utils/interpolatePath.js +60 -100
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +5 -5
- package/lib/commonjs/components/AnimatedText.js +29 -67
- package/lib/commonjs/index.js +19 -19
- package/lib/commonjs/types.js +2 -2
- package/lib/commonjs/utils/formatDatetime.js +9 -5
- package/lib/commonjs/utils/formatPrice.js +6 -10
- package/lib/commonjs/utils/index.js +13 -13
- package/lib/commonjs/utils/usePrevious.js +6 -8
- package/lib/module/charts/candle/Candle.js +76 -126
- package/lib/module/charts/candle/Candles.js +30 -52
- package/lib/module/charts/candle/Chart.js +19 -22
- package/lib/module/charts/candle/Context.js +29 -47
- package/lib/module/charts/candle/Crosshair.js +69 -142
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +51 -101
- package/lib/module/charts/candle/DatetimeText.js +5 -5
- package/lib/module/charts/candle/Line.js +19 -37
- package/lib/module/charts/candle/PriceText.js +5 -5
- package/lib/module/charts/candle/index.js +2 -2
- package/lib/module/charts/candle/types.js +1 -1
- package/lib/module/charts/candle/useCandleData.js +7 -3
- package/lib/module/charts/candle/useCandlestickChart.js +1 -1
- package/lib/module/charts/candle/useDatetime.js +12 -10
- package/lib/module/charts/candle/usePrice.js +14 -12
- package/lib/module/charts/candle/utils/getDomain.js +6 -2
- package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/module/charts/candle/utils/getHeight.js +8 -9
- package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/module/charts/candle/utils/getPrice.js +8 -4
- package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/module/charts/candle/utils/getY.js +8 -4
- package/lib/module/charts/candle/utils/getY.js.map +1 -1
- package/lib/module/charts/candle/utils/index.js +1 -1
- package/lib/module/charts/line/Axis.js +113 -189
- package/lib/module/charts/line/Chart.js +40 -73
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/ChartPath.js +90 -238
- package/lib/module/charts/line/Context.js +29 -61
- package/lib/module/charts/line/Cursor.js +61 -82
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +47 -99
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +52 -107
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/Data.js +28 -41
- package/lib/module/charts/line/DatetimeText.js +5 -5
- package/lib/module/charts/line/Dot.js +39 -93
- package/lib/module/charts/line/Gradient.js +41 -79
- package/lib/module/charts/line/Group.js +14 -15
- package/lib/module/charts/line/Group.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +32 -61
- package/lib/module/charts/line/HorizontalLine.js +27 -49
- package/lib/module/charts/line/HoverTrap/index.js +2 -3
- package/lib/module/charts/line/HoverTrap/index.web.js +34 -34
- package/lib/module/charts/line/LineChartPathContext.js +3 -3
- package/lib/module/charts/line/Path.js +20 -33
- package/lib/module/charts/line/PriceText.js +25 -42
- package/lib/module/charts/line/Tooltip.js +89 -151
- package/lib/module/charts/line/Tooltip.js.map +1 -1
- package/lib/module/charts/line/index.js +2 -2
- package/lib/module/charts/line/types.js +1 -1
- package/lib/module/charts/line/useAnimatedPath.js +16 -22
- package/lib/module/charts/line/useCurrentY.js +9 -4
- package/lib/module/charts/line/useDatetime.js +22 -26
- package/lib/module/charts/line/useLineChart.js +7 -10
- package/lib/module/charts/line/usePrice.js +20 -22
- package/lib/module/charts/line/utils/getArea.js +8 -15
- package/lib/module/charts/line/utils/getDomain.js +5 -2
- package/lib/module/charts/line/utils/getDomain.js.map +1 -1
- package/lib/module/charts/line/utils/getPath.js +8 -21
- package/lib/module/charts/line/utils/getXPositionForCurve.js +2 -5
- package/lib/module/charts/line/utils/index.js +1 -1
- package/lib/module/charts/line/utils/interpolatePath.js +57 -97
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js +2 -2
- package/lib/module/components/AnimatedText.js +21 -25
- package/lib/module/index.js +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/utils/formatDatetime.js +6 -2
- package/lib/module/utils/formatPrice.js +3 -7
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/usePrevious.js +1 -1
- package/lib/typescript/src/charts/candle/Candle.d.ts +31 -45
- package/lib/typescript/src/charts/candle/Candles.d.ts +13 -24
- package/lib/typescript/src/charts/candle/Chart.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Context.d.ts +7 -12
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +9 -17
- package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +8 -15
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +9 -15
- package/lib/typescript/src/charts/candle/Line.d.ts +5 -10
- package/lib/typescript/src/charts/candle/PriceText.d.ts +7 -13
- package/lib/typescript/src/charts/candle/index.d.ts +13 -32
- package/lib/typescript/src/charts/candle/types.d.ts +16 -16
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +9 -13
- package/lib/typescript/src/charts/candle/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/getY.d.ts +5 -9
- package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/Axis.d.ts +14 -27
- package/lib/typescript/src/charts/line/Chart.d.ts +23 -33
- package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/ChartPath.d.ts +15 -28
- package/lib/typescript/src/charts/line/Context.d.ts +9 -16
- package/lib/typescript/src/charts/line/Cursor.d.ts +14 -22
- package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +11 -23
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/CursorLine.d.ts +9 -15
- package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Data.d.ts +13 -17
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +8 -14
- package/lib/typescript/src/charts/line/Dot.d.ts +25 -38
- package/lib/typescript/src/charts/line/Gradient.d.ts +5 -9
- package/lib/typescript/src/charts/line/Group.d.ts +3 -6
- package/lib/typescript/src/charts/line/Group.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/Highlight.d.ts +9 -17
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts +22 -30
- package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +1 -1
- package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +4 -4
- package/lib/typescript/src/charts/line/Path.d.ts +23 -28
- package/lib/typescript/src/charts/line/PriceText.d.ts +20 -28
- package/lib/typescript/src/charts/line/Tooltip.d.ts +20 -32
- package/lib/typescript/src/charts/line/index.d.ts +20 -33
- package/lib/typescript/src/charts/line/types.d.ts +17 -19
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +7 -10
- package/lib/typescript/src/charts/line/useCurrentY.d.ts +2 -2
- package/lib/typescript/src/charts/line/useDatetime.d.ts +7 -11
- package/lib/typescript/src/charts/line/useLineChart.d.ts +10 -10
- package/lib/typescript/src/charts/line/usePrice.d.ts +7 -11
- package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -17
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -1
- package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -21
- package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/index.d.ts +1 -1
- package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +5 -17
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -4
- package/lib/typescript/src/components/AnimatedText.d.ts +4 -7
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/types.d.ts +4 -7
- package/lib/typescript/src/utils/formatDatetime.d.ts +5 -9
- package/lib/typescript/src/utils/formatPrice.d.ts +5 -9
- package/lib/typescript/src/utils/index.d.ts +1 -1
- package/lib/typescript/src/utils/usePrevious.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# react-native-wagmi-charts 💸
|
|
2
2
|
|
|
3
|
-
A sweet & simple chart library for React Native that will make us feel like
|
|
3
|
+
A sweet & simple chart library for React Native that will make us feel like
|
|
4
|
+
**W**e're **A**ll **G**onna **M**ake **I**t
|
|
4
5
|
|
|
5
6
|
<div style="display: flex; align-items: center; justify-content: center; width: 100%;">
|
|
6
7
|
<img src="https://user-images.githubusercontent.com/7336481/133024970-07321941-4f26-44d2-867f-dac19d110941.gif" width="300px" />
|
|
@@ -86,29 +87,37 @@ A sweet & simple chart library for React Native that will make us feel like **W*
|
|
|
86
87
|
|
|
87
88
|
## Install
|
|
88
89
|
|
|
89
|
-
To get started with using WAGMI charts in your React Native project, install the
|
|
90
|
+
To get started with using WAGMI charts in your React Native project, install the
|
|
91
|
+
`react-native-wagmi-charts` package.
|
|
90
92
|
|
|
91
|
-
```
|
|
93
|
+
```bash
|
|
92
94
|
npm install react-native-wagmi-charts
|
|
93
95
|
```
|
|
94
96
|
|
|
95
|
-
WAGMI charts also depends on a few libraries, you will also need to install
|
|
97
|
+
WAGMI charts also depends on a few libraries, you will also need to install
|
|
98
|
+
these packages if you don't already have them:
|
|
96
99
|
|
|
97
|
-
```
|
|
100
|
+
```bash
|
|
98
101
|
npm install react-native-reanimated react-native-gesture-handler react-native-haptic-feedback
|
|
99
102
|
```
|
|
100
103
|
|
|
101
104
|
## Basic Usage
|
|
102
105
|
|
|
103
|
-
The library currently comes with 2 types of charts: Line & Candlestick. Below
|
|
106
|
+
The library currently comes with 2 types of charts: Line & Candlestick. Below
|
|
107
|
+
are the most basic usages of them.
|
|
104
108
|
|
|
105
109
|
### Line chart
|
|
106
110
|
|
|
107
|
-
To render a simple line chart, you will need to use the `LineChart.Provider`,
|
|
111
|
+
To render a simple line chart, you will need to use the `LineChart.Provider`,
|
|
112
|
+
`LineChart` & `LineChart.Path` components.
|
|
108
113
|
|
|
109
|
-
The `LineChart.Provider` component sets up the context of your chart,
|
|
114
|
+
The `LineChart.Provider` component sets up the context of your chart,
|
|
115
|
+
`LineChart` composes the chart elements, and the `LineChart.Path` component
|
|
116
|
+
renders your data in the form of a line path.
|
|
110
117
|
|
|
111
|
-
> Note: This chart does not include an interactive cursor like in the animated
|
|
118
|
+
> Note: This chart does not include an interactive cursor like in the animated
|
|
119
|
+
> example above. If you want one,
|
|
120
|
+
> [check out the "Interactive Cursors" guide](#interactive-cursors)
|
|
112
121
|
|
|
113
122
|
```jsx
|
|
114
123
|
import { LineChart } from 'react-native-wagmi-charts';
|
|
@@ -145,11 +154,17 @@ function Example() {
|
|
|
145
154
|
|
|
146
155
|
### Candlestick chart
|
|
147
156
|
|
|
148
|
-
To render a simple candlestick chart, you will need to use the
|
|
157
|
+
To render a simple candlestick chart, you will need to use the
|
|
158
|
+
`CandlestickChart` & `CandlestickChart.Candles` components.
|
|
149
159
|
|
|
150
|
-
The `CandlestickChart.Provider` component sets up the context of your chart,
|
|
160
|
+
The `CandlestickChart.Provider` component sets up the context of your chart,
|
|
161
|
+
`CandlestickChart` composes the chart elements, and the
|
|
162
|
+
`CandlestickChart.Candles` component renders your data in the form of a line
|
|
163
|
+
path.
|
|
151
164
|
|
|
152
|
-
> Note: This chart does not include an interactive cursor like in the animated
|
|
165
|
+
> Note: This chart does not include an interactive cursor like in the animated
|
|
166
|
+
> example above. If you want one,
|
|
167
|
+
> [check out the "Interactive Cursors" guide](#interactive-cursors)
|
|
153
168
|
|
|
154
169
|
```jsx
|
|
155
170
|
import { CandlestickChart } from 'react-native-wagmi-charts';
|
|
@@ -198,11 +213,13 @@ function Example() {
|
|
|
198
213
|
|
|
199
214
|
## Line Chart Guides
|
|
200
215
|
|
|
201
|
-
Below are some line chart guides to help you make your charts suit your brand.
|
|
216
|
+
Below are some line chart guides to help you make your charts suit your brand.
|
|
217
|
+
Hopefully a combination of the below will enable you to make a great chart! :-)
|
|
202
218
|
|
|
203
219
|
### Interactive cursors
|
|
204
220
|
|
|
205
|
-
To render an interactive cursor on your line chart, you can include either the
|
|
221
|
+
To render an interactive cursor on your line chart, you can include either the
|
|
222
|
+
`LineChart.CursorCrosshair` or `LineChart.CursorLine` components:
|
|
206
223
|
|
|
207
224
|
##### `LineChart.CursorCrosshair`
|
|
208
225
|
|
|
@@ -232,7 +249,8 @@ To render an interactive cursor on your line chart, you can include either the `
|
|
|
232
249
|
|
|
233
250
|
### Interactive labels
|
|
234
251
|
|
|
235
|
-
To render an interactive label on your line chart as your cursor moves along
|
|
252
|
+
To render an interactive label on your line chart as your cursor moves along
|
|
253
|
+
the graph, you can use the `PriceText` or `DatetimeText` components:
|
|
236
254
|
|
|
237
255
|
> Note: These components **must** be within the `LineChart.Provider` component.
|
|
238
256
|
|
|
@@ -251,7 +269,8 @@ To render an interactive label on your line chart as your cursor moves along the
|
|
|
251
269
|
|
|
252
270
|
### Interactive tooltips
|
|
253
271
|
|
|
254
|
-
To render an interactive tooltip that follows your cursor, you can use the
|
|
272
|
+
To render an interactive tooltip that follows your cursor, you can use the
|
|
273
|
+
`Tooltip` component.
|
|
255
274
|
|
|
256
275
|
```jsx
|
|
257
276
|
<LineChart.Provider data={data}>
|
|
@@ -286,8 +305,10 @@ You can even add another tooltip to show something like date/time:
|
|
|
286
305
|
|
|
287
306
|
### Tooltips / Labels
|
|
288
307
|
|
|
289
|
-
You can also use the `Tooltip` component to render a "static" tooltip at a
|
|
290
|
-
|
|
308
|
+
You can also use the `Tooltip` component to render a "static" tooltip at a
|
|
309
|
+
given index, by specifying the `at` prop (similar to [Dots](#dots)). Note that
|
|
310
|
+
the tooltip will disappear when there is interaction with a cursor on the
|
|
311
|
+
chart.
|
|
291
312
|
|
|
292
313
|
```jsx
|
|
293
314
|
<LineChart.Provider data={data}>
|
|
@@ -303,7 +324,8 @@ Note that the tooltip will disappear when there is interaction with a cursor on
|
|
|
303
324
|
|
|
304
325
|
### Haptic feedback
|
|
305
326
|
|
|
306
|
-
By making use of the chart event handlers, you are able to integrate haptic
|
|
327
|
+
By making use of the chart event handlers, you are able to integrate haptic
|
|
328
|
+
feedback into your charts.
|
|
307
329
|
|
|
308
330
|
We can utilise the `onActivated` and `onEnded` events to create haptic feedback
|
|
309
331
|
on our line chart. This will cause a vibration on touch down/up.
|
|
@@ -358,7 +380,8 @@ function Example() {
|
|
|
358
380
|
}
|
|
359
381
|
```
|
|
360
382
|
|
|
361
|
-
If you want to synchronize two graphs, or even initialize a new graph with a
|
|
383
|
+
If you want to synchronize two graphs, or even initialize a new graph with a
|
|
384
|
+
cursor position, you can use the `at` prop:
|
|
362
385
|
|
|
363
386
|
```tsx
|
|
364
387
|
<LineChart.Provider data={data}>
|
|
@@ -371,11 +394,14 @@ If you want to synchronize two graphs, or even initialize a new graph with a cur
|
|
|
371
394
|
|
|
372
395
|
### Colors
|
|
373
396
|
|
|
374
|
-
By default, the charts come with default colors out-of-the-box... But you
|
|
397
|
+
By default, the charts come with default colors out-of-the-box... But you
|
|
398
|
+
probably will want to change these to suit your brand.
|
|
375
399
|
|
|
376
400
|
#### Coloring the path
|
|
377
401
|
|
|
378
|
-
To customise the color of the line chart path, supply a `color` prop to
|
|
402
|
+
To customise the color of the line chart path, supply a `color` prop to
|
|
403
|
+
`LineChart.Path`. This can be any valid React Native `StyleSheet` compatible
|
|
404
|
+
color.
|
|
379
405
|
|
|
380
406
|
```jsx
|
|
381
407
|
<LineChart.Provider data={data}>
|
|
@@ -389,7 +415,9 @@ To customise the color of the line chart path, supply a `color` prop to `LineCha
|
|
|
389
415
|
|
|
390
416
|
#### Coloring the cursor
|
|
391
417
|
|
|
392
|
-
To customise the color of the line chart cursor, supply a `color` prop to
|
|
418
|
+
To customise the color of the line chart cursor, supply a `color` prop to
|
|
419
|
+
`LineChart.CursorCrosshair`. This can be any valid React Native `StyleSheet`
|
|
420
|
+
compatible color.
|
|
393
421
|
|
|
394
422
|
> Note: This also works for `LineChart.CursorLine`
|
|
395
423
|
|
|
@@ -408,9 +436,9 @@ To customise the color of the line chart cursor, supply a `color` prop to `LineC
|
|
|
408
436
|
|
|
409
437
|
By default, the cursor is triggered whenever you press the chart.
|
|
410
438
|
|
|
411
|
-
If your app runs on Web, you may want to trigger the cursor when a user hovers,
|
|
412
|
-
|
|
413
|
-
|
|
439
|
+
If your app runs on Web, you may want to trigger the cursor when a user hovers,
|
|
440
|
+
too. To achieve this, simply add `<LineChart.HoverTrap />` as the child of your
|
|
441
|
+
cursor.
|
|
414
442
|
|
|
415
443
|
```jsx
|
|
416
444
|
<LineChart.Provider data={data}>
|
|
@@ -425,7 +453,8 @@ To achieve this, simply add `<LineChart.HoverTrap />` as the child of your curso
|
|
|
425
453
|
|
|
426
454
|
### Gradients
|
|
427
455
|
|
|
428
|
-
By using the `LineChart.Gradient` component, you can apply a gradient to the
|
|
456
|
+
By using the `LineChart.Gradient` component, you can apply a gradient to the
|
|
457
|
+
area underneath your path.
|
|
429
458
|
|
|
430
459
|
```jsx
|
|
431
460
|
<LineChart.Provider data={data}>
|
|
@@ -439,7 +468,8 @@ By using the `LineChart.Gradient` component, you can apply a gradient to the are
|
|
|
439
468
|
|
|
440
469
|
<img width="346" alt="Screen Shot 2021-10-25 at 8 32 07 pm" src="https://user-images.githubusercontent.com/7336481/138672128-c691036e-404f-4148-8a3b-00ea2f7df27f.png">
|
|
441
470
|
|
|
442
|
-
The gradient will inherit your path's color by default, however, you can
|
|
471
|
+
The gradient will inherit your path's color by default, however, you can
|
|
472
|
+
provide a color prop to `LineChart.Gradient`.
|
|
443
473
|
|
|
444
474
|
```jsx
|
|
445
475
|
<LineChart.Provider data={data}>
|
|
@@ -501,7 +531,9 @@ You can highlight a section of your path with `LineChart.Highlight`.
|
|
|
501
531
|
|
|
502
532
|
### Horizontal lines
|
|
503
533
|
|
|
504
|
-
You can render a static horizontal line on your line chart which moves whenever
|
|
534
|
+
You can render a static horizontal line on your line chart which moves whenever
|
|
535
|
+
your data change. In this example, the y value of the line is equal to the y
|
|
536
|
+
value of the point at index `0`.
|
|
505
537
|
|
|
506
538
|
```jsx
|
|
507
539
|
<LineChart.Provider data={data}>
|
|
@@ -515,7 +547,8 @@ You can render a static horizontal line on your line chart which moves whenever
|
|
|
515
547
|
|
|
516
548
|
<img width="345" alt="Screen Shot 2021-11-23 at 11 51 45 am" src="https://user-images.githubusercontent.com/7336481/143009672-54dac2c7-7de1-4299-a96f-7cc380e82b46.png">
|
|
517
549
|
|
|
518
|
-
You can also
|
|
550
|
+
You can also directly specify the y value of the `HorizontalLine` with the
|
|
551
|
+
`value` attribute:
|
|
519
552
|
|
|
520
553
|
```jsx
|
|
521
554
|
<LineChart.Provider data={data}>
|
|
@@ -529,7 +562,9 @@ You can also pass a (y) value to `HorizontalLine` with the `value` attribute:
|
|
|
529
562
|
|
|
530
563
|
### Customizing size
|
|
531
564
|
|
|
532
|
-
You can modify the width & height of the charts by providing `width` and
|
|
565
|
+
You can modify the width & height of the charts by providing `width` and
|
|
566
|
+
`height` props to `LineChart` or `CandlestickChart`. Your chart should adapt
|
|
567
|
+
to it's size.
|
|
533
568
|
|
|
534
569
|
```jsx
|
|
535
570
|
<LineChart.Provider data={data}>
|
|
@@ -545,7 +580,9 @@ You can modify the width & height of the charts by providing `width` and `height
|
|
|
545
580
|
|
|
546
581
|
##### Precision
|
|
547
582
|
|
|
548
|
-
By default, the price labels have a precision of `2`, meaning that the prices
|
|
583
|
+
By default, the price labels have a precision of `2`, meaning that the prices
|
|
584
|
+
will always be to 2 decimal places. However, you can customize this with the
|
|
585
|
+
`precision` prop:
|
|
549
586
|
|
|
550
587
|
```jsx
|
|
551
588
|
<LineChart.PriceText precision={4} />
|
|
@@ -553,9 +590,13 @@ By default, the price labels have a precision of `2`, meaning that the prices wi
|
|
|
553
590
|
|
|
554
591
|
##### Custom formatting
|
|
555
592
|
|
|
556
|
-
To customize the formatting of the price text, you can supply a `format`
|
|
593
|
+
To customize the formatting of the price text, you can supply a `format`
|
|
594
|
+
function in the form of a
|
|
595
|
+
[reanimated worklet](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets):
|
|
557
596
|
|
|
558
|
-
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
597
|
+
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
598
|
+
> that run on the React Native JS thread.
|
|
599
|
+
> [Read more here](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets)
|
|
559
600
|
|
|
560
601
|
```jsx
|
|
561
602
|
<LineChart.PriceText
|
|
@@ -571,7 +612,9 @@ To customize the formatting of the price text, you can supply a `format` functio
|
|
|
571
612
|
|
|
572
613
|
##### Date/time options
|
|
573
614
|
|
|
574
|
-
Internally, WAGMI charts uses
|
|
615
|
+
Internally, WAGMI charts uses
|
|
616
|
+
[`Date.prototype.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
|
|
617
|
+
to generate the date/time label. You can customise it's options like so:
|
|
575
618
|
|
|
576
619
|
```jsx
|
|
577
620
|
<LineChart.DatetimeText
|
|
@@ -589,9 +632,13 @@ Internally, WAGMI charts uses [`Date.prototype.toLocaleString()`](https://develo
|
|
|
589
632
|
|
|
590
633
|
##### Custom formatting
|
|
591
634
|
|
|
592
|
-
To customize the formatting of the date/time text, you can supply a `format`
|
|
635
|
+
To customize the formatting of the date/time text, you can supply a `format`
|
|
636
|
+
function in the form of a
|
|
637
|
+
[reanimated worklet](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets):
|
|
593
638
|
|
|
594
|
-
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
639
|
+
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
640
|
+
> that run on the React Native JS thread.
|
|
641
|
+
> [Read more here](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets)
|
|
595
642
|
|
|
596
643
|
```jsx
|
|
597
644
|
<LineChart.DatetimeText
|
|
@@ -625,11 +672,13 @@ You can customize the style of the tooltip by providing the `textStyle` prop:
|
|
|
625
672
|
|
|
626
673
|
#### Gutter
|
|
627
674
|
|
|
628
|
-
You can customize the gutters of the tooltip by providing `cursorGutter`,
|
|
675
|
+
You can customize the gutters of the tooltip by providing `cursorGutter`,
|
|
676
|
+
`xGutter` or `yGutter`.
|
|
629
677
|
|
|
630
678
|
`cursorGutter` is the gutter between the cursor and the tooltip.
|
|
631
679
|
|
|
632
|
-
`xGutter` and `yGutter` is the gutter on the x & y axis of the chart (the
|
|
680
|
+
`xGutter` and `yGutter` is the gutter on the x & y axis of the chart (the
|
|
681
|
+
tooltip can't pass the gutter).
|
|
633
682
|
|
|
634
683
|
```jsx
|
|
635
684
|
<LineChart.Tooltip cursorGutter={60} xGutter={16} yGutter={16} />
|
|
@@ -654,7 +703,8 @@ You can render an axis on your line chart with `LineChart.Axis`.
|
|
|
654
703
|
|
|
655
704
|
### Interactive cursors
|
|
656
705
|
|
|
657
|
-
To render an interactive cursor on your candlestick chart, you can include the
|
|
706
|
+
To render an interactive cursor on your candlestick chart, you can include the
|
|
707
|
+
`CandlestickChart.Crosshair` component:
|
|
658
708
|
|
|
659
709
|
```jsx
|
|
660
710
|
<CandlestickChart.Provider data={data}>
|
|
@@ -669,9 +719,11 @@ To render an interactive cursor on your candlestick chart, you can include the `
|
|
|
669
719
|
|
|
670
720
|
### Interactive labels
|
|
671
721
|
|
|
672
|
-
To render an interactive label on your candlestick chart, you can use the
|
|
722
|
+
To render an interactive label on your candlestick chart, you can use the
|
|
723
|
+
`PriceText` or `DatetimeText` components:
|
|
673
724
|
|
|
674
|
-
> Note: These components **must** be within the `CandlestickChart.Provider`
|
|
725
|
+
> Note: These components **must** be within the `CandlestickChart.Provider`
|
|
726
|
+
> component.
|
|
675
727
|
|
|
676
728
|
```jsx
|
|
677
729
|
<CandlestickChart.Provider data={data}>
|
|
@@ -691,7 +743,8 @@ To render an interactive label on your candlestick chart, you can use the `Price
|
|
|
691
743
|
|
|
692
744
|
### Interactive tooltips
|
|
693
745
|
|
|
694
|
-
To render an interactive tooltip that follows your crosshair, you can use the
|
|
746
|
+
To render an interactive tooltip that follows your crosshair, you can use the
|
|
747
|
+
`Tooltip` component.
|
|
695
748
|
|
|
696
749
|
```jsx
|
|
697
750
|
<CandlestickChart.Provider data={data}>
|
|
@@ -708,9 +761,11 @@ To render an interactive tooltip that follows your crosshair, you can use the `T
|
|
|
708
761
|
|
|
709
762
|
### Haptic feedback
|
|
710
763
|
|
|
711
|
-
By making use of the chart event handlers, you are able to integrate haptic
|
|
764
|
+
By making use of the chart event handlers, you are able to integrate haptic
|
|
765
|
+
feedback into your charts.
|
|
712
766
|
|
|
713
|
-
We can utilise the `onCurrentXChange` event to create haptic feedback on our
|
|
767
|
+
We can utilise the `onCurrentXChange` event to create haptic feedback on our
|
|
768
|
+
candlestick chart.
|
|
714
769
|
|
|
715
770
|
```jsx
|
|
716
771
|
import * as haptics from 'expo-haptics';
|
|
@@ -737,11 +792,14 @@ function Example() {
|
|
|
737
792
|
|
|
738
793
|
### Colors
|
|
739
794
|
|
|
740
|
-
By default, the charts come with default colors out-of-the-box... But you
|
|
795
|
+
By default, the charts come with default colors out-of-the-box... But you
|
|
796
|
+
probably will want to change these to suit your brand.
|
|
741
797
|
|
|
742
798
|
#### Coloring the candles
|
|
743
799
|
|
|
744
|
-
To customise the color of the candlestick chart candles, supply a
|
|
800
|
+
To customise the color of the candlestick chart candles, supply a
|
|
801
|
+
`negativeColor` and a `positiveColor` to `CandlestickChart.Candles`. This can
|
|
802
|
+
be any valid React Native `StyleSheet` compatible color.
|
|
745
803
|
|
|
746
804
|
```jsx
|
|
747
805
|
<CandlestickChart.Provider data={data}>
|
|
@@ -755,7 +813,9 @@ To customise the color of the candlestick chart candles, supply a `negativeColor
|
|
|
755
813
|
|
|
756
814
|
#### Coloring the crosshair
|
|
757
815
|
|
|
758
|
-
To customise the color of the line chart cursor, supply a `color` prop to
|
|
816
|
+
To customise the color of the line chart cursor, supply a `color` prop to
|
|
817
|
+
`CandlestickChart.Crosshair`. This can be any valid React Native `StyleSheet`
|
|
818
|
+
compatible color.
|
|
759
819
|
|
|
760
820
|
```jsx
|
|
761
821
|
<CandlestickChart.Provider data={data}>
|
|
@@ -774,7 +834,9 @@ To customise the color of the line chart cursor, supply a `color` prop to `Candl
|
|
|
774
834
|
|
|
775
835
|
##### Precision
|
|
776
836
|
|
|
777
|
-
By default, the price labels have a precision of `2`, meaning that the prices
|
|
837
|
+
By default, the price labels have a precision of `2`, meaning that the prices
|
|
838
|
+
will always be to 2 decimal places. However, you can customize this with the
|
|
839
|
+
`precision` prop:
|
|
778
840
|
|
|
779
841
|
```jsx
|
|
780
842
|
<CandlestickChart.PriceText precision={4} />
|
|
@@ -782,9 +844,13 @@ By default, the price labels have a precision of `2`, meaning that the prices wi
|
|
|
782
844
|
|
|
783
845
|
##### Custom formatting
|
|
784
846
|
|
|
785
|
-
To customize the formatting of the price text, you can supply a `format`
|
|
847
|
+
To customize the formatting of the price text, you can supply a `format`
|
|
848
|
+
function in the form of a
|
|
849
|
+
[reanimated worklet](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets):
|
|
786
850
|
|
|
787
|
-
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
851
|
+
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
852
|
+
> that run on the React Native JS thread.
|
|
853
|
+
> [Read more here](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets)
|
|
788
854
|
|
|
789
855
|
```jsx
|
|
790
856
|
<CandlestickChart.PriceText
|
|
@@ -800,7 +866,9 @@ To customize the formatting of the price text, you can supply a `format` functio
|
|
|
800
866
|
|
|
801
867
|
##### Date/time options
|
|
802
868
|
|
|
803
|
-
Internally, WAGMI charts uses
|
|
869
|
+
Internally, WAGMI charts uses
|
|
870
|
+
[`Date.prototype.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString)
|
|
871
|
+
to generate the date/time label. You can customise it's options like so:
|
|
804
872
|
|
|
805
873
|
```jsx
|
|
806
874
|
<CandlestickChart.DatetimeText
|
|
@@ -818,9 +886,13 @@ Internally, WAGMI charts uses [`Date.prototype.toLocaleString()`](https://develo
|
|
|
818
886
|
|
|
819
887
|
##### Custom formatting
|
|
820
888
|
|
|
821
|
-
To customize the formatting of the date/time text, you can supply a `format`
|
|
889
|
+
To customize the formatting of the date/time text, you can supply a `format`
|
|
890
|
+
function in the form of a
|
|
891
|
+
[reanimated worklet](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets):
|
|
822
892
|
|
|
823
|
-
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
893
|
+
> Note: due to the nature of reanimated worklets, you cannot define functions
|
|
894
|
+
> that run on the React Native JS thread.
|
|
895
|
+
> [Read more here](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets)
|
|
824
896
|
|
|
825
897
|
```jsx
|
|
826
898
|
<CandlestickChart.DatetimeText
|
|
@@ -871,18 +943,18 @@ To customize the formatting of the date/time text, you can supply a `format` fun
|
|
|
871
943
|
| `crosshairProps` | `ViewProps` | | Props of the crosshair dot |
|
|
872
944
|
| `crosshairOuterProps` | `ViewProps` | | Props of the crosshair outer dot |
|
|
873
945
|
| `snapToPoint` | `boolean` | `false` | **REACT NATIVE ONLY** Snap cursor to X position of nearest data point |
|
|
874
|
-
| `persistOnEnd`
|
|
946
|
+
| `persistOnEnd` | `boolean` | `false` | Keep the cursor pinned at its last position after the gesture ends |
|
|
875
947
|
| `at` | `number` | | Index of followed `data` item. |
|
|
876
948
|
| `...props` | `LongPressGestureHandlerProps` | | |
|
|
877
949
|
|
|
878
950
|
### LineChart.CursorLine
|
|
879
951
|
|
|
880
|
-
| Prop
|
|
881
|
-
|
|
|
882
|
-
| `color`
|
|
883
|
-
| `lineProps`
|
|
952
|
+
| Prop | Type | Default | Description |
|
|
953
|
+
| -------------- | ----------- | -------- | ------------------------------------------------------------------ |
|
|
954
|
+
| `color` | `string` | `"gray"` | Color of the cursor line |
|
|
955
|
+
| `lineProps` | `LineProps` | | Props of the cursor line. Takes React Native SVG's `Line` props. |
|
|
884
956
|
| `persistOnEnd` | `boolean` | `false` | Keep the cursor pinned at its last position after the gesture ends |
|
|
885
|
-
| `at`
|
|
957
|
+
| `at` | `number` | | Index of followed `data` item. |
|
|
886
958
|
|
|
887
959
|
### LineChart.Dot
|
|
888
960
|
|
|
@@ -960,9 +1032,9 @@ To customize the formatting of the date/time text, you can supply a `format` fun
|
|
|
960
1032
|
|
|
961
1033
|
### LineChart.HoverTrap
|
|
962
1034
|
|
|
963
|
-
This component doesn't take any props.
|
|
964
|
-
|
|
965
|
-
|
|
1035
|
+
This component doesn't take any props. Place it as the child of your cursor
|
|
1036
|
+
component to trap hover events on Web. If you're using mutliple cursors, place
|
|
1037
|
+
this as the child of your lowest-rendered cursor.
|
|
966
1038
|
|
|
967
1039
|
```tsx
|
|
968
1040
|
<LineChart.HoverTrap />
|
|
@@ -1046,7 +1118,8 @@ Place it as the child of your cursor component to trap hover events on Web. If y
|
|
|
1046
1118
|
|
|
1047
1119
|
## Hooks
|
|
1048
1120
|
|
|
1049
|
-
The following hooks are only accessible inside the `LineChart.Provider` or
|
|
1121
|
+
The following hooks are only accessible inside the `LineChart.Provider` or
|
|
1122
|
+
`CandlestickChart.Provider`.
|
|
1050
1123
|
|
|
1051
1124
|
### LineChart.useChart
|
|
1052
1125
|
|
|
@@ -1213,7 +1286,8 @@ const { value, formatted } = CandlestickChart.usePrice({
|
|
|
1213
1286
|
|
|
1214
1287
|
Web support is currently experimental.
|
|
1215
1288
|
|
|
1216
|
-
Currently, transitions for a line chart's path flicker a little. You can
|
|
1289
|
+
Currently, transitions for a line chart's path flicker a little. You can
|
|
1290
|
+
disable them on Web with the `isTransitionEnabled` prop.
|
|
1217
1291
|
|
|
1218
1292
|
### Disable Transitions
|
|
1219
1293
|
|
|
@@ -1231,7 +1305,9 @@ const isWeb = Platform.OS === 'web'
|
|
|
1231
1305
|
|
|
1232
1306
|
### Reanimated Version
|
|
1233
1307
|
|
|
1234
|
-
In order to support SVG animations on Web, you'll need at least Reanimated
|
|
1308
|
+
In order to support SVG animations on Web, you'll need at least Reanimated
|
|
1309
|
+
version `2.3.0-beta.2`. Or, you can use the patch from
|
|
1310
|
+
[Issue #8](https://github.com/coinjar/react-native-wagmi-charts/issues/8#issuecomment-938097099).
|
|
1235
1311
|
|
|
1236
1312
|
## Credits
|
|
1237
1313
|
|