Customized a Column Series Chart


Hello All, 

So I have a Column Series Chart, how can I set the color of each BAR I add to the chart ? The color of the bar is set by a rule that is fuction of the y Value.

Also if I have a chart with 120 points but I only want to show 30 at a time, is there to set up a “window” i.e xAxis zoom level so that the person only sees 30 or so but then can pan forward and back to see older or new data points 

This charts also updates dynamically as new data comes in. How do I add a point to the chart and respect that fact that they maybe looking at another region of the plot via a zoom or pan gesture ? 

Thanks !



  1. You can subclass SChartColumnSeries and override styleForPoint: and then set whatever attributes you require there.

  2. You can use the defaultRange property on your x-axis to limit the range to your first 30 datapoints

  3. To prevent the chart resetting the range when reloading your chart with a new datapoint, you can disable autocalculateAxisRanges

I hope that’s of some help,



Hi Sam ! 

Thanks for the great tips, on point #3 how do you do this when the xAxis if of type SChartDiscontinuousDateTimeAxis 

Does the  self.m_dailyChart.xAxis.defaultRange.minimum and maximum just become the indicies for the array being plotted  ?

Also the min and max property are read only ! Is there another way to set them  ?



No problem  :grin:

Yes you’re correct about the datetime axis’ minimum and maximum values default to the earliest and last dates in your data set.

You should be able to create a new range and set that as your chart’s defaultRange (for datetime axes you would use an SChartDateRange) as follows:

_chart.xAxis.defaultRange = [[SChartDateRange alloc] initWithDateMinimum:[self dateFromString:@"01-02-2015"] andDateMaximum:[self dateFromString:@"01-03-2015"]];

Say you had data for 01 Feb to 01 April, this would result in the x axis adjusting to fit just the data from 01 Feburary to 01 March initially, with the user being able to pan and see the remaining datapoints  (provided gesture panning is enabled of course!).

I hope that helps!



Hi Sam ! 

Thanks for this suggestion, you know how you can make calls like this 

[self.m_dailyChartremoveNumberOfDataPoints:removedCount fromStartOfSeriesAtIndex:0];

how can I make a similar call to get the current number of points in a series at Index 0 ? 


You should be able to do something like the following to achieve that:

SChartSeries *series = [_chart.series objectAtIndex:0];
NSUInteger numberOfDatapointsInSeries = [series.dataSeries.dataPoints count];