Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can't get JFreeChart to work

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Unhappy Can't get JFreeChart to work

    Hi all,
    I've wasted the whole day trying to get JFreeChart to work in NetBeans, in both Windows and Linux and have completely failed. Does anyone have any experience with this? I don't care what OS gets it up and running, I just need to use it for my GUI. I followed the help pdf and read the README and followed the instructions to the letter, but the classpaths don't seem to recognised.

    Any help would be massively appreciated

    Ps. I'm not tied to NetBeans, any method would work


  2. #2
    Junior Member
    Join Date
    Jun 2009
    Posts
    18
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default Re: Can't get JFreeChart to work

    Used the jar file from JKLJar File Download and it worked fine, maybe the newest one has some bugs?
    Anyway, 13 works fine for me

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can't get JFreeChart to work

    Hi Igniteflow,

    Download Jfreechar from here Download JFreeChart from SourceForge.net

    once downloaded extract the file onto your desktop!,once extracted,open up netbeans -> right click on the libraries(place on left side of your netbeans project)->select add jar/folder->dialog box pops up,navigate to the lib folder of your downloaded jfreechart-1.0.13,and add them all.now all the required libraries are placed.

    Once you are done with that,try this code out!

    import javax.swing.JFrame;
     
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.plot.PiePlot3D;
    import org.jfree.data.general.DefaultPieDataset;
    import org.jfree.data.general.PieDataset;
    import org.jfree.util.Rotation;
     
     
     
     
     
     
     
    public class PieChart extends JFrame {
     
     
    	public PieChart(String applicationTitle, String chartTitle) {
            super(applicationTitle);
            // This will create the dataset
            PieDataset dataset = createDataset();
            // based on the dataset we create the chart
            JFreeChart chart = createChart(dataset, chartTitle);
            // we put the chart into a panel
            ChartPanel chartPanel = new ChartPanel(chart);
            // default size
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            // add it to our application
            setContentPane(chartPanel);
     
        }
     
        /**
         * Creates a sample dataset
         */
        private  PieDataset createDataset() {
            DefaultPieDataset result = new DefaultPieDataset();
            result.setValue("Linux", 50);
            result.setValue("Mac", 20);
            result.setValue("Windows", 51);
            return result;
     
        }
     
        /**
         * Creates a chart
         */
        private JFreeChart createChart(PieDataset dataset, String title) {
     
            JFreeChart chart = ChartFactory.createPieChart3D(
                title,  				// chart title
                dataset,                // data
                true,                   // include legend
                true,
                false
            );
     
            PiePlot3D plot = (PiePlot3D) chart.getPlot();
            plot.setStartAngle(290);
            plot.setDirection(Rotation.CLOCKWISE);
            plot.setForegroundAlpha(0.5f);
            return chart;
     
        }
     
     
     
     
    }
     
     
     
    class Main
    {
    	 public static void main(String[] args) {
    	        PieChart demo = new PieChart("Comparison", "Which operating system are you using?");
    	        demo.pack();
    	        demo.setVisible(true);
    	    }
    }



    Kind Regards,
    Manish87

Similar Threads

  1. Long term project work from home developer
    By internext in forum Paid Java Projects
    Replies: 17
    Last Post: May 2nd, 2012, 07:51 PM
  2. Why won't this while loop work?
    By trueblue in forum Loops & Control Statements
    Replies: 2
    Last Post: July 17th, 2009, 09:10 AM