Mercurial > public > stock-charts
comparison Sources/StockCharts/LineChart/LineChartView.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 | 46e874c1f459 |
children | 5057c45046c1 |
comparison
equal
deleted
inserted
replaced
107:b0c81b2e624d | 108:f53d8b9ca92b |
---|---|
10 public struct LineChartView: View { | 10 public struct LineChartView: View { |
11 public var data: [Double] | 11 public var data: [Double] |
12 public var dates: [String]? | 12 public var dates: [String]? |
13 public var hours: [String]? | 13 public var hours: [String]? |
14 public var dragGesture: Bool? | 14 public var dragGesture: Bool? |
15 public var style: LineChartStyle | |
15 | 16 |
16 @State var showingIndicators = false | 17 @State var showingIndicators = false |
17 @State var indexPosition = Int() | 18 @State var indexPosition = Int() |
18 | 19 |
19 public init(data: [Double], dates: [String]?, hours: [String]?, dragGesture: Bool?) { | 20 public init(data: [Double], dates: [String]?, hours: [String]?, dragGesture: Bool?, style: LineChartStyle) { |
20 self.data = data | 21 self.data = data |
21 self.dates = dates | 22 self.dates = dates |
22 self.hours = hours | 23 self.hours = hours |
23 self.dragGesture = dragGesture | 24 self.dragGesture = dragGesture |
25 self.style = style | |
24 } | 26 } |
25 | 27 |
26 public var body: some View { | 28 public var body: some View { |
27 if !data.isEmpty { | 29 if !data.isEmpty { |
28 VStack { | 30 VStack { |
29 if dragGesture ?? true { | 31 if dragGesture ?? true { |
30 ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition) | 32 ChartLabel(data: data, dates: dates, hours: hours, style: style, indexPosition: $indexPosition) |
31 .opacity(showingIndicators ? 1: 0) | 33 .opacity(showingIndicators ? 1: 0) |
32 } | 34 } |
33 | 35 |
34 LineView(data: data, dates: dates, hours: hours, dragGesture: dragGesture, showingIndicators: $showingIndicators, indexPosition: $indexPosition) | 36 LineView(data: data, dates: dates, hours: hours, dragGesture: dragGesture, style: style, showingIndicators: $showingIndicators, indexPosition: $indexPosition) |
35 } | 37 } |
36 } | 38 } |
37 } | 39 } |
38 } | 40 } |