Skip to main content

How to use Pie Chart in Java in Intellij Idea IDE

Graphs make information easier to see. This is especially true when two or more sets of numbers are related in some way. Scientists and engineers use graphs so that they can get a better understanding of the broad meaning and importance of their data.

Pie Chart

A circular statistical graph, which is divided into slices to illustrate numerical proportion.

Before starting the code, we will need a JFreechart library to show different charts in our application.
JFreeChart is a free 100% Java chart library that makes it easy for developers to display professional quality charts in their applications.
You can download JFreeChart library from this URL.


Once you download the Zip file, after unzipping the file you will get multiple jar files in lib folder. For this tutorial we do not need all jars of this library.
We will use two jar files for this example.
1). jfreechart-x.x.x
2). jcommon-x.x.x

Let’s begin.

(1). Create a simple Java Application Project in Intellij IDEA.

(2). Add those 2 jar files (jfreechart-x.x.x, jcommon-x.x.x) in your project. (If you don’t know how to add, watch this post first).

(3). Create a simple GUI Form, lets give it a name PieChartForm.


(4). In .form file design a simple UI shown below.


(5). PieChartForm.java class will extend JFrame so that we can show the chart.

In this code I have given Student Grades as first argument to give this chart a name.
And a createDataSet() method which will populate the graph with data

Output:


In this example I have populated the chart with static data sets, you can replace them with yours dynamically by using your logic.

Comments

  1. Our Free Game Helps Young People Ages 16 To 21 Develop Work Readiness Skills From Home.
    Embark On Your Virtual Journey Around The Globe And Try Out Jobs In Growth Industries
    Now! Life Skills Curriculum. Global Youth Job Skills. Holistic Approach.
    vstkey.com
    WebStorm Crack
    Electronik Sound Lab Drumart Crack
    JetBrains PhpStorm Crack
    PhpStorm Crack
    Adobe Illustrator Crack
    Adobe Acrobat Pro DC Crack
    Adobe Dreamweaver CC Crack

    ReplyDelete

Post a Comment

Popular posts from this blog

How to add external libraries/jar files in Intellij IDE

At many situations we must need to add external libraries to our projects to solve a problem or to add some extra functionality. Intellij IDE offers two ways to add external libraries to your project  By adding Jar Files.  Using maven dependency code By adding jar files. For this you will need that external jar file/s in your system. Now follow these steps:- (a). Click on File, and click on Project Structures… (b). A dialog box having name Project Structure will open (c). Click on Libraries (In left side), then click on green plus Icon and then click on Java (d). A dialog box having name Select Library Files will open. Navigate through Folders and select jar file/s you want to add in your project. Then click OK. Your jar files are now added to your project.

How to use FormLayout (JGoodies) in Intellij IDE

The FormLayout helps you lay out and implement consistent Swing panels fast. FormLayout makes simple things easy and the hard stuff possible. • Powerful, flexible, previse layout • Easy to learn and easy to work with • Faster panel production • Better code readability To use this Layout in Intellij or any other IDE you will need to add its jar files into your project. First download jar files in your system using this URL and then add these jars to your project. If you don’t know how to add external libraries in project in Intellij IDEA, you can get help of this post .