Conforming to the Plottable protocol
Until now, we have been under the assumption that any data set we threw on our charts would work. However, we saw that the proxy object can perform interesting calculations that are not possible with any data, and that’s only one reason why our data types need to support the ability to be drawn in a chart.
Therefore, the Swift Charts framework only works with data types that conform to the Plottable protocol, which allows data to be drawn in a chart.
First, every primitive data type already conforms to the Plottable protocol. Also, the Date class that we used in our last example conforms to the Plottable protocol. We can even see that in the apple header files:
extension Date : Plottable, PrimitivePlottableProtocol extension String : Plottable, PrimitivePlottableProtocol
However, working only with primitive or Foundation types is not always practical.
Let’s take, for example, our Sales structure from the Adding Stacked...