diff --git a/Kit/plugins/Charts.swift b/Kit/plugins/Charts.swift index 0e162534..f37f4b79 100644 --- a/Kit/plugins/Charts.swift +++ b/Kit/plugins/Charts.swift @@ -125,13 +125,13 @@ public class LineChartView: NSView { context.setShouldAntialias(true) let offset: CGFloat = 1 / (NSScreen.main?.backingScaleFactor ?? 1) - let height: CGFloat = dirtyRect.height - self.frame.origin.y - offset - let xRatio: CGFloat = dirtyRect.width / CGFloat(points.count-1) + let height: CGFloat = self.frame.height - self.frame.origin.y - offset + let xRatio: CGFloat = self.frame.width / CGFloat(points.count-1) let list = points.enumerated().compactMap { (i: Int, v: Double) -> (value: Double, point: CGPoint) in return (v, CGPoint( - x: (CGFloat(i) * xRatio) + dirtyRect.origin.x, - y: scaleValue(scale: self.scale, value: v, maxValue: maxValue, maxHeight: height) + dirtyRect.origin.y + offset + x: (CGFloat(i) * xRatio) + self.frame.origin.x, + y: scaleValue(scale: self.scale, value: v, maxValue: maxValue, maxHeight: height) + self.frame.origin.y + offset )) } @@ -375,7 +375,7 @@ public class NetworkChartView: NSView { underLinePath.close() underLinePath.addClip() self.outColor.withAlphaComponent(0.5).setFill() - NSBezierPath(rect: dirtyRect).fill() + NSBezierPath(rect: self.frame).fill() context.restoreGState() context.saveGState() @@ -386,7 +386,7 @@ public class NetworkChartView: NSView { underLinePath.close() underLinePath.addClip() self.inColor.withAlphaComponent(0.5).setFill() - NSBezierPath(rect: dirtyRect).fill() + NSBezierPath(rect: self.frame).fill() context.restoreGState() diff --git a/Modules/CPU/popup.swift b/Modules/CPU/popup.swift index 428258c5..9c5d66ed 100644 --- a/Modules/CPU/popup.swift +++ b/Modules/CPU/popup.swift @@ -246,16 +246,9 @@ internal class Popup: PopupWrapper { box.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor box.layer?.cornerRadius = 3 - let chart = LineChartView(frame: NSRect( - x: Constants.Popup.spacing, - y: Constants.Popup.spacing, - width: view.frame.width - (Constants.Popup.spacing*2), - height: box.frame.height - Constants.Popup.spacing - ), num: 120) - chart.color = self.chartColor - self.lineChart = chart - - box.addSubview(chart) + self.lineChart = LineChartView(frame: NSRect(x: 1, y: 0, width: box.frame.width, height: box.frame.height), num: 120) + self.lineChart?.color = self.chartColor + box.addSubview(self.lineChart!) return box }()