mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: adjusted LineChart size
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user