Skip to content

Commit 30dfcd8

Browse files
committed
Misc NSInteger type issues when compiling with strict and floats on 32 bit fr
Add EOL to some files Fix for bezier edge of closed background (need to simplify) New delegate to reformat yaxis labels don't remove top level views when no data Calc locations after sections laid out Fix for right hand label out of bounds
1 parent 5c5bcf3 commit 30dfcd8

9 files changed

Lines changed: 138 additions & 82 deletions

File tree

Classes/BEMAverageLine.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ - (instancetype) initWithCoder:(NSCoder *)coder {
3535

3636
RestoreProperty (enableAverageLine, Bool);
3737
RestoreProperty (color, Object);
38-
RestoreProperty (yValue, Double);
39-
RestoreProperty (alpha, Double);
40-
RestoreProperty (width, Double);
38+
RestoreProperty (yValue, Float);
39+
RestoreProperty (alpha, Float);
40+
RestoreProperty (width, Float);
4141
RestoreProperty (dashPattern, Object);
4242
RestoreProperty (title, Object);
4343
#pragma clang diagnostic pop
@@ -51,9 +51,9 @@ - (void) encodeWithCoder: (NSCoder *)coder {
5151
#define EncodeProperty(property, type) [coder encode ## type: self.property forKey:@#property]
5252
EncodeProperty (enableAverageLine, Bool);
5353
EncodeProperty (color, Object);
54-
EncodeProperty (yValue, Float);
55-
EncodeProperty (alpha, Float);
56-
EncodeProperty (width, Float);
54+
EncodeProperty (yValue, Double);
55+
EncodeProperty (alpha, Double);
56+
EncodeProperty (width, Double);
5757
EncodeProperty (dashPattern, Object);
5858
EncodeProperty (title, Object);
5959
}

Classes/BEMCircle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
/// The value of the point
2929
@property (nonatomic) CGFloat absoluteValue;
3030

31-
@end
31+
@end

Classes/BEMCircle.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ - (void)drawRect:(CGRect)rect {
2727
CGContextFillPath(ctx);
2828
}
2929

30-
@end
30+
@end

Classes/BEMGraphCalculator.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ - (NSNumber *)calculateCorrelationCoefficientUsingCorrelationMethod:(BEMCorrelat
272272
// Calculate the correlational value
273273
CGFloat numeratorFirstChunk = (pointsCount * sumXY); // Calculate the mean of the points
274274
CGFloat numeratorSecondChunk = (sumX * sumY); // Calculate total graph values
275-
CGFloat denomenatorFirstChunk = sqrt(pointsCount * sumX2 - (sumX * sumX)); // Square root of the sum of all X-Values squared
276-
CGFloat denomenatorSecondChunk = sqrt(pointsCount * sumY2 - (sumY * sumY)); // Square root of the sum of all Y-Values squared
277-
CGFloat correlation = (numeratorFirstChunk - numeratorSecondChunk) / (denomenatorFirstChunk * denomenatorSecondChunk);
275+
double denomenatorFirstChunk = sqrt(pointsCount * sumX2 - (sumX * sumX)); // Square root of the sum of all X-Values squared
276+
double denomenatorSecondChunk = sqrt(pointsCount * sumY2 - (sumY * sumY)); // Square root of the sum of all Y-Values squared
277+
double correlation = (numeratorFirstChunk - numeratorSecondChunk) / (denomenatorFirstChunk * denomenatorSecondChunk);
278278

279279
// NSLog(@"CORRELATION:\nSlope: %f\nIntercept:%f\nCorrelation:%f", slope, intercept, correlation);
280280

281-
return [NSNumber numberWithFloat:correlation];
281+
return @(correlation);
282282
}
283283

284284
- (BEMPearsonCorrelationStrength)calculatePearsonCorrelationStrengthOnGraph:(BEMSimpleLineGraphView *)graph xAxisScale:(nonnull NSNumber *)scale {

Classes/BEMLine.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ - (void)drawRect:(CGRect)rect {
7373
if (self.enableReferenceLines == YES) {
7474
if (self.arrayOfVerticalReferenceLinePoints.count > 0) {
7575
for (NSNumber *xNumber in self.arrayOfVerticalReferenceLinePoints) {
76-
CGFloat xValue =[xNumber doubleValue];
76+
CGFloat xValue =[xNumber floatValue];
7777
CGPoint initialPoint = CGPointMake(xValue, self.frame.size.height);
7878
CGPoint finalPoint = CGPointMake(xValue, 0);
7979

@@ -333,7 +333,7 @@ - (void)drawRect:(CGRect)rect {
333333
}
334334

335335
static CGPoint midPointForPoints(CGPoint p1, CGPoint p2) {
336-
CGFloat avgY = (p1.y + p2.y) / 2.0;
336+
CGFloat avgY = (p1.y + p2.y) / 2.0f;
337337
if (isinf(avgY)) avgY = BEMNullGraphValue;
338338
return CGPointMake((p1.x + p2.x) / 2, avgY);
339339
}
@@ -344,14 +344,16 @@ + (UIBezierPath *)pathWithPoints:(NSArray <NSValue *> *)points curved:(BOOL) cur
344344
//Also, if not open, then first/last points are for frame, and should not affect curve.
345345
UIBezierPath *path = [UIBezierPath bezierPath];
346346
CGPoint p1 = [points[0] CGPointValue];
347-
NSUInteger dataStart = open ? 1 : 2;
348-
NSUInteger dataEnd = points.count-(open ? 1 : 2);
347+
NSUInteger dataStart = 1;
348+
NSUInteger dataEnd = points.count-1;
349349
[path moveToPoint:p1];
350350
if (!open) {
351-
//skip first point (not data)
352-
dataStart = 2;
353-
p1 = [points[1] CGPointValue];
351+
//skip first/last points (frame, not data) to ensure line/frame use same bezier path
352+
[path addLineToPoint:[points[1] CGPointValue]];
353+
p1 = [points[2] CGPointValue];
354354
[path addLineToPoint:p1];
355+
dataStart += 2;
356+
dataEnd -= 2;
355357
}
356358
CGPoint oldControlPoint = p1;
357359
for (NSUInteger pointIndex = dataStart; pointIndex< points.count; pointIndex++) {

Classes/BEMSimpleLineGraphView.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,15 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
430430
*/
431431
- (nullable NSString *)lineGraph:(nonnull BEMSimpleLineGraphView *)graph labelOnXAxisForLocation:(CGFloat)location;
432432

433+
//------- Y AXIS -------//
434+
435+
/** The string to display on the label on the Y-axis at a given value.
436+
@discussion this overrids yAxisPrefixOnLineGraph and yAxisSuffixfixOnLineGraph.
437+
@param graph The graph object which is requesting the label on the specified Y-Axis position.
438+
@param location The value for a label in the same units/range as valueForPointAtIndex.
439+
*/
440+
- (nullable NSString *)lineGraph:(nonnull BEMSimpleLineGraphView *)graph labelOnYAxisForValue:(CGFloat)value;
441+
433442

434443
@end
435444

0 commit comments

Comments
 (0)