fix: fixed Line Chart widget size when label option is enabled (#678)

This commit is contained in:
Serhiy Mytrovtsiy
2021-11-02 19:59:12 +01:00
parent bf9b7af73b
commit e1bac3ffa0
2 changed files with 4 additions and 4 deletions

View File

@@ -169,7 +169,7 @@ public class LineChart: WidgetWrapper {
let box = NSBezierPath(roundedRect: NSRect(
x: x+offset,
y: offset,
width: self.width - Constants.Widget.margin.x - (x+offset)*2,
width: self.width - Constants.Widget.margin.x*2 - offset*2,
height: boxSize.height - (offset*2)
), xRadius: 2, yRadius: 2)
@@ -189,7 +189,7 @@ public class LineChart: WidgetWrapper {
let chartFrame = NSRect(
x: x+offset+lineWidth,
y: offset,
width: self.width - (x+offset+lineWidth)*2,
width: box.bounds.width - (offset*2+lineWidth),
height: box.bounds.height - offset
)
self.chart.color = color

View File

@@ -39,7 +39,7 @@ public class LineChartView: NSView {
public var color: NSColor = controlAccentColor
public init(frame: NSRect, num: Int) {
self.points = Array(repeating: 0, count: num)
self.points = Array(repeating: 0.01, count: num)
super.init(frame: frame)
}
@@ -88,7 +88,7 @@ public class LineChartView: NSView {
let underLinePath = line.copy() as! NSBezierPath
underLinePath.line(to: CGPoint(x: columnXPoint(self.points.count), y: offset))
underLinePath.line(to: CGPoint(x: 0, y: offset))
underLinePath.line(to: CGPoint(x: columnXPoint(0), y: offset))
underLinePath.close()
underLinePath.addClip()