@@ -15,8 +15,8 @@ public struct Colors {
1515 public static let color2Accent : Color = Color ( hexString: " #4266E8 " )
1616 public static let color3 : Color = Color ( hexString: " #FCECEA " )
1717 public static let color3Accent : Color = Color ( hexString: " #E1614C " )
18- public static let OrangeStart : Color = Color ( hexString: " #FF782C " )
19- public static let OrangeEnd : Color = Color ( hexString: " #EC2301 " )
18+ public static let OrangeEnd : Color = Color ( hexString: " #FF782C " )
19+ public static let OrangeStart : Color = Color ( hexString: " #EC2301 " )
2020 public static let LegendText : Color = Color ( hexString: " #A7A6A8 " )
2121 public static let LegendColor : Color = Color ( hexString: " #E8E7EA " )
2222 public static let LegendDarkColor : Color = Color ( hexString: " #545454 " )
@@ -30,6 +30,25 @@ public struct Colors {
3030 public static let BorderBlue : Color = Color ( hexString: " #4EBCFF " )
3131}
3232
33+ public struct GradientColor {
34+ public let start : Color
35+ public let end : Color
36+
37+ init ( start: Color , end: Color ) {
38+ self . start = start
39+ self . end = end
40+ }
41+
42+ public func getGradient( ) -> Gradient {
43+ return Gradient ( colors: [ start, end] )
44+ }
45+ }
46+
47+ public struct GradientColors {
48+ public static let orange = GradientColor ( start: Colors . OrangeStart, end: Colors . OrangeEnd)
49+ public static let blue = GradientColor ( start: Colors . GradientPurple, end: Colors . GradientNeonBlue)
50+ }
51+
3352public struct Styles {
3453 public static let lineChartStyleOne = ChartStyle (
3554 backgroundColor: Color . white,
@@ -82,8 +101,8 @@ public struct Styles {
82101
83102 public static let pieChartStyleOne = ChartStyle (
84103 backgroundColor: Color . white,
85- accentColor: Colors . OrangeStart ,
86- secondGradientColor: Colors . OrangeEnd ,
104+ accentColor: Colors . OrangeEnd ,
105+ secondGradientColor: Colors . OrangeStart ,
87106 textColor: Color . black,
88107 legendTextColor: Color . gray)
89108
@@ -114,31 +133,40 @@ public struct ChartForm {
114133public class ChartStyle {
115134 public var backgroundColor : Color
116135 public var accentColor : Color
117- public var secondGradientColor : Color
136+ public var gradientColor : GradientColor
118137 public var textColor : Color
119138 public var legendTextColor : Color
120139 public weak var darkModeStyle : ChartStyle ?
121140
122141 public init ( backgroundColor: Color , accentColor: Color , secondGradientColor: Color , textColor: Color , legendTextColor: Color ) {
123142 self . backgroundColor = backgroundColor
124143 self . accentColor = accentColor
125- self . secondGradientColor = secondGradientColor
144+ self . gradientColor = GradientColor ( start: accentColor, end: secondGradientColor)
145+ self . textColor = textColor
146+ self . legendTextColor = legendTextColor
147+ }
148+
149+ public init ( backgroundColor: Color , accentColor: Color , gradientColor: GradientColor , textColor: Color , legendTextColor: Color ) {
150+ self . backgroundColor = backgroundColor
151+ self . accentColor = accentColor
152+ self . gradientColor = gradientColor
126153 self . textColor = textColor
127154 self . legendTextColor = legendTextColor
128155 }
129156
130157 public init ( formSize: CGSize ) {
131158 self . backgroundColor = Color . white
132159 self . accentColor = Colors . OrangeStart
133- self . secondGradientColor = Colors . OrangeEnd
160+ self . gradientColor = GradientColors . orange
134161 self . legendTextColor = Color . gray
135162 self . textColor = Color . black
136163 }
137164}
138165
139- public class ChartData : ObservableObject {
166+ public class ChartData : ObservableObject , Identifiable {
140167 @Published var points : [ ( String , Double ) ]
141168 var valuesGiven : Bool = false
169+ var ID = UUID ( )
142170
143171 public init < N: BinaryFloatingPoint > ( points: [ N ] ) {
144172 self . points = points. map { ( " " , Double ( $0) ) }
@@ -165,6 +193,24 @@ public class ChartData: ObservableObject {
165193 }
166194}
167195
196+ public class MultiLineChartData : ChartData {
197+ var gradient : GradientColor
198+
199+ public init < N: BinaryFloatingPoint > ( points: [ N ] , gradient: GradientColor ) {
200+ self . gradient = gradient
201+ super. init ( points: points)
202+ }
203+
204+ public init < N: BinaryFloatingPoint > ( points: [ N ] , color: Color ) {
205+ self . gradient = GradientColor ( start: color, end: color)
206+ super. init ( points: points)
207+ }
208+
209+ public func getGradient( ) -> GradientColor {
210+ return self . gradient
211+ }
212+ }
213+
168214public class TestData {
169215 static public var data : ChartData = ChartData ( points: [ 37 , 72 , 51 , 22 , 39 , 47 , 66 , 85 , 50 ] )
170216 static public var values : ChartData = ChartData ( values: [ ( " 2017 Q3 " , 220 ) ,
0 commit comments