From 076f260d2f63dc58d591f90ce6b6de83e9df7b0f Mon Sep 17 00:00:00 2001 From: Dominique Stranz Date: Sun, 4 Nov 2018 23:00:03 +0100 Subject: [PATCH] Add missing properties to copy(with:) methods (#3715) * #3578 Add missing properties to copy(with:) methods * Add NSCopying conformance --- .../Data/Implementations/ChartBaseDataSet.swift | 17 +++++++++++++++-- .../Standard/BarChartDataEntry.swift | 5 +++-- .../Standard/BarChartDataSet.swift | 6 ++++-- ...BarLineScatterCandleBubbleChartDataSet.swift | 4 ++-- .../Standard/BubbleChartDataEntry.swift | 4 ++-- .../Standard/BubbleChartDataSet.swift | 5 +++-- .../Standard/CandleChartDataEntry.swift | 4 ++-- .../Standard/ChartDataEntry.swift | 4 ++-- .../Implementations/Standard/ChartDataSet.swift | 6 ++++-- .../Standard/LineChartDataSet.swift | 7 +++++-- .../Standard/LineRadarChartDataSet.swift | 8 +++++--- .../LineScatterCandleRadarChartDataSet.swift | 4 ++-- .../Standard/PieChartDataEntry.swift | 4 ++-- .../Standard/PieChartDataSet.swift | 15 +++++++++++++-- .../Standard/RadarChartDataEntry.swift | 4 ++-- .../Standard/ScatterChartDataSet.swift | 4 ++-- 16 files changed, 68 insertions(+), 33 deletions(-) diff --git a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift index b78867679e..ff91f44c29 100644 --- a/Source/Charts/Data/Implementations/ChartBaseDataSet.swift +++ b/Source/Charts/Data/Implementations/ChartBaseDataSet.swift @@ -13,7 +13,7 @@ import Foundation import CoreGraphics -open class ChartBaseDataSet: NSObject, IChartDataSet +open class ChartBaseDataSet: NSObject, IChartDataSet, NSCopying { public required override init() { @@ -411,13 +411,26 @@ open class ChartBaseDataSet: NSObject, IChartDataSet // MARK: - NSCopying - @objc open func copyWithZone(_ zone: NSZone?) -> AnyObject + open func copy(with zone: NSZone? = nil) -> Any { let copy = type(of: self).init() copy.colors = colors copy.valueColors = valueColors copy.label = label + copy.axisDependency = axisDependency + copy.highlightEnabled = highlightEnabled + copy._valueFormatter = _valueFormatter + copy.valueFont = valueFont + copy.form = form + copy.formSize = formSize + copy.formLineWidth = formLineWidth + copy.formLineDashPhase = formLineDashPhase + copy.formLineDashLengths = formLineDashLengths + copy.drawValuesEnabled = drawValuesEnabled + copy.drawValuesEnabled = drawValuesEnabled + copy.iconsOffset = iconsOffset + copy.visible = visible return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift index 5c60dabb6e..d93fd36cdd 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift @@ -217,12 +217,13 @@ open class BarChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarChartDataEntry + let copy = super.copy(with: zone) as! BarChartDataEntry copy._yVals = _yVals copy.y = y copy._negativeSum = _negativeSum + copy._positiveSum = _positiveSum return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift index 1bdca1b0f8..d3549ea06a 100644 --- a/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift @@ -151,14 +151,16 @@ open class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBarChartDat // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarChartDataSet + let copy = super.copy(with: zone) as! BarChartDataSet copy._stackSize = _stackSize copy._entryCountStacks = _entryCountStacks copy.stackLabels = stackLabels copy.barShadowColor = barShadowColor + copy.barBorderWidth = barBorderWidth + copy.barBorderColor = barBorderColor copy.highlightAlpha = highlightAlpha return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift index 02b942f479..91382515a8 100644 --- a/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift @@ -26,9 +26,9 @@ open class BarLineScatterCandleBubbleChartDataSet: ChartDataSet, IBarLineScatter // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BarLineScatterCandleBubbleChartDataSet + let copy = super.copy(with: zone) as! BarLineScatterCandleBubbleChartDataSet copy.highlightColor = highlightColor copy.highlightLineWidth = highlightLineWidth copy.highlightLineDashPhase = highlightLineDashPhase diff --git a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift index 7f412d7397..25cfc739d6 100644 --- a/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift @@ -68,9 +68,9 @@ open class BubbleChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BubbleChartDataEntry + let copy = super.copy(with: zone) as! BubbleChartDataEntry copy.size = size return copy } diff --git a/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift index cdc3567e69..775fafb8bd 100644 --- a/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift @@ -45,12 +45,13 @@ open class BubbleChartDataSet: BarLineScatterCandleBubbleChartDataSet, IBubbleCh // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! BubbleChartDataSet + let copy = super.copy(with: zone) as! BubbleChartDataSet copy._xMin = _xMin copy._xMax = _xMax copy._maxSize = _maxSize + copy.normalizeSizeEnabled = normalizeSizeEnabled copy.highlightCircleWidth = highlightCircleWidth return copy } diff --git a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift index 538066ad87..3010717ead 100644 --- a/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift @@ -97,9 +97,9 @@ open class CandleChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! CandleChartDataEntry + let copy = super.copy(with: zone) as! CandleChartDataEntry copy.high = high copy.low = low copy.open = open diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift index 9021c56670..41094cf4e4 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift @@ -11,7 +11,7 @@ import Foundation -open class ChartDataEntry: ChartDataEntryBase +open class ChartDataEntry: ChartDataEntryBase, NSCopying { /// the x value @objc open var x = Double(0.0) @@ -79,7 +79,7 @@ open class ChartDataEntry: ChartDataEntryBase // MARK: NSCopying - @objc open func copyWithZone(_ zone: NSZone?) -> AnyObject + open func copy(with zone: NSZone? = nil) -> Any { let copy = type(of: self).init() diff --git a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift index 8d1736bb97..1ee39f7030 100644 --- a/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift @@ -495,13 +495,15 @@ open class ChartDataSet: ChartBaseDataSet // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! ChartDataSet + let copy = super.copy(with: zone) as! ChartDataSet copy.values = values copy._yMax = _yMax copy._yMin = _yMin + copy._xMax = _xMax + copy._xMin = _xMin return copy } diff --git a/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift index d8c29c0acd..1b5b106a36 100644 --- a/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift @@ -153,11 +153,13 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineChartDataSet + let copy = super.copy(with: zone) as! LineChartDataSet copy.circleColors = circleColors + copy.circleHoleColor = circleHoleColor copy.circleRadius = circleRadius + copy.circleHoleRadius = circleHoleRadius copy.cubicIntensity = cubicIntensity copy.lineDashPhase = lineDashPhase copy.lineDashLengths = lineDashLengths @@ -165,6 +167,7 @@ open class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet copy.drawCirclesEnabled = drawCirclesEnabled copy.drawCircleHoleEnabled = drawCircleHoleEnabled copy.mode = mode + copy._fillFormatter = _fillFormatter return copy } } diff --git a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift index 5f1770a0b7..50161909e5 100644 --- a/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift @@ -71,10 +71,12 @@ open class LineRadarChartDataSet: LineScatterCandleRadarChartDataSet, ILineRadar // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineRadarChartDataSet - copy.fillColor = fillColor + let copy = super.copy(with: zone) as! LineRadarChartDataSet + copy.fill = fill + copy.fillAlpha = fillAlpha + copy._fillColor = _fillColor copy._lineWidth = _lineWidth copy.drawFilledEnabled = drawFilledEnabled return copy diff --git a/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift index b21868ab08..698fb16629 100644 --- a/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift @@ -40,9 +40,9 @@ open class LineScatterCandleRadarChartDataSet: BarLineScatterCandleBubbleChartDa // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! LineScatterCandleRadarChartDataSet + let copy = super.copy(with: zone) as! LineScatterCandleRadarChartDataSet copy.drawHorizontalHighlightIndicatorEnabled = drawHorizontalHighlightIndicatorEnabled copy.drawVerticalHighlightIndicatorEnabled = drawVerticalHighlightIndicatorEnabled return copy diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift index e833609959..7777af222b 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift @@ -93,9 +93,9 @@ open class PieChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! PieChartDataEntry + let copy = super.copy(with: zone) as! PieChartDataEntry copy.label = label return copy } diff --git a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift index 5847796068..857a8ea69b 100644 --- a/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift @@ -110,11 +110,22 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet // MARK: - NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! PieChartDataSet + let copy = super.copy(with: zone) as! PieChartDataSet copy._sliceSpace = _sliceSpace + copy.automaticallyDisableSliceSpacing = automaticallyDisableSliceSpacing copy.selectionShift = selectionShift + copy.xValuePosition = xValuePosition + copy.yValuePosition = yValuePosition + copy.valueLineColor = valueLineColor + copy.valueLineWidth = valueLineWidth + copy.valueLinePart1OffsetPercentage = valueLinePart1OffsetPercentage + copy.valueLinePart1Length = valueLinePart1Length + copy.valueLinePart2Length = valueLinePart2Length + copy.valueLineVariableLength = valueLineVariableLength + copy.entryLabelFont = entryLabelFont + copy.entryLabelColor = entryLabelColor copy.highlightColor = highlightColor return copy } diff --git a/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift b/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift index 4cf7189008..9fd5cf1ba1 100644 --- a/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift +++ b/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift @@ -42,9 +42,9 @@ open class RadarChartDataEntry: ChartDataEntry // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! RadarChartDataEntry + let copy = super.copy(with: zone) as! RadarChartDataEntry return copy } diff --git a/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift b/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift index 8aee713389..bc9767a06c 100644 --- a/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift +++ b/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift @@ -66,9 +66,9 @@ open class ScatterChartDataSet: LineScatterCandleRadarChartDataSet, IScatterChar // MARK: NSCopying - open override func copyWithZone(_ zone: NSZone?) -> AnyObject + open override func copy(with zone: NSZone? = nil) -> Any { - let copy = super.copyWithZone(zone) as! ScatterChartDataSet + let copy = super.copy(with: zone) as! ScatterChartDataSet copy.scatterShapeSize = scatterShapeSize copy.scatterShapeHoleRadius = scatterShapeHoleRadius copy.scatterShapeHoleColor = scatterShapeHoleColor