Skip to content

Commit

Permalink
Merge pull request #2961 from pascalherrmann/master
Browse files Browse the repository at this point in the history
added highlightColor parameter for pie charts
  • Loading branch information
pmairoldi authored Nov 15, 2017
2 parents e8fa7ad + 57c2e11 commit b27e366
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,17 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet
/// the color for the slice-text labels
open var entryLabelColor: NSUIColor? = nil

/// the color for the highlighted sector
open var highlightColor: NSUIColor? = nil

// MARK: - NSCopying

open override func copyWithZone(_ zone: NSZone?) -> AnyObject
{
let copy = super.copyWithZone(zone) as! PieChartDataSet
copy._sliceSpace = _sliceSpace
copy.selectionShift = selectionShift
copy.highlightColor = highlightColor
return copy
}
}
3 changes: 3 additions & 0 deletions Source/Charts/Data/Interfaces/IPieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ public protocol IPieChartDataSet: IChartDataSet

/// the color for the slice-text labels
var entryLabelColor: NSUIColor? { get set }

/// get/sets the color for the highlighted sector
var highlightColor: NSUIColor? { get set }
}
4 changes: 2 additions & 2 deletions Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ open class PieChartRenderer: DataRenderer

let accountForSliceSpacing = sliceSpace > 0.0 && sliceAngle <= 180.0

context.setFillColor(set.color(atIndex: index).cgColor)
context.setFillColor(set.highlightColor?.cgColor ?? set.color(atIndex: index).cgColor)

let sliceSpaceAngleOuter = visibleAngleCount == 1 ?
0.0 :
sliceSpace / (ChartUtils.Math.FDEG2RAD * radius)
Expand Down

0 comments on commit b27e366

Please sign in to comment.