How to add a JFreeChart Pie Chart to a Panel in Netbeans Using Java
This tutorial is all about How to add a JFreeChart Pie Chart to a Panel in Netbeans. In this tutorial you will learn how to create a professional quality charts in your applications. JFreeChart is an opensource or more specifically, free software. This tutorial uses jfreechart-1.0.19.jar version Package library and Netbeans IDE. Please follow all the steps below to complete this tutorial.
Steps on How to add a JFreeChart Pie Chart to a Panel in Netbeans Using
Download the JFreeChart library in this website www.jfree.org/jfreechart
If the download is done, add it to your project by right clicking the Libraries folder located in your project and then Add JAR/Folder and browse where your downloaded package located and inside lib folder add all the libraries listed.
The next step is to
Create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. And then drag a button in your form.
After that you need to import these packages
above your class and
then double click your button and copy paste the code below:
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue(“Value 1”, new Integer(10));
dataset.setValue(“Value 2”, new Integer(20));
dataset.setValue(“Value 3”, new Integer(30));
dataset.setValue(“Value 4”, new Integer(40));
JFreeChart chart = ChartFactory.createPieChart(“Your title”, dataset, true, true, true);
ChartFrame yourFrame = new ChartFrame(“Your title”, chart);
Then you’re done. Run your project and see if it works.
About How to add a JFreeChart Pie Chart to a Panel in Netbeans In Java
|Project Name:||How to add a JFreeChart Pie Chart to a Panel in Netbeans|
For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:
E-Mail: [email protected]
Contact No.: +639098911050
Ryan A. Salem
BSIT Graduate, soon to be MIT.
Java Developer / System Developer
Related topic(s) that you make like:
1.) Create Login Form in Java
2.) How to Add Textbox KeyListener in Java