android - how to set custom Y-labels in MPAndroid chart -
i use mpandroid chart present values in time (the performance of users). code prepared chart data is:
barchart chart = (barchart) rootview.findviewbyid(r.id.chart); arraylist<barentry> enteries = new arraylist<>(); arraylist<string> labels = new arraylist<>(); (int = 0; < data.length; i++) { enteries.add(new barentry(data[i].getvalue(), i)); labels.add(data[i].getname()); } bardataset dataset = new bardataset(enteries, ""); int[] clr = new int[]{color.red, color.red, color.red, color.rgb(0xff, 0xff, 0x00), color.blue, color.black}; dataset.setcolors(clr); chart.setdata(new bardata(labels, dataset)); chart.animatey(500);
values in 'data' in 'seconds'.
how can show values both in y-labels , above bars in hhhh:mm:ss
format, i.e. 1:40 (1 minute , 40 seconds) instead of 100.
edit1:
solved problem of y-lables defining custom yaxisvalueformatter
class:
public class myyaxisvalueformatter implements yaxisvalueformatter{ public myyaxisvalueformatter () { } @override public string getformattedvalue(float value, yaxis yaxis) { string ylabel=""; int h=(int)(value/3600); int m=(int)((value%3600)/60); int s=(int)(value%60); if(h>0) ylabel=ylabel+integer.tostring(h)+":"; if(m>0) ylabel=ylabel+integer.tostring(m)+":"; ylabel=ylabel+integer.tostring(s); return ylabel; } }
but couldn't find way change format of values above bars yet!
Comments
Post a Comment