Appendix A: The DataProvider Struct

This entry is part 4 of 4 in the series SwiftUI Charts Gestures

The real heart of the demonstration app, is something that we didn’t cover at all, in the tutorial. That’s the Data Model for the app, which is in the DataProvider.swift structural type.

It’s a fairly basic type, that consumes some CSV (Comma-Separated-Values) data, and formats it into a configuration that can drive the chart.

Read more

Adding A Selection Gesture

This entry is part 2 of 4 in the series SwiftUI Charts Gestures

We now have a nice bar chart. It shows the entire range of our dataset, sizes itself accordingly, shows the difference between the new users, and the active users, has the Y-Axis labels on the left (leading) edge of the chart, and has the X-Axis values displayed from the start to the finish, in discrete steps.

We want to add the ability to touch the chart, have the bar under the touch, become “selected,” and display its values, in a text item.

We want the selection to follow the touch, and disappear, once the touch ends.

Read more

The Initial Setup

This entry is part 1 of 4 in the series SwiftUI Charts Gestures

SwiftUI Charts are a flexible, relatively simple way to generate data displays for your application. Apple uses them, in a lot of their own applications.

By default, they are fairly static displays, but it’s possible to add some interactivity to them.

In this series, we’ll take a basic static bar chart, and add two gestures to it: A tap/swipe gesture, to indicate selection of an X-axis point, and a magnification (pinch) gesture, to “zoom in” to specific ranges, on the X-axis.

In this post, we’ll start with a small running SwiftUI app, displaying a simple, static, bar chart.

Read more