https://github.com/blackcoder56/reusable-java-charts
Reusable Java Swing Pie Chart component using JFreeChart. Just pass a title and a data map to render a chart panel. Easily integrate dynamic pie charts into any desktop app without rewriting chart logic
https://github.com/blackcoder56/reusable-java-charts
barchart java pie-chart swing visualization
Last synced: 9 months ago
JSON representation
Reusable Java Swing Pie Chart component using JFreeChart. Just pass a title and a data map to render a chart panel. Easily integrate dynamic pie charts into any desktop app without rewriting chart logic
- Host: GitHub
- URL: https://github.com/blackcoder56/reusable-java-charts
- Owner: BlackCoder56
- Created: 2025-07-11T08:47:10.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-11T09:04:32.000Z (11 months ago)
- Last Synced: 2025-07-23T07:13:10.859Z (11 months ago)
- Topics: barchart, java, pie-chart, swing, visualization
- Language: Java
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ CustomPieChart Java Component
A reusable Java Swing component that displays a pie chart using **JFreeChart**. This class allows you to easily generate pie charts anywhere in your application by passing a data map and a chart title.
---
## โ
Features
- ๐ฆ Easy to plug into any Swing UI (`JPanel`)
- โป๏ธ Reusable โ no need to rewrite chart logic for each use
- ๐ง Accepts dynamic data via `Map`
- ๐ฏ Built on the popular [JFreeChart](https://sourceforge.net/projects/jfreechart/) library
---
## ๐ Files
- `CustomPieChart.java` - The reusable class for generating pie charts
- `PieChartDemo.java` - A sample file showing how to use the chart
---
## ๐ Requirements
- Java 8 or above
- JFreeChart library:
- `jfreechart-x.x.x.jar`
- `jcommon-x.x.x.jar`
> ๐ฅ [Download JFreeChart](https://sourceforge.net/projects/jfreechart/)
---
## ๐งช How to Use
### 1. Add the `CustomPieChart.java` class to your project.
```java
import java.util.Map;
CustomPieChart chart = new CustomPieChart("Chart Title", yourMapData);
JPanel chartPanel = chart.getChartPanel();
yourContainerPanel.add(chartPanel);
### 2. Pass a map with your data:
```
```java
Map data = new HashMap<>();
data.put("January", 1200.0);
data.put("February", 900.0);
data.put("March", 1500.0);
```
๐ Example
```java
Map fruits = new HashMap<>();
myData.put("Apples", 25.0);
myData.put("Oranges", 20.0);
myData.put("Bananas", 40.0);
myData.put("Mangoes", 15.0);
CustomPieChart pie = new CustomPieChart("Fruit Distribution", fruits);
JPanel chartPanel = pie.getChartPanel();
myMainPanel.add(chartPanel);
```
### ๐ท Screenshot

๐ License
This project is open for educational and personal use. JFreeChart is under LGPL.
๐โโ๏ธ Author
Elisha โ IT Student & Java Developer
๐ซ Contact: blackcoda56@gmail.com
๐ Projects: Web | Desktop | Data Visualization | Computer vision