From 63a1d9167870b1e4d45bd748ae6ca440d32cd1d7 Mon Sep 17 00:00:00 2001 From: Gavin Bunney Date: Sun, 2 Nov 2014 15:30:41 +1000 Subject: [PATCH] Split enableReferenceAxisLines into two properties Allow individual specifying of just X, Y or both reference lines --- Classes/BEMSimpleLineGraphView.h | 9 ++++++--- Classes/BEMSimpleLineGraphView.m | 9 ++++----- Sample Project/SimpleLineChart/ViewController.m | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Classes/BEMSimpleLineGraphView.h b/Classes/BEMSimpleLineGraphView.h index 75738a2..45944f7 100644 --- a/Classes/BEMSimpleLineGraphView.h +++ b/Classes/BEMSimpleLineGraphView.h @@ -170,11 +170,14 @@ @property (nonatomic) BOOL autoScaleYAxis; -/// Draws a translucent vertical lines along the graph for each X-Axis label, when set to YES. Default value is NO. -@property (nonatomic) BOOL enableReferenceAxisLines; +/// Draws a translucent vertical lines along the graph for each X-Axis when set to YES. Default value is NO. +@property (nonatomic) BOOL enableReferenceXAxisLines; + +/// Draws a translucent horizontal lines along the graph for each Y-Axis label, when set to YES. Default value is NO. +@property (nonatomic) BOOL enableReferenceYAxisLines; /** Draws a translucent frame between the graph and any enabled axis, when set to YES. Default value is NO. - @see enableReferenceAxisLines must be set to YES for this property to have any affect. */ + @see enableReferenceXAxisLines or enableReferenceYAxisLines must be set to YES for this property to have any affect. */ @property (nonatomic) BOOL enableReferenceAxisFrame; diff --git a/Classes/BEMSimpleLineGraphView.m b/Classes/BEMSimpleLineGraphView.m index 7abfd8f..a03bbe6 100644 --- a/Classes/BEMSimpleLineGraphView.m +++ b/Classes/BEMSimpleLineGraphView.m @@ -437,13 +437,12 @@ - (void)drawLine { } else { line.xAxisBackgroundColor = self.colorBackgroundXaxis; } - if (self.enableReferenceAxisLines == YES) { - if (self.enableReferenceAxisFrame) line.enableRefrenceFrame = YES; - else line.enableRefrenceFrame = NO; + if (self.enableReferenceXAxisLines || self.enableReferenceYAxisLines) { + line.enableRefrenceFrame = self.enableReferenceAxisFrame; line.enableRefrenceLines = YES; - line.arrayOfVerticalRefrenceLinePoints = xAxisLabelPoints; - line.arrayOfHorizontalRefrenceLinePoints = yAxisLabelPoints; + line.arrayOfVerticalRefrenceLinePoints = self.enableReferenceXAxisLines ? xAxisLabelPoints : nil; + line.arrayOfHorizontalRefrenceLinePoints = self.enableReferenceYAxisLines ? yAxisLabelPoints : nil; } line.frameOffset = self.XAxisLabelYOffset; diff --git a/Sample Project/SimpleLineChart/ViewController.m b/Sample Project/SimpleLineChart/ViewController.m index 69875fe..c22d634 100644 --- a/Sample Project/SimpleLineChart/ViewController.m +++ b/Sample Project/SimpleLineChart/ViewController.m @@ -57,7 +57,8 @@ - (void)viewDidLoad { self.myGraph.enableYAxisLabel = YES; self.myGraph.autoScaleYAxis = YES; self.myGraph.alwaysDisplayDots = NO; - self.myGraph.enableReferenceAxisLines = YES; + self.myGraph.enableReferenceXAxisLines = YES; + self.myGraph.enableReferenceYAxisLines = YES; self.myGraph.enableReferenceAxisFrame = YES; self.myGraph.animationGraphStyle = BEMLineAnimationDraw;