diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift index 5847796068..205c2a8ff0 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift @@ -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 useValueColorForLine: Bool = false + /// When valuePosition is OutsideSlice, indicates line width open var valueLineWidth: CGFloat = 1.0 diff --git a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift index 872a031170..b85249a292 100644 --- a/Source/Charts/Data/Interfaces/IPieChartDataSet.swift +++ b/Source/Charts/Data/Interfaces/IPieChartDataSet.swift @@ -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 useValueColorForLine: Bool { get set } + /// When valuePosition is OutsideSlice, indicates line width var valueLineWidth: CGFloat { get set } diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index c1ceb7c1fe..e50106c351 100644 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -438,9 +438,20 @@ open class PieChartRenderer: DataRenderer labelPoint = CGPoint(x: pt2.x + 5, y: pt2.y - lineHeight) } - if dataSet.valueLineColor != nil + DrawLine: do { - context.setStrokeColor(dataSet.valueLineColor!.cgColor) + if dataSet.useValueColorForLine + { + context.setStrokeColor(dataSet.color(atIndex: j).cgColor) + } + else if let valueLineColor = dataSet.valueLineColor + { + context.setStrokeColor(valueLineColor.cgColor) + } + else + { + return + } context.setLineWidth(dataSet.valueLineWidth) context.move(to: CGPoint(x: pt0.x, y: pt0.y)) @@ -449,7 +460,7 @@ open class PieChartRenderer: DataRenderer context.drawPath(using: CGPathDrawingMode.stroke) } - + if drawXOutside && drawYOutside { ChartUtils.drawText(