android - chart values not showing for bar chart achartengine -
i creating default bar chart using achartengine library. values doesn't show properly. want show chart value @ top of bar , align center. me values first bar visible, want see values both bars. how can that? appreciate help.
here code
public intent getintent(context context) { // bar 1 int[] y = { 124, 135, 443, 456, 234, 123, 342, 134, 123, 643, 234, 274 }; categoryseries series = new categoryseries("demo bar graph 1"); (int = 0; < y.length; i++) { series.add("bar " + (i+1), y[i]); } // bar 2 int[] y2 = { 124, 135, 243, 256, 234, 223, 242, 234, 223, 243, 234, 274 }; categoryseries series2 = new categoryseries("demo bar graph 2"); (int = 0; < y.length; i++) { series2.add("bar " + (i+1), y2[i]); } xymultipleseriesdataset dataset = new xymultipleseriesdataset(); dataset.addseries(series.toxyseries()); dataset.addseries(series2.toxyseries()); // how "graph" xymultipleseriesrenderer mrenderer = new xymultipleseriesrenderer(); mrenderer.setcharttitle("demo graph title"); mrenderer.setxtitle("x values"); mrenderer.setytitle("y values"); mrenderer.setaxescolor(color.green); mrenderer.setlabelscolor(color.red); mrenderer.setbarspacing(2.0f); // customize bar 1 xyseriesrenderer renderer = new xyseriesrenderer(); renderer.setcolor(color.red); renderer.setdisplaychartvalues(true); renderer.setchartvaluesspacing((float) 2.5); mrenderer.addseriesrenderer(renderer); // customize bar 2 xyseriesrenderer renderer2 = new xyseriesrenderer(); renderer.setcolor(color.green); renderer.setdisplaychartvalues(true); renderer.setchartvaluesspacing((float) 2.5); mrenderer.addseriesrenderer(renderer2); intent intent = chartfactory.getbarchartintent(context, dataset,mrenderer, type.default); return intent; }
you instantiating renderer
, renderer2
, calling renderer.setdisplaychartvalues(true)
twice , never call renderer2.setdisplaychartvalue(true);
Comments
Post a Comment