I’ve a view the place I show information inside a chart with the Charts bundle in SwiftUI. Once I solely use LineMark to show my information all the things works wonderful. However after I wish to add a PointMark to this chart I get the error, that Xcode can not compile that view:
The compiler is unable to type-check this expression in cheap time; strive breaking apart the expression into distinct sub-expressions.
That is my code:
struct VoltageDataVView: View {
@Binding var yValues: [Double]
@Binding var voltageValues: [[[Double]]]
@Binding var rowIndex: Double
@Binding var rowPoint: Double
var physique: some View {
Chart {
ForEach(0..<self.voltageValues.depend, id:.self) { i in
if self.voltageValues[i].depend > 0 {
ForEach(0..<self.voltageValues[i][0].depend, id:.self) { j in
LineMark(
x: .worth("x1", self.yValues[j]),
y: .worth("y1", self.voltageValues[i][Int(self.rowIndex)][j])
)
}
.foregroundStyle(by: .worth("value1", i))
}
}
PointMark(x: .worth("x-point-row", self.xValues[Int(self.rowPoint)]),
y: .worth("y-point-row", self.voltageValues[0][Int(self.rowIndex)][Int(self.rowPoint)]))
}
.chartXScale(area: self.yValues.min()!...self.yValues.max()!)
.chartXAxisLabel("variety of datapoints")
.chartYAxisLabel("y values")
.body(width: 400, peak: 300)
.rotationEffect(.levels(-90))
.offset(y: 50)
}
}
I don’t know what I can simplify or breakdown there. What can I do to keep away from the error?