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

Constantly showing the most recent selected circle #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Empty file modified Classes/BEMAverageLine.h
100644 → 100755
Empty file.
Empty file modified Classes/BEMAverageLine.m
100644 → 100755
Empty file.
Empty file modified Classes/BEMCircle.h
100644 → 100755
Empty file.
Empty file modified Classes/BEMCircle.m
100644 → 100755
Empty file.
Empty file modified Classes/BEMLine.h
100644 → 100755
Empty file.
Empty file modified Classes/BEMLine.m
100644 → 100755
Empty file.
Empty file modified Classes/BEMPermanentPopupView.h
100644 → 100755
Empty file.
Empty file modified Classes/BEMPermanentPopupView.m
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions Classes/BEMSimpleLineGraphView.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
//------------------------------------------------------------------------------------//


/// If set to YES, the graph will be constantly showing the most recent selected circle. Default value is NO.
@property (nonatomic) BOOL alwaysShowSelectedCircle;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the property could be a little bit more explicit.
How do you feel about something like persistLatestPopUpLabel?


/// The graphs's most recently selected circle.
@property (strong, nonatomic, nullable) BEMCircle *selectedCircle;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why expose the property selectedCircle publicly?
If necessary, shouldn't it be read-only?



/// The graph's label font used on various axis. This property may be privately overwritten, do not expect full functionality from this property.
@property (strong, nonatomic, nullable) UIFont *labelFont;

Expand Down
7 changes: 6 additions & 1 deletion Classes/BEMSimpleLineGraphView.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ - (void)commonInit {
_enableYAxisLabel = NO;
_YAxisLabelXOffset = 0;
_autoScaleYAxis = YES;
_alwaysShowSelectedCircle = NO;
_alwaysDisplayDots = NO;
_alwaysDisplayPopUpLabels = NO;
_enableLeftReferenceAxisFrameLine = YES;
Expand Down Expand Up @@ -1179,9 +1180,12 @@ - (UIImage *)graphSnapshotImageRenderedWhileInBackground:(BOOL)appIsInBackground
#pragma mark - Data Source

- (void)reloadGraph {
self.selectedCircle = nil;

for (UIView *subviews in self.subviews) {
[subviews removeFromSuperview];
}

[self drawGraph];
// [self setNeedsLayout];
}
Expand Down Expand Up @@ -1321,6 +1325,7 @@ - (void)handleGestureAction:(UIGestureRecognizer *)recognizer {
closestDot = [self closestDotFromtouchInputLine:self.touchInputLine];
closestDot.alpha = 0.8;

self.selectedCircle = closestDot;

if (self.enablePopUpReport == YES && closestDot.tag >= DotFirstTag100 && closestDot.tag < DotLastTag1000 && [closestDot isKindOfClass:[BEMCircle class]] && self.alwaysDisplayPopUpLabels == NO) {
[self setUpPopUpLabelAbovePoint:closestDot];
Expand Down Expand Up @@ -1355,7 +1360,7 @@ - (void)handleGestureAction:(UIGestureRecognizer *)recognizer {
}

[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
if (self.alwaysDisplayDots == NO && self.displayDotsOnly == NO) {
if (self.alwaysDisplayDots == NO && self.displayDotsOnly == NO && self.alwaysShowSelectedCircle == NO) {
closestDot.alpha = 0;
}

Expand Down