Major gridline style


#1

Is there a way to edit the major gridlines so that every other line (or every 3rd line) is a different width and/or color?

Can I display minor gridlines?


#2

Has anyone seen a solution that can help me with this?


#3

Hi rtvanals,

This isn’t a feature we support out of the box.

However, you could use SChartAnnotations to mimic Major gridlines by calling “+verticalBandAtPosition:andMaxX:withXAxis:andYAxis:withColor:”.

The same can be said for minor gridlines, they aren’t something we support but could be done by using SChartAnnotations.

More information on SChartAnnotations can be found HERE.

Let me know if you have any other questions.

Kind Regards,
Andrew Polkinghorn


#4

Hi Andrew,

Thanks for the response.  The solution worked great for me.  

In case others are looking for how I did this, here is the code:

#define X_AXIS_COUNT 100
#define FREQUENCY_OF_BOLD_LINES 3

for (int i = 0; i < X_AXIS_COUNT; i++) {
   int tickFrequncy = X_AXIS_COUNT * i;
   if (i % FREQUENCY_OF_BOLD_LINES == 0) {
     SChartAnnotation *annotation = [SChartAnnotation verticalBandAtPosition:@(tickFrequncy) andMaxX:nil withXAxis:_chart.xAxis andYAxis:_chart.yAxis withColor:[UIColor colorWithRed:255./255. green:0. blue:0. alpha:.6]];
     [_chart addAnnotation: annotation];
   }
}

#5

Thanks guys, for this discussion.

Just wanted to lodge as a feature request to be able to adjust the z-order of annotations. Faking distinct major grid line styles via the above proposed annotations, works well enough, but results in them being displayed ontop of everything.  As you probably know grid lines are (as prefered) displayed underneath.

Cheers. 


#6

>> Just wanted to lodge as a feature request to be able to adjust the z-order of annotations. Faking distinct major grid line styles via the above proposed annotations, works well enough, but results in them being displayed ontop of everything.  As you probably know grid lines are (as prefered) displayed underneath.

Actually, nevermind! I just discovered this:

annotation.position = SChartAnnotationBelowData;



This allows us to 'fake' major gridlines to appear underneath plot data.