From de2ffb2ee432911d73cec5b1c3835503a80ec584 Mon Sep 17 00:00:00 2001 From: Bartosz Olszanowski Date: Sat, 9 Apr 2016 18:12:05 +0200 Subject: [PATCH 1/2] Property circleHoleRadius added to ILineChartDataSet protocol. The new circleHoleRadius value is set only if it is less than circleRadius. Otherwise a default value (4.0) is used. --- .../Implementations/Standard/LineChartDataSet.swift | 13 +++++++++++++ .../Classes/Data/Interfaces/ILineChartDataSet.swift | 3 +++ Charts/Classes/Renderers/LineChartRenderer.swift | 4 ++-- ChartsRealm/Classes/Data/RealmLineDataSet.swift | 13 +++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift index babdafc289..c0e5365277 100644 --- a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift @@ -40,6 +40,7 @@ public class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet // MARK: - Styling functions and accessors private var _cubicIntensity = CGFloat(0.2) + private var _circleHoleRadius = CGFloat(4.0) /// Intensity for cubic lines (min = 0.05, max = 1) /// @@ -79,6 +80,18 @@ public class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet /// The radius of the drawn circles. public var circleRadius = CGFloat(8.0) + /// The radius of the drawn circles. + public var circleHoleRadius : CGFloat { + get { + return _circleHoleRadius; + } + set { + if newValue < self.circleRadius { + _circleHoleRadius = newValue + } + } + } + public var circleColors = [NSUIColor]() /// - returns: the color at the given index of the DataSet's circle-color array. diff --git a/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift b/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift index 4a413a760a..b2408f32aa 100644 --- a/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift +++ b/Charts/Classes/Data/Interfaces/ILineChartDataSet.swift @@ -41,6 +41,9 @@ public protocol ILineChartDataSet: ILineRadarChartDataSet /// The radius of the drawn circles. var circleRadius: CGFloat { get set } + /// The hole radius of the drawn circles. + var circleHoleRadius: CGFloat { get set } + var circleColors: [NSUIColor] { get set } /// - returns: the color at the given index of the DataSet's circle-color array. diff --git a/Charts/Classes/Renderers/LineChartRenderer.swift b/Charts/Classes/Renderers/LineChartRenderer.swift index 65486f5af3..e9101b565e 100644 --- a/Charts/Classes/Renderers/LineChartRenderer.swift +++ b/Charts/Classes/Renderers/LineChartRenderer.swift @@ -585,8 +585,8 @@ public class LineChartRenderer: LineRadarChartRenderer let circleRadius = dataSet.circleRadius let circleDiameter = circleRadius * 2.0 - let circleHoleDiameter = circleRadius - let circleHoleRadius = circleHoleDiameter / 2.0 + let circleHoleRadius = dataSet.circleHoleRadius + let circleHoleDiameter = circleHoleRadius * 2.0 let isDrawCircleHoleEnabled = dataSet.isDrawCircleHoleEnabled guard let diff --git a/ChartsRealm/Classes/Data/RealmLineDataSet.swift b/ChartsRealm/Classes/Data/RealmLineDataSet.swift index f0be0688d8..1ca9ff67bd 100644 --- a/ChartsRealm/Classes/Data/RealmLineDataSet.swift +++ b/ChartsRealm/Classes/Data/RealmLineDataSet.swift @@ -30,6 +30,7 @@ public class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet // MARK: - Styling functions and accessors private var _cubicIntensity = CGFloat(0.2) + private var _circleHoleRadius = CGFloat(4.0) /// Intensity for cubic lines (min = 0.05, max = 1) /// @@ -69,6 +70,18 @@ public class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet /// The radius of the drawn circles. public var circleRadius = CGFloat(8.0) + /// The radius of the drawn circles. + public var circleHoleRadius : CGFloat { + get { + return _circleHoleRadius; + } + set { + if newValue < self.circleRadius { + _circleHoleRadius = newValue + } + } + } + public var circleColors = [NSUIColor]() /// - returns: the color at the given index of the DataSet's circle-color array. From d42c59b3238993f7f5bf356a7ef348ec1d7edb56 Mon Sep 17 00:00:00 2001 From: Bartosz Olszanowski Date: Mon, 11 Apr 2016 13:02:23 +0200 Subject: [PATCH 2/2] Fixed code styling for circleHoleRadius variable. --- .../Standard/LineChartDataSet.swift | 17 +++++++++++------ ChartsRealm/Classes/Data/RealmLineDataSet.swift | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift index c0e5365277..7960503807 100644 --- a/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift +++ b/Charts/Classes/Data/Implementations/Standard/LineChartDataSet.swift @@ -40,7 +40,6 @@ public class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet // MARK: - Styling functions and accessors private var _cubicIntensity = CGFloat(0.2) - private var _circleHoleRadius = CGFloat(4.0) /// Intensity for cubic lines (min = 0.05, max = 1) /// @@ -80,13 +79,19 @@ public class LineChartDataSet: LineRadarChartDataSet, ILineChartDataSet /// The radius of the drawn circles. public var circleRadius = CGFloat(8.0) - /// The radius of the drawn circles. - public var circleHoleRadius : CGFloat { - get { + private var _circleHoleRadius = CGFloat(4.0) + + /// The hole radius of the drawn circles (new value is set only if it is less than circleRadius value) + public var circleHoleRadius : CGFloat + { + get + { return _circleHoleRadius; } - set { - if newValue < self.circleRadius { + set + { + if newValue < self.circleRadius + { _circleHoleRadius = newValue } } diff --git a/ChartsRealm/Classes/Data/RealmLineDataSet.swift b/ChartsRealm/Classes/Data/RealmLineDataSet.swift index 1ca9ff67bd..fc8c9dd2ec 100644 --- a/ChartsRealm/Classes/Data/RealmLineDataSet.swift +++ b/ChartsRealm/Classes/Data/RealmLineDataSet.swift @@ -30,7 +30,6 @@ public class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet // MARK: - Styling functions and accessors private var _cubicIntensity = CGFloat(0.2) - private var _circleHoleRadius = CGFloat(4.0) /// Intensity for cubic lines (min = 0.05, max = 1) /// @@ -70,13 +69,19 @@ public class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet /// The radius of the drawn circles. public var circleRadius = CGFloat(8.0) - /// The radius of the drawn circles. - public var circleHoleRadius : CGFloat { - get { + private var _circleHoleRadius = CGFloat(4.0) + + /// The hole radius of the drawn circles (new value is set only if it is less than circleRadius value) + public var circleHoleRadius : CGFloat + { + get + { return _circleHoleRadius; } - set { - if newValue < self.circleRadius { + set + { + if newValue < self.circleRadius + { _circleHoleRadius = newValue } }