fix: moved from frame to dirtyRect origin for line chart

This commit is contained in:
Serhiy Mytrovtsiy
2023-10-22 13:34:01 +02:00
parent 1a9a5e7839
commit 51bf0b4091

View File

@@ -125,13 +125,13 @@ public class LineChartView: NSView {
context.setShouldAntialias(true)
let offset: CGFloat = 1 / (NSScreen.main?.backingScaleFactor ?? 1)
let height: CGFloat = self.frame.height - self.frame.origin.y - offset
let height: CGFloat = self.frame.height - dirtyRect.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) + self.frame.origin.x,
y: scaleValue(scale: self.scale, value: v, maxValue: maxValue, maxHeight: height) + self.frame.origin.y + offset
x: (CGFloat(i) * xRatio) + dirtyRect.origin.x,
y: scaleValue(scale: self.scale, value: v, maxValue: maxValue, maxHeight: height) + dirtyRect.origin.y + offset
))
}