Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added highlightColor parameter for pie charts #2961

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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