2015-01-08 23 views
0
GraphViewData[] data = new GraphViewData[numElements];  
for (int c = 0; c<numElements; c++) { 
data[c] = new GraphViewData(c+1, pvalueArray[c]); 
} 
GraphView graphView = new LineGraphView(this, Captionname); 
GraphViewSeries graphViewSeries = new GraphViewSeries(data); 

我正在像上面那樣填充圖形,我的數組包含的值設置爲2位小數。Eclipse中GraphView上的Y軸可以設置爲2位小數

當我在我的應用程序中使用圖形時,Y軸上升到小數點後3位。我可以強迫它成爲2嗎?

我使用的是3.1.3版本。我真的不想升級並且不得不更改大量代碼。

如何使用DefaultLabelFormatter? - 對不起,我不能添加評論,因爲我是新的!

+0

你用'DefaultLabelFormatter(xAxisNumberFormatter,yAxisNumberFormatter)'試過了嗎? –

+0

GraphView 3.x的示例仍可在https://github.com/jjoe64/GraphView-Demos/tree/3.x – appsthatmatter

回答

0

我已經升級到4.0版本,然後我可以使用

NumberFormat nf = NumberFormat.getInstance(); 
nf.setMinimumFractionDigits(1); 
nf.setMinimumIntegerDigits(2); 
graph.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter(nf, nf)); 

現在停留在如何從我的數組中添加數據!

+0

上查看文檔和GraphView-Demos項目。 http://www.android-graphview.org/documentation/how-to-create-a-simple-graph – appsthatmatter