An open API service indexing awesome lists of open source software.

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

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
![Pie Chart Screenshot](images/piechartScreenshot.png)

๐Ÿ“„ 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