Skip to content

Commit

Permalink
add an option to set line cap of axis grid line
Browse files Browse the repository at this point in the history
  • Loading branch information
mconintet committed Jan 9, 2016
1 parent b9f9972 commit 1d8a24a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions Charts/Classes/Components/ChartAxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ChartAxisBase: ChartComponentBase
public var gridLineWidth = CGFloat(0.5)
public var gridLineDashPhase = CGFloat(0.0)
public var gridLineDashLengths: [CGFloat]!
public var gridLineCap = CGLineCap.Square

public var drawGridLinesEnabled = true
public var drawAxisLineEnabled = true
Expand Down
2 changes: 2 additions & 0 deletions Charts/Classes/Renderers/ChartXAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ public class ChartXAxisRenderer: ChartAxisRendererBase

CGContextSetStrokeColorWithColor(context, _xAxis.gridColor.CGColor)
CGContextSetLineWidth(context, _xAxis.gridLineWidth)
CGContextSetLineCap(context, _xAxis.gridLineCap)

if (_xAxis.gridLineDashLengths != nil)
{
CGContextSetLineDash(context, _xAxis.gridLineDashPhase, _xAxis.gridLineDashLengths, _xAxis.gridLineDashLengths.count)
Expand Down
2 changes: 2 additions & 0 deletions Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public class ChartXAxisRendererBarChart: ChartXAxisRenderer

CGContextSetStrokeColorWithColor(context, _xAxis.gridColor.CGColor)
CGContextSetLineWidth(context, _xAxis.gridLineWidth)
CGContextSetLineCap(context, _xAxis.gridLineCap)

if (_xAxis.gridLineDashLengths != nil)
{
CGContextSetLineDash(context, _xAxis.gridLineDashPhase, _xAxis.gridLineDashLengths, _xAxis.gridLineDashLengths.count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public class ChartXAxisRendererHorizontalBarChart: ChartXAxisRendererBarChart

CGContextSetStrokeColorWithColor(context, _xAxis.gridColor.CGColor)
CGContextSetLineWidth(context, _xAxis.gridLineWidth)
CGContextSetLineCap(context, _xAxis.gridLineCap)

if (_xAxis.gridLineDashLengths != nil)
{
CGContextSetLineDash(context, _xAxis.gridLineDashPhase, _xAxis.gridLineDashLengths, _xAxis.gridLineDashLengths.count)
Expand Down
2 changes: 2 additions & 0 deletions Charts/Classes/Renderers/ChartYAxisRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ public class ChartYAxisRenderer: ChartAxisRendererBase

CGContextSetStrokeColorWithColor(context, _yAxis.gridColor.CGColor)
CGContextSetLineWidth(context, _yAxis.gridLineWidth)
CGContextSetLineCap(context, _yAxis.gridLineCap)

if (_yAxis.gridLineDashLengths != nil)
{
CGContextSetLineDash(context, _yAxis.gridLineDashPhase, _yAxis.gridLineDashLengths, _yAxis.gridLineDashLengths.count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ public class ChartYAxisRendererHorizontalBarChart: ChartYAxisRenderer

CGContextSetStrokeColorWithColor(context, _yAxis.gridColor.CGColor)
CGContextSetLineWidth(context, _yAxis.gridLineWidth)
CGContextSetLineCap(context, _yAxis.gridLineCap)

if (_yAxis.gridLineDashLengths != nil)
{
CGContextSetLineDash(context, _yAxis.gridLineDashPhase, _yAxis.gridLineDashLengths, _yAxis.gridLineDashLengths.count)
Expand Down
2 changes: 2 additions & 0 deletions ChartsDemo/Classes/Demos/LineChart1ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ - (void)viewDidLoad
leftAxis.customAxisMin = -50.0;
leftAxis.startAtZeroEnabled = NO;
leftAxis.gridLineDashLengths = @[@5.f, @5.f];
leftAxis.gridLineWidth = 2;
leftAxis.gridLineCap = kCGLineCapRound;
leftAxis.drawLimitLinesBehindDataEnabled = YES;

_chartView.rightAxis.enabled = NO;
Expand Down

0 comments on commit 1d8a24a

Please sign in to comment.