Android GraphView - 如何使用颜色填充折线图下的区域?

时间:2014-08-14 11:19:29

标签: android graph android-graphview

我创建了一个LineGraph,它看起来像这样:

enter image description here

但是我希望像这样填写grap下方的区域:

enter image description here

如何实现此功能?你能救我吗?

2 个答案:

答案 0 :(得分:5)

使用setDrawBackground方法启用它。

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

答案 1 :(得分:0)

对于更多当前版本的GraphView,请在系列中设置背景颜色和drawBackground:

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);
相关问题