Skip to content

Commit

Permalink
Add option to draw grid lines in front of data
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi authored and SwiftPolar committed Mar 20, 2023
1 parent ba680ba commit 10c245f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
17 changes: 14 additions & 3 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
rightYAxisRenderer.renderAxisLine(context: context)

// 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
{
Expand All @@ -234,6 +237,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
}
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 (valuesToHighlight())
{
Expand Down
12 changes: 11 additions & 1 deletion Source/Charts/Components/AxisBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ open class AxisBase: ComponentBase
private var _limitLines = [ChartLimitLine]()

/// Are the LimitLines drawn behind the data or in front of the data?
///
///
/// **default**: 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
@objc open var gridAntialiasEnabled = true
Expand Down Expand Up @@ -188,6 +193,11 @@ open class AxisBase: ComponentBase
/// **default**: false
@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`
@objc open var spaceMin: Double = 0.0

Expand Down

0 comments on commit 10c245f

Please sign in to comment.