fix: fixed updates of sensor chart

This commit is contained in:
Serhiy Mytrovtsiy
2022-03-14 18:34:58 +01:00
parent 54932ccaba
commit e39f4f731e
2 changed files with 9 additions and 9 deletions

View File

@@ -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()
}
}

View File

@@ -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)
}
}