java - Achartengine : remove chart before and redraw new chart -


i frustased redraw chart using achartengine library, have remove view, chart make new on top chart, confused... have search method can't it.. question before : achartengine : how repaint / redraw chart

how redraw chart everytime slide seekbar?

this source code :

        @override     protected void onresume() {         // todo auto-generated method stub         super.onresume();          if (mchartview == null) {    lnchart = (linearlayout) findviewbyid(r.id.chart);               mchartview = chartfactory.getlinechartview(this, mdataset, mrenderer);               mchartview.setonclicklistener(new view.onclicklistener() {                     @override                     public void onclick(view v) {                       seriesselection seriesselection = mchartview.getcurrentseriesandpoint();                       double[] xy = mchartview.torealpoint(0);                       if (seriesselection == null) {                             toast.maketext(getapplicationcontext(), "tidak ada chart yang dipilih", toast.length_short)                                 .show();                           } else {                         toast.maketext(                                 getapplicationcontext(),                                 "nilai " + listdata.get(seriesselection.getpointindex()).getinunilai()+                                 "  tanggal " + listdata.get(seriesselection.getpointindex()).gettanggal(),                                  toast.length_short).show();                              }                     }                   });               lnchart.addview(mchartview, 0, new layoutparams(layoutparams.fill_parent, layoutparams.fill_parent));               }          else { mchartview.repaint();              }     }      public void renderchart(arraylist<nabdetail> listdata) {         // todo auto-generated method stub          string seriestitle = "";         xyseries series = new xyseries(seriestitle);         mdataset.addseries(series);         mcurrentseries = series;         xyseriesrenderer renderer = new xyseriesrenderer();         renderer.setfillbelowline(true);         renderer.setfillbelowlinecolor(color.transparent);         renderer.setcolor(color.yellow);         mrenderer.addseriesrenderer(renderer);         mrenderer.setinscroll(true);         mrenderer.setshowlegend(false);         //hide x label         mrenderer.setxlabels(result_ok);         renderer.setfillpoints(true);         mcurrentrenderer = renderer;           (int = 0; < listdata.size(); i++) {              mcurrentseries.add(i,listdata.get(i).getinunilai()                      );          }      if (mchartview != null) {          lnchart.removeviewat(0);             mchartview.repaint();         }     } } 

i have used lnchart.removeviewat(0); mchartview.repaint(); chart still not redraw... how redraw , remove chart before? must put right code?

please.. hope can me solve problem

this piece of code should work you.

public void renderchart(arraylist<nabdetail> listdata) {     // clear previous chart dataset , renderer.     mdataset.clear();     mrenderer = new xymultipleseriesrenderer();      string seriestitle = "";     xyseries series = new xyseries(seriestitle);     mdataset.addseries(series);     mcurrentseries = series;     xyseriesrenderer renderer = new xyseriesrenderer();     renderer.setfillbelowline(true);     renderer.setfillbelowlinecolor(color.transparent);     renderer.setcolor(color.yellow);     mrenderer.addseriesrenderer(renderer);     mrenderer.setinscroll(true);     mrenderer.setshowlegend(false);     //hide x label     mrenderer.setxlabels(result_ok);     renderer.setfillpoints(true);     mcurrentrenderer = renderer;      (int = 0; < listdata.size(); i++) {         mcurrentseries.add(i,listdata.get(i).getinunilai());     }      // repaint chart new mdataset , mrenderer.     repaint(); }  private void repaint() {     lnchart = (linearlayout) findviewbyid(r.id.chart);      if (mchartview != null) {         lnchart.removeview(mchartview);     }      mchartview = chartfactory.getlinechartview(this, mdataset, mrenderer);      lnchart.addview(mchartview, 0, new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -