view InteractiveCharts/LineChart/ChartView.swift @ 8:959175ee5ebd

Implement interaction with ChartView
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Mon, 26 Apr 2021 23:06:42 +0200
parents f828c7c408d4
children
line wrap: on
line source

//
//  ChartView.swift
//  InteractiveCharts
//
//  Created by Dennis Concepción Martín on 26/4/21.
//

import SwiftUI

struct ChartView: View {
    var data: [Double]
    var dates: [String]?
    var hours: [String]?
    
    @State private var showingIndicators = false
    @State private var indexPosition = Int()
    
    var body: some View {
        VStack {
            ChartLabel(data: data, dates: dates, hours: hours, indexPosition: $indexPosition)
                .opacity(showingIndicators ? 1: 0)
                .padding(.vertical)

            LineView(data: data, showingIndicators: $showingIndicators, indexPosition: $indexPosition)
        }
    }
}