view Sources/StockCharts/LineChart/LineChartView.swift @ 68:34844d649ed7

Hide ChartLabel on dragGesture
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 08 May 2021 18:38:35 +0200
parents 1a5b4d95e068
children b9aa9d7b030d
line wrap: on
line source

//
//  LineChartView.swift
//  StockCharts
//
//  Created by Dennis Concepción Martín on 30/4/21.
//

import SwiftUI

public struct LineChartView: View {
    public var data: [Double]
    public var dates: [String]?
    public var hours: [String]?
    public var dragGesture: Bool?
    
    @State var showingIndicators = false
    @State var indexPosition = Int()
    
    public init(data: [Double], dates: [String]?, hours: [String]?, dragGesture: Bool?) {
        self.data = data
        self.dates = dates
        self.hours = hours
        self.dragGesture = dragGesture
    }
    
    public var body: some View {
        VStack {
            if dragGesture ?? true {
                ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition)
                    .opacity(showingIndicators ? 1: 0)
                    .padding(.vertical)
            }

            LineView(data: data, dates: dates, hours: hours, dragGesture: dragGesture, showingIndicators: $showingIndicators, indexPosition: $indexPosition)
        }
    }
}