Mercurial > public > stock-charts
changeset 20:24dfde3727c1 v0.2-alpha
Make variables and structures public
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 28 Apr 2021 20:24:54 +0200 |
parents | 647d3a64ca3f |
children | 5135ff3343ae |
files | Package.swift Sources/InteractiveCharts/LineChart/ChartView.swift Sources/InteractiveCharts/LineChart/Helpers/ChartLabel.swift Sources/InteractiveCharts/LineChart/Helpers/IndicatorPoint.swift Sources/InteractiveCharts/LineChart/Helpers/LineView.swift SwiftUI-InteractiveCharts.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate |
diffstat | 6 files changed, 11 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Package.swift Wed Apr 28 20:15:46 2021 +0200 +++ b/Package.swift Wed Apr 28 20:24:54 2021 +0200 @@ -14,7 +14,7 @@ ], products: [ .library( - name: "InteractiveCharts", + name: "SwiftUIInteractiveCharts", targets: ["SwiftUI-InteractiveCharts"]), ], dependencies: [
--- a/Sources/InteractiveCharts/LineChart/ChartView.swift Wed Apr 28 20:15:46 2021 +0200 +++ b/Sources/InteractiveCharts/LineChart/ChartView.swift Wed Apr 28 20:24:54 2021 +0200 @@ -12,8 +12,8 @@ var dates: [String]? var hours: [String]? - @State private var showingIndicators = false - @State private var indexPosition = Int() + @State var showingIndicators = false + @State var indexPosition = Int() public var body: some View { VStack {
--- a/Sources/InteractiveCharts/LineChart/Helpers/ChartLabel.swift Wed Apr 28 20:15:46 2021 +0200 +++ b/Sources/InteractiveCharts/LineChart/Helpers/ChartLabel.swift Wed Apr 28 20:24:54 2021 +0200 @@ -7,14 +7,14 @@ import SwiftUI -struct ChartLabel: View { +public struct ChartLabel: View { var data: [Double] var dates: [String]? var hours: [String]? @Binding var indexPosition: Int // Data point position - var body: some View { + public var body: some View { HStack { Group { if let dates = self.dates { @@ -36,7 +36,7 @@ Take string in format yy-MM-dd (2021-01-01) and transform it to long default string format */ - private func formatStringDate(_ stringDate: String) -> String { + public func formatStringDate(_ stringDate: String) -> String { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yy-MM-dd" let date = dateFormatter.date(from: stringDate)
--- a/Sources/InteractiveCharts/LineChart/Helpers/IndicatorPoint.swift Wed Apr 28 20:15:46 2021 +0200 +++ b/Sources/InteractiveCharts/LineChart/Helpers/IndicatorPoint.swift Wed Apr 28 20:24:54 2021 +0200 @@ -15,9 +15,3 @@ } } - -struct IndicatorPoint_Previews: PreviewProvider { - static var previews: some View { - IndicatorPoint() - } -}
--- a/Sources/InteractiveCharts/LineChart/Helpers/LineView.swift Wed Apr 28 20:15:46 2021 +0200 +++ b/Sources/InteractiveCharts/LineChart/Helpers/LineView.swift Wed Apr 28 20:24:54 2021 +0200 @@ -14,8 +14,8 @@ @Binding var showingIndicators: Bool @Binding var indexPosition: Int - @State private var IndicatorPointPosition: CGPoint = .zero - @State private var pathPoints = [CGPoint]() + @State var IndicatorPointPosition: CGPoint = .zero + @State var pathPoints = [CGPoint]() public var body: some View { ZStack { @@ -55,7 +55,7 @@ /* Color path depending on data. */ - private func colorLine() -> Color { + public func colorLine() -> Color { var color = Color(.systemGreen) if data.first! > data.last! { @@ -73,7 +73,7 @@ /* When the user drag on Path -> Modifiy indicator point to move it on the path accordingly */ - private func dragGesture(_ longPressLocation: CGPoint) { + public func dragGesture(_ longPressLocation: CGPoint) { let (closestXPoint, closestYPoint, yPointIndex) = getClosestValueFrom(longPressLocation, inData: pathPoints) self.IndicatorPointPosition.x = closestXPoint self.IndicatorPointPosition.y = closestYPoint @@ -85,7 +85,7 @@ First, search the closest X point in Path from the tapped location. Then, find the correspondent Y point in Path. */ - private func getClosestValueFrom(_ value: CGPoint, inData: [CGPoint]) -> (CGFloat, CGFloat, Int) { + public func getClosestValueFrom(_ value: CGPoint, inData: [CGPoint]) -> (CGFloat, CGFloat, Int) { let touchPoint: (CGFloat, CGFloat) = (value.x, value.y) let xPathPoints = inData.map { $0.x } let yPathPoints = inData.map { $0.y }