Sometimes, we'd like to show multiple graphs to compare them or simply to show multiple data sets at the same time. Let's do some modifications to allow two graphs at the same time in our graph custom view. It can be further extended to support even more graphs, but let's limit it to two to simplify the logic in this example.
First, we need to create different Paint and Path objects for each graph. We'll create arrays to store them as it'll be easier, later on, to iterate and render them. For example, we can create several Paint objects with different colors for each graph:
linePaint = new Paint[2]; linePaint[0] = new Paint(); linePaint[0].setAntiAlias(true); linePaint[0].setColor(0xffffffff); linePaint[0].setStrokeWidth(8.f); ...