Search code examples
androideclipseandroid-graphview

Can Y Axis on GraphView in eclipse be set to 2 decimal places


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

I am populating a graph as above, my array contains values set to 2 decimal places.

When I use the graph on my app, the Y axis goes up to 3 decimal places. Can I force it to be 2?

I am using version 3.1.3. I don't really want to upgrade and have to change loads of code.

How do I use DefaultLabelFormatter? - Sorry I can't add a comment as I'm new!


Solution

  • I have had to upgrade to version 4 then I can use

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

    Now stuck on how to add data from my array!!!