From 9a7aeb242da614893ee98e5ce0398fc62528abab Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Sun, 22 May 2016 15:20:06 +0300 Subject: [PATCH] Clip drawing area of limit lines when !isDrawLimitLinesBehindDataEnabled (Closes #1052) --- .../Classes/Charts/BarLineChartViewBase.swift | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Charts/Classes/Charts/BarLineChartViewBase.swift b/Charts/Classes/Charts/BarLineChartViewBase.swift index c252da5f67..fbb1e2db73 100644 --- a/Charts/Classes/Charts/BarLineChartViewBase.swift +++ b/Charts/Classes/Charts/BarLineChartViewBase.swift @@ -216,52 +216,55 @@ public class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChar // make sure the graph values and grid cannot be drawn outside the content-rect CGContextSaveGState(context) - CGContextClipToRect(context, _viewPortHandler.contentRect) _xAxisRenderer?.renderGridLines(context: context) _leftYAxisRenderer?.renderGridLines(context: context) _rightYAxisRenderer?.renderGridLines(context: context) - if (_xAxis.isDrawLimitLinesBehindDataEnabled) + if _xAxis.isDrawLimitLinesBehindDataEnabled { _xAxisRenderer?.renderLimitLines(context: context) } - if (_leftAxis.isDrawLimitLinesBehindDataEnabled) + if _leftAxis.isDrawLimitLinesBehindDataEnabled { _leftYAxisRenderer?.renderLimitLines(context: context) } - if (_rightAxis.isDrawLimitLinesBehindDataEnabled) + if _rightAxis.isDrawLimitLinesBehindDataEnabled { _rightYAxisRenderer?.renderLimitLines(context: context) } renderer?.drawData(context: context) - + // if highlighting is enabled if (valuesToHighlight()) { renderer?.drawHighlighted(context: context, indices: _indicesToHighlight) } - - // Removes clipping rectangle + CGContextRestoreGState(context) renderer!.drawExtras(context: context) - if (!_xAxis.isDrawLimitLinesBehindDataEnabled) + CGContextSaveGState(context) + CGContextClipToRect(context, _viewPortHandler.contentRect) + + if !_xAxis.isDrawLimitLinesBehindDataEnabled { _xAxisRenderer?.renderLimitLines(context: context) } - if (!_leftAxis.isDrawLimitLinesBehindDataEnabled) + if !_leftAxis.isDrawLimitLinesBehindDataEnabled { _leftYAxisRenderer?.renderLimitLines(context: context) } - if (!_rightAxis.isDrawLimitLinesBehindDataEnabled) + if !_rightAxis.isDrawLimitLinesBehindDataEnabled { _rightYAxisRenderer?.renderLimitLines(context: context) } + CGContextRestoreGState(context) + _xAxisRenderer.renderAxisLabels(context: context) _leftYAxisRenderer.renderAxisLabels(context: context) _rightYAxisRenderer.renderAxisLabels(context: context)