Search code examples
objective-cshinobi

ShinobiCharts x axis labels folding when zoom out


Im using ShinobiCharts line type kind ,my x values are date strings and y are the values - longs.

The chars points are displayed correctly but the x values lables are shown along the whole chart points, and shown on top of each other x labels overlay

This is chart initialisation I'm using:

 mainChart = [[ShinobiChart alloc] initWithFrame:frame   withPrimaryXAxisType:SChartAxisTypeCategory withPrimaryYAxisType:SChartAxisTypeNumber];

And this is how i create my dataPoint:

SChartDataPoint* dataPoint = [SChartDataPoint new];    
dataPoint.xValue =key;
dataPoint.yValue = value;

Any ideas what am i missing?


Solution

  • You need to make your x-axis a SChartDateTimeAxis, not an SChartCategoryAxis. Your xValue needs to be an NSDate, not an NSString. Use the NSDateFormatter to get the dateFromString:

    NSDateFormatter *dateFormatter = [NSDateFormatter new];
    dateFormatter.dateFormat = @"dd/MM/yy";
    
    dataPoint.xValue = [dateFormatter dateFromString:key];
    ...