Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit e1c6fd6

Browse files
committed
Ensure circleDots always same length as dataPoints
Use lack of superview to distinguish Null points
1 parent 2072327 commit e1c6fd6

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Classes/BEMSimpleLineGraphView.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -539,24 +539,21 @@ - (BEMCircle *)circleDotAtIndex:(NSUInteger)index forValue:(CGFloat)dotValue reu
539539

540540
[yAxisValues addObject:@(positionOnYAxis)];
541541

542+
CGRect dotFrame = CGRectMake(0, 0, self.sizePoint, self.sizePoint);
542543
BEMCircle *circleDot = nil;
543544
if (reuseNumber < self.circleDots.count) {
544545
circleDot = self.circleDots[reuseNumber];
545-
}
546-
if (dotValue >= BEMNullGraphValue) {
547-
// If we're dealing with an null value, don't draw the dot (but put it in yAxis to interpolate line)
548-
[circleDot removeFromSuperview];
549-
return nil;
550-
}
551-
552-
CGRect dotFrame = CGRectMake(0, 0, self.sizePoint, self.sizePoint);
553-
if (circleDot) {
554546
circleDot.frame = dotFrame;
555547
[circleDot setNeedsDisplay];
556548
} else {
557549
circleDot = [[BEMCircle alloc] initWithFrame:dotFrame];
558550
[self.circleDots addObject:circleDot];
559551
}
552+
if (dotValue >= BEMNullGraphValue) {
553+
// If we're dealing with an null value, don't draw the dot (but leave it in yAxis to interpolate line)
554+
[circleDot removeFromSuperview];
555+
return nil;
556+
}
560557

561558
circleDot.center = CGPointMake(positionOnXAxis, positionOnYAxis);
562559
circleDot.tag = (NSInteger) index + DotFirstTag100;
@@ -1362,6 +1359,7 @@ - (BEMCircle *)closestDotFromTouchInputLine:(UIView *)touchInputLine {
13621359
BEMCircle * closestDot = nil;
13631360
CGFloat currentlyCloser = CGFLOAT_MAX;
13641361
for (BEMCircle *point in self.circleDots) {
1362+
if (!point.superview) continue;
13651363
if (self.alwaysDisplayDots == NO && self.displayDotsOnly == NO) {
13661364
point.alpha = 0;
13671365
}

0 commit comments

Comments
 (0)