Inconsistent x-axis label placement/intervals


Hi there

I have been struggling the last week with getting the x-axis labels for a SChartDateTimeAxis to display properly. I have a pretty basic line chart that loads datapoints from our server. Our chart has 3 views, a day-view overview of the data, a weekview, and a monthview.

My problems are:

  • Sometimes only one label is displayed at the start of the x-axis.
  • Sometimes the last label cuts off(goes over the bounds of the chartview)
  • Sometimes I get duplicate dates on the x-axis

I have tried various things,letting the chart calculate it automatically, setting the anchorpoint to the first date, calculating the amount of days and hours in my daterange and setting the majorTickFrequency with that,setMinimumFreeAxisSpace tweaks,SChartTickLabelClippingModeTicksAndLabelsPersist, (NSString *)sChart:(ShinobiChart *)chart longestLabelStringOnAxis:(SChartAxis *)axis,-(void)sChart:(ShinobiChart *)chart alterTickMark:(SChartTickMark *)tickMark beforeAddingToAxis:(SChartAxis *)axis etc

I think one of the problems is that there might be data gaps on our datasource, data is not always guaranteed in regular intervals,thus the chart is struggling to cacluate at what intervals to display the labels. 

Ok long story short, is there a way to always display 3 labels on the x-axis. One at the beginning, one in the middle and one at the end(without cutting off).  Are there any other methods I can use to customize the x-axis? Is it possible to hardcode?

Any help would be greatly appreciated!


If anyone is interested, I managed to solve it by using seconds in the MajortickFrequency. StarDate and EndDate is from your current dataset. The below will give you 3 dates on the x-axis.

 NSDateComponents *components = [gregorianCalendar components:NSCalendarUnitSecond




        float seconds =components.second/2;

        [_chart.xAxissetMajorTickFrequency: [SChartDateFrequencydateFrequencyWithSecond:seconds]];

To solve the clipping of the last label:

-(void)sChart:(ShinobiChart *)chart alterTickMark:(SChartTickMark *)tickMark beforeAddingToAxis:(SChartAxis *)axis


    if (!axis.isXAxis)




        if(tickMark.tickLabel.frame.size.width+tickMark.tickLabel.frame.origin.x > _chart.frame.size.width)


            tickMark.tickLabel.frame = CGRectMake(tickMark.tickLabel.frame.origin.x-20, tickMark.tickLabel.frame.origin.y, tickMark.tickLabel.frame.size.width,  tickMark.tickLabel.frame.size.height);