Hi everyone, this is a nice library to create a nice chart, but i wish to have a feature like the gif below:
https://media.giphy.com/media/hqllPKwVIxuetd3RBg/giphy.gif

Thanks. =)
+1
I am trying to figure out the same thing.
+1
I've done it by adding a view over the chart (or as a parent) and overriding the pan gestures with
this.panResponder = PanResponder.create({
onMoveShouldSetPanResponder: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
onPanResponderMove: this._onMove.bind(this),
onPanResponderRelease: this._pressDragRelease.bind(this),
});
<View {...this.panResponder.panHandlers}>
...
</View>
You have to calculate where are you in your data based on xPos, chartWidth, numberOfDataPoints. Then you know which value to show at the top. I am also adding an indicator on the chart while dragging the line.
@ssuchanowski Do you have an example of your final code?
You have to calculate where are you in your data based on
xPos,chartWidth,numberOfDataPoints. Then you know which value to show at the top. I am also adding an indicator on the chart while dragging the line.
@ssuchanowski This approach only seems accurate for evenly spaced data points. Can you please confirm?
It would be great if we could get the coordinates of all data points using a ref or similar to the chart.
yes but I have it working for not evenly spaced data points as well - only condition is that chart has to show values in linear scale (in other scales would work too but it would need to take it into account). I am calculating my position and basing on left and right value I decide which one to highlight.
Let see some example:
This is vary simple approach and probably could be better but it does the job. We need to take into account starting point - if it is always 0 or it is the first value but you can figure it out from this point.
@ssuchanowski Thanks for taking the time to reply. Your solution works great!
Great @ssuchanowski working snippet example of this proposal? Thanks !!!
Most helpful comment
yes but I have it working for not evenly spaced data points as well - only condition is that chart has to show values in linear scale (in other scales would work too but it would need to take it into account). I am calculating my position and basing on left and right value I decide which one to highlight.
Let see some example:
(12-1)0.5 = 5.5
we have 1 and 10
This is vary simple approach and probably could be better but it does the job. We need to take into account starting point - if it is always 0 or it is the first value but you can figure it out from this point.