2
votes

Am trying to use the ios-charts library based off the MPAndroidCharts; however am having some trouble getting a scrollable graph to work.

By scrollable I mean that I try to show only a portion of the data of the line and that you can scroll horizontally to see more results. E.g I have 30 results and I only show 10 at a time and then scroll horizontally to see more.

Have come up with an approximation by using the method

[self.containerView setVisibleXRangeWithMinXRange:24.0f maxXRange:24.0f];

However this seems to make the scrolling kind of jittery as it keeps on redrawing.

Am looking for an ios-charts example and clarification on methods to see whether I am on the right track or not.

1

1 Answers

7
votes

Similar to your question:

https://github.com/danielgindi/ios-charts/issues/267

Quote:

I was able to achieve this after playing with it a bit. It is actually pretty straight forward.

chart.data = data; // This is the MAIN reason, data for the chart has to be set first before the next 2 steps otherwise they will just get ignored like nothing has been set.

// set the max x data point to 10, which is what i wanted showing only 10 data points for the line or bar chart, from 100 data points. [chart setVisibleXRangeMaximum:10]; // move the chart view to 90 index of X, which is the last 10 entries I want to see. and it works as expected. [chart moveViewToX:90];

Other helpful ones:

https://github.com/danielgindi/ios-charts/issues/226

https://github.com/danielgindi/ios-charts/issues/258