2015-02-07 131 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()); 
}