fix: fixed Line Chart draw offset

This commit is contained in:
Serhiy Mytrovtsiy
2026-04-06 14:51:44 +02:00
parent 53db845506
commit 6a881aed28
4 changed files with 9 additions and 10 deletions

View File

@@ -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 {

View File

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

View File

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

View File

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