From a perfomance perspective your going to have a few issues here.
every time the scroll position updates (for either chart) both charts will need to fully re-evaluting there full content
the scroll position binding is not going to keep these charts perfectly in sync, in when it comes to edge effect bounces.
To solve issue 1)
do not bound your chartScrollPosition bindings from within the same hosting view as the Chart.
Instead higher up in your view tree create an @Observable class and inject that into the env.
then create a SwiftUI ViewModifer that reads this env value and from it creates a binding for the .chartScrollPosition(id: $state.scrollPos)
then you arched this to your chart Chart {}.viewModifier(MyScrollModifer()) you shoudl also do the same for the axis modifier.
This way when the scroll offset updates your not triggering on each tiny update the full chart content to re-evaluate.
for issue number 2, you can use the swfitui scroll behavior modifiers to stop your charts having over scroll this way the scrolling between the charts will align better.
In general you must structure your code in a way that means the view body that hosts your Chart {} is ONLY ever re-evaluated when the data your passing into the chart changes! you shoudl be able to start you app, open then screen then place a breakpoint within that view body and then continue to use teh charts, scrolling etc without ever hitting that breakpoint unless you expliclty changed the data being provided. That Chart {}. is very costly to evaluate (very very) and you DO NOT want to do so during scroll.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: