java - The shape is not getting changed within if and else if statements in Jfreechart -


in single series i.e in time series chart different shapes have obtained . not coming... pls refer following code , tell me mistake have committed ?

      timeseriescollection dataset = new timeseriescollection(glucoseries);                                                       jfreechart chart = chartfactory.createtimeserieschart("glucometer","date","value",dataset,true,true,false);                                  xyplot xyplot = (xyplot)chart.getplot();      xylineandshaperenderer  renderer = (xylineandshaperenderer) xyplot.getrenderer();       int glucovalue = integer.parseint(glcvalue);      if(glucovalue<80)     {          renderer.setseriesshape(0,new ellipse2d.double(-3.0,-3.0,8.0,8.0));     renderer.setseriesshapesvisible(0,true);      }     else if(glucovalue>80 && glucovalue<100)     {                    renderer.setseriesshape(0,shapeutilities.createuptriangle(4.0f));     renderer.setseriesshapesvisible(0,true);                 }     else if(glucovalue>100 && glucovalue< 120)     {                        renderer.setseriesshape(0,shapeutilities.creatediamond(4.0f));     renderer.setseriesshapesvisible(0,true);                         }     else     {     renderer.setseriesshape(0,shapeutilities.createdowntriangle(4.0f));     renderer.setseriesshapesvisible(0,true);                         }       chartrenderinginfo info = new chartrenderinginfo(new standardentitycollection());     file file1 = new file(request.getrealpath("\\jspchart\\gluco7.png"));     chartutilities.savechartaspng(file1, chart, 700, 400, info);     

enter image description here

the logic in if statement evaluated once, need subclass xylineandshaperenderer#getitemshape return shape based on current value. this

    xylineandshaperenderer renderer =  new xylineandshaperenderer(true, true){         shape ellipse = new ellipse2d.double(-3.0,-3.0,8.0,8.0);         shape uptriangle = shapeutilities.createuptriangle(4.0f);         shape diamond = shapeutilities.creatediamond(4.0f);         shape downtriangle = shapeutilities.createdowntriangle(4.0f);           @override         public shape getitemshape(int row, int column) {             double value = (double) plot.getdataset(0).gety(row, column);             if (value > 6.0 ) {                 return ellipse;             } else if (value >= 5.0 ) {                 return uptriangle;             } else if (value >= 2.0 ) {                 return diamond;             }else {                 return downtriangle;             }         }      };    plot.setrenderer(renderer); 

enter image description here


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -