// ChangeAxis:
// A graph's display properties (axis characteristics, orientation, and
// so on) are general properties that are defined in the graph's model.
// Thus, to change a RadarChart's axis characteristics,
// 1) Create an AxisModel or any other objects needed to define
// axis characteristics (line style, tick intervals, ...)
// 2) Use the RadarChart to set the axis definitions on the chart
// This example creates a StrokeLineStyle to define a
// 3pt solid red line for the axis lines.
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 com.sas.graphics.components.radarchart.RadarChartModel;
import com.sas.graphics.components.AxisModel;
import com.sas.graphics.components.GraphConstants;
import com.sas.graphics.components.StrokeLineStyle;
import com.sas.measures.BaseLength;
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 ChangeAxis extends JPanel {
private ChangeAxis theApp;
public ChangeAxis () {
setLayout(new BorderLayout());
// Create a data model and attach the data (defined below)
RadarChartTableDataModel dataModel=null;
dataModel=new RadarChartTableDataModel(new SampleData());
// 1) Create the objects needed to define axis characteristics.
// A StrokeLineStyle is needed to define line characteristics
// for the axis lines
StrokeLineStyle lineStyle=new StrokeLineStyle(
StrokeLineStyle.SASGRAPH_LINE01,
Color.red,
new BaseLength(3, "pt"),
GraphConstants.TRUE);
// 2) Use the RadarChart to set the axis definitions on the chart
RadarChart radarChart=new RadarChart(dataModel);
radarChart.getGraphModel().getAxisModel()
.setAxisLineStyle(lineStyle);
// Assign the Category and Response variable roles
dataModel.setCategoryVariable(
new ClassificationVariable("Cause"));
dataModel.setResponseVariable(
new AnalysisVariable("Count"));
// 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());
ChangeAxis bipGraphSample = new ChangeAxis ();
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);
}
}