Saturday, 15 March 2014

android - TimeStamp on Custom X-Labels with an array of 1 value -



android - TimeStamp on Custom X-Labels with an array of 1 value -

i have issue xlabels in achartengine when there 1 value in arraylist. generate own xlabels line chart, when there 1 info array value, unwanted timestamp on top of generated xlabels.

my code:

private xymultipleseriesdataset getdemodataset() { calendar cal = calendar.getinstance(); date date = new date(); date_value = new string[list.size()]; value_value = new string[list.size()]; for(int k = 0; k < list.size(); k++){ date_value[k] = list.get(k).get(date); value_value[k] = list.get(k).get(value); } timeseries series = new timeseries("line graph"); for(int j=0; j < date_value.length; j++) { series.add(formatter.stringtodate(date_value[j]), integer.parseint()); } xymultipleseriesdataset dataset = new xymultipleseriesdataset(); dataset.addseries(series); homecoming dataset; }

setchartsetting:

private void setchartsetting(xymultipleseriesrenderer renderer){ renderer.setxroundedlabels(true); renderer.setxtitle("dates"); renderer.setytitle(kpiname); renderer.setapplybackgroundcolor(true); renderer.setfitlegend(false); renderer.setaxescolor(color.dkgray); renderer.setshowgrid(true); renderer.setzoomenabled(false); renderer.setxlabels(0); renderer.setylabels(10); renderer.setzoomenabled(false, false); renderer.setpanenabled(false, false); //string[] date_value = new string[list.size()]; //string[] value_value = new string[list.size()]; if(list.isempty() || list.size() == 0 || list == null ){ return; } if(name.equals(recovered) || name.equals(conversion)){ largest_size = (int)double.parsedouble(value_value[0]); }else{ if(!(value_value.length == 0)){ largest_size = integer.parseint(value_value[0]); }else{ return; } } //used determine maximum value y-axis for(int x =0; x < value_value.length; x++){ if(integer.parseint(value_value[x]) > largest_size){ largest_size = integer.parseint(value_value[x]); } } renderer.setyaxismax((double)largest_size); renderer.setyaxismin(0); int value_size = value_value.length; int m = 0; //int add together = value_size/10; int add together = largest_size/10; /*instance variables setting labels on x-axis based on weather values in array * more 10 items or less*/ double d; long l; long l1; double d1; if(date_value.length <= 1){ int lastly = date_value.length; int mod = 0; //int add_mod = math.round(last/10); int add_mod = (int)math.round((double)math.round(last)); l = long.valueof(formatter.stringtodatereport(date_value[0]).gettime()); d = l.doublevalue(); /*tried see if can remove timestamp*/ //renderer.addxtextlabel(0.0, ""); //renderer.removextextlabel(0.0); //renderer.clearxtextlabels(); renderer.addxtextlabel(d, date_value[0]); } else if(date_value.length < 10){ for(int = 0; < date_value.length; i++){ if(i >= date_value.length){ break; } l = long.valueof(formatter.stringtodatereport(date_value[i]).gettime()); d = l.doublevalue(); renderer.addxtextlabel(d, date_value[i]); } } else if(date_value.length >= 10){ int lastly = date_value.length; //int lastly = 28; //log.d(tag, "last " + last); int mod = 0; //int add_mod = math.round(last/10); int add_mod = (int)math.round((double)math.round(last) /10); // decimal value double , round nearset whole int for(int =0; < date_value.length; i++){ if(mod >= date_value.length){ break; } l1 = long.valueof(formatter.stringtodatereport(date_value[mod]).gettime()); d1 = l1.doublevalue(); renderer.addxtextlabel(d1, date_value[mod]); mod+=add_mod; } } } }

and then:

chartview = chartfactory.getlinechartview(context, getdemodataset(), setchartsettings(renderer));

when there multiple values, plots graph custom xlabels(format mmm-yyyy), when there 1 value in arraylist, generates thats time stamp.

here image:

this bug, indeed. can download version including prepare feature here.

android achartengine

No comments:

Post a Comment