Skip to content

Commit

Permalink
fix types casting and modern syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
skywinder committed Oct 27, 2014
1 parent e4ba73c commit 683a260
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Classes/BEMSimpleLineGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -514,29 +514,29 @@ - (void)drawXAxis {
UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(3+self.YAxisLabelXOffset, self.frame.size.height-20, viewWidth/2, 20)];
firstLabel.text = firstXLabel;
firstLabel.font = self.labelFont;
firstLabel.textAlignment = 0;
firstLabel.textAlignment = NSTextAlignmentLeft;
firstLabel.textColor = self.colorXaxisLabel;
firstLabel.backgroundColor = [UIColor clearColor];
firstLabel.tag = DotLastTag;
[self addSubview:firstLabel];
[xAxisValues addObject:firstXLabel];
[xAxisLabels addObject:firstLabel];
NSNumber *xFirstAxisLabelCoordinate = [NSNumber numberWithFloat:firstLabel.center.x-self.YAxisLabelXOffset];

NSNumber *xFirstAxisLabelCoordinate = @(firstLabel.center.x - self.YAxisLabelXOffset);
[xAxisLabelPoints addObject:xFirstAxisLabelCoordinate];

UILabel *lastLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width/2 - 3, self.frame.size.height-20, self.frame.size.width/2, 20)];
lastLabel.text = lastXLabel;
lastLabel.font = self.labelFont;
lastLabel.textAlignment = 2;
lastLabel.textAlignment = NSTextAlignmentRight;
lastLabel.textColor = self.colorXaxisLabel;
lastLabel.backgroundColor = [UIColor clearColor];
lastLabel.tag = DotLastTag;
[self addSubview:lastLabel];
[xAxisValues addObject:lastXLabel];
[xAxisLabels addObject:lastLabel];

NSNumber *xLastAxisLabelCoordinate = [NSNumber numberWithFloat:lastLabel.center.x-self.YAxisLabelXOffset];
NSNumber *xLastAxisLabelCoordinate = @(lastLabel.center.x - self.YAxisLabelXOffset);
[xAxisLabelPoints addObject:xLastAxisLabelCoordinate];

} else {
Expand Down Expand Up @@ -668,11 +668,11 @@ - (void)drawYAxis {
[self addSubview:labelYAxis];
[yAxisLabels addObject:labelYAxis];

NSNumber *yAxisLabelCoordinate = [NSNumber numberWithFloat:labelYAxis.center.y];
NSNumber *yAxisLabelCoordinate = @(labelYAxis.center.y);
[yAxisLabelPoints addObject:yAxisLabelCoordinate];
}
} else {
CGFloat numberOfLabels;
NSInteger numberOfLabels;
if ([self.delegate respondsToSelector:@selector(numberOfYAxisLabelsOnLineGraph:)]) numberOfLabels = [self.delegate numberOfYAxisLabelsOnLineGraph:self];
else numberOfLabels = 3;

Expand All @@ -697,19 +697,19 @@ - (void)drawYAxis {

[yAxisLabels addObject:labelYAxis];

NSNumber *yAxisLabelCoordinate = [NSNumber numberWithFloat:labelYAxis.center.y];
NSNumber *yAxisLabelCoordinate = @(labelYAxis.center.y);
[yAxisLabelPoints addObject:yAxisLabelCoordinate];
}
}

// Detect overlapped labels
__block NSUInteger lastMatchIndex;
__block NSUInteger lastMatchIndex = 0;
NSMutableArray *overlapLabels = [NSMutableArray arrayWithCapacity:0];
[yAxisLabels enumerateObjectsUsingBlock:^(UILabel *label, NSUInteger idx, BOOL *stop) {

if (idx==0) lastMatchIndex = 0;
else { // Skip first one
UILabel *prevLabel = [yAxisLabels objectAtIndex:lastMatchIndex];
UILabel *prevLabel = yAxisLabels[lastMatchIndex];
CGRect r = CGRectIntersection(prevLabel.frame, label.frame);
if (CGRectIsNull(r)) lastMatchIndex = idx;
else [overlapLabels addObject:label]; // overlapped
Expand Down Expand Up @@ -743,9 +743,9 @@ - (void)displayPermanentLabelForPoint:(BEMCircle *)circleDot {
self.enablePopUpReport = NO;
self.xCenterLabel = circleDot.center.x;
UILabel *permanentPopUpLabel = [[UILabel alloc] init];
permanentPopUpLabel.textAlignment = 1;
permanentPopUpLabel.textAlignment = NSTextAlignmentCenter;
permanentPopUpLabel.numberOfLines = 0;
permanentPopUpLabel.text = [NSString stringWithFormat:@"%@", [NSNumber numberWithInteger:circleDot.absoluteValue]];
permanentPopUpLabel.text = [NSString stringWithFormat:@"%@", @((NSInteger) circleDot.absoluteValue)];
permanentPopUpLabel.font = self.labelFont;
permanentPopUpLabel.backgroundColor = [UIColor clearColor];
[permanentPopUpLabel sizeToFit];
Expand Down

0 comments on commit 683a260

Please sign in to comment.