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.
Files changed (132) hide show
  1. package/.DS_Store +0 -0
  2. package/.prettierrc.js +5 -0
  3. package/README.md +171 -121
  4. package/example/.DS_Store +0 -0
  5. package/example/README.md +32 -0
  6. package/example/package.json +1 -1
  7. package/example/src/App.tsx +32 -7
  8. package/example/src/CandlestickChart.tsx +23 -11
  9. package/example/src/LineChart.tsx +51 -20
  10. package/example/src/{candlestick-data.json → data/candlestick-data.json} +0 -0
  11. package/example/src/{candlestick-data2.json → data/candlestick-data2.json} +0 -0
  12. package/example/src/{line-data.json → data/line-data.json} +0 -0
  13. package/example/src/{line-data2.json → data/line-data2.json} +0 -0
  14. package/example/yarn.lock +5 -5
  15. package/lib/commonjs/charts/candle/Crosshair.js +6 -17
  16. package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
  17. package/lib/commonjs/charts/candle/CrosshairTooltip.js +12 -8
  18. package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
  19. package/lib/commonjs/charts/candle/DatetimeText.js +7 -8
  20. package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
  21. package/lib/commonjs/charts/candle/Line.js.map +1 -1
  22. package/lib/commonjs/charts/candle/PriceText.js +7 -8
  23. package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
  24. package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
  25. package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
  26. package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
  27. package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
  28. package/lib/commonjs/charts/candle/utils.js.map +1 -1
  29. package/lib/commonjs/charts/line/Chart.js.map +1 -1
  30. package/lib/commonjs/charts/line/Cursor.js.map +1 -1
  31. package/lib/commonjs/charts/line/CursorCrosshair.js +4 -3
  32. package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
  33. package/lib/commonjs/charts/line/CursorLine.js +8 -1
  34. package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
  35. package/lib/commonjs/charts/line/DatetimeText.js +7 -8
  36. package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
  37. package/lib/commonjs/charts/line/Path.js +13 -16
  38. package/lib/commonjs/charts/line/Path.js.map +1 -1
  39. package/lib/commonjs/charts/line/PriceText.js +7 -8
  40. package/lib/commonjs/charts/line/PriceText.js.map +1 -1
  41. package/lib/commonjs/charts/line/interpolatePath.js +600 -0
  42. package/lib/commonjs/charts/line/interpolatePath.js.map +1 -0
  43. package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
  44. package/lib/commonjs/charts/line/usePrice.js.map +1 -1
  45. package/lib/commonjs/charts/line/utils.js +1 -70
  46. package/lib/commonjs/charts/line/utils.js.map +1 -1
  47. package/lib/commonjs/components/AnimatedText.js +63 -0
  48. package/lib/commonjs/components/AnimatedText.js.map +1 -0
  49. package/lib/commonjs/utils.js.map +1 -1
  50. package/lib/module/charts/candle/Crosshair.js +7 -16
  51. package/lib/module/charts/candle/Crosshair.js.map +1 -1
  52. package/lib/module/charts/candle/CrosshairTooltip.js +10 -8
  53. package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
  54. package/lib/module/charts/candle/DatetimeText.js +6 -7
  55. package/lib/module/charts/candle/DatetimeText.js.map +1 -1
  56. package/lib/module/charts/candle/Line.js.map +1 -1
  57. package/lib/module/charts/candle/PriceText.js +6 -7
  58. package/lib/module/charts/candle/PriceText.js.map +1 -1
  59. package/lib/module/charts/candle/useCandleData.js.map +1 -1
  60. package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
  61. package/lib/module/charts/candle/useDatetime.js.map +1 -1
  62. package/lib/module/charts/candle/usePrice.js.map +1 -1
  63. package/lib/module/charts/candle/utils.js.map +1 -1
  64. package/lib/module/charts/line/Chart.js.map +1 -1
  65. package/lib/module/charts/line/Cursor.js.map +1 -1
  66. package/lib/module/charts/line/CursorCrosshair.js +4 -3
  67. package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
  68. package/lib/module/charts/line/CursorLine.js +7 -1
  69. package/lib/module/charts/line/CursorLine.js.map +1 -1
  70. package/lib/module/charts/line/DatetimeText.js +6 -7
  71. package/lib/module/charts/line/DatetimeText.js.map +1 -1
  72. package/lib/module/charts/line/Path.js +11 -15
  73. package/lib/module/charts/line/Path.js.map +1 -1
  74. package/lib/module/charts/line/PriceText.js +6 -7
  75. package/lib/module/charts/line/PriceText.js.map +1 -1
  76. package/lib/module/charts/line/interpolatePath.js +587 -0
  77. package/lib/module/charts/line/interpolatePath.js.map +1 -0
  78. package/lib/module/charts/line/useDatetime.js.map +1 -1
  79. package/lib/module/charts/line/usePrice.js.map +1 -1
  80. package/lib/module/charts/line/utils.js +1 -66
  81. package/lib/module/charts/line/utils.js.map +1 -1
  82. package/lib/module/components/AnimatedText.js +43 -0
  83. package/lib/module/components/AnimatedText.js.map +1 -0
  84. package/lib/module/utils.js.map +1 -1
  85. package/lib/typescript/src/charts/candle/Crosshair.d.ts +4 -4
  86. package/lib/typescript/src/charts/candle/DatetimeText.d.ts +3 -2
  87. package/lib/typescript/src/charts/candle/Line.d.ts +1 -1
  88. package/lib/typescript/src/charts/candle/PriceText.d.ts +3 -3
  89. package/lib/typescript/src/charts/candle/types.d.ts +8 -3
  90. package/lib/typescript/src/charts/candle/useCandleData.d.ts +3 -3
  91. package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +2 -1
  92. package/lib/typescript/src/charts/candle/useDatetime.d.ts +5 -7
  93. package/lib/typescript/src/charts/candle/usePrice.d.ts +5 -8
  94. package/lib/typescript/src/charts/candle/utils.d.ts +1 -1
  95. package/lib/typescript/src/charts/line/Chart.d.ts +1 -1
  96. package/lib/typescript/src/charts/line/Cursor.d.ts +1 -2
  97. package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
  98. package/lib/typescript/src/charts/line/DatetimeText.d.ts +5 -6
  99. package/lib/typescript/src/charts/line/Path.d.ts +17 -1
  100. package/lib/typescript/src/charts/line/PriceText.d.ts +3 -2
  101. package/lib/typescript/src/charts/line/interpolatePath.d.ts +50 -0
  102. package/lib/typescript/src/charts/line/useDatetime.d.ts +4 -5
  103. package/lib/typescript/src/charts/line/usePrice.d.ts +3 -2
  104. package/lib/typescript/src/charts/line/utils.d.ts +0 -13
  105. package/lib/typescript/src/components/AnimatedText.d.ts +9 -0
  106. package/lib/typescript/src/utils.d.ts +2 -4
  107. package/package.json +4 -4
  108. package/src/charts/candle/Crosshair.tsx +20 -20
  109. package/src/charts/candle/CrosshairTooltip.tsx +11 -4
  110. package/src/charts/candle/DatetimeText.tsx +5 -4
  111. package/src/charts/candle/Line.tsx +1 -1
  112. package/src/charts/candle/PriceText.tsx +5 -5
  113. package/src/charts/candle/types.ts +11 -3
  114. package/src/charts/candle/useCandleData.ts +3 -2
  115. package/src/charts/candle/useCandlestickChart.ts +2 -1
  116. package/src/charts/candle/useDatetime.ts +7 -3
  117. package/src/charts/candle/usePrice.ts +10 -3
  118. package/src/charts/candle/utils.ts +1 -1
  119. package/src/charts/line/Chart.tsx +1 -1
  120. package/src/charts/line/Cursor.tsx +7 -3
  121. package/src/charts/line/CursorCrosshair.tsx +4 -3
  122. package/src/charts/line/CursorLine.tsx +9 -1
  123. package/src/charts/line/DatetimeText.tsx +8 -7
  124. package/src/charts/line/Path.tsx +25 -21
  125. package/src/charts/line/PriceText.tsx +5 -4
  126. package/src/charts/line/interpolatePath.ts +650 -0
  127. package/src/charts/line/useDatetime.ts +3 -2
  128. package/src/charts/line/usePrice.ts +2 -1
  129. package/src/charts/line/utils.ts +2 -79
  130. package/src/components/AnimatedText.tsx +53 -0
  131. package/src/utils.ts +3 -3
  132. package/yarn.lock +5 -5
package/.DS_Store CHANGED
Binary file
package/.prettierrc.js ADDED
@@ -0,0 +1,5 @@
1
+ const packageJson = require('./package.json');
2
+
3
+ const config = packageJson.eslintConfig.rules['prettier/prettier'][1];
4
+
5
+ module.exports = config;
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 | Type | Default | Description |
537
- | ---------- | ----------- | --------- | ------------------------------------------------------------- |
538
- | `color` | `string` | `"black"` | Color of the line path |
539
- | `width` | `number` | `3` | Width of the line path |
540
- | `...props` | `PathProps` | | This component also inherits React Native SVG's `Path` props. |
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 | Default | Description |
545
- | ----------------------- | ----------- | --------- | ----------------------------------------------- |
546
- | `color` | `string` | `"black"` | Color of the crosshair dot |
547
- | `size` | `number` | `8` | Size of the crosshair dot |
548
- | `outerSize` | `number` | `32` | Size of the outer crosshair dot (faded dot) |
549
- | `crosshairWrapperProps` | `ViewProps` | | Props of the wrapper component of the crosshair |
550
- | `crosshairProps` | `ViewProps` | | Props of the crosshair dot |
551
- | `crosshairOuterProps` | `ViewProps` | | Props of the crosshair outer dot |
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 | Default | Description |
563
- | -------------- | ------------------ | ------- | ---------------------------------------------------- |
564
- | `xGutter` | `number` | `8` | X axis gutter in which the tooltip will not pass. |
565
- | `yGutter` | `number` | `8` | Y axis gutter in which the tooltip will not pass. |
566
- | `cursorGutter` | `number` | `48` | Gutter (spacing) between the cursor and the tooltip. |
567
- | `position` | `"top" | "bottom"` | `"top"` | Position of the tooltip relative to the cursor. |
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 | Description |
572
- | ----------- | ---------------------------------- | ------------- | ------------------------------------------ |
573
- | `format` | `({ value, formatted }) => string` | | Custom format function of the price. |
574
- | `precision` | `number` | `2` | Default precision of the price. |
575
- | `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the price value. |
576
- | `...props` | `TextProps` | | Inherits React Native's `Text` props |
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 | Description |
581
- | --------- | ---------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
582
- | `format` | `({ value, formatted }) => string` | | Custom format function of the timestamp. |
583
- | `locale` | `string` | `"en-US"` | Locale of the timestamp. |
584
- | `options` | `{}` | | Options to pass to `toLocaleString()`. [Available options are here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) |
585
- | `style` | `{}` | | Style of the price text |
586
- | `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the timestamp value. |
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 | Type | Default | Description |
617
- | ------- | -------- | --------- | ---------------------- |
618
- | `color` | `string` | `"black"` | Color of the crosshair | |
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 | Description |
631
- | ----------- | ---------------------------------- | ------------- | ------------------------------------------ |
632
- | `format` | `({ value, formatted }) => string` | | Custom format function of the price. |
633
- | `precision` | `number` | `2` | Default precision of the price. |
634
- | `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the price value. |
635
- | `...props` | `TextProps` | | Inherits React Native's `Text` props |
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 | Description |
640
- | --------- | ---------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
641
- | `format` | `({ value, formatted }) => string` | | Custom format function of the timestamp. |
642
- | `locale` | `string` | `"en-US"` | Locale of the timestamp. |
643
- | `options` | `{}` | | Options to pass to `toLocaleString()`. [Available options are here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) |
644
- | `style` | `{}` | | Style of the price text |
645
- | `variant` | `"formatted" | "value"` | `"formatted"` | Default representation of the timestamp value. |
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
- currentX,
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
@@ -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"
@@ -1,6 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import 'react-native-gesture-handler';
3
- import { Box, Text, Provider as BumbagNativeProvider } from 'bumbag-native';
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
- <Box.Touchable onPress={() => setSelected('candlestick')}>
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
- </Box.Touchable>
19
- <Box.Touchable onPress={() => setSelected('line')}>
41
+ </Button>
42
+ <Button onPress={() => setSelected('line')}>
20
43
  <Text>Line</Text>
21
- </Box.Touchable>
44
+ </Button>
22
45
  </Box>
23
46
  )}
24
- {selected === 'candlestick' && <CandlestickChart />}
25
- {selected === 'line' && <LineChart />}
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>