mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: fixed CPU line chart baseline in the popup view
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user