I am trying to add a chart to my iWatch application, but there are all sorts of errors. I am definitely missing some knowledge, but you can see my code below and I am following the instructions here.
I am not sure where to add the code for the chart. Is it supposed to go in the View
file?
The error I see when using the code below is:
Cannot convert value of type '(TeamsView) -> () -> some View' to expected argument type 'CGRect'
import SwiftUI
import YOChartImageKit
struct TeamsView: View {
private var image: YOLineChartImage = {
let image = YOLineChartImage()
image.strokeWidth = 4.0
image.strokeColor = UIColor(displayP3Red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
image.values = [0.0, 1.0, 2.0]
image.smooth = false
image.drawImage(frame, scale: 1)
return image
}()
var body: some View {
VStack{
Text("Teams")
List([Team(id: "1", name: "Liverpool"),
Team(id: "2", name: "Man Utd.")]) {
team in TeamRow(team: team)
}
image
}
}
}