@@ -14,6 +14,7 @@ import com.github.mikephil.charting.utils.Transformer
1414import com.github.mikephil.charting.utils.Utils
1515import com.github.mikephil.charting.utils.ViewPortHandler
1616import androidx.core.graphics.withSave
17+ import androidx.core.graphics.withClip
1718
1819open class YAxisRenderer (viewPortHandler : ViewPortHandler , @JvmField protected var yAxis : YAxis , trans : Transformer ? ) :
1920 AxisRenderer (viewPortHandler, trans, yAxis) {
@@ -135,27 +136,25 @@ open class YAxisRenderer(viewPortHandler: ViewPortHandler, @JvmField protected v
135136 if (! yAxis.isEnabled) return
136137
137138 if (yAxis.isDrawGridLinesEnabled) {
138- val clipRestoreCount = c.save()
139- c.clipRect(gridClippingRect !! )
139+ c.withClip(gridClippingRect !! ) {
140+ val positions = transformedPositions
140141
141- val positions = transformedPositions
142+ paintGrid.color = yAxis.gridColor
143+ paintGrid.strokeWidth = yAxis.gridLineWidth
144+ paintGrid.setPathEffect(yAxis.gridDashPathEffect)
142145
143- paintGrid.color = yAxis.gridColor
144- paintGrid.strokeWidth = yAxis.gridLineWidth
145- paintGrid.setPathEffect(yAxis.gridDashPathEffect)
146-
147- val gridLinePath = renderGridLinesPath
148- gridLinePath.reset()
149-
150- // draw the grid
151- var i = 0
152- while (i < positions.size) {
153- // draw a path because lines don't support dashing on lower android versions
154- c.drawPath(linePath(gridLinePath, i, positions)!! , paintGrid)
146+ val gridLinePath = renderGridLinesPath
155147 gridLinePath.reset()
156- i + = 2
148+
149+ // draw the grid
150+ var i = 0
151+ while (i < positions.size) {
152+ // draw a path because lines don't support dashing on lower android versions
153+ c.drawPath(linePath(gridLinePath, i, positions)!! , paintGrid)
154+ gridLinePath.reset()
155+ i + = 2
156+ }
157157 }
158- c.restoreToCount(clipRestoreCount)
159158 }
160159
161160
0 commit comments