Android - Chart scrolling


#1

Ok, so I have a graph with two NumberAxis axes. I have a center “cursor” line, which snaps to the center-most datapoint in the graph. This is fine, except when you get to the beginning, or end of the data.

The idea is that when you scroll the graph, the “cursor” rests on a data point (in which the data for that point is displayed in a separate View on screen). With how I have it setup now, you can’t keep the cursor over the beginning/ending datapoints, as the graph snaps back.

I tried setting the RangePadding, but that didn’t seem to have any effect. Just increasing the visible range isn’t a good enough solution either.


#2

I solved my issue with a creative mixture of slightly extending the range, and using allowPanningOutOfMaxRange. I won’t bother posting the code here, as it’s pretty specific to what I’m doing. However, it would be nice if this was something the library could handle.


#3

Hi ryanbis,

Did you try using our Annotations functionality at all? Could you, for example, place a vertical line annotation at your desired data point? There’s more info in our User Guide and API docs.

By default, the chart will snap back to the default range (which if not explicitly set will be the data range) but as you have found using the allowPanningOutOfMaxRange method will stop this happening. You could also experiment with setting a default range on the axis and using the allowPanningOutOfDefaultRange method too.

Kind regards,

Patrick