-
-
Save tonyarnold/b6a1c2b36a16929c1176 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)sChartRenderFinished:(ShinobiChart *)chart | |
{ | |
if (YES == self.firstChartRender) { | |
self.firstChartRender = NO; | |
[chart removeAllAnnotations]; | |
SChartCategoryAxis *categoryAxis = (SChartCategoryAxis *)chart.xAxis; | |
for (NSDictionary *resultDictionary in self.leftBreastData) { | |
NSNumber *referenceDate = resultDictionary[TBDEventAttributes.groupingDateSinceReferenceDate]; | |
__block NSInteger xIndex = NSNotFound; | |
[categoryAxis.categories enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) { | |
if (obj.doubleValue == referenceDate.doubleValue) { | |
xIndex = idx; | |
*stop = YES; | |
} | |
}]; | |
if (NSNotFound == xIndex) { | |
continue; | |
} | |
NSNumber *duration = resultDictionary[@"result"]; | |
SChartAnnotation *newAnnotation = [SChartAnnotation annotationWithText:[NSString stringWithFormat:@"%.1f", [duration doubleValue] / 60.0 / 60.0] // Hours | |
andFont:[UIFont systemFontOfSize:10.f] | |
withXAxis:chart.xAxis | |
andYAxis:chart.yAxis | |
atXPosition:@(xIndex) | |
andYPosition:duration | |
withTextColor:[UIColor blackColor] | |
withBackgroundColor:[UIColor clearColor]]; | |
newAnnotation.position = SChartAnnotationAboveData; | |
[chart addAnnotation:newAnnotation]; | |
newAnnotation.transform = CGAffineTransformMakeTranslation(-14.f, -6.f); | |
} | |
for (NSDictionary *resultDictionary in self.rightBreastData) { | |
NSNumber *referenceDate = resultDictionary[TBDEventAttributes.groupingDateSinceReferenceDate]; | |
__block NSInteger xIndex = NSNotFound; | |
[categoryAxis.categories enumerateObjectsUsingBlock:^(NSNumber *obj, NSUInteger idx, BOOL *stop) { | |
if (obj.doubleValue == referenceDate.doubleValue) { | |
xIndex = idx; | |
*stop = YES; | |
} | |
}]; | |
if (NSNotFound == xIndex) { | |
continue; | |
} | |
NSNumber *duration = resultDictionary[@"result"]; | |
SChartAnnotation *newAnnotation = [SChartAnnotation annotationWithText:[NSString stringWithFormat:@"%.1f", [duration doubleValue] / 60.0 / 60.0] // Hours | |
andFont:[UIFont systemFontOfSize:10.f] | |
withXAxis:chart.xAxis | |
andYAxis:chart.yAxis | |
atXPosition:@(xIndex) | |
andYPosition:duration | |
withTextColor:[UIColor blackColor] | |
withBackgroundColor:[UIColor clearColor]]; | |
newAnnotation.position = SChartAnnotationAboveData; | |
[chart addAnnotation:newAnnotation]; | |
newAnnotation.transform = CGAffineTransformMakeTranslation(14.f, -6.f); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment