X axis scale linked to zoom level
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Can we control the time indications on the graphs better. When you zoom in the x-axis scale is completely generic. It give very strange time intervals. Ex 0248, 0311, 0323 etc. I would like it to be,
- Full hours when not zoomed in. 0200, 0300, 0400 etc.
- When you zoom in beyond where you see more than 2 hours at the same time the scale changes to 30 minutes intervals. Still full halfhours. 0200, 0230, 0300 etc.
- Next zoom level show 10-minute intervals, 0200,0210,0220,0230 etc.
- Next minutes. 0201, 0202, 0203 etc.
ℹ I tried setting `GRANULARITY 3600.0f` but this change the x axis values to very strange values.
ℹ I tried rounding the values and this works, but when I zoom in there are duplicates and I can not get the half hour intervals and 10-minute intervals. I am stuck with 1 hour intervals.
- (NSString *)stringForValue:(double)value axis:(ChartAxisBase *)axis
{
if (value > 0) {
NSNumber *num = [NSNumber numberWithDouble:value];
NSDate *date = [NSDate dateWithTimeIntervalSince1970:[num longLongValue]];
NSDateComponents *time = [[NSCalendar currentCalendar]
components:NSCalendarUnitHour | NSCalendarUnitMinute
fromDate:date];
NSInteger minutes = [time minute];
float minuteUnit = ceil((float) minutes / 60.0);
minutes = minuteUnit * 60.0;
[time setMinute: minutes];
date = [[NSCalendar currentCalendar] dateFromComponents:time];
return [_dateFormatter stringFromDate:date];
}
}
From what I read this is not a possible way to get what I need. If someone knows a workaround it would be great.
Contributor guide
Research direction
Start with ChartAxisBase, the x-axis value formatter stringForValue:axis:, and the GRANULARITY setting described in the issue. Reproduce the chart at each zoom level and inspect how axis entries and time values are generated. Done means the labels use full-hour, half-hour, 10-minute, and one-minute intervals without strange values or duplicate labels.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100