Compare commits

...

1 Commits

Author SHA1 Message Date
Andras Samu 04b6e385ea Fixed chart clipping, and value animation issue 2020-01-07 09:56:16 +01:00
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ struct Line: View {
@Binding var showIndicator: Bool
@State private var showFull: Bool = false
@State var showBackground: Bool = true
let padding:CGFloat = 3
let padding:CGFloat = 30
var stepWidth: CGFloat {
if data.points.count < 2 {
return 0
@@ -24,7 +24,7 @@ struct Line: View {
}
var stepHeight: CGFloat {
if let min = data.points.min(), let max = data.points.max(), min != max {
if (min < 0){
if (min <= 0){
return (frame.size.height-padding) / CGFloat(data.points.max()! - data.points.min()!)
}else{
return (frame.size.height-padding) / CGFloat(data.points.max()! + data.points.min()!)
@@ -72,14 +72,14 @@ public struct LineChartView: View {
Spacer()
}
.transition(.scale)
.animation(.spring())
// .animation(.spring())
}
Spacer()
GeometryReader{ geometry in
Line(data: self.data, frame: .constant(geometry.frame(in: .local)), touchLocation: self.$touchLocation, showIndicator: self.$showIndicatorDot)
}
.frame(width: frame.width, height: frame.height)
.frame(width: frame.width, height: frame.height + 30)
.clipShape(RoundedRectangle(cornerRadius: 20))
.offset(x: 0, y: 0)
}.frame(width: self.formSize.width, height: self.formSize.height)