2015-02-07 134 views
1

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

+0

这是一个重复:http://stackoverflow.com/questions/28705981/android-graphview-4-x-bar-graph-not-fitting/28809786#28809786 – arober11 2015-03-02 15:32:49

回答

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()); 
}