diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift index 0a5d9a4029..f7fd919046 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift @@ -105,6 +105,9 @@ 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 @@ -112,6 +115,7 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet let copy = super.copyWithZone(zone) as! PieChartDataSet copy._sliceSpace = _sliceSpace copy.selectionShift = selectionShift + copy.highlightColor = highlightColor return copy } } diff --git a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift index 51e7baa488..1e027be0cb 100644 --- a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift @@ -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 } } diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index 2ad91ccddc..327cbc8503 100755 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -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)