Skip to content

Commit

Permalink
Fixed issue MultiLineChartView Rate AppPear#263:
Browse files Browse the repository at this point in the history
If the rateValue is absent, the chart will not display the rateValue and percentage.
  • Loading branch information
meetAhmed committed Jul 7, 2023
1 parent 102b51b commit 3b6b751
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Sources/SwiftUICharts/LineChart/LineChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public struct LineChartView: View {
}else{
Image(systemName: "arrow.down")
}
Text("\(rateValue!)%")
Text("\(rateValue)%")
}
}
}
Expand Down Expand Up @@ -142,10 +142,10 @@ public struct LineChartView: View {
struct WidgetView_Previews: PreviewProvider {
static var previews: some View {
Group {
LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Basic")
LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Basic", rateValue: nil)
.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")
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", rateValue: nil)
.environment(\.colorScheme, .light)
}
}
Expand Down
14 changes: 8 additions & 6 deletions Sources/SwiftUICharts/LineChart/MultiLineChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ public struct MultiLineChartView: View {
.font(.callout)
.foregroundColor(self.colorScheme == .dark ? self.darkModeStyle.legendTextColor : self.style.legendTextColor)
}
HStack {
if (rateValue ?? 0 >= 0){
Image(systemName: "arrow.up")
}else{
Image(systemName: "arrow.down")
if let rateValue {
HStack {
if (rateValue >= 0){
Image(systemName: "arrow.up")
}else{
Image(systemName: "arrow.down")
}
Text("\(rateValue)%")
}
Text("\(rateValue ?? 0)%")
}
}
.transition(.opacity)
Expand Down

0 comments on commit 3b6b751

Please sign in to comment.