I want the line grow without a canvas resize so I need to scale the canvas before the animation.
If I apply both X and Y Scale modifiers to set the domain, animation doesn't work, if I comment either of both, yes... Any idea why and any workaround?
import SwiftUI
import Charts
struct Entry: Identifiable {
var id = UUID()
var time: Double
var value: Double
}
struct ContentView: View {
@State var data: [Entry] = [
.init(time: 0, value: 0),
.init(time: 1, value: 1)]
var body: some View {
VStack{
Button("+"){
data.append(.init(time: 2, value: 3))
}
Chart(data){entry in
LineMark(x: .value("time", entry.time),
y: .value("value", entry.value))
}
.chartXScale(domain: 0...3)
.chartYScale(domain: 0...3)
.padding()
.animation(.easeIn(duration:3), value: data)
}
}
}