I am building a line chart for one of our applications. The linear part of the diagram works fine, but now I have to fill in the area under the line with color, something like this image below.

I use this code to draw a string into a bitmap using canvas.
List<Float> xCoordinates = (List<Float>) coordinates[0];
List<Float> yCoordinates = (List<Float>) coordinates[1];
for (int i = 0; i < xCoordinates.size(); i++) {
if (!firstSet) {
x = xCoordinates.get(i);
y = yCoordinates.get(i);
p.moveTo(x, y);
firstSet = true;
} else {
x = xCoordinates.get(i);
y = yCoordinates.get(i);
p.lineTo(x, y);
}
}
textureCanvas.drawPath(p, pG);
What do I need to know, is there a way to easily find the area under the line and make it color, or do I need to calculate each area between 3 points for the graph and fill it with color?
I cannot use existing chart libraries, for example, AchartEngine , ChartDroid , aFreeChart .
source
share