java - jfreeChart : Draw XYlinechart dynamically -


i'm new between it's min first post;) start jfreechart of java find interesting lost it! want make chart , xyline suits me, find static gente can not add points dataset after execution of program. want click on point of chart drawing point, here end of code, can not dynamically, can not it. first concern use method recover coordinates of point when click on chart foam clicked not exact, has work on ?? voluntary svp below training code.

    /*  * change license header, choose license headers in project properties.  * change template file, choose tools | templates  * , open template in editor.  */ package audiogramme;  /**  *  * @author user  */  import java.awt.color;  import java.awt.basicstroke;  import java.awt.point; import java.awt.geom.point2d; import java.awt.geom.rectangle2d;  import org.jfree.chart.chartpanel;  import org.jfree.chart.jfreechart;  import org.jfree.data.xy.xydataset;  import org.jfree.data.xy.xyseries;  import org.jfree.ui.applicationframe;  import org.jfree.ui.refineryutilities;  import org.jfree.chart.plot.xyplot;  import org.jfree.chart.chartfactory;  import org.jfree.chart.chartmouseevent; import org.jfree.chart.chartrenderinginfo; import org.jfree.chart.axis.valueaxis; import org.jfree.chart.event.chartprogressevent; import org.jfree.chart.event.chartprogresslistener; import org.jfree.chart.plot.plotorientation;  import org.jfree.data.xy.xyseriescollection;  import org.jfree.chart.renderer.xy.xylineandshaperenderer; import org.jfree.data.general.datasetutilities; import org.jfree.ui.rectangleedge;  public class xylinechart_essaie1 extends applicationframe {       final xyseriescollection dataset = new xyseriescollection( );             final xyseriescollection dataset1 = new xyseriescollection( );       final xyseries audiogramme = new xyseries( "audiogramme" );          final xyseries firefox = new xyseries( "firefox" );   chartpanel chartpanel;      final xyseriescollection madataset = new xyseriescollection( );      private object xcrosshair;     public xylinechart_essaie1( string applicationtitle, string charttitle ) {       super(applicationtitle);       jfreechart xylinechart = chartfactory.createxylinechart(          charttitle ,          "category" ,          "score" ,          createdataset() ,          plotorientation.vertical ,          true , true , false);          chartpanel = new chartpanel( xylinechart );        chartpanel.setpreferredsize( new java.awt.dimension( 560 , 367 ) );        final xyplot plot = xylinechart.getxyplot( );        xylineandshaperenderer renderer = new xylineandshaperenderer( );       renderer.setseriespaint( 0 , color.red );       renderer.setseriespaint( 1 , color.green );       renderer.setseriespaint( 2 , color.yellow );       renderer.setseriesstroke( 0 , new basicstroke( 4.0f ) );       renderer.setseriesstroke( 1 , new basicstroke( 3.0f ) );       renderer.setseriesstroke( 2 , new basicstroke( 2.0f ) );       plot.setrenderer( renderer );        setcontentpane( chartpanel );    xylinechart.addprogresslistener(new chartprogresslistener() {           private object firefox1;          @override       public void chartprogress(chartprogressevent cpe) {         if(cpe.gettype()==chartprogressevent.drawing_finished){          system.out.println("click event!");         xyplot xyplot2 = chartpanel.getchart().getxyplot();         system.out.println(xyplot2.getdomaincrosshairvalue() + " "             + xyplot2.getrangecrosshairvalue());           }         }     });      }      private xydataset createdataset( ) {        firefox.add( 1.0 , 1.0 );                 firefox.add( 2.0 , 4.0 );                 firefox.add( 3.0 , 3.0 );                  dataset.addseries( firefox );                 return dataset;    }      public static void main( string[ ] args ) {       xylinechart_essaie1 chart = new xylinechart_essaie1("browser usage statistics",          "which browser using?");       chart.pack( );                 refineryutilities.centerframeonscreen( chart );                 chart.setvisible( true );     } } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -