-
Notifications
You must be signed in to change notification settings - Fork 382
New TestBed App and multiple bug fixes/cleanups #295
Conversation
Add averageValue delegate method to allow BEMLineGraph to be separate from BEMCalculator Restore modifyPopUpView delegate method Use caption preferredFont instead of SystemFont fro NoData Handle overlapping labels better Reuse code for popup and permanent labels Bug fixes ensure chart doesn't grow views when zero or one data points
Add coding to AverageLine Move gradient properties to strong to properly retain Fix compiler error about integers used in enums Change alwaysDisplayPopupatIndex to use NSUInteger for index instead of float Fix Frame warning in SimpleLineChart's launch Screen
Fix many bugs and buglets
AverageLine: •Color should be picked up from line if not set (default nil) Typo in encoding macro Line: If null data and interpolation on, then extrapolate for beginning/ending nulls. Bezier curve should be used even when only two points. If interpolation off, then bezier line should be interrupted by gaps (but not top/bottom). Avoid infinity result in midPoint calculation SimpleLineGraphView: Support restoration during startup. NoDataLabel color should not default from Line (which defaults to white, same as background) If null value, ensure corresponding Dot isn't left on chart If label isn't used after initially being created, ensure it's removed from view If neither X nor Y reference lines, set line's enableRefLines to NO (although default, might have been previously YES If Xaxis background is defaulting to colorBottom, then also use alphaBottom to match; same for Yaxis and colorTop. Avoid possible infinite loop if delegate gives a zero incrementIndex for x axis Fix one-pixel gap between yaxis and graph Remove spurious NSLogs
I have no idea about the CI build error; RVM and Debian? In running the BEMSimple tests, I noticed a couple of issues. I also note that I left a spurious Oh, one other thought: do you like separating the colors/alpha/gradients, or should they be with their groups. More broadly, the grouping of parameters may need to be rethought here. |
Line clipsToBounds to avoid drawing outside the box (when extrapolating nulls or user set minValue too High) Top/Bottom reference lines were outside box When Bezier off and Interpolate nulls off, properly draws line segments now Removed VMA NSLog from TestBed/MasterController
This looks very solid @mackworth! I'll make sure to make some time and review the PR soon. Thanks a lot for your work =) |
Thanks; I look forward to your comments. More broadly, is there a current project plan? As I'm going to be using this in my own project, I've been making some other (what I consider) improvements, and I don't know what things you all are working on, or would be interested in receiving. For example, I've moved to a cubic Bezier (from the quadratic) to fix the wave-like pattern on linear growth curves. I also needed a more flexible X-axis (where an X value can be any float, not just integers) to display data that might be timestamped at any time. I've implemented it for my own use, but I'd need to collaborate on the API to be able to submit it as a possible PR. Finally, as I fully "get" the code now, I'd be happy to put some time in to implement other features high on your wishlist as well. Let me know. |
Superseded by PR #300, which also incorporates the changes mentioned above. I created a separate pull request in case the addition of the pan/zoom and variableX are determined to be inappropriate for this library. Let me know what you think and/or if you have any problems with the other build. |
Thanks for creating a new PR. And I'm really sorry for not reviewing all of this earlier. I've been busy with life/work, but truly appreciate your work and want to get at it as soon as possible. |
No problem. As a first step, try running the new Testbed, preferably on an iPad to get a feel for some of the new changes. |
@mackworth @Boris-Em I have begun my review of the changes and should finish in the next day or two. There are some changes & fixes which I definitely would like to see integrated into the project and that I believe will move the it in the correct direction. That being said, I still need to test and use all the changed aspects, and (after having read through the commits & change logs) there are some things of which I am skeptical. I will also take a look at PR #300 (thank you for separating this requests). Thank you, @mackworth, for your extensive work on the project. Your contributions are greatly appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for you work @mackworth. This is really helpful!
I just did a first pass and found a few minor things here and there. I'll spend more time reviewing the changes tomorrow, digging more into the business logic.
A few thoughts:
- While I agree that this PR doesn't break any public APIs, it's still a pretty risky one, and some of the rendering is changed (for example reference lines).
- Do we want to keep both the Sample App and the TestBed app? I feel like the TestBed app is just superior at that point. @Sam-Spencer thoughts?
- On iPhone, it's sort of hard to go back to the graph VC from the options. Could we get a button in the navigation bar to navigate to the Graph VC?
Classes/BEMAverageLine.m
Outdated
_alpha = 1.0; | ||
_width = 3.0; | ||
_yValue = NAN; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (instancetype) initWithCoder:(NSCoder *)coder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra space.
return self; | ||
} | ||
|
||
- (void) encodeWithCoder: (NSCoder *)coder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra space.
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: let's remove that comment.
Classes/BEMLine.m
Outdated
@@ -59,8 +60,8 @@ - (void)drawRect:(CGRect)rect { | |||
if (self.enableReferenceFrame == YES) { | |||
if (self.enableBottomReferenceFrameLine) { | |||
// Bottom Line | |||
[referenceFramePath moveToPoint:CGPointMake(0, self.frame.size.height)]; | |||
[referenceFramePath addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)]; | |||
[referenceFramePath moveToPoint:CGPointMake(0, self.frame.size.height-self.referenceLineWidth/4)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that this wasn't introduced by you @mackworth, but could we use a constant here for all of the magic numbers (4)?
Classes/BEMLine.m
Outdated
@@ -85,15 +86,15 @@ - (void)drawRect:(CGRect)rect { | |||
if (self.enableReferenceLines == YES) { | |||
if (self.arrayOfVerticalReferenceLinePoints.count > 0) { | |||
for (NSNumber *xNumber in self.arrayOfVerticalReferenceLinePoints) { | |||
CGFloat xValue; | |||
CGFloat xValue =[xNumber doubleValue]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing space after =
.
Classes/BEMSimpleLineGraphView.m
Outdated
@@ -1207,6 +1233,7 @@ - (UIImage *)graphSnapshotImageRenderedWhileInBackground:(BOOL)appIsInBackground | |||
|
|||
- (void)reloadGraph { | |||
[self drawGraph]; | |||
// [self setNeedsLayout]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this dead code.
Classes/BEMSimpleLineGraphView.m
Outdated
@@ -1394,7 +1464,8 @@ - (CGFloat)yPositionForDotValue:(CGFloat)dotValue { | |||
|
|||
#pragma mark - Deprecated Methods | |||
|
|||
- (NSNumber *)calculatePointValueSum { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's remove the extra line.
// Copyright © 2017 Boris Emorine. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cleanup all of the default comments and unused methods on this file.
@property (strong, nonatomic) UIView * currentColorChip; | ||
@end | ||
|
||
@implementation UITextField (Numbers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this category on its own file?
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view, typically from a nib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's set the title of the view controller somewhere in viewDidLoad: self.title = @"Options".
This way the back arrow will display "Options" instead of "Master" which doesn't really make sense.
Fixing breaks, spaces to match project style Explaining constant 4 in BEMLine (note bug on line76 0+offset should be 0)
Fix top reference line offset bug Adds categories for UIKit extensions in MasterVC Adds Options title for iPhone version of TestBed Only changes in storyboard due to newer IB
There you go on the requested changes. Still don't know what to do about Travis
Definitely agreed on the risky; I've built it into my app, and it's running great, but it might be good to get a couple of others to try even before putting it in "Feature". On reference lines, assuming you mean the frame ones, they were just wrong before! (Even now, as a result of your question on "4", i noticed that the top line was still not right.
I would definitely keep both; Testbed is way too complicated to be your sample. OTOH, Sample App might want to be stripped some to make it even simpler to follow as an example.
I did most of my work on the iPad( and it's really a far better vehicle to avoid going back and forth), but agreed and done. Note that if you decide not to implement #300, or only some parts of it, then I'll have to move some of the fixes in #300 back into this branch. Conversely, if you want both, then I'll have to merge these changes into that PR. Looking forward to more comments... |
Thank you for being so responsive @mackworth! |
Spacing consistency with rest of project topline fix Move UIButton+switch and UITextField+Numbers from Master to separate files Title of Master "Options" Add Graph button if collapsed
Fix Travis Build
Okay, yes, looks like that travis.yml now passes. I updated it in #300 as well, and it passes there too. |
Any further thoughts on this PR? |
@Sam-Spencer, did you get a chance to finish your review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so I have three major thoughts on this pull request:
- There's a whole pile of great bug fixes and minor improvements in here that are much needed for the project. A few may need some tweaking, but from what I can see it looks good and I'm satisfied that these changes are heading in the right direction. Especially appreciated changes include the addition of
NSCoding
compliance andNSArray
with type specifications. I also like the changes you've made to the line and frame drawings, and the related issues fixed in that scope. @Boris-Em As you stated in your review, I don't think that the internal API changes here are too severe - and in cases where the changes may affect implementation I think that it would be worth it. - The use of other third-party libraries in this project makes me very nervous. I would imagine that developers looking to integrate a UIKit project would like it to be as self-contained as possible... it's already a risk including a third-party project in your app (let alone including one that relies on other ones, etc.). I think in most cases where these dependencies have been added, they can be removed and replaced with much simpler self-contained solutions (i.e. choose between two fonts or colors).
- In all honesty I am not 100% sure how I feel about the TestBed application. I can see where it may be useful to test all of the different available properties on the graph, however to me it seems that a more effective use of time and resources would be to maintain unit tests and good documentation. Frankly, I can't see a use case for the TestBed that isn't already covered by the sample app, unit tests, and documentation. If testing different properties or features is the goal, I personally find it easier to make the necessary changes in code and then quickly build, run, and analyze. Maybe you could explain where this addition would be helpful?
With that in mind, know that I am open to approving and merging this pull request as is. Once on the feature branch we can work on it and improve it until its at the point where we are ready for master.
Thank you for all of your contributions, @mackworth! This means a lot.
@@ -516,7 +520,7 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel | |||
@param graph The graph object requesting the padding value. | |||
@param popupView The popup view owned by the graph that needs to be modified | |||
@param index The index of the element associated with the popup view */ | |||
- (void)lineGraph:(BEMSimpleLineGraphView *)graph modifyPopupView:(UIView *)popupView forIndex:(NSUInteger)index __unavailable; | |||
- (void)lineGraph:(BEMSimpleLineGraphView *)graph modifyPopupView:(UIView *)popupView forIndex:(NSUInteger)index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential misunderstanding here... why has this been marked as available again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, never saw it as unavailable. Why was it taken out? How are you supposed to use the custom Popup if it stays the same on every point?
Classes/BEMSimpleLineGraphView.m
Outdated
#pragma clang diagnostic pop | ||
} | ||
|
||
- (void) encodeWithEncoder: (NSCoder *)coder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love ❤️ that you've added NSCoding support to this object. If not already written, unit tests for this should be added. Documentation should also cover this.
- (void)layoutNumberOfPoints { | ||
// Get the total number of data points from the delegate | ||
#ifndef TARGET_INTERFACE_BUILDER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, good move with the interface builder compatibility.
|
||
if (self.enableTouchReport && [self.delegate respondsToSelector:@selector(lineGraph:didTouchGraphWithClosestIndex:)]) { | ||
[self.delegate lineGraph:self didTouchGraphWithClosestIndex:index]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this was introduced in this PR but it looks like when the data source provides a BEMNullGraphValue for a data point it also gets returned by the touch report and displayed in popup views. Something to look into... should be an easy fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think so; circleDots aren't created when there's no value, so closestDotfromTouchInputLine can't see them. I tried it in TestBed and it didn't show null values.
@@ -35,7 +35,7 @@ | |||
|
|||
|
|||
/// Dash pattern for the average line | |||
@property (strong, nonatomic, nullable) NSArray *dashPattern; | |||
@property (strong, nonatomic, nullable) NSArray <NSNumber *> *dashPattern; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Love these changes! Perfect!
|
||
@import UIKit; | ||
|
||
@class ARFontPickerViewController; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very wary of using third-party dependencies for a demo / test app included with the project unless it is absolutely necessary. While this is a robust solution, it may be better to simply include a toggle between two hard-coded system-installed fonts.
@@ -142,26 +143,62 @@ - (void)drawRect:(CGRect)rect { | |||
|
|||
self.points = [NSMutableArray arrayWithCapacity:self.arrayOfPoints.count]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely agreed. Maybe this is something we can work on after merging...
@@ -12,7 +12,7 @@ | |||
#pragma clang diagnostic ignored "-Wfloat-equal" | |||
|
|||
@interface BEMSimpleLineGraphView () | |||
// Allow tester to get to internal properties | |||
//Allow tester to get to internal properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: need space between comment marker and first word.
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class MSSliderView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I am concerned about including third-party components here when not absolutely necessary. For example, this color choice problem can be easily solved with a few lines of our own code that provide a few standard values... rather than relying on external code which may cause issues, need to be rewritten, updated, etc. at some point.
#import "MSColorWheelView.h" | ||
#import "MSColorUtils.h" | ||
|
||
@interface MSColorWheelView () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comments about third-party library inclusion...
Thank you @Sam-Spencer!
|
So, thanks for the nice compliments. To respond to the general points, On the third-party libraries, Boris is correct, there's no dependency for the library itself, just internal to TestBed. The sample app is to see how to incorporate SimpleLineGraphView into your own program; Testbed is to see what all the possibilities are. But as I've said, it's your library :), so let me know. To summarize, I think the open questions are:
|
Avoid comma operator in ColorPicker (compiler correctly complains)
So, @Sam-Spencer, are we good on 1 and 2 above, and any further info on 3 and 4? |
* commit '3dd033de496f74a541c3117f3e7432cbb8bce2c7': (37 commits) Remove unuseful breaking test Update .travis.yml Add "Graph" button to Compact devices Further fixes for more substantive comments on PR Boris-Em#295 Fix top reference line offset bug Adds categories for UIKit extensions in MasterVC Adds Options title for iPhone version of TestBed Only changes in storyboard due to newer IB Requested changes to PR 3295 Fixing breaks, spaces to match project style Explaining constant 4 in BEMLine (note bug on line76 0+offset should be 0) Bug fixes: Line clipsToBounds to avoid drawing outside the box (when extrapolating nulls or user set minValue too High) Top/Bottom reference lines were outside box When Bezier off and Interpolate nulls off, properly draws line segments now Removed VMA NSLog from TestBed/MasterController Fix bug with TouchLineInput color (doesn't change after initial setting) Allow use on iPhone and Split View Fix assorted bugs in BEMSimpleLineGraph, especially null-data related AverageLine: •Color should be picked up from line if not set (default nil) Typo in encoding macro Add colors, gradients, and alphas to TestBed Fix many bugs and buglets Create new TestBed app to manipulate almost all parameters Add coding to AverageLine Move gradient properties to strong to properly retain Fix compiler error about integers used in enums Change alwaysDisplayPopupatIndex to use NSUInteger for index instead of float Fix Frame warning in SimpleLineChart's launch Screen Add Types to all Arrays Add encoder/decoder for BEMLineGraph properties Add averageValue delegate method to allow BEMLineGraph to be separate from BEMCalculator Restore modifyPopUpView delegate method Use caption preferredFont instead of SystemFont fro NoData Handle overlapping labels better Reuse code for popup and permanent labels Travis CI Yet another Travis CI change Update .travis.yml N^th time's a charm? Storyboard Update (to fix Travis CI) Update .travis.yml Update .travis.yml ... # Conflicts: # Classes/BEMLine.m # Classes/BEMSimpleLineGraphView.h # Classes/BEMSimpleLineGraphView.m
@mackworth It looks like when a Interestingly enough, it seems that the graph does not display a dot when it comes across one of these values. Yet it is still also reported back to the delegate in other methods (i.e. Here's what it looks like when this happens: I should also note that this behavior only seems to occur when doing subsequent (non-initial) graph updates (e.g. a point has been added or removed and the graph object is reloaded). |
Use lack of superview to distinguish Null points
Good catch! There was a confusion whether to have the same number of circleDots as dataPoints (including Nulls) or only have one for each valid dataPoint. |
The PR now looks good to merge into the feature branch. Thank you so much for all the work you've done here @mackworth! 🙌 |
Summary
Creates new TestBed application to manipulate essentially all properties. Also miscellaneous bug fixes, particularly around Null data values.
Fixes Issues
This pull request fixes the following issues:
Changes
The following changes are included in this pull request:
NSArray <BEMCircle *> *
)midPoint
calculation.Notes
Include any additional notes on your pull request
After working on another app for a while, I'm back to the one I wanted to use this for, so I've been fixing bugs in the revised version (both mine and long-standing ones). I've merged in the changes that Sam Spencer did, but I may have misunderstood some of those; please check.
In the process of doing this, I wanted a visualization tool that would let me check various attributes beyond what the demo program or IB does. I then got carried away and essentially implemented all the properties. (Remaining unimplemented ones are touchReportFingersRequired, autoScaleYAxis, Dashpatterns for averageLine, XAxis, Yaxis, and Gradient choices beyond a default one.) It also would be cool if it could export to the clipboard the choices you've made into ObjC (or Swift).
The only breaking API change is that I couldn't restrain myself from fixing the multiple typos of Refrence in Line. h. As this is primarily an internal API, I think that's ok, but feel free to put it back if you differ.
I don't think I've broken any real API calls, but there are some changes:
Some of the types are now decorated (e.g. NSArray <NSNumber *> *) and for nullability
alwaysDisplayPopUpAtIndex is now an NSUInteger rather than a CGFloat
Gradients are now strongly held
Added averageValueForLineGraph to delegate
Restored modifyPopupView to be available again; not clear why removed.
Added title and label properties to AverageLine API
As last time, I apologize if I've overstepped, but I really like this library and want it to be as useful as possible