Skip to content

Commit

Permalink
Add option to disable clipping data to contentRect (#3360)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtmoose authored and jjatie committed Mar 30, 2018
1 parent 1a95a1f commit 269fef7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
/// When enabled, the values will be clipped to contentRect, otherwise they can bleed outside the content rect.
@objc open var clipValuesToContentEnabled: Bool = false

/// When disabled, the data and/or highlights will not be clipped to contentRect. Disabling this option can
/// be useful, when the data lies fully within the content rect, but is drawn in such a way (such as thick lines)
/// that there is unwanted clipping.
@objc open var clipDataToContentEnabled: Bool = true

/// Sets the minimum offset (padding) around the chart, defaults to 10
@objc open var minOffset = CGFloat(10.0)

Expand Down Expand Up @@ -218,9 +223,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
rightYAxisRenderer.renderLimitLines(context: context)
}

// make sure the data cannot be drawn outside the content-rect
context.saveGState()
context.clip(to: _viewPortHandler.contentRect)
// make sure the data cannot be drawn outside the content-rect
if clipDataToContentEnabled {
context.clip(to: _viewPortHandler.contentRect)
}
renderer.drawData(context: context)

// if highlighting is enabled
Expand Down

0 comments on commit 269fef7

Please sign in to comment.