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

Multiple colors for valueline (Fixes #3480) #3709

Merged
merged 8 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -84,6 +84,9 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet
/// When valuePosition is OutsideSlice, indicates line color
open var valueLineColor: NSUIColor? = NSUIColor.black

/// When valuePosition is OutsideSlice and enabled, line will have the same color as the slice
open var valueLineAutoColor: Bool = false
AlexeiGitH marked this conversation as resolved.
Show resolved Hide resolved

/// When valuePosition is OutsideSlice, indicates line width
open var valueLineWidth: CGFloat = 1.0

Expand Down
3 changes: 3 additions & 0 deletions Source/Charts/Data/Interfaces/IPieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public protocol IPieChartDataSet: IChartDataSet
/// When valuePosition is OutsideSlice, indicates line color
var valueLineColor: NSUIColor? { get set }

/// When valuePosition is OutsideSlice and enabled, line will have the same color as the slice
var valueLineAutoColor: Bool { get set }

/// When valuePosition is OutsideSlice, indicates line width
var valueLineWidth: CGFloat { get set }

Expand Down
6 changes: 5 additions & 1 deletion Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,11 @@ open class PieChartRenderer: DataRenderer

if dataSet.valueLineColor != nil
{
context.setStrokeColor(dataSet.valueLineColor!.cgColor)
if dataSet.valueLineAutoColor {
context.setStrokeColor(dataSet.color(atIndex: j).cgColor)
} else {
context.setStrokeColor(dataSet.valueLineColor!.cgColor)
}
context.setLineWidth(dataSet.valueLineWidth)

context.move(to: CGPoint(x: pt0.x, y: pt0.y))
Expand Down