diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift index 07287ad06f..c2940919eb 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift @@ -106,6 +106,18 @@ open class PieChartDataSet: ChartDataSet, PieChartDataSetProtocol /// the color for the highlighted sector open var highlightColor: NSUIColor? = nil + /// the width for slice stroke + open var sliceStrokeWidth: CGFloat = 0.0 + + /// the color for the slice stroke pattern + open var sliceLineDashPattern: [NSNumber] = [0, 0] + + /// the color to fill slice + open var sliceFillColor: CGColor = UIColor.clear.cgColor + + /// the line join style for the slice + open var sliceStrokeLineJoinStyle: CAShapeLayerLineJoin = .miter + // MARK: - NSCopying open override func copy(with zone: NSZone? = nil) -> Any diff --git a/Source/Charts/Data/Interfaces/PieChartDataSetProtocol.swift b/Source/Charts/Data/Interfaces/PieChartDataSetProtocol.swift index 1b8ea87850..e2470a5907 100644 --- a/Source/Charts/Data/Interfaces/PieChartDataSetProtocol.swift +++ b/Source/Charts/Data/Interfaces/PieChartDataSetProtocol.swift @@ -60,5 +60,17 @@ public protocol PieChartDataSetProtocol: ChartDataSetProtocol /// get/sets the color for the highlighted sector var highlightColor: NSUIColor? { get set } + + /// the width for slice stroke + var sliceStrokeWidth: CGFloat { get set } + + /// the color for the slice stroke pattern + var sliceLineDashPattern: [NSNumber] { get set } + + /// the color to fill slice + var sliceFillColor: CGColor { get set } + + /// the line join style for the slice + var sliceStrokeLineJoinStyle: CAShapeLayerLineJoin { get set } } diff --git a/Source/Charts/Renderers/PieChartRenderer.swift b/Source/Charts/Renderers/PieChartRenderer.swift index 18f571bc79..1f4c35bdd4 100644 --- a/Source/Charts/Renderers/PieChartRenderer.swift +++ b/Source/Charts/Renderers/PieChartRenderer.swift @@ -278,6 +278,16 @@ open class PieChartRenderer: NSObject, DataRenderer context.addPath(path) context.fillPath(using: .evenOdd) + // to customize stroke edges for the slices + let layer = CAShapeLayer() + layer.lineWidth = dataSet.sliceStrokeWidth + layer.lineJoin = dataSet.sliceStrokeLineJoinStyle + layer.lineDashPattern = dataSet.sliceLineDashPattern + layer.fillColor = dataSet.sliceFillColor + layer.strokeColor = dataSet.color(atIndex: j).cgColor + layer.path = path + layer.render(in: context) + let axElement = createAccessibleElement(withIndex: j, container: chart, dataSet: dataSet)