feat: adjusted LineChart size

This commit is contained in:
Serhiy Mytrovtsiy
2021-10-28 17:13:15 +02:00
parent 3bf846fa0f
commit 83cea2bcd9
2 changed files with 9 additions and 9 deletions

View File

@@ -167,9 +167,9 @@ public class LineChart: WidgetWrapper {
}
let box = NSBezierPath(roundedRect: NSRect(
x: x + offset,
x: x+offset,
y: offset,
width: boxSize.width - (offset*2),
width: self.width - Constants.Widget.margin.x - (x+offset)*2,
height: boxSize.height - (offset*2)
), xRadius: 2, yRadius: 2)
@@ -187,10 +187,10 @@ public class LineChart: WidgetWrapper {
context.saveGState()
let chartFrame = NSRect(
x: x+offset,
y: 1,
width: box.bounds.width,
height: box.bounds.height-1
x: x+offset+lineWidth,
y: offset,
width: self.width - (x+offset+lineWidth)*2,
height: box.bounds.height - offset
)
self.chart.color = color
self.chart.setFrameSize(NSSize(width: chartFrame.width, height: chartFrame.height))

View File

@@ -71,7 +71,7 @@ public class LineChartView: NSView {
return (CGFloat(point) * xRatio) + dirtyRect.origin.x
}
let columnYPoint = { (point: Int) -> CGFloat in
return CGFloat((CGFloat(truncating: self.points[point] as NSNumber) * height)) + dirtyRect.origin.y + 0.5
return CGFloat((CGFloat(truncating: self.points[point] as NSNumber) * height)) + dirtyRect.origin.y + offset
}
let line = NSBezierPath()
@@ -87,8 +87,8 @@ public class LineChartView: NSView {
let underLinePath = line.copy() as! NSBezierPath
underLinePath.line(to: CGPoint(x: columnXPoint(self.points.count - 1), y: 0))
underLinePath.line(to: CGPoint(x: columnXPoint(0), y: 0))
underLinePath.line(to: CGPoint(x: columnXPoint(self.points.count), y: offset))
underLinePath.line(to: CGPoint(x: 0, y: offset))
underLinePath.close()
underLinePath.addClip()