Skip to content

Commit

Permalink
Fix a crash when setting holeColor = nil (Fixes ChartsOrg#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Jan 27, 2016
1 parent 607c451 commit 33f30f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Charts/Classes/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ public class PieChartView: PieRadarChartViewBase
{
get
{
return (renderer as! PieChartRenderer).holeColor!
return (renderer as? PieChartRenderer)?.holeColor
}
set
{
(renderer as! PieChartRenderer).holeColor = newValue
(renderer as? PieChartRenderer)?.holeColor = newValue
setNeedsDisplay()
}
}
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ public class PieChartRenderer: ChartDataRendererBase
let holeRadius = radius * holeRadiusPercent
let center = chart.centerCircleBox

if (holeColor !== nil && holeColor != UIColor.clearColor())
if holeColor !== nil && holeColor != UIColor.clearColor()
{
// draw the hole-circle
CGContextSetFillColorWithColor(context, holeColor!.CGColor)
CGContextFillEllipseInRect(context, CGRect(x: center.x - holeRadius, y: center.y - holeRadius, width: holeRadius * 2.0, height: holeRadius * 2.0))
}

// only draw the circle if it can be seen (not covered by the hole)
if (transparentCircleRadiusPercent > holeRadiusPercent)
if holeColor != nil && transparentCircleRadiusPercent > holeRadiusPercent
{
let alpha = holeAlpha * animator.phaseX * animator.phaseY
let secondHoleRadius = radius * transparentCircleRadiusPercent
Expand Down

0 comments on commit 33f30f8

Please sign in to comment.