diff Sources/StockCharts/LineChart/Helpers/LineView.swift @ 108:f53d8b9ca92b

Custom style implemented
author Dennis Concepción Martín <dennisconcepcionmartin@gmail.com>
date Sun, 04 Jul 2021 16:40:24 +0100
parents 0c0d38dca6d8
children 5057c45046c1
line wrap: on
line diff
--- a/Sources/StockCharts/LineChart/Helpers/LineView.swift	Mon Jun 28 14:01:13 2021 +0200
+++ b/Sources/StockCharts/LineChart/Helpers/LineView.swift	Sun Jul 04 16:40:24 2021 +0100
@@ -12,6 +12,7 @@
     public var dates: [String]?
     public var hours: [String]?
     public var dragGesture: Bool?
+    public var style: LineChartStyle
     
     @Binding var showingIndicators: Bool
     @Binding var indexPosition: Int
@@ -26,7 +27,7 @@
             }
             
             if showingIndicators {
-                IndicatorPoint()
+                IndicatorPoint(style: style)
                     .position(x: IndicatorPointPosition.x, y: IndicatorPointPosition.y)
             }
         }
@@ -58,14 +59,14 @@
      Color path depending on data.
      */
     public func colorLine() -> Color {
-        var color = Color.green
+        var color = style.uptrendLineColor
         
         if showingIndicators {
-            color = Color.blue
+            color = style.showingIndicatorLineColor
         } else if data.first! > data.last! {
-            color = Color.red
+            color = style.downtrendLineColor
         } else if data.first! == data.last! {
-            color = Color.blue
+            color = style.flatTrendLineColor
         }
         
         return color