ShinobiCharts: Missing TickMark Labels


#1

I have simple chart with 7 dates corresponding to 7 values. The chart displays properly but I can’t get the tickmark labels on datetime axis to draw. (only the first dara point has a label) Tried instantiating the axis using range, setting the major tick frequency to daily, but still no luck. Am I mising something?

Here’s the code I’m using:

self.chart = (ShinobiChart *)[cell.contentView viewWithTag:270];
    self.chart.datasource = self;
    self.chart.delegate = self;
    self.chart.backgroundColor = [UIColor whiteColor];
    self.chart.title = @" ";
    self.chart.licenseKey = @"key";
    SChartDateRange *dateRange = [[SChartDateRange alloc] initWithDateMinimum:self.categories.firstObject andDateMaximum:self.categories.lastObject];
    SChartDateTimeAxis *xAxis = [[SChartDateTimeAxis alloc] initWithRange:dateRange];
    SChartDateFrequency *frequency = [[SChartDateFrequency alloc] initWithDay:1];
    xAxis.majorTickFrequency = frequency;
    xAxis.style.lineColor = [UIColor colorWithWhite:.90 alpha:1];
    xAxis.style.lineWidth = @1;
    xAxis.style.majorTickStyle.labelFont = [UIFont fontWithName:@"OpenSans-Light" size:12];
    xAxis.style.majorTickStyle.showTicks = YES;
    self.chart.xAxis = xAxis;
    
    // set the y axis here.... works fine

And here’s the data:

Printing description of self->_categories:
<__NSArrayI 0x7ffab0445140>(
2015-06-21 04:00:00 +0000,
2015-06-22 04:00:00 +0000,
2015-06-23 04:00:00 +0000,
2015-06-24 04:00:00 +0000,
2015-06-25 04:00:00 +0000,
2015-06-26 04:00:00 +0000,
2015-06-27 04:00:00 +0000
)

Printing description of self->_values:
<__NSArrayM 0x7ffab5132f40>(
0,
45,
300,
0,
0,
0,
0
)

And this is what I get:

Thanks!


#2

Hi,

I think we’ve corresponded via email, however I thought I’d pop this on here in case it’s useful for others in the future.

The issue with the tick labels not displaying is actually expected behaviour. 

This arises as the chart will initially try and display a tick label at a frequency of 1 tick label per day. However on a smaller device, such as an iPhone in portrait mode, there is not enough space to display the labels. In this case, we fall back to displaying tick labels at a frequency of one tick label per week.

There are a couple of things you could do to display tick labels at more frequent intervals:

  1. Edit the default range to be a subset of your data (e.g. 21st June to 24th June), this will ensure there is enough space for the labels to display… the user could then pan to see the remaining datapoints

  2. You could adjust the majoTickFrequency to show tick labels every two days e.g. 

    xAxis.majorTickFrequency = [SChartDateFrequency dateFrequencyWithDay:2];

I hope that is of some help!

Thanks,

Sam


#3

Hi Sam,

Thanks a lot for your help!

This explains it!

Cheers!