mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user