@@ -31,7 +31,7 @@ public struct LineChartView: View {
3131 }
3232 }
3333 let frame = CGSize ( width: 180 , height: 120 )
34- private var rateValue : Int
34+ private var rateValue : Int ?
3535
3636 public init ( data: [ Double ] ,
3737 title: String ,
@@ -48,9 +48,9 @@ public struct LineChartView: View {
4848 self . style = style
4949 self . darkModeStyle = style. darkModeStyle != nil ? style. darkModeStyle! : Styles . lineViewDarkMode
5050 self . formSize = form!
51- self . rateValue = rateValue!
5251 self . dropShadow = dropShadow!
5352 self . valueSpecifier = valueSpecifier!
53+ self . rateValue = rateValue
5454 }
5555
5656 public var body : some View {
@@ -72,12 +72,16 @@ public struct LineChartView: View {
7272 . foregroundColor ( self . colorScheme == . dark ? self . darkModeStyle. legendTextColor : self . style. legendTextColor)
7373 }
7474 HStack {
75- if ( self . rateValue >= 0 ) {
76- Image ( systemName: " arrow.up " )
77- } else {
78- Image ( systemName: " arrow.down " )
75+
76+ if ( self . rateValue ?? 0 != 0 )
77+ {
78+ if ( self . rateValue ?? 0 >= 0 ) {
79+ Image ( systemName: " arrow.up " )
80+ } else {
81+ Image ( systemName: " arrow.down " )
82+ }
83+ Text ( " \( self . rateValue!) % " )
7984 }
80- Text ( " \( self . rateValue) % " )
8185 }
8286 }
8387 . transition ( . opacity)
@@ -96,11 +100,11 @@ public struct LineChartView: View {
96100 Spacer ( )
97101 GeometryReader { geometry in
98102 Line ( data: self . data,
99- frame: . constant( geometry. frame ( in: . local) ) ,
100- touchLocation: self . $touchLocation,
101- showIndicator: self . $showIndicatorDot,
102- minDataValue: . constant( nil ) ,
103- maxDataValue: . constant( nil )
103+ frame: . constant( geometry. frame ( in: . local) ) ,
104+ touchLocation: self . $touchLocation,
105+ showIndicator: self . $showIndicatorDot,
106+ minDataValue: . constant( nil ) ,
107+ maxDataValue: . constant( nil )
104108 )
105109 }
106110 . frame ( width: frame. width, height: frame. height + 30 )
0 commit comments