From 48b9dc76ed7d91061e7d1b879b7eef5b39779b41 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Sun, 11 Oct 2015 22:54:12 +0300 Subject: [PATCH] Add ability to turn off antialias for grid lines --- Charts/Classes/Components/ChartAxisBase.swift | 3 +++ Charts/Classes/Renderers/ChartXAxisRenderer.swift | 7 ++++++- Charts/Classes/Renderers/ChartYAxisRenderer.swift | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Charts/Classes/Components/ChartAxisBase.swift b/Charts/Classes/Components/ChartAxisBase.swift index 1bfda86692..3119844ec2 100644 --- a/Charts/Classes/Components/ChartAxisBase.swift +++ b/Charts/Classes/Components/ChartAxisBase.swift @@ -44,6 +44,9 @@ public class ChartAxisBase: ChartComponentBase /// **default**: false public var drawLimitLinesBehindDataEnabled = false + /// the flag can be used to turn off the antialias for grid lines + public var gridAntialiasEnabled = true + public override init() { super.init() diff --git a/Charts/Classes/Renderers/ChartXAxisRenderer.swift b/Charts/Classes/Renderers/ChartXAxisRenderer.swift index 5394302863..29f241a9f1 100644 --- a/Charts/Classes/Renderers/ChartXAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartXAxisRenderer.swift @@ -201,7 +201,12 @@ public class ChartXAxisRenderer: ChartAxisRendererBase } CGContextSaveGState(context) - + + if (!_xAxis.gridAntialiasEnabled) + { + CGContextSetShouldAntialias(context, false) + } + CGContextSetStrokeColorWithColor(context, _xAxis.gridColor.CGColor) CGContextSetLineWidth(context, _xAxis.gridLineWidth) if (_xAxis.gridLineDashLengths != nil) diff --git a/Charts/Classes/Renderers/ChartYAxisRenderer.swift b/Charts/Classes/Renderers/ChartYAxisRenderer.swift index d2ef5d3059..419a7cd171 100644 --- a/Charts/Classes/Renderers/ChartYAxisRenderer.swift +++ b/Charts/Classes/Renderers/ChartYAxisRenderer.swift @@ -274,7 +274,12 @@ public class ChartYAxisRenderer: ChartAxisRendererBase } CGContextSaveGState(context) - + + if (!_yAxis.gridAntialiasEnabled) + { + CGContextSetShouldAntialias(context, false) + } + CGContextSetStrokeColorWithColor(context, _yAxis.gridColor.CGColor) CGContextSetLineWidth(context, _yAxis.gridLineWidth) if (_yAxis.gridLineDashLengths != nil)