diff --git a/Kit/plugins/Charts.swift b/Kit/plugins/Charts.swift index a8970a42..224b629b 100644 --- a/Kit/plugins/Charts.swift +++ b/Kit/plugins/Charts.swift @@ -37,6 +37,7 @@ public class LineChartView: NSView { public var shadowPoints: [Double] = [] public var transparent: Bool = true public var color: NSColor = controlAccentColor + public var suffix: String = "%" private var cursor: NSPoint? = nil private var stop: Bool = false @@ -168,7 +169,7 @@ public class LineChartView: NSView { NSAttributedString.Key.paragraphStyle: style ] let rect = CGRect(x: textPosition.x, y: textPosition.y, width: 26, height: 10) - let value = "\(Int(nearest.value.rounded(toPlaces: 2) * 100))%" + let value = "\(Int(nearest.value.rounded(toPlaces: 2) * 100))\(self.suffix)" let str = NSAttributedString.init(string: value, attributes: stringAttributes) str.draw(with: rect) } diff --git a/Modules/Sensors/popup.swift b/Modules/Sensors/popup.swift index 9a02bd52..87feddaa 100644 --- a/Modules/Sensors/popup.swift +++ b/Modules/Sensors/popup.swift @@ -256,7 +256,7 @@ internal class ValueSensorView: NSStackView { internal class ChartSensorView: NSStackView { private var chart: LineChartView? = nil - public init(width: CGFloat) { + public init(width: CGFloat, suffix: String) { super.init(frame: NSRect(x: 0, y: 0, width: width, height: 60)) self.wantsLayer = true @@ -267,6 +267,7 @@ internal class ChartSensorView: NSStackView { self.layer?.cornerRadius = 3 self.chart = LineChartView(frame: NSRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height), num: 120) + self.chart?.suffix = suffix if let view = self.chart { self.addArrangedSubview(view)