// SpecifyColumns:


// To generate a radar chart for each value of a categorical variable
// and align the charts horizontally, assign the Column variable role
// to an appropriate categorical variable.

   import com.sas.graphics.components.radarchart.RadarChart;
   import com.sas.graphics.components.radarchart.RadarChartTableDataModel;
   import com.sas.graphics.components.AnalysisVariable;
   import com.sas.graphics.components.ClassificationVariable;
   import java.awt.BorderLayout;
   import java.awt.Color;
   import java.awt.Container;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
   import javax.swing.JFrame;
   import javax.swing.JPanel;
   import javax.swing.table.DefaultTableModel;

   public class SpecifyColumns extends JPanel  {
     private SpecifyColumns  theApp;
     public SpecifyColumns () {
        setLayout(new BorderLayout());

     // Create a data model and attach the data (defined below)
        RadarChartTableDataModel dataModel=null;
        dataModel=new RadarChartTableDataModel(new SampleData());

      // Assign the Category and Response variable roles
         dataModel.setCategoryVariable(
                  new ClassificationVariable("Cause"));
         dataModel.setResponseVariable(
                  new AnalysisVariable("Count"));
        dataModel.setColumnVariable(
                  new ClassificationVariable("Process"));

     // Create a radar chart and set its data model
        RadarChart radarChart=new RadarChart(dataModel);

     // Set a graph title
        radarChart.getTitle1().setText("Causes of Failure");

        add(radarChart, BorderLayout.CENTER);
      }
   // Create the data source
      static private class SampleData extends DefaultTableModel {
        private static Class  columnClass[]={String.class, String.class,
                                             String.class, Double.class};
        private static String columnNames[]={"Process","Day","Cause","Count"};
          public SampleData() {
	    super();
            Object data[][] = {
              {"Process A", "March 1", "Contamination",  new Double(15)}, 
              {"Process A", "March 1", "Corrosion",      new Double(2) }, 
              {"Process A", "March 1", "Doping",         new Double(1) },
              {"Process A", "March 1", "Metallization",  new Double(2) }, 
              {"Process A", "March 1", "Miscellaneous",  new Double(3) },
              {"Process A", "March 1", "Oxide Defect",   new Double(8) }, 
              {"Process A", "March 1", "Silicon Defect", new Double(1) }, 
              {"Process A", "March 2", "Contamination",  new Double(16)},
              {"Process A", "March 2", "Corrosion",      new Double(3) },
              {"Process A", "March 2", "Doping",         new Double(1) }, 
              {"Process A", "March 2", "Metallization",  new Double(3) },
              {"Process A", "March 2", "Miscellaneous",  new Double(1) }, 
              {"Process A", "March 2", "Oxide Defect",   new Double(9) },
              {"Process A", "March 2", "Silicon Defect", new Double(2) }, 
              {"Process A", "March 3", "Contamination",  new Double(20)},
              {"Process A", "March 3", "Corrosion",      new Double(1) }, 
              {"Process A", "March 3", "Doping",         new Double(1) }, 
              {"Process A", "March 3", "Metallization",  new Double(0) },
              {"Process A", "March 3", "Miscellaneous",  new Double(3) },
              {"Process A", "March 3", "Oxide Defect",   new Double(7) },
              {"Process A", "March 3", "Silicon Defect", new Double(2) }, 
              {"Process A", "March 4", "Contamination",  new Double(12)}, 
              {"Process A", "March 4", "Corrosion",      new Double(1) }, 
              {"Process A", "March 4", "Doping",         new Double(1) }, 
              {"Process A", "March 4", "Metallization",  new Double(0) },
              {"Process A", "March 4", "Miscellaneous",  new Double(0) },
              {"Process A", "March 4", "Oxide Defect",  new Double(10)},
              {"Process A", "March 4", "Silicon Defect", new Double(1) }, 
              {"Process A", "March 5", "Contamination",  new Double(23)},
              {"Process A", "March 5", "Corrosion",      new Double(1) }, 
              {"Process A", "March 5", "Doping",         new Double(1) }, 
              {"Process A", "March 5", "Metallization",  new Double(0) },
              {"Process A", "March 5", "Miscellaneous",  new Double(1) }, 
              {"Process A", "March 5", "Oxide Defect",   new Double(8) }, 
              {"Process A", "March 5", "Silicon Defect", new Double(2) }, 
              {"Process B", "March 1", "Contamination", new Double(8) }, 
              {"Process B", "March 1", "Corrosion",      new Double(2) }, 
              {"Process B", "March 1", "Doping",         new Double(1) }, 
              {"Process B", "March 1", "Metallization",  new Double(4) },
              {"Process B", "March 1", "Miscellaneous",  new Double(2) }, 
              {"Process B", "March 1", "Oxide Defect",  new Double(10)},
              {"Process B", "March 1", "Silicon Defect", new Double(3) },
              {"Process B", "March 2", "Contamination", new Double(9) },
              {"Process B", "March 2", "Corrosion",      new Double(0) },
              {"Process B", "March 2", "Doping",         new Double(1) }, 
              {"Process B", "March 2", "Metallization",  new Double(2) }, 
              {"Process B", "March 2", "Miscellaneous",  new Double(4) },
              {"Process B", "March 2", "Oxide Defect",   new Double(9) },
              {"Process B", "March 2", "Silicon Defect", new Double(2) }, 
              {"Process B", "March 3", "Contamination", new Double(4) },
              {"Process B", "March 3", "Corrosion",      new Double(1) }, 
              {"Process B", "March 3", "Doping",         new Double(1) }, 
              {"Process B", "March 3", "Metallization",  new Double(0) },
              {"Process B", "March 3", "Miscellaneous",  new Double(0) },
              {"Process B", "March 3", "Oxide Defect",  new Double(10)},
              {"Process B", "March 3", "Silicon Defect", new Double(1) }, 
              {"Process B", "March 4", "Contamination", new Double(2) }, 
              {"Process B", "March 4", "Corrosion",      new Double(2) }, 
              {"Process B", "March 4", "Doping",         new Double(1) }, 
              {"Process B", "March 4", "Metallization",  new Double(0) },
              {"Process B", "March 4", "Miscellaneous",  new Double(3) },
              {"Process B", "March 4", "Oxide Defect",   new Double(7) },
              {"Process B", "March 4", "Silicon Defect", new Double(1) }, 
              {"Process B", "March 5", "Contamination", new Double(1) }, 
              {"Process B", "March 5", "Corrosion",      new Double(3) },
              {"Process B", "March 5", "Doping",         new Double(1) }, 
              {"Process B", "March 5", "Metallization",  new Double(0) },
              {"Process B", "March 5", "Miscellaneous",  new Double(1) }, 
              {"Process B", "March 5", "Oxide Defect",   new Double(8) }, 
              {"Process B", "March 5", "Silicon Defect", new Double(2) } 
            };
            setDataVector(data, columnNames);
          }
          public Class getColumnClass(int column) {
	    return columnClass[column];
	  }
       } 
      public static void main(String[] args) {
      	  JFrame frame = new JFrame("BIP Graph Sample");
      	  Container container = frame.getContentPane();
          container.setLayout(new BorderLayout());
          container.setBackground(Color.white);

          JPanel bipPanel = new JPanel();
          bipPanel.setLayout(new BorderLayout());
          SpecifyColumns  bipGraphSample = new SpecifyColumns ();

          bipPanel.add(bipGraphSample, BorderLayout.CENTER);
          container.add(bipPanel, BorderLayout.CENTER);

          frame.setSize(900,450);
          frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                     System.exit(0);
              }
          } );
          frame.setVisible(true);
      }
   }