mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix: fixed Line Chart draw offset
This commit is contained in:
@@ -226,17 +226,16 @@ public class LineChart: WidgetWrapper {
|
||||
}
|
||||
|
||||
context.saveGState()
|
||||
|
||||
let chartFrame = NSRect(
|
||||
x: x+offset+lineWidth,
|
||||
y: offset,
|
||||
context.translateBy(x: x+offset+lineWidth, y: offset)
|
||||
|
||||
let chartSize = NSSize(
|
||||
width: box.bounds.width - (offset*2+lineWidth),
|
||||
height: box.bounds.height - offset
|
||||
)
|
||||
self.chart.color = color
|
||||
self.chart.setFrameSize(NSSize(width: chartFrame.width, height: chartFrame.height))
|
||||
self.chart.draw(chartFrame)
|
||||
|
||||
self.chart.setFrameSize(chartSize)
|
||||
self.chart.draw(NSRect(origin: .zero, size: chartSize))
|
||||
|
||||
context.restoreGState()
|
||||
|
||||
if self.boxState || self.frameState {
|
||||
|
||||
@@ -233,7 +233,7 @@ public class LineChartView: NSView {
|
||||
}
|
||||
|
||||
let point = CGPoint(
|
||||
x: (CGFloat(i) * xRatio) + dirtyRect.origin.x,
|
||||
x: CGFloat(i) * xRatio,
|
||||
y: y
|
||||
)
|
||||
line.append(point)
|
||||
|
||||
@@ -238,7 +238,7 @@ internal class Popup: PopupWrapper {
|
||||
box.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor
|
||||
box.layer?.cornerRadius = 3
|
||||
|
||||
let chartFrame = NSRect(x: 1, y: 0, width: box.frame.width, height: box.frame.height)
|
||||
let chartFrame = NSRect(x: 1, y: 0, width: box.frame.width - 2, height: box.frame.height)
|
||||
self.lineChart = LineChartView(frame: chartFrame, num: self.lineChartHistory, scale: self.lineChartScale, fixedScale: self.lineChartFixedScale)
|
||||
self.lineChart?.color = self.chartColor
|
||||
box.addSubview(self.lineChart!)
|
||||
|
||||
@@ -164,7 +164,7 @@ internal class Popup: PopupWrapper {
|
||||
container.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor
|
||||
container.layer?.cornerRadius = 3
|
||||
|
||||
let chartFrame = NSRect(x: 1, y: 0, width: view.frame.width, height: container.frame.height)
|
||||
let chartFrame = NSRect(x: 1, y: 0, width: view.frame.width - 2, height: container.frame.height)
|
||||
self.chart = LineChartView(frame: chartFrame, num: self.lineChartHistory, scale: self.lineChartScale, fixedScale: self.lineChartFixedScale)
|
||||
self.chart?.color = self.chartColor
|
||||
container.addSubview(self.chart!)
|
||||
|
||||
Reference in New Issue
Block a user