How to give titles on X-Axis and Y-Axis in android graph using achartengine library? -


i'm working on android eclipse project in have show teachers feedback report in graph, have made graph static values have give titles on x-axis , y-axis. on x-axis there q1,q2,q3,q4 upto q15 15 blocks existing in graph, on y-axis have give single title 'performance' , show question numbers on x-axis,i have show values on y-axis 1,2,3,4 , 5(the highest value of graph).

here code have used make graph using achartengine library.

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.barchart);     //define buttons     btn1=(button)findviewbyid(r.id.button5);     btn2=(button)findviewbyid(r.id.button1);     btn3=(button)findviewbyid(r.id.button2);     btn4=(button)findviewbyid(r.id.button3);     btn5=(button)findviewbyid(r.id.button4);     qdetail=(button)findviewbyid(r.id.button6);      //define textviews     tv1=(textview)findviewbyid(r.id.textview04);     tv2=(textview)findviewbyid(r.id.textview02);     tv3=(textview)findviewbyid(r.id.textview03);     tv4=(textview)findviewbyid(r.id.textview01);     tv5=(textview)findviewbyid(r.id.textview1);       la = (linearlayout) findviewbyid(r.id.lchart);      //change color     btn1.setbackgroundcolor(color.blue);     btn2.setbackgroundcolor(color.yellow);     btn3.setbackgroundcolor(color.green);     btn4.setbackgroundcolor(color.magenta);     btn5.setbackgroundcolor(color.red);      qdetail.setbackgroundcolor(color.cyan);      //change text     tv1.settext("amir rashid");     tv2.settext("azhar jamil");     tv3.settext("ikram afzal");     tv4.settext("zainab akbar");     tv5.settext("munir ahmed");     //     qdetail.setonclicklistener(new view.onclicklistener()      {         @override         public void onclick(view arg0)          {             // todo auto-generated method stub             intent openstartingpoint=new intent("com.p.evaluate.question");             startactivity(openstartingpoint);                                    }     });      int teacher[] = { 1,2,3,4,5 };     int feedback[] = { 300,200,100,400,500 };     for(int m=0;m<15;m++)     {      (int j = 0; j < teacher.length; j++)      {         drawchart(1, teacher[j], feedback[j]);     }     view view=new view(this);     view.setlayoutparams(new linearlayout.layoutparams(18,0));     linearlayout.layoutparams params=(linearlayout.layoutparams)view.getlayoutparams();     params.setmargins(1,0,0,0);     view.setlayoutparams(params);     la.addview(view);      }  }  private void drawchart(int count, int teacher, int feedback) {     // todo auto-generated method stub     system.out.println(count + teacher+ feedback);     if (teacher == 1) {         teacher = color.blue;                     }     if (teacher == 2) {         teacher = color.yellow;                     }     if (teacher == 3) {         teacher= color.green;                     }      if (teacher == 4) {         teacher = color.magenta;                     }     if (teacher == 5) {         teacher= color.red;                     }       for(int k=1;k<=count;k++)     {         view view=new view(this);         view.setbackgroundcolor(teacher);         view.setlayoutparams(new linearlayout.layoutparams(6,feedback));         linearlayout.layoutparams params=(linearlayout.layoutparams)view.getlayoutparams();         params.setmargins(0,0,0,0);         view.setlayoutparams(params);         la.addview(view);         view.sethorizontalscrollbarenabled(true);     }     }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; } 

}

you can put x-axis , y-axis title in xymultipleseriesrenderer class.

xymultipleseriesrenderer mrenderer = new xymultipleseriesrenderer(); mrenderer.setxtitle("put x-axis title here"); mrenderer.setytitle("put y-axis title here"); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -