Swift Charts
Apple released their Swift Charts library back in 2022 as a native way to generate a whole host of different chart types without having to reach for an external library, or do what I did, and roll your own. The benefits should be clear as to why to use the inbuilt approach, but accessibility and simplicity were top of my list and the negatives mainly down to lacking features (no pie chart!?).
The Cricket App I’ve been building has been a slow burn, initially built at a time long before Swift Charts, and given that I’d been coding it exclusively on Swift Playgrounds, support for Charts was even longer coming. So by the time it was available, I had a chart I was happy with and couldn’t see a good reason to change. Until now.
With the introduction of the Vision Pro, I thought now was a good time (excuse) to transition across to benefit from better native support for things like interactions and view resizing. Having allocated an evening to get things up and running, I was pleased to discover that with only a few lines of code, I was able to get a chart up and running. With a bit more playing with styling, particularly with axis, I could a near replica of the original chart (left) with only 10% of the original code. There’s a few visual changes, mainly to accommodate the chart on the Vision Pro at this point.
Going forwards this new approach will allow much quicker iterations on how the chart looks and feels and hopefully lets me explore some new options with other data that can be charted in other areas of the app without having to code a completely new custom chart.