android - how to change display value of x axis in bar graph-achartengine -
i'm using achartengine library forline graph.instead of timestamp how can show date in x-axis
my code is
public graphicalview getline(context context, linkedhashmap<string, list<item>> data, string value2, string value3) { list<timeseries> series=new arraylist<timeseries>(); set<string> keys = data.keyset(); for(string key:keys) { timeseries series1 = new timeseries(key); list<item> value=data.get(key); for(item itm:value) { double temp=double.parsedouble(itm.getdataitem(value3)); string temp1=null; if(value2.equals("created_time")) { temp1=itm.getcreated_time(); } else { try { temp1=itm.getmodified_time(); } catch (nullpointerexception e) { temp1=itm.getcreated_time(); } } timestamp timestamp = new timestamp(integer.parseint(temp1.substring(0,10))); date date = new date(timestamp.gettime()*1000); series1.add(date,temp); } series.add(series1); } xymultipleseriesdataset dataset = new xymultipleseriesdataset(); for(timeseries serie:series) { dataset.addseries(serie); } xymultipleseriesrenderer mrenderer = new xymultipleseriesrenderer(); // holds collection of xyseriesrenderer , customizes graph mrenderer.setbackgroundcolor(color.black); mrenderer.setzoomenabled(true); mrenderer.setantialiasing(true); for(timeseries serie:series) { xyseriesrenderer renderer = new xyseriesrenderer(); // used customize line 1 mrenderer.addseriesrenderer(renderer); int color; random rnd = new random(); color = color.argb(200, rnd.nextint(256), rnd.nextint(256), rnd.nextint(256)); renderer.setcolor(color); renderer.setpointstyle(pointstyle.circle); renderer.setfillpoints(true); } return chartfactory.getlinechartview(context, dataset, mrenderer); }
you can set custom labels:
renderer.addxtextlabel(x, formatteddate);
Comments
Post a Comment