Fix the size of the JFreeChart by default when it is plot

A discussion forum for JSFreeChart (a 2D chart library written in JavaScript).
Post Reply
Divya Shrungar
Posts: 1
Joined: Wed Jan 03, 2018 7:28 am
antibot: No, of course not.

Fix the size of the JFreeChart by default when it is plot

Post by Divya Shrungar » Wed Jan 03, 2018 7:39 am

I have an internal pane inside a desktop pane, and I have a chart panel inside the JInertnalFrame. When I run the application, I am getting plot in not like I want, I am able to plot the graph but I have to resize that using mouse. I want to plot the graph and the plot should be according to the chartpanel.How to do that? I am reading the data to plot from a text file.

Code: Select all

public JInternalFrame OpenOption(JFileChooser path) throws FileNotFoundException
        String p=path.toString();
        File f=path.getSelectedFile();

        JInternalFrame iFrame=new JInternalFrame(f.getAbsolutePath(),true,true,true,true);
         iFrame.setSize(900, 500);

         Scanner scan=new Scanner(path.getSelectedFile()).useDelimiter("\\s*(=>|,|;|\\s)\\s*");
         XYSeries series = new XYSeries(path.getSelectedFile());
            while (scan.useDelimiter("\\s*(=>|,|;|\\s)\\s*").hasNextDouble()) 

            XYDataset xyDataset = new XYSeriesCollection(series);

            JFreeChart chart = ChartFactory.createXYLineChart
                    ("","Wave number cm"+'\u2212'+'\u00B9',"Intensity",
                     xyDataset, PlotOrientation.VERTICAL, false, true, false);

             chart.getPlot().setBackgroundPaint( Color.WHITE);
             XYPlot plot = (XYPlot) chart.getPlot();
                plot.setDomainGridlinePaint(new Color(0xC0,0xC0,0xC0));
                plot.setRangeGridlinePaint(new Color(0xC0,0xC0,0xC0));

                //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                plot.getDomainAxis().setRange(plot.getDomainAxis().getRange().getLowerBound() - 0.10,
                           plot.getDomainAxis().getRange().getUpperBound() + 0.10);

             //JPanel chartPanel = new ChartPanel(chart);
             ChartPanel chartPan = new ChartPanel(chart);
             //chartPanel.setPreferredSize(new Dimension(500, 270));
             chartPan.setMinimumDrawWidth( 0 );
             chartPan.setMinimumDrawHeight( 0 );
             chartPan.setMaximumDrawWidth( 1920 );
             chartPan.setMaximumDrawHeight( 1200 );

             return iFrame;


Posts: 1
Joined: Tue May 15, 2018 9:04 pm
antibot: No, of course not.

Re: Fix the size of the JFreeChart by default when it is plot

Post by Alesasa » Tue May 15, 2018 9:08 pm

We are very lucky that we have taken this coding as our prime intern for the main domain of the project. This coding help to generate the maximum energy to create the project for more contact the Hp Support.

Post Reply