Create Wind Chart Using JFreeChart

Create Wind Chart Using JFreeChart explains about creating a simple wind chart using JFreechart API

How To Create Wind 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 Wind 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 (Wind Chart)

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;

public class JFreeChartWindChartExample extends JFrame {

private static final long serialVersionUID = 1L;
private static Calendar cal = new GregorianCalendar();

public JFreeChartWindChartExample(String applicationTitle) {
// Creates a sample dataset for wind chart
WindDataset dataSet = getWindDataset();
// Based on the dataset we are creating WindChart
JFreeChart windChart = ChartFactory.createWindPlot("WindChart Example", "Date", "Direction", dataSet, true, false, false);
// Adding chart into a chart panel
ChartPanel chartPanel = new ChartPanel(windChart);
// setting default size
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
// add to contentPane

public static WindDataset getWindDataset() {
Object[][][] data = new Object[][][] { { { createDate(2012, Calendar.MARCH, 3), new Double(0.0), new Double(10.0) },
{ createDate(2012, Calendar.MARCH, 4), new Double(1.0), new Double(8.5) },
{ createDate(2012, Calendar.MARCH, 5), new Double(2.0), new Double(10.0) },
{ createDate(2012, Calendar.MARCH, 6), new Double(3.0), new Double(10.0) },
{ createDate(2012, Calendar.MARCH, 7), new Double(4.0), new Double(7.0) },
{ createDate(2012, Calendar.MARCH, 8), new Double(5.0), new Double(10.0) },
{ createDate(2012, Calendar.MARCH, 9), new Double(6.0), new Double(8.0) },
{ createDate(2012, Calendar.MARCH, 10), new Double(7.0), new Double(11.0) },
{ createDate(2012, Calendar.MARCH, 11), new Double(8.0), new Double(10.0) },
{ createDate(2012, Calendar.MARCH, 12), new Double(9.0), new Double(11.0) },
{ createDate(2012, Calendar.MARCH, 13), new Double(10.0), new Double(3.0) },
{ createDate(2012, Calendar.MARCH, 14), new Double(11.0), new Double(9.0) },
{ createDate(2012, Calendar.MARCH, 15), new Double(12.0), new Double(11.0) },
{ createDate(2012, Calendar.MARCH, 16), new Double(0.0), new Double(0.0) } } };

return new DefaultWindDataset(new String[] { "Wind!!" }, data);

private static Date createDate(int year, int month, int day) {
cal.set(year, month, day);
return cal.getTime();

public static void main(String[] args) {
JFreeChartWindChartExample chart = new JFreeChartWindChartExample("Wind Statistics");

Create Wind Chart Using JFreeChart

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