SChartColumnSeries and SChartDateRange



I’m trying to render a column series with a SChartDateTimeAxis as x-axis. I’m getting the data from a backend system, which I can’t change. The x-axis needs a data range. If I get just one datapoint back, the graph does not render at all. With 2 datapoints, it is all fine. 

I created a demo project as an example (As soon as I change the return value for numberOfDataPointsForSeriesAtIndex to 2, it works) . I have no idea, why it is not rendering with one datapoint. Do I miss something? If not, is there a workaround?

Any help would be appreciated…

  • (void)viewDidLoad {


    ShinobiChart *demoChart = [[ShinobiChartalloc] initWithFrame:CGRectMake(50, 50, 600, 200) withTheme:[[SChartiOS7Themealloc] init]];

    [self.view addSubview:demoChart];

    demoChart.xAxis = [[SChartDateTimeAxis alloc] init];

    NSDate *from = [NSDatedateWithTimeIntervalSince1970:1367743752 - 300000];

    NSDate *to = [NSDatedateWithTimeIntervalSince1970:1367743752 + 300000];

    SChartDateRange *nr = [[SChartDateRangealloc] initWithDateMinimum:from andDateMaximum:to];

    demoChart.xAxis.defaultRange = nr;

    demoChart.datasource = self;


-(SChartSeries *)sChart:(ShinobiChart *)chart seriesAtIndex:(int)index {

    SChartColumnSeries *barSeries = [[SChartColumnSeriesalloc] init];

    return barSeries;


-(NSInteger)numberOfSeriesInSChart:(ShinobiChart *)chart {

    return 1;


  • (int)sChart:(ShinobiChart *)chart numberOfDataPointsForSeriesAtIndex:(int)seriesIndex {   



  • (id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex {

SChartDataPoint *datapoint = [[SChartDataPointalloc] init];

    datapoint.xValue = [NSNumber numberWithDouble:(1367743752 + (dataIndex * 10000))];

    datapoint.yValue = @1.13;

    return datapoint;



Hi gerke,

You might want to try initializing your axis with the range, E.g. xAxis = [[SChartDateTimeAxisalloc] initWithRange:range]

Alternatively, if you do set the range afterwards, you will want axis.axisRange, not axis.defaultRange.


Thanks for your response. Neither of the suggestions worked for me. In the meantime I’m checking if there is one datapoint only. If yes, I add a second one out of the range of the graph (basically in the “invisble” part of the chart, e.g. -1, if the range is from 0 to 10). Not nice, but this workaround works for me at the moment. 


Hi Gerke74,

I tested this against our latest release and I’m able to replicate your issue. It does look like this is an issue on our end, although I’d need to investigate this to be certain!

I’m glad you’ve managed to find a suitable workaround, and that’s actually the type of workaround I’d have been looking for to give you. I understand it’s not ideal so I’ve raised this in our backlog, and we’ll be looking into it.

Jan Akerman