Adding advanced features
We've been building a simple implementation of a charts custom view. But we'll need some more features or our custom view might feel a bit static or not really useful. We can't build all the features we might think of or probably need. Also, we should be careful of not building a Swiss army knife custom view as it might become hard to maintain and might have an impact on the custom view performance.
Real-time updates
In our first plain implementation of our custom view, we've created a method to set the data points but we couldn't modify or update the data. Let's implement some quick changes to be able to dynamically add points. In this implementation, we adjusted the values to the 0 to 1 scale directly on the setDataPoints()
method. As we'll provide a method to add new data values, we might get values outside the original minimum and maximum values, invalidating the scale we calculated before.
Let's first store the data in a collection instead of an array, so we can...