Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/BEMSimpleLineGraphView.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@
/// Color of the label's text displayed on the X-Axis.
@property (strong, nonatomic) UIColor *colorXaxisLabel;

/// The gesture recognizer picking up the pan in the graph view
@property (strong, nonatomic) UIPanGestureRecognizer *panGesture;

/// View for picking up pan gesture
@property (strong, nonatomic, readonly) UIView *panView;

@end

Expand Down
29 changes: 22 additions & 7 deletions Classes/BEMSimpleLineGraphView.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ @interface BEMSimpleLineGraphView () {
/// The animation delegate for lines and dots
@property (strong, nonatomic) BEMAnimations *animationDelegate;

/// View for picking up pan gesture
@property (strong, nonatomic, readwrite) UIView *panView;

/// Find which dot is currently the closest to the vertical line
- (BEMCircle *)closestDotFromVerticalLine:(UIView *)verticalLine;

Expand Down Expand Up @@ -144,21 +147,33 @@ - (void)layoutSubviews {
self.verticalLine.alpha = 0;
[self addSubview:self.verticalLine];

UIView *panView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.viewForBaselineLayout.frame.size.width, self.viewForBaselineLayout.frame.size.height)];
panView.backgroundColor = [UIColor clearColor];
[self.viewForBaselineLayout addSubview:panView];
self.panView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.viewForBaselineLayout.frame.size.width, self.viewForBaselineLayout.frame.size.height)];
self.panView.backgroundColor = [UIColor clearColor];
[self.viewForBaselineLayout addSubview:self.panView];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
panGesture.delegate = self;
[panGesture setMaximumNumberOfTouches:1];
[panView addGestureRecognizer:panGesture];
self.panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
self.panGesture.delegate = self;
[self.panGesture setMaximumNumberOfTouches:1];
[self.panView addGestureRecognizer:self.panGesture];
}

// Let the delegate know that the graph finished layout updates
if ([self.delegate respondsToSelector:@selector(lineGraphDidFinishLoading:)])
[self.delegate lineGraphDidFinishLoading:self];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isEqual:self.panGesture]) {
if (gestureRecognizer.numberOfTouches > 0) {
CGPoint translation = [self.panGesture velocityInView:self.panView];
return fabs(translation.y) < fabs(translation.x);
} else {
return NO;
}
}
return YES;
}

- (void)didAddSubview:(UIView *)subview {
[super didAddSubview:subview];

Expand Down

This file was deleted.