Use SChartCategoryAxis with a predefined range


I have the below requirement for 2 sets of graphs. I have been trying a couple of stuff but nothing works perfectly yet . My requirement is as follows :

  1. Weekly Graph

a)X axis shows seven days of the week as (Sun , Mon , Tue , Wed , Thur , Fri , Sat) and y axis has certain predefined values .

b)The x-axis needs to be set with this predefined range because even if certain days of the week does not have y axis value , I would still need the x-axis to show all these 5 days a week 

2 . Monthly Graph :

a)X axis shows predefined 5 points (Aug 5 , Aug 10 , Aug 15, Aug 20, Aug 25) (Aug being a sample month) (Need to change it dynamically for each month where the data is available)

b)The x-axis needs to be set with this predefined range 

Earlier When I was using the below code for the weekly axis what happens is that if for a certain day ,  the y axis does not have values then automatically the x-axis for that specifc tick is also removed 

Please guide me on how to set the x-axis range for the SChartCategory xAxis. (For the SChartNumberAxis I can set the range with the integet values but not able to do with the SChartCategoryAxis)

Code that is working :

SChartNumberRange *range=[[SChartNumberRange alloc]initWithMinimum:[NSNumber numberWithInt:0] andMaximum:[NSNumber numberWithInt:32]];

    SChartNumberAxis *xAxis = [[SChartNumberAxis alloc] initWithRange:range];

How can I use a similar logic for the SChartCategoryAxis so that  I can set the range as mentioned with the string values for the x-axis


Here is my latest update for the Monthly graph View . I tried using the DateTime axis and here is the code below : 

//Details on the x-axis

_shinobiChart = [[ShinobiChartalloc] initWithFrame:self.view.frame



   SChartDateRange *range = [[SChartDateRangealloc] initWithDateMinimum:month.startDateOfMonthandDateMaximum:month.endDateOfMonth];

    SChartDateTimeAxis *xAxis = [[SChartDateTimeAxisalloc] initWithRange:range];

    NSDateFormatter *dayFormatter = [[NSDateFormatteralloc] init];

    [dayFormatter setDateFormat:@“d”];

    SChartTickLabelFormatter *formatter = [SChartTickLabelFormatterdateFormatter];

    [formatter setFormatter:dayFormatter];

    xAxis.labelFormatter = formatter; = NO; = NO; = SChartTitlePositionTopOrRight;

    xAxis.majorTickFrequency = [SChartDateFrequencydateFrequencyWithDay:1];

    xAxis.title = NSLocalizedString(@“BP.Days.Heading”, @""); //Sim modified for localization;

    _shinobiChart.xAxis = xAxis;

    //Details on the Y-axis

    SChartNumberRange *rangeY=[[SChartNumberRangealloc]initWithMinimum:minY.intValue<=19 ? @(0) : [NSNumbernumberWithInt:minY.intValue-20] andMaximum:[NSNumbernumberWithInt:maxY.intValue+20]];

    SChartNumberAxis *YAxis = [[SChartNumberAxisalloc] initWithRange:rangeY];;

    _shinobiChart.yAxis = YAxis;

   //Populating the datapoint :

SChartDataPoint*  datapoint = [selfdataPointForValue:[NSNumbernumberWithInt:dayNumber] andValue:day.systolic];

                datapoint.xValue = [NSNumbernumberWithInt:dayNumber]; //This should indicate the specific date ( 5th , 6th 7th etc of the month)


                SChartDataPoint* datapoint1 = [selfdataPointForValue:[NSNumbernumberWithInt:dayNumber] andValue:day.diastolic];

                datapoint1.xValue = [NSNumbernumberWithInt:dayNumber];


The end of this I do not get the data populated correctly . My ultimate goal is to show the months as (Aug 01 , Aug 2, Aug 3rd etc)

Any help on this will be greatly appreciated 


Hi there,

SChartDateTimeAxis is definitely the way to go for your x-axis.

  1. I think some of your questions regarding the weekly graph have been covered in this thread

  2. For your monthly graph.

  • For your labels to appear as Aug 5, Aug 20 e.t.c you can use the following format:

    xAxis.labelFormatString = @“MMM d”;

I’m afraid I don’t completely understand what you meany by 5 predefined points. Could you clarify it if the following doesn’t help?

  • You could have tick labels at 5 day intervals using 

    xAxis.majorTickFrequency = [[SChartDateFrequency alloc] initWithDay:5];

  • There is a delegate method  sChart:alterTickMark:beforeAddingToAxis: which may be what you’re after.

Hope the above is of some help!