Create Bubble Chart Using JFreeChart

Create Bubble Chart Using JFreeChart explains about creating a simple bubble chart using JFreechart API

A bubble chart or bubble graph is a type of chart that displays three dimensions of data. Each entity with its triplet (v1, v2, v3) of associated data is plotted as a disk that expresses two of the vi values through the disk's xy location and the third through its size. Bubble charts can facilitate the understanding of social, economical, medical, and other scientific relationships.

Reference ->

How To Create Bubble Chart Using JFreeChart library?

JFreeChart is a free and open source java chart library used for creating professional quality charts. JFreeChart is purely written in java language, we can very easily incorporate JFreeChart in our java standalone and web applications.

Referenece - >

Here I am showing an example about How to create  a simple Bubble Chart using JFreeChart.


1) If you need pie chart example, You can follow Create Pie Chart Using JFreeChart

2) If you need line chart example, You can follow Create Line Chart Using JFreeChart

3) If you need bar chart example, You can follow Create Bar Chart Using JFreeChart

4) If you need polar chart example, You can follow Create Polar Chart Using JFreeChart

5) If you need bubble chart example, You can follow Create Bubble Chart Using JFreeChart

6) If you need wind chart example, You can follow Create Wind Chart Using JFreeChart

Required Libraries

You need to download

  1. JFreeChart

Following jar must be in classpath

  1. jfreechart-1.5.0.jar
  2. jcommon-1.0.24.jar



We can create following professional quality charts by using jfreechart.

  • Single valued Charts such as compass, speedometer, thermometer
  • Line Chart
  • Pie Chart
  • Bar Chart
  • Bubble Chart
  • Wind Chart
  • Polar Chart

JFreeChart Example (Bubble Chart)

import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;

public class JFreeChartBubbleChartExample extends JFrame {

private static final long serialVersionUID = 1L;
private static final int SIZE = 10;
public JFreeChartBubbleChartExample(String applicationTitle) {
// Creates a sample dataset for bubble chart
final NormalizedMatrixSeries series = new NormalizedMatrixSeries("Grid 1", SIZE, SIZE);
for (int count = 0; count < SIZE; count++) {
final int i = (int) (Math.random() * SIZE);
final int j = (int) (Math.random() * SIZE);
final int k = (int) (Math.random() * SIZE);
(i, j, k);
        MatrixSeriesCollection dataSet =
new MatrixSeriesCollection(series);

// Based on the dataset we are creating BubbleChart
JFreeChart bubbleChart = ChartFactory.createBubbleChart("Population Details", "X", "Y", dataSet, PlotOrientation.VERTICAL, true, true,false);
        XYPlot plot = bubbleChart.getXYPlot
        NumberAxis domainAxis =
(NumberAxis) plot.getDomainAxis();
        NumberAxis rangeAxis =
(NumberAxis) plot.getRangeAxis();
// Adding chart into a chart panel
ChartPanel chartPanel = new ChartPanel(bubbleChart);
// settind default size
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
// add to contentPane

public static void main(String[] args) {
JFreeChartBubbleChartExample chart = new JFreeChartBubbleChartExample("Population Usage Statistics");

Create Bubble Chart Using JFreeChart

Your email address will not be published. Required fields are marked *