Pepa Zapletal
Pepa Zapletal

Reputation: 2979

Android GraphView - how to fill area under the Line Graph with color?

I have created a LineGraph, it´s look like this:

enter image description here

But I want fill the area below the grap like this:

enter image description here

How can I implement this feature? Can you help me?

Upvotes: 3

Views: 3572

Answers (2)

Terry Seidler
Terry Seidler

Reputation: 2043

For more current versions of GraphView, set the background colour and drawBackground on the series:

GraphView graph = (GraphView) findViewById(R.id.YOUR_GRAPH_ID_HERE);
LineGraphSeries<DataPoint> mySeries = new LineGraphSeries<DataPoint>(new DataPoint[] {
    new DataPoint(0, 0),
    new DataPoint(1, 5),
    new DataPoint(2, 10)
});

mySeries.setBackgroundColor(Color.GREEN);
mySeries.setDrawBackground(true);

graph.addSeries(mySeries);

Upvotes: 2

devnoel
devnoel

Reputation: 66

Use the setDrawBackground method to enable it.

LineGraphView graphView = new LineGraphView(this,"My Line Graph");
graphView.setDrawBackground(true);

Upvotes: 5

Related Questions