// Basic Requirements:
// Basic requirements for creating a radar chart:
// 1) Create a RadarChart instance and a data source
// 2) Create a data model and attach the data source to it
// 3) Assign the Category and Response variable roles
// to appropriate variables
// 4) Assign the data model to the RadarChart
// To set a title or footnote, get the appropriate RadarChart
// title or footnote, and then set the returned object's text.
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 BasicRequirements extends JPanel {
private BasicRequirements theApp;
public BasicRequirements () {
setLayout(new BorderLayout());
// 1) Create a RadarChart and a data source
RadarChart radarChart=new RadarChart();
SampleData dataTable=new SampleData();
// 2) Create a data model and attach the data source
RadarChartTableDataModel dataModel=
new RadarChartTableDataModel();
dataModel.setModel(dataTable);
// 3) Assign the Category and Response variable roles
dataModel.setCategoryVariable(
new ClassificationVariable("Cause"));
dataModel.setResponseVariable(
new AnalysisVariable("Count"));
// 4) Assign the data model to the RadarChart
radarChart.setDataModel(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());
BasicRequirements bipGraphSample = new BasicRequirements ();
bipPanel.add(bipGraphSample, BorderLayout.CENTER);
container.add(bipPanel, BorderLayout.CENTER);
frame.setSize(600,450);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
} );
frame.setVisible(true);
}
}