Skip to content

Commit

Permalink
Bigger scale (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
satan87 authored Jun 16, 2020
1 parent 74140af commit 27e7e0d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftUICharts/LineChart/Legend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct Legend: View {
if (min < 0){
return (frame.size.height-padding) / CGFloat(max - min)
}else{
return (frame.size.height-padding) / CGFloat(max + min)
return (frame.size.height-padding) / CGFloat(max - min)
}
}
return 0
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftUICharts/LineChart/Line.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public struct Line: View {
if (min <= 0){
return (frame.size.height-padding) / CGFloat(max - min)
}else{
return (frame.size.height-padding) / CGFloat(max + min)
return (frame.size.height-padding) / CGFloat(max - min)
}
}
return 0
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftUICharts/LineChart/LineChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ struct WidgetView_Previews: PreviewProvider {
Group {
LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Basic")
.environment(\.colorScheme, .light)

LineChartView(data: [282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188], title: "Line chart", legend: "Basic")
.environment(\.colorScheme, .light)
}
}
}
9 changes: 7 additions & 2 deletions Sources/SwiftUICharts/LineChart/LineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public struct LineView: View {
showBackground: false,
gradient: self.style.gradientColor
)
.offset(x: 30, y: 0)
.offset(x: 30, y: -20)
.onAppear(){
self.showLegend = true
}
Expand Down Expand Up @@ -121,7 +121,12 @@ public struct LineView: View {

struct LineView_Previews: PreviewProvider {
static var previews: some View {
LineView(data: [8,23,54,32,12,37,7,23,43], title: "Full chart", style: Styles.lineChartStyleOne)
Group {
LineView(data: [8,23,54,32,12,37,7,23,43], title: "Full chart", style: Styles.lineChartStyleOne)

LineView(data: [282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188], title: "Full chart", style: Styles.lineChartStyleOne)

}
}
}

0 comments on commit 27e7e0d

Please sign in to comment.