mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed updates of sensor chart
This commit is contained in:
@@ -97,11 +97,11 @@ public class LineChartView: NSView {
|
||||
underLinePath.fill()
|
||||
}
|
||||
|
||||
public func addValue(_ value: Double, redraw: Bool = true) {
|
||||
public func addValue(_ value: Double) {
|
||||
self.points.remove(at: 0)
|
||||
self.points.append(value)
|
||||
|
||||
if redraw && self.window?.isVisible ?? true {
|
||||
if self.window?.isVisible ?? false {
|
||||
self.display()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ internal class Popup: NSStackView, Popup_p {
|
||||
}
|
||||
|
||||
internal func usageCallback(_ values: [Sensor_p]) {
|
||||
values.filter({ $0 is Sensor }).forEach { (s: Sensor_p) in
|
||||
if let sensor = self.list[s.key] as? SensorView {
|
||||
sensor.addHistoryPoint(s)
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async(execute: {
|
||||
values.filter({ $0 is Sensor }).forEach { (s: Sensor_p) in
|
||||
if let sensor = self.list[s.key] as? SensorView {
|
||||
sensor.addHistoryPoint(s)
|
||||
}
|
||||
}
|
||||
|
||||
if self.window?.isVisible ?? false {
|
||||
values.forEach { (s: Sensor_p) in
|
||||
switch self.list[s.key] {
|
||||
@@ -283,7 +283,7 @@ internal class ChartSensorView: NSStackView {
|
||||
}
|
||||
|
||||
public func update(_ value: Double) {
|
||||
self.chart?.addValue(value/100, redraw: false)
|
||||
self.chart?.addValue(value/100)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user