java - achartengine two lines with 2 y-axis and 1 x-axis -> second line dont fit -


i trying draw 2 lines in 1 linegraph 2 y-axis , 1 x-axis. first line correct second line doesn't fit x-values.

it looks this:

enter image description here

here code:

bmiseries =  new xyseries("bmi",0);     bmiseries2 =  new xyseries("bmi trefethen",1);      dataset = new xymultipleseriesdataset();      bmirenderer = new xyseriesrenderer();     bmirenderer.setcolor(getresources().getcolor(r.color.green));     bmirenderer.setpointstyle(pointstyle.circle);     bmirenderer.setfillpoints(true);     bmirenderer.setlinewidth(2);     bmirenderer.setdisplaychartvalues(true);      bmirenderer2 = new xyseriesrenderer();     bmirenderer2.setcolor(getresources().getcolor(r.color.red));     bmirenderer2.setpointstyle(pointstyle.circle);     bmirenderer2.setfillpoints(true);     bmirenderer2.setlinewidth(2);     bmirenderer2.setdisplaychartvalues(true);        multirenderer = new xymultipleseriesrenderer(2);     multirenderer.setxlabels(0);     multirenderer.setzoombuttonsvisible(true);     multirenderer.setmargins(new int[] {0, 25 ,25,25});      for(int i=0; i<bmilist.size();i++){         bmiseries.add(i, bmilist.get(i).getbmi_old());         bmiseries2.add(i, bmilist.get(i).getbmi_new());         date dat = bmilist.get(i).getdate();         format formatter = new simpledateformat("yyyy-mm-dd hh:mm:ss");         string date = formatter.format(dat);         multirenderer.addxtextlabel(i, date);     }       dataset.addseries(0, bmiseries);     dataset.addseries(1, bmiseries2);      multirenderer.addseriesrenderer(bmirenderer);     multirenderer.addseriesrenderer(bmirenderer2);     multirenderer.setbarspacing(4);     multirenderer.setapplybackgroundcolor(true);     multirenderer.setbackgroundcolor(color.argb(0x00, 0x01, 0x01, 0x01));     multirenderer.setmarginscolor(color.argb(0x00, 0x01, 0x01, 0x01));     multirenderer.setylabelscolor(0, color.black);     multirenderer.setxlabelscolor(color.black);     multirenderer.setshowgrid(true);     multirenderer.setzoomenabled(true, false);     multirenderer.setxtitle("date");     multirenderer.setytitle("bmi");     multirenderer.setlabelstextsize(15);     multirenderer.setxaxismin(-1);     multirenderer.setxaxismax(2);     multirenderer.setyaxismin(bmiseries.getminy()-5,0);     multirenderer.setyaxismax(bmiseries.getmaxy()+3,0);     multirenderer.setyaxismin(bmiseries2.getminy()-5,1);     multirenderer.setyaxismax(bmiseries2.getmaxy()+3,1);     multirenderer.setyaxisalign(align.right, 0);     multirenderer.setpanenabled(true, false);     multirenderer.setchartvaluestextsize(10);     multirenderer.setzoomlimits(new double[] {-2,10,0,10});     multirenderer.setpanlimits(new double[] { bmiseries.getminx()-1, bmiseries.getmaxx()+10, bmiseries.getminy(), bmiseries.getmaxy()  });      linearlayout chartcontainer = (linearlayout) findviewbyid(r.id.chart_container);     zoomlistener listener = new zoomlistener() {             @override             public void zoomreset() {                 zoomr = 1;                 multirenderer.setchartvaluestextsize(10*zoomr);                 multirenderer.setlabelstextsize(15);              }              @override             public void zoomapplied(zoomevent e) {                 if(e.iszoomin()){                     zoomr += 0.3;                 }                 else{                     zoomr -= 0.3;                 }                 multirenderer.setchartvaluestextsize(10*zoomr);                 multirenderer.setlabelstextsize(15*zoomr);              }     };      mchart = (graphicalview) chartfactory.getlinechartview(getbasecontext(), dataset, multirenderer);     mchart.addzoomlistener(listener, true, true);     chartcontainer.addview(mchart); 

i hope can me

the problem setting x axis range first scale. so, either remove setxaxis* calls or add similar ones second scale have:

multirenderer.setxaxismin(-1, 1); multirenderer.setxaxismax(2, 1); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -