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

Commit

Permalink
Merge pull request #218 from dkk/master
Browse files Browse the repository at this point in the history
Reference Line Width
  • Loading branch information
Sam Spencer committed Jul 31, 2015
2 parents 929df84 + fb81820 commit 0bb60c9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
3 changes: 3 additions & 0 deletions Classes/BEMLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ typedef NS_ENUM(NSUInteger, BEMLineGradientDirection) {
/// The width of the line
@property (nonatomic) float lineWidth;

/// The width of a reference line
@property (nonatomic) float referenceLineWidth;



//----- BEZIER CURVE -----//
Expand Down
16 changes: 8 additions & 8 deletions Classes/BEMLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ - (void)drawRect:(CGRect)rect {

if (self.enableLeftReferenceFrameLine) {
// Left Line
[referenceFramePath moveToPoint:CGPointMake(0+self.lineWidth/4, self.frame.size.height)];
[referenceFramePath addLineToPoint:CGPointMake(0+self.lineWidth/4, 0)];
[referenceFramePath moveToPoint:CGPointMake(0+self.referenceLineWidth/4, self.frame.size.height)];
[referenceFramePath addLineToPoint:CGPointMake(0+self.referenceLineWidth/4, 0)];
}

if (self.enableTopReferenceFrameLine) {
// Top Line
[referenceFramePath moveToPoint:CGPointMake(0+self.lineWidth/4, 0)];
[referenceFramePath moveToPoint:CGPointMake(0+self.referenceLineWidth/4, 0)];
[referenceFramePath addLineToPoint:CGPointMake(self.frame.size.width, 0)];
}

if (self.enableRightReferenceFrameLine) {
// Right Line
[referenceFramePath moveToPoint:CGPointMake(self.frame.size.width - self.lineWidth/4, self.frame.size.height)];
[referenceFramePath addLineToPoint:CGPointMake(self.frame.size.width - self.lineWidth/4, 0)];
[referenceFramePath moveToPoint:CGPointMake(self.frame.size.width - self.referenceLineWidth/4, self.frame.size.height)];
[referenceFramePath addLineToPoint:CGPointMake(self.frame.size.width - self.referenceLineWidth/4, 0)];
}

[referenceFramePath closePath];
Expand Down Expand Up @@ -268,7 +268,7 @@ - (void)drawRect:(CGRect)rect {
verticalReferenceLinesPathLayer.path = verticalReferenceLinesPath.CGPath;
verticalReferenceLinesPathLayer.opacity = self.lineAlpha == 0 ? 0.1 : self.lineAlpha/2;
verticalReferenceLinesPathLayer.fillColor = nil;
verticalReferenceLinesPathLayer.lineWidth = self.lineWidth/2;
verticalReferenceLinesPathLayer.lineWidth = self.referenceLineWidth/2;

if (self.lineDashPatternForReferenceYAxisLines) {
verticalReferenceLinesPathLayer.lineDashPattern = self.lineDashPatternForReferenceYAxisLines;
Expand All @@ -290,7 +290,7 @@ - (void)drawRect:(CGRect)rect {
horizontalReferenceLinesPathLayer.path = horizontalReferenceLinesPath.CGPath;
horizontalReferenceLinesPathLayer.opacity = self.lineAlpha == 0 ? 0.1 : self.lineAlpha/2;
horizontalReferenceLinesPathLayer.fillColor = nil;
horizontalReferenceLinesPathLayer.lineWidth = self.lineWidth/2;
horizontalReferenceLinesPathLayer.lineWidth = self.referenceLineWidth/2;
if(self.lineDashPatternForReferenceXAxisLines) {
horizontalReferenceLinesPathLayer.lineDashPattern = self.lineDashPatternForReferenceXAxisLines;
}
Expand All @@ -311,7 +311,7 @@ - (void)drawRect:(CGRect)rect {
referenceLinesPathLayer.path = referenceFramePath.CGPath;
referenceLinesPathLayer.opacity = self.lineAlpha == 0 ? 0.1 : self.lineAlpha/2;
referenceLinesPathLayer.fillColor = nil;
referenceLinesPathLayer.lineWidth = self.lineWidth/2;
referenceLinesPathLayer.lineWidth = self.referenceLineWidth/2;

if (self.refrenceLineColor) referenceLinesPathLayer.strokeColor = self.refrenceLineColor.CGColor;
else referenceLinesPathLayer.strokeColor = self.color.CGColor;
Expand Down
4 changes: 4 additions & 0 deletions Classes/BEMSimpleLineGraphView.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
@property (nonatomic) IBInspectable CGFloat widthLine;


/// Width of the reference lines of the graph. Default is the value of widthLine/2.
@property (nonatomic) IBInspectable CGFloat widthReferenceLines;


/// Color of the reference lines of the graph. Default is same color as `colorLine`.
@property (strong, nonatomic) UIColor *colorReferenceLines;

Expand Down
2 changes: 2 additions & 0 deletions Classes/BEMSimpleLineGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ - (void)commonInit {

// Set Size Values
_widthLine = 1.0;
_widthReferenceLines = 1.0;
_sizePoint = 10.0;

// Set Default Feature Values
Expand Down Expand Up @@ -580,6 +581,7 @@ - (void)drawLine {
line.topGradient = self.gradientTop;
line.bottomGradient = self.gradientBottom;
line.lineWidth = self.widthLine;
line.referenceLineWidth = self.widthReferenceLines?self.widthReferenceLines:(self.widthLine/2);
line.lineAlpha = self.alphaLine;
line.bezierCurveIsEnabled = self.enableBezierCurve;
line.arrayOfPoints = yAxisValues;
Expand Down
Loading

0 comments on commit 0bb60c9

Please sign in to comment.