在条形图中设置条的宽度

时间:2015-02-07 18:58:27

标签: android-graphview

有没有办法控制条形图中条形的宽度?目前我看到第一个和最后一个条默认为剩余(中间)条的宽度的一半。

1 个答案:

答案 0 :(得分:2)

注意,这是Duplicate:无论如何,v3.1.3和4.0.0之间出现了相当多的变化,因为我也遇到了这个变化。库中v3的BarGraph特定逻辑将视口上下移动了半个xInterval,因此屏幕上的第一个和最后一个条目的全宽度条似乎已被删除,但代码却很简单例如

double xInterval=1.0;
graphView.getViewport().setXAxisBoundsManual(true);
if (dataSeries instanceof BarGraphSeries ) {
    // Shunt the viewport, per v3.1.3 to show the full width of the first and last bars. 
    graphView.getViewport().setMinX(dataSeries.getLowestValueX() - (xInterval/2.0));
    graphView.getViewport().setMaxX(dataSeries.getHighestValueX() + (xInterval/2.0));
} else {
    graphView.getViewport().setMinX(dataSeries.getLowestValueX() );
    graphView.getViewport().setMaxX(dataSeries.getHighestValueX());
}