Mercurial > public > stock-charts
comparison Sources/StockCharts/LineChart/LineChartView.swift @ 116:5057c45046c1
Add default initializers
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 09 Aug 2021 16:32:45 +0100 |
parents | f53d8b9ca92b |
children |
comparison
equal
deleted
inserted
replaced
115:f90a675e5e95 | 116:5057c45046c1 |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 public struct LineChartView: View { | 10 public struct LineChartView: View { |
11 public var data: [Double] | 11 public var lineChartController: LineChartController |
12 public var dates: [String]? | |
13 public var hours: [String]? | |
14 public var dragGesture: Bool? | |
15 public var style: LineChartStyle | |
16 | 12 |
17 @State var showingIndicators = false | 13 @State var showingIndicators = false |
18 @State var indexPosition = Int() | 14 @State var indexPosition = Int() |
19 | 15 |
20 public init(data: [Double], dates: [String]?, hours: [String]?, dragGesture: Bool?, style: LineChartStyle) { | 16 public init(lineChartController: LineChartController) { |
21 self.data = data | 17 self.lineChartController = lineChartController |
22 self.dates = dates | |
23 self.hours = hours | |
24 self.dragGesture = dragGesture | |
25 self.style = style | |
26 } | 18 } |
27 | 19 |
28 public var body: some View { | 20 public var body: some View { |
29 if !data.isEmpty { | 21 if lineChartController.prices.isEmpty { |
22 | |
23 } else { | |
30 VStack { | 24 VStack { |
31 if dragGesture ?? true { | 25 if lineChartController.dragGesture { |
32 ChartLabel(data: data, dates: dates, hours: hours, style: style, indexPosition: $indexPosition) | 26 ChartLabel(lineChartController: lineChartController, indexPosition: $indexPosition) |
33 .opacity(showingIndicators ? 1: 0) | 27 .opacity(showingIndicators ? 1: 0) |
34 } | 28 } |
35 | 29 |
36 LineView(data: data, dates: dates, hours: hours, dragGesture: dragGesture, style: style, showingIndicators: $showingIndicators, indexPosition: $indexPosition) | 30 LineView( |
31 lineChartController: lineChartController, | |
32 showingIndicators: $showingIndicators, | |
33 indexPosition: $indexPosition | |
34 ) | |
37 } | 35 } |
38 } | 36 } |
39 } | 37 } |
40 } | 38 } |