When data points are very close, the chart clusters points irregardless of zoom


Okay, created a sample project for this one. It create 3000 data points starting from a large number (not that it matters), and incremeting by 1 each time. The y values are randomly generated. Here’s what I expect to get when I draw this chart:

And here’s what I actually get:

The first image is when I use the same data except I increase the increment to 100 instead of 1. This data should display exactly the same at the default range. This is a pretty massive problem. Any workaround, or is this a known bug with a fix (soon) incoming? I’m absolutely loving the charts in general, but these little issues (see the last topic I created) are dealbreakers if they can’t be fixed. Any insight would be much appreciated.

Edit: I’ll email the sample project because I’m not sure if you want the trial binary being distributed on your forums.


Thanks for the sample project, let’s communicate on this thread to keep everything in one place.  :smile:


EDIT: I now understand that these are seperate issues.


Hi Jonathon,

Cheers for raising this issue with us - this is something we’ll be looking to address in future releases of charts.

It looks like we’re losing precision when we’re converting the x values of the data points into floats when we pass them to our OpenGL rendering code.  This seems to be due to the high starting value for the x values in the data.  You’ll be able to replicate the same issue at your end if you add the following log statement to your generateData method: 

double startValue = 1194890368;
int increment = 1; // change as needed
for (double i = startValue; i < totalNumberOfItems * increment + startValue; i += increment) {
    SChartDataPoint *point = [[SChartDataPoint alloc] init];
    point.yValue = randomNumber(50, 400);		
    point.xValue = @(i);
    NSLog(@"%f", [point.xValue floatValue]);
    [data addObject:point];

 Instead of seeing each increment, we’re seeing increments every 128 values.  This is causing the clustering of data points you’re seeing.

 This is something we’re going to look at going forward.  In the meantime, if you need a workaround for this issue, I would suggest the following:

  • SChartAxis has two private methods on its interface: 


An axis has an internal representation of its data values, and an external one which it presents to the world.  For numeric axes, these representations are currently the same, but it wouldn’t take too much work to make the internal values relative to a starting value.

If you subclass the SChartNumberAxis, and override these methods, you could implement this kind of strategy.  As the range of your data points isn’t that high, you should find that this would allow you to work around this loss of precision issue which we’re seeing.  In future releases of charts, we’ll probably be adding this kind of implementation to numeric axes by default.  :-)

I hope this helps, and I wish you well with your app development!



Thanks for the reply Dan. I’m no longer working on the project, however I will forward this to the appropriate team so that they can try this out.