Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

How to get the date range of the data that is currently displayed in a Apple Chart?

I have a Swiftui app, and I'm using the Apple Chart framework to chart user transactions over time. I'd like to be able to show an annotation at the top of the chart that shows the date range of the records currently visible on the chart. Much like Apple does in their Heath App charts.

But I just can't seem to find a method to read the current date range displayed on the chart once the user has scrolled though the chart.

Has anyone done anything similar, or maybe seen some sample code? So far I'm striking out on this...

Thanks in advance

You should be able to use chartScrollPosition(x:) to get the value provided when the chart scrolls and use that to construct your range. Visualizing your app’s data sample project has an example of this, you should checkout the implementation of SalesDetails.swift and DailySalesChart.swift in the sample code.

How to get the date range of the data that is currently displayed in a Apple Chart?
 
 
Q