android - mpandroid chart certain methods unable to resolve -
so i'm using awesome mpandroid chart library make simple linechart. able customize heavily using example project on github.
the problem is, when move own code, methods no longer able resolved:
mlinechart.setextraoffsets() , mlinechart.setautoscaleminmaxenabled() in particular. there might others these 2 i've noticed.
everything else works fine though. idea why can't access these 2 methods? should dig find out more why case?
public class myfragment extends fragment { private linechart mlinechart; // stuff here @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // stuff here // creating numbers line chart candidate linechart numchart = (linechart)view.findviewbyid(r.id.numberslinechart); setnumchart(numchart, mobject.getnums()); // stuff here } public void setnumchart(linechart linechart, list<integer> nums){ mlinechart = linechart; mlinechart.setdrawgridbackground(false); // no description text mlinechart.setdescription(""); mlinechart.setnodatatextdescription("you need provide data chart."); // enable value highlighting mlinechart.sethighlightenabled(true); // enable touch gestures mlinechart.settouchenabled(true); // enable scaling , dragging mlinechart.setdragenabled(false); mlinechart.setscaleenabled(false); // if disabled, scaling can done on x- , y-axis separately mlinechart.setpinchzoom(false); // create custom markerview (extend markerview , specify layout use it) mymarkerviewv2 mv = new mymarkerviewv2(getactivity(), r.layout.custom_marker_view, mlinechart); // set marker chart mlinechart.setmarkerview(mv); // disable axes lines , labels yaxis leftaxis = mlinechart.getaxisleft(); leftaxis.setenabled(false); mlinechart.getaxisright().setenabled(false); xaxis bottomaxis = mlinechart.getxaxis(); bottomaxis.setenabled(false); // add data setlinechartdata(nums); //this method cannot resolved******************** mlinechart.setextraoffsets(30f,50f,30f,0f); // legend (only possible after setting data) legend l = mlinechart.getlegend(); l.setenabled(false); mlinechart.invalidate(); } public void setlinechartdata(list<integer> nums){ //create xvariables aka strings of months arraylist<string> xvals = new arraylist<string>(); (int = 0; < nums.size(); i++) { xvals.add(month.getmonthfromindex(i).getabbrev()); } //add corresponding numbers arraylist<entry> yvals = new arraylist<entry>(); (int = 0; < nums.size(); i++) { yvals.add(new entry(nums.get(i), i)); } // create dataset , give type linedataset set1 = new linedataset(yvals, "dataset"); set1.setcolor(color.black); set1.setcirclecolor(color.black); set1.setlinewidth(0.75f); set1.setdrawcircles(true); set1.setdrawvalues(false); set1.setcirclesize(1.75f); set1.setdrawcirclehole(false); arraylist<linedataset> datasets = new arraylist<linedataset>(); datasets.add(set1); // add datasets // create data object datasets linedata data = new linedata(xvals, datasets); // set data mlinechart.setdata(data); } // stuff here class mymarkerviewv2 extends markerview { private textview markercontent; private linechart mchart; public mymarkerviewv2(context context, int layoutresource, linechart lchart) { super(context, layoutresource); mchart = lchart; markercontent = (textview) findviewbyid(r.id.markercontent); } // callbacks everytime markerview redrawn, can used update // content (user-interface) @override public void refreshcontent(entry e, int datasetindex) { if (e instanceof candleentry) { candleentry ce = (candleentry) e; list<string> months = mchart.getlinedata().getxvals(); markercontent.settext(months.get(e.getxindex() % 12) + "\n" + utils.formatnumber(ce.gethigh(), 0, true) + "%"); } else { list<string> months = mchart.getlinedata().getxvals(); markercontent.settext(months.get(e.getxindex() % 12) + "\n" + utils.formatnumber(e.getval(), 0, true) + "%"); } } @override public int getxoffset() { // center marker-view horizontally return -(getwidth() / 2); } @override public int getyoffset() { // cause marker-view above selected value return -getheight(); } }
i have linechart wrapped inside vertical linearlayout other elements , whole thing wrapped inside scrollview. not sure if that's what's causing problem or not.
nevermind, figured out. it's because library downloaded maven , gradle not same 1 included in example project on website.
Comments
Post a Comment