Selaa lähdekoodia

Merge branch 'feature/grid_lines_behind_data'

* feature/grid_lines_behind_data:
  Add option to draw grid lines in front of data
Daniel Cohen Gindi 5 vuotta sitten
vanhempi
commit
67fe2f40dc

+ 14 - 3
Source/Charts/Charts/BarLineChartViewBase.swift

@@ -208,9 +208,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
         rightYAxisRenderer.renderAxisLine(context: context)
         rightYAxisRenderer.renderAxisLine(context: context)
 
 
         // The renderers are responsible for clipping, to account for line-width center etc.
         // The renderers are responsible for clipping, to account for line-width center etc.
-        xAxisRenderer.renderGridLines(context: context)
-        leftYAxisRenderer.renderGridLines(context: context)
-        rightYAxisRenderer.renderGridLines(context: context)
+        if xAxis.drawGridLinesBehindDataEnabled
+        {
+            xAxisRenderer.renderGridLines(context: context)
+            leftYAxisRenderer.renderGridLines(context: context)
+            rightYAxisRenderer.renderGridLines(context: context)
+        }
         
         
         if _xAxis.isEnabled && _xAxis.isDrawLimitLinesBehindDataEnabled
         if _xAxis.isEnabled && _xAxis.isDrawLimitLinesBehindDataEnabled
         {
         {
@@ -234,6 +237,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
         }
         }
         renderer.drawData(context: context)
         renderer.drawData(context: context)
         
         
+        // The renderers are responsible for clipping, to account for line-width center etc.
+        if !xAxis.drawGridLinesBehindDataEnabled
+        {
+            xAxisRenderer.renderGridLines(context: context)
+            leftYAxisRenderer.renderGridLines(context: context)
+            rightYAxisRenderer.renderGridLines(context: context)
+        }
+        
         // if highlighting is enabled
         // if highlighting is enabled
         if (valuesToHighlight())
         if (valuesToHighlight())
         {
         {

+ 11 - 1
Source/Charts/Components/AxisBase.swift

@@ -63,9 +63,14 @@ open class AxisBase: ComponentBase
     private var _limitLines = [ChartLimitLine]()
     private var _limitLines = [ChartLimitLine]()
     
     
     /// Are the LimitLines drawn behind the data or in front of the data?
     /// Are the LimitLines drawn behind the data or in front of the data?
-    /// 
+    ///
     /// **default**: false
     /// **default**: false
     @objc open var drawLimitLinesBehindDataEnabled = false
     @objc open var drawLimitLinesBehindDataEnabled = false
+    
+    /// Are the grid lines drawn behind the data or in front of the data?
+    ///
+    /// **default**: true
+    @objc open var drawGridLinesBehindDataEnabled = true
 
 
     /// the flag can be used to turn off the antialias for grid lines
     /// the flag can be used to turn off the antialias for grid lines
     @objc open var gridAntialiasEnabled = true
     @objc open var gridAntialiasEnabled = true
@@ -188,6 +193,11 @@ open class AxisBase: ComponentBase
     /// **default**: false
     /// **default**: false
     @objc open var isDrawLimitLinesBehindDataEnabled: Bool { return drawLimitLinesBehindDataEnabled }
     @objc open var isDrawLimitLinesBehindDataEnabled: Bool { return drawLimitLinesBehindDataEnabled }
     
     
+    /// Are the grid lines drawn behind the data or in front of the data?
+    ///
+    /// **default**: true
+    @objc open var isDrawGridLinesBehindDataEnabled: Bool { return drawGridLinesBehindDataEnabled }
+    
     /// Extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
     /// Extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
     @objc open var spaceMin: Double = 0.0
     @objc open var spaceMin: Double = 0.0