Android GraphView - how to fill the area under the line graph with color?

I created a LineGraph, it looks like this:

enter image description here

But I want to fill the area under the graph like this:

enter image description here

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

+3


source to share


2 answers


Use the method setDrawBackground

to enable it.



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

      

+4


source


For more accurate versions of GraphView, set the background color and drawBackground in 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);

      

0


source







All Articles