JFreeChart - Wafer Map Chart example

Posted on February 21, 2017


A Wafer Map chart is used to represent the performance of a semiconductor device on a substrate or wafer. The Wafer Map chart represents the variation in performance as color-coded grids.

In this post, we will show you how to create a Wafer Map chart using the JFreeChart 1.0.19 library.

The following example demonstrates how to create a simple WaferMap chart using the JFreeChart.

WaferMapChartExample.java

package com.boraji.tutorial.jfreechart;

import java.util.Random;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.WaferMapDataset;

/**
 * @author imssbora
 */
public class WaferMapChartExample extends JFrame {
   private static final long serialVersionUID = 6294689542092367723L;

   public WaferMapChartExample(String title) {
      super(title);

      // Create dataset
      WaferMapDataset dataset = createDataset();

      // Create chart
      JFreeChart chart = ChartFactory.createWaferMapChart(
            "Wafer Map Chart Example | BORAJI.COM", 
            dataset, PlotOrientation.HORIZONTAL, true, false, false);

      // Create Panel
      ChartPanel panel = new ChartPanel(chart);
      setContentPane(panel);
   }

   private WaferMapDataset createDataset() {
      WaferMapDataset dataset = new WaferMapDataset(10, 10);

      // Random data for wafer dataset
      Random random = new Random();
      
      for (int i = 1; i < 10; i++) {
         for (int j = 1; j < 10; j++) {
            dataset.addValue(random.nextInt(3)+1, i, j);
         }
      }

      return dataset;
   }

   public static void main(String[] args) {
      SwingUtilities.invokeLater(() -> {
         WaferMapChartExample example = new WaferMapChartExample(
               "Wafer Map Chart Example | BORAJI.COM");
         example.setSize(800, 400);
         example.setLocationRelativeTo(null);
         example.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         example.setVisible(true);
      });
   }
}

Output

wafermapchart.png