So I have a chart displaying line data at equal x intervals, with varying y values - something like this:
let ints = Array([0...10])
Chart {
ForEach(ints) { int in
let someRandomYValue = Int.random()
LineMark(x: int, y: someRandomYValue, series: "Line")
}
}
And I need to put an overlay exactly in the middle of two consecutive points. The overlay needs to touch the line.
So I need the x and the y value to place the overlay.
It's easy enough to get the x value - I just need the split the difference between my two x values. But I can't figure out how to get the y value.
Is there any way to "query" the y value of a line mark at specified x value? Maybe something like this:
let queriedY = LineMark(series: "Line").yValue(at: 8.5)