安卓GraphView - 如何填充线图下方的区域颜色?

3
我已经创建了一个折线图,它看起来像这样:

enter image description here

但我希望填充图形下方的区域,就像这样:

enter image description here

我该如何实现这个功能?你能帮我吗?

太晚了,但你能找到解决方案吗? - Fahid Nadeem
2个回答

5
使用setDrawBackground方法启用它。
LineGraphView graphView = new LineGraphView(this,"My Line Graph");
graphView.setDrawBackground(true);

还需要设置setBackgroundColor()。 - Pepa Zapletal
有没有办法仅为特定系列绘制背景? - hotzen
我在当前版本中找不到这个属性。 - Roel
这个库的名字是什么? - Khalid Taha

2

如果您使用的是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);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接