【问题标题】:Android GraphView - how to fill area under the Line Graph with color?Android GraphView - 如何用颜色填充折线图下的区域?
【发布时间】:2014-08-14 11:19:28
【问题描述】:

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

但我想像这样填充抓地力下方的区域:

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

【问题讨论】:

  • 太晚了,但你能找到解决方案吗?

标签: android graph android-graphview


【解决方案1】:

使用setDrawBackground 方法启用它。

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

【讨论】:

  • 还需要设置setBackgroundColor()
  • 有没有办法只为特定系列绘制背景?
  • 我在当前版本中找不到这个属性
  • 这个库叫什么名字?
【解决方案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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-26
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多