diff --git a/Classes/Drawing/ReferenceLineDrawingView.swift b/Classes/Drawing/ReferenceLineDrawingView.swift index 827ebad..9e9e6eb 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 "" } @@ -82,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 + minString + } else { + minString += self.units + } addLine(withTag: maxString, from: maxLineStart, to: maxLineEnd, in: referenceLinePath) addLine(withTag: minString, from: minLineStart, to: minLineEnd, in: referenceLinePath) @@ -157,7 +172,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;