feat: added an option to separate download and upload scale in the Network chart (#966)

fix: restore the scale in the Network chart after a restart
This commit is contained in:
Serhiy Mytrovtsiy
2022-08-30 18:18:18 +02:00
parent 13be2d03d7
commit 22c84ff305
2 changed files with 36 additions and 2 deletions

View File

@@ -303,6 +303,7 @@ public class NetworkChartView: NSView {
private var minMax: Bool = false
private var scale: Scale = .none
private var commonScale: Bool = true
public init(frame: NSRect, num: Int, minMax: Bool = true) {
self.minMax = minMax
@@ -330,6 +331,14 @@ public class NetworkChartView: NSView {
downloadMax = 1
}
if !self.commonScale {
if downloadMax > uploadMax {
uploadMax = downloadMax
} else {
downloadMax = uploadMax
}
}
let lineWidth = 1 / (NSScreen.main?.backingScaleFactor ?? 1)
let offset = lineWidth / 2
let zero: CGFloat = (dirtyRect.height/2) + dirtyRect.origin.y
@@ -427,8 +436,10 @@ public class NetworkChartView: NSView {
}
}
public func setScale(_ newScale: Scale) {
public func setScale(_ newScale: Scale, _ commonScale: Bool) {
self.scale = newScale
self.commonScale = commonScale
if self.window?.isVisible ?? false {
self.display()
}