Commit 2b6ab69
committed
feat: introduce deterministic pan
Before, panning was done by linearly interpolating the data points.
Now, we have a deterministic pan gesture that accurately computes
the data points that are being panned to.
Key Highlights:
- Introduced a deterministic pan gesture that accurately computes
the data points that are being panned to. Before, a simple linear
interpolation was used to determine the data points. However, this
was inaccurate and doesn't fit our use case.
- Modified the linearForX function to getClosestPointForX that finds
the closest data point to the given x value (gesture). This method
returns the (x, y) on the chart, and the index the input corresponds
to in the data array.
Next steps:
- Implement binary search to find the closest point to the given x
value instead of iteratively searching through the data array.
- Create a caching mechanism to store the last point that was panned to.
If it does not differ from the current point, we can skip propagating
the gesture event to the parent component. This allows things like
Haptics to be triggered only when the point changes.1 parent 4cbcb7d commit 2b6ab69
File tree
5 files changed
+803
-79
lines changed- example
- app
- src/store/prices
- src
- components/MultiLineChart
- utils
5 files changed
+803
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 15 | | |
19 | 16 | | |
| 17 | + | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| |||
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
50 | 60 | | |
51 | 61 | | |
52 | 62 | | |
53 | | - | |
54 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
55 | 71 | | |
56 | 72 | | |
57 | 73 | | |
| |||
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
63 | | - | |
64 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
65 | 87 | | |
66 | 88 | | |
67 | 89 | | |
| |||
0 commit comments