From 913e1b6ad0bdb013ca0661dce52488c282fb96f2 Mon Sep 17 00:00:00 2001 From: nikiloban Date: Wed, 2 Dec 2020 14:33:33 +0300 Subject: [PATCH 1/3] add unit aligment --- Classes/Drawing/ReferenceLineDrawingView.swift | 11 +++++++++-- Classes/Reference/ReferenceLines.swift | 6 ++++++ GraphView/GraphView.xcodeproj/project.pbxproj | 10 ++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Classes/Drawing/ReferenceLineDrawingView.swift b/Classes/Drawing/ReferenceLineDrawingView.swift index 827ebad..2c9af04 100644 --- a/Classes/Drawing/ReferenceLineDrawingView.swift +++ b/Classes/Drawing/ReferenceLineDrawingView.swift @@ -16,6 +16,9 @@ internal class ReferenceLineDrawingView : UIView { private var currentRange: (min: Double, max: Double) = (0,100) private var topMargin: CGFloat = 10 private var bottomMargin: CGFloat = 10 + private var unitsAligment: UnitsAligment { + return self.settings.unitsAligment + } private var lineWidth: CGFloat { get { @@ -26,7 +29,7 @@ internal class ReferenceLineDrawingView : UIView { private var units: String { get { if let units = self.settings.referenceLineUnits { - return " \(units)" + return "\(units)" } else { return "" } @@ -157,7 +160,11 @@ internal class ReferenceLineDrawingView : UIView { var valueString = numberFormatter.string(from: value as NSNumber)! if(self.settings.shouldAddUnitsToIntermediateReferenceLineLabels) { - valueString += " \(units)" + if self.unitsAligment == .right { + valueString += "\(self.units)" + } else { + valueString = "\(self.units) \(valueString)" + } } addLine(withTag: valueString, from: lineStart, to: lineEnd, in: path) diff --git a/Classes/Reference/ReferenceLines.swift b/Classes/Reference/ReferenceLines.swift index 38f12aa..3173727 100644 --- a/Classes/Reference/ReferenceLines.swift +++ b/Classes/Reference/ReferenceLines.swift @@ -63,6 +63,7 @@ open class ReferenceLines { @IBInspectable open var dataPointLabelBottomMargin: CGFloat = 0 /// The font for the data point labels. @IBInspectable open var dataPointLabelColor: UIColor = UIColor.black + @IBInspectable open var unitsAligment: UnitsAligment = .right /// The colour for the data point labels. open var dataPointLabelFont: UIFont? = UIFont.systemFont(ofSize: 10) /// Used to force the graph to show every n-th dataPoint label @@ -88,3 +89,8 @@ open class ReferenceLines { @objc public enum ScrollableGraphViewReferenceLineType : Int { case cover } + + +@objc public enum UnitsAligment: Int { + case left, right +} diff --git a/GraphView/GraphView.xcodeproj/project.pbxproj b/GraphView/GraphView.xcodeproj/project.pbxproj index e2372b3..da9729c 100644 --- a/GraphView/GraphView.xcodeproj/project.pbxproj +++ b/GraphView/GraphView.xcodeproj/project.pbxproj @@ -287,6 +287,7 @@ TargetAttributes = { 2918399D1C72E6A400753A45 = { CreatedOnToolsVersion = 7.2.1; + DevelopmentTeam = MX8X2BSFQH; LastSwiftMigration = 1000; }; }; @@ -296,6 +297,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -505,11 +507,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = MX8X2BSFQH; INFOPLIST_FILE = GraphView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.ios.GraphViewCode; + PRODUCT_BUNDLE_IDENTIFIER = com.ios.GraphViewCode.fork; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_VERSION = 4.2; @@ -522,11 +524,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = MX8X2BSFQH; INFOPLIST_FILE = GraphView/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.ios.GraphViewCode; + PRODUCT_BUNDLE_IDENTIFIER = com.ios.GraphViewCode.fork; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_VERSION = 4.2; From 591c5e4fd106f26ccc67450276ab04c5856d7e1b Mon Sep 17 00:00:00 2001 From: nikiloban Date: Wed, 2 Dec 2020 16:50:45 +0300 Subject: [PATCH 2/3] fix --- Classes/Drawing/ReferenceLineDrawingView.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Classes/Drawing/ReferenceLineDrawingView.swift b/Classes/Drawing/ReferenceLineDrawingView.swift index 2c9af04..74cbc79 100644 --- a/Classes/Drawing/ReferenceLineDrawingView.swift +++ b/Classes/Drawing/ReferenceLineDrawingView.swift @@ -85,8 +85,20 @@ internal class ReferenceLineDrawingView : UIView { let numberFormatter = referenceNumberFormatter() - let maxString = numberFormatter.string(from: self.currentRange.max as NSNumber)! + units - let minString = numberFormatter.string(from: self.currentRange.min as NSNumber)! + units + var maxString = numberFormatter.string(from: self.currentRange.max as NSNumber)! + if self.unitsAligment == .left { + maxString = self.units + maxString + } else { + maxString += self.units + } + + var minString = numberFormatter.string(from: self.currentRange.min as NSNumber)! + + if self.unitsAligment == .left { + minString = self.units + maxString + } else { + minString += self.units + } addLine(withTag: maxString, from: maxLineStart, to: maxLineEnd, in: referenceLinePath) addLine(withTag: minString, from: minLineStart, to: minLineEnd, in: referenceLinePath) From de29b1975b9f6f6924be3893531f23d91f95a479 Mon Sep 17 00:00:00 2001 From: nikiloban Date: Wed, 2 Dec 2020 17:18:16 +0300 Subject: [PATCH 3/3] fix --- Classes/Drawing/ReferenceLineDrawingView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Drawing/ReferenceLineDrawingView.swift b/Classes/Drawing/ReferenceLineDrawingView.swift index 74cbc79..9e9e6eb 100644 --- a/Classes/Drawing/ReferenceLineDrawingView.swift +++ b/Classes/Drawing/ReferenceLineDrawingView.swift @@ -95,7 +95,7 @@ internal class ReferenceLineDrawingView : UIView { var minString = numberFormatter.string(from: self.currentRange.min as NSNumber)! if self.unitsAligment == .left { - minString = self.units + maxString + minString = self.units + minString } else { minString += self.units }