android - How to move Date under X axis? -
i using philjay/mpandroidchart library in app , i'd know if 2 things possible:
- to show last 14 days , scroll previous days?
- can dates (currently on top of graph) moved bottom, along x axis?
here current pic app , want move date
my method:
private void populategraph(cursor data) { arraylist<entry> cravingspoints = new arraylist<entry>(); arraylist<entry> severitypoints = new arraylist<entry>(); arraylist<string> dates = new arraylist<string>(); int index = 0; (int = 0; < data.getcount(); i++) { if (i == 0) { // if orientation changed need start first 1 again data.movetofirst(); } else { data.movetonext(); } try { string date = data.getstring(data.getcolumnindex(smokefreecontentprovider.diary_date)); int cravings = data.getint(data.getcolumnindex(smokefreecontentprovider.diary_cravings_count)); int severity = data.getint(data.getcolumnindex(smokefreecontentprovider.diary_cravings_severity)); datetime diaryentry = datetimeformat.forpattern("yyyymmdd").parsedatetime(date); string entrylabel = diaryentry.tostring("dd mmm"); cravingspoints.add(new entry(cravings, index)); severitypoints.add(new entry(severity, index)); dates.add(entrylabel); index++; } catch (exception e) { log.e("smokefreecravingsgraph", e.getmessage(), e); } } linedataset cravingslinedata = new linedataset(cravingspoints, getstring(r.string.cravings)); linedataset severitylinedata = new linedataset(severitypoints, getstring(r.string.severity)); cravingslinedata.setcirclesize(4f); cravingslinedata.setlinewidth(6f); cravingslinedata.setcolor(getresources().getcolor(r.color.green)); severitylinedata.setcirclesize(4f); severitylinedata.setlinewidth(6f); severitylinedata.setcolor(getresources().getcolor(android.r.color.holo_blue_light)); arraylist<linedataset> datasets = new arraylist<linedataset>(); datasets.add(cravingslinedata); datasets.add(severitylinedata); paint infopaint = new paint(paint.anti_alias_flag); infopaint.settextalign(paint.align.center); infopaint.settextsize(com.github.mikephil.charting.utils.utils.convertdptopixel(14f)); infopaint.setcolor(getresources().getcolor(r.color.dark_grey)); mchart.setdrawgridbackground(false); mchart.setdrawyvalues(false); mchart.setdescription(""); mchart.setstartatzero(true); mchart.setpaint(infopaint, chart.paint_info); mchart.setnodatatext(getstring(r.string.no_cravings_info)); mchart.setnodatatextdescription(getstring(r.string.no_cravings_full_info)); mchart.setdata(new linedata(dates, datasets)); }
yes, check documentation: modifying viewport
take @
setvisiblexrange(float xrange)
method.yes, check documentation: xaxis
take @
xaxis.setposition(...)
method.
Comments
Post a Comment