Instantly share code, notes, and snippets.

@tonyarnold /datasource.m Secret
Created May 17, 2013

Embed
What would you like to do?
- (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