diff --git a/Charts/Classes/Components/ChartAxisBase.swift b/Charts/Classes/Components/ChartAxisBase.swift index 3119844ec2..4de4147533 100644 --- a/Charts/Classes/Components/ChartAxisBase.swift +++ b/Charts/Classes/Components/ChartAxisBase.swift @@ -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.Butt public var drawGridLinesEnabled = true public var drawAxisLineEnabled = true diff --git a/Charts/Classes/Renderers/ChartXAxisRenderer.swift b/Charts/Classes/Renderers/ChartXAxisRenderer.swift index 4811855e7e..77f3bc90a2 100644 --- a/Charts/Classes/Renderers/ChartXAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartXAxisRenderer.swift @@ -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) diff --git a/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift b/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift index 59012fba1a..1c8205836d 100644 --- a/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift +++ b/Charts/Classes/Renderers/ChartXAxisRendererBarChart.swift @@ -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) diff --git a/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift b/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift index 82bc411902..f8b61a62be 100644 --- a/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift +++ b/Charts/Classes/Renderers/ChartXAxisRendererHorizontalBarChart.swift @@ -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) diff --git a/Charts/Classes/Renderers/ChartYAxisRenderer.swift b/Charts/Classes/Renderers/ChartYAxisRenderer.swift index d2ee98e4a7..3f48dfae35 100644 --- a/Charts/Classes/Renderers/ChartYAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartYAxisRenderer.swift @@ -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) diff --git a/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift b/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift index 86bb20f85f..af4c3b65ea 100644 --- a/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift +++ b/Charts/Classes/Renderers/ChartYAxisRendererHorizontalBarChart.swift @@ -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) diff --git a/ChartsDemo/Classes/Demos/LineChart1ViewController.m b/ChartsDemo/Classes/Demos/LineChart1ViewController.m index 579fcda079..f8bd097b09 100644 --- a/ChartsDemo/Classes/Demos/LineChart1ViewController.m +++ b/ChartsDemo/Classes/Demos/LineChart1ViewController.m @@ -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;