Daylight saving issue


#1

I encounter an issue which i think is daylight saving that cause the xAxis(SChartDateTimeAxis) shown wrong date.

  1. The device was set to timezone Sydney Australia

  2. Zoom chart until xAxis show individual day and month (ie. 1 April, 2 April, 3 April…)

  3. Scroll the chart from 1 April 2013 to 31 April 2013, notice there will be date changed when 8 April was moved out of the chart. The day will make a day jump. Zoom on xAxis will see on 8 April had the time had changed to 23:00, before 8 April was 24:00.

Appreciate any suggestion on how to solve this issue.

I used ShinobiCharts 2.5.7

I shared a testing project that i created on github: https://github.com/ylchoo/Test


#2

Hi. Thank you for reporting this issue, We will look into the issue and let you know our findings.

Thanks,

Kai.


#3

Hello, any updates on this ?

We have the same issue on Shinobi 2.8.5-3, also it seems that leap years also affected by the issue.

Thanks.


#4

Unfortunately this bug still exists. It’s caused by an optimisation we make to avoid fairly expensive calendar operations. However, we need to alter it slightly to detect when a timezone boundary has been crossed. I’ll make sure this is brought up at our next planning meeting and is prioritised accordingly.

For now, there is a workaround that involves calculating the label dates yourself using one of the datasource methods:

- (NSArray *)sChart:(ShinobiChart *)chart majorTickValuesForAxis:(SChartAxis *)axis
{
    // Only want to calculate our own tick labels for the x-axis, return nil for the chart to auto-caulate y-axis labels
    if (![axis isXAxis])
    {
        return nil;
    }
    
    NSMutableArray *dates = [NSMutableArray array];
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    
    NSDate *maxDate = [NSDate dateWithTimeIntervalSince1970:[axis.range.maximum doubleValue]];
    NSDate *minDate = [NSDate dateWithTimeIntervalSince1970:[axis.range.minimum doubleValue]];
    
    // Convert min date to midnight
    NSDateComponents *comps = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:minDate];
    NSDate *currentLabelDate = [calendar dateFromComponents:comps];
    
    // Assuming we're happy with a constant tick frequency of 1 day
    while ([currentLabelDate timeIntervalSinceDate:maxDate] < 0)
    {
        [dates addObject:currentLabelDate];
        
        currentLabelDate = [self skipDate:currentLabelDate forwardByNumberOfDays:1];
    }
    
    return dates;
}

- (NSDate *)skipDate:(NSDate *)date forwardByNumberOfDays:(NSUInteger)numberOfDays
{
    NSDateComponents *dayComponent = [NSDateComponents new];
    dayComponent.day = numberOfDays;
    
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *nextDate = [calendar dateByAddingComponents:dayComponent toDate:date options:0];
    
    return nextDate;
}

I appreciate that it’s far from perfect, however I hope that helps you to workaround the problem for now.

Many thanks,

Sam


#5

I’m still seeing this issue in version 2.9.4. Although this workaround is effective, it seems like something that should be addressed in the framework itself. Any chance it’ll be resolved soon?


#6

Hi tschmitz,

Thanks for bringing this to our attention again. I’ve moved the issue up in our backlog so hopefully we’ll be able to start work on it soon.

Regards,

Alison