// HighLowPlot:
// To generate a high-low plot or use error values in a plot,
// specify multiple columns on the PlotVariable(s) used in
// the plot. The first specified column is used for the
// variable's assigned roll, the second for the high values,
// and the third for the low values.
import com.sas.graphics.components.ClassificationVariable;
import com.sas.graphics.components.PlotVariable;
import com.sas.graphics.components.PlotVariableList;
import com.sas.graphics.components.scatterplot.ScatterPlot;
import com.sas.graphics.components.scatterplot.ScatterPlotTableDataModel;
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 HighLowPlot extends JPanel {
private HighLowPlot theApp;
public HighLowPlot () {
setLayout(new BorderLayout());
// Create a ScatterPlot and a data model (data defined below)
ScatterPlotTableDataModel dataModel = null;
dataModel = new ScatterPlotTableDataModel(new PlotData());
// Create two PlotVariables with high and low values
dataModel.setXVariable(new PlotVariable("Month"));
dataModel.setYVariable(new PlotVariableList(
new PlotVariable[] {
new PlotVariable("Dow","#.00",null,"Dow Jones Composite"
, "Dow-high", "Dow High", "Dow-low", "Dow Low" )
, new PlotVariable("Nikkei-DOW","Best4.", null, "Nikkei-DOW"
, "Nikkei-high", "Nikkei High", "Nikkei-low", "Nikkei Low")
,new PlotVariable("U.K.-All Shares","#.00", null, "U.K.-All Shares"
, "U.K.-high", "U.K. High", "U.K.-low", "U.K. Low")
}));
dataModel.setColumnVariable(new ClassificationVariable("Year"));
// Create a scatter plot and turn on interpolation
ScatterPlot scatterPlot = new ScatterPlot(dataModel);
scatterPlot.getGraphModel().setInterpolationEnabled(true);
// Set graph titles and footnote
scatterPlot.getTitle1().setText(
"Market indices with low and high ranges") ;
scatterPlot.getTitle2().setText(
"Values are normalized based on Jan 4,1988 value") ;
scatterPlot.getFootnote1().setText(
"source: sashelp-Citibase daily indicaters");
add(scatterPlot, BorderLayout.CENTER);
}
// Create the data source
static private class PlotData extends DefaultTableModel
{
private static Class columnClass[]={ String.class
, String.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
, Double.class
};
private static String columnNames[]={ "Month"
, "Year"
, "Dow"
, "Dow-low"
, "Dow-high"
, "NYSE"
, "NYSE-low"
, "NYSE-high"
, "Wilshire 500"
, "Wilshire-low"
, "Wilshire-high"
, "U.K.-All Shares"
, "U.K.-low"
, "U.K.-high"
, "Nikkei-DOW"
, "Nikkei-low"
, "Nikkei-high"
};
public PlotData()
{
super();
Object data[][]={
{ "Jan", "1988", nd(0.9756904), nd(0.02905431), nd(0.047060), nd(0.983523), nd(0.0267705), nd(0.037400), nd(0.986229), nd(0.025076), nd(0.037202), nd(1.014748), nd(0.046125), nd(0.018349), nd(1.071193), nd(0.071193), nd(0.042172) },
{ "Feb", "1988", nd(0.9999151), nd(0.03668893), nd(0.040020), nd(1.015542), nd(0.0334566), nd(0.037362), nd(1.038919), nd(0.051701), nd(0.373886), nd(1.011233), nd(0.029631), nd(0.02024), nd(1.144688), nd(0.032592), nd(0.045055) },
{ "Mar", "1988", nd(1.0355110), nd(0.02536506), nd(0.021271), nd(1.048830), nd(0.0263669), nd(0.019609), nd(1.056281), nd(0.025166), nd(0.018599), nd(1.046769), nd(0.035206), nd(0.026508), nd(1.212926), nd(0.014196), nd(0.027590) },
{ "Apr", "1988", nd(1.0247597), nd(0.02634037), nd(0.036143), nd(1.037795), nd(0.0221900), nd(0.034283), nd(1.046809), nd(0.021214), nd(0.031914), nd(1.033537), nd(0.026024), nd(0.014562), nd(1.266318), nd(0.026024), nd(0.026705) },
{ "May", "1988", nd(0.9970321), nd(0.02526774), nd(0.035054), nd(1.013159), nd(0.0179878), nd(0.026519), nd(1.025107), nd(0.020294), nd(0.025872), nd(1.039180), nd(0.015908), nd(0.010397), nd(1.293568), nd(0.013415), nd(0.017642) },
{ "Jun", "1988", nd(1.0594495), nd(0.02601263), nd(0.023474), nd(1.068751), nd(0.0213754), nd(0.018373), nd(1.079495), nd(0.023726), nd(0.017734), nd(1.077280), nd(0.025086), nd(0.017756), nd(1.314474), nd(0.023149), nd(0.021361) },
{ "Jul", "1988", nd(1.0616133), nd(0.02571763), nd(0.027187), nd(1.065027), nd(0.0241594), nd(0.023636), nd(1.079324), nd(0.025495), nd(0.022510), nd(1.088757), nd(0.008114), nd(0.010059), nd(1.304469), nd(0.024883), nd(0.019930) },
{ "Aug", "1988", nd(1.0369524), nd(0.0279008), nd(0.038865), nd(1.044458), nd(0.0231843), nd(0.033429), nd(1.054611), nd(0.022979), nd(0.033111), nd(1.074941), nd(0.047225), nd(0.028928), nd(1.318075), nd(0.028265), nd(0.021574) },
{ "Sep", "1988", nd(1.0536747), nd(0.03771954), nd(0.023831), nd(1.059425), nd(0.0329728), nd(0.016712), nd(1.068734), nd(0.032068), nd(0.016735), nd(1.037064), nd(0.023618), nd(0.030686), nd(1.300108), nd(0.030645), nd(0.015988) },
{ "Oct", "1988", nd(1.0919938), nd(0.01837856), nd(0.017652), nd(1.094208), nd(0.0240195), nd(0.021397), nd(1.100568), nd(0.020766), nd(0.019484), nd(1.080150), nd(0.025339), nd(0.013014), nd(1.292462), nd(0.013208), nd(0.026409) },
{ "Nov", "1988", nd(1.0755588), nd(0.0281392), nd(0.031210), nd(1.067994), nd(0.0255869), nd(0.031236), nd(1.070761), nd(0.024291), nd(0.031630), nd(1.070411), nd(0.024873), nd(0.022336), nd(1.354090), nd(0.040694), nd(0.040021) },
{ "Dec", "1988", nd(1.1046296), nd(0.0249214), nd(0.017013), nd(1.087347), nd(0.0165278), nd(0.010624), nd(1.089444), nd(0.015097), nd(0.011016), nd(1.031821), nd(0.014415), nd(0.017734), nd(1.402474), nd(0.013492), nd(0.018978) },
{ "Jan", "1989", nd(1.1481725), nd(0.04448429), nd(0.055718), nd(1.120765), nd(0.0362300), nd(0.045296), nd(1.124912), nd(0.035266), nd(0.044364), nd(1.098322), nd(0.059157), nd(0.091718), nd(1.464350), nd(0.041730), nd(0.027193) },
{ "Feb", "1989", nd(1.1900250), nd(0.02427249), nd(0.020661), nd(1.155679), nd(0.0239783), nd(0.020108), nd(1.162863), nd(0.021869), nd(0.018429), nd(1.194901), nd(0.022425), nd(0.026577), nd(1.509517), nd(0.031428), nd(0.020031) },
{ "Mar", "1989", nd(1.1702184), nd(0.02370393), nd(0.026310), nd(1.151264), nd(0.0194237), nd(0.025083), nd(1.159719), nd(0.018749), nd(0.023937), nd(1.213873), nd(0.027838), nd(0.028857), nd(1.505708), nd(0.023727), nd(0.042043) },
{ "Apr", "1989", nd(1.2122892), nd(0.03081127), nd(0.038805), nd(1.185308), nd(0.0240063), nd(0.026239), nd(1.195960), nd(0.025478), nd(0.027774), nd(1.203424), nd(0.020762), nd(0.026175), nd(1.566016), nd(0.019810), nd(0.022983) },
{ "May", "1989", nd(1.2610011), nd(0.03333294), nd(0.028191), nd(1.227931), nd(0.0326893), nd(0.027143), nd(1.242656), nd(0.031480), nd(0.027303), nd(1.240119), nd(0.017378), nd(0.036147), nd(1.601772), nd(0.012658), nd(0.013286) },
{ "Jun", "1989", nd(1.2912720), nd(0.01613016), nd(0.025156), nd(1.264960), nd(0.0200331), nd(0.016916), nd(1.279220), nd(0.024162), nd(0.015815), nd(1.242755), nd(0.026568), nd(0.028187), nd(1.572962), nd(0.021704), nd(0.028645) },
{ "Jul", "1989", nd(1.3357291), nd(0.05122489), nd(0.056868), nd(1.293415), nd(0.0442201), nd(0.053051), nd(1.303936), nd(0.042782), nd(0.049770), nd(1.295614), nd(0.044818), nd(0.03173), nd(1.595098), nd(0.030771), nd(0.052345) },
{ "Aug", "1989", nd(1.4399211), nd(0.0609424), nd(0.049487), nd(1.350117), nd(0.0207260), nd(0.017623), nd(1.360841), nd(0.019220), nd(0.018292), nd(1.348873), nd(0.028557), nd(0.018425), nd(1.640589), nd(0.017780), nd(0.015666) },
{ "Sep", "1989", nd(1.4588142), nd(0.02325626), nd(0.038092), nd(1.351868), nd(0.0156186), nd(0.022310), nd(1.366351), nd(0.013295), nd(0.019720), nd(1.358564), nd(0.042749), nd(0.024177), nd(1.632526), nd(0.024683), nd(0.049612) },
{ "Oct", "1989", nd(1.4177790), nd(0.07807349), nd(0.088773), nd(1.347029), nd(0.0484986), nd(0.047932), nd(1.363569), nd(0.050285), nd(0.048683), nd(1.253107), nd(0.065797), nd(0.073391), nd(1.664975), nd(0.040400), nd(0.016621) },
{ "Nov", "1989", nd(1.3580734), nd(0.01977291), nd(0.015028), nd(1.321051), nd(0.0280489), nd(0.017927), nd(1.333956), nd(0.027005), nd(0.016439), nd(1.250284), nd(0.025546), nd(0.034172), nd(1.697938), nd(0.035573), nd(0.058612) },
{ "Dec", "1989", nd(1.3898271), nd(0.02484464), nd(0.017955), nd(1.348026), nd(0.0226232), nd(0.016845), nd(1.353445), nd(0.024870), nd(0.015227), nd(1.325929), nd(0.028118), nd(0.033011), nd(1.796280), nd(0.046146), nd(0.037900) },
{ "Jan", "1990", nd(1.3563103), nd(0.08276259), nd(0.067156), nd(1.318380), nd(0.0697447), nd(0.067204), nd(1.322607), nd(0.074881), nd(0.067925), nd(1.337458), nd(0.047497), nd(0.046445), nd(1.771230), nd(0.040100), nd(0.053383) },
{ "Feb", "1990", nd(1.3134470), nd(0.0187294), nd(0.018720), nd(1.277855), nd(0.0227817), nd(0.014657), nd(1.279613), nd(0.021590), nd(0.015157), nd(1.293327), nd(0.035628), nd(0.032099), nd(1.722970), nd(0.152446), nd(0.052340) },
{ "Mar", "1990", nd(1.3596989), nd(0.02480288), nd(0.021563), nd(1.303458), nd(0.0192029), nd(0.016766), nd(1.308608), nd(0.021606), nd(0.017285), nd(1.258678), nd(0.015271), nd(0.020893), nd(1.519423), nd(0.112849), nd(0.085775) },
{ "Apr", "1990", nd(1.3584231), nd(0.03807722), nd(0.024933), nd(1.299797), nd(0.0349962), nd(0.022387), nd(1.302320), nd(0.035218), nd(0.022138), nd(1.228585), nd(0.051868), nd(0.025301), nd(1.378780), nd(0.058989), nd(0.053933) },
{ "May", "1990", nd(1.3823403), nd(0.05202413), nd(0.022902), nd(1.340430), nd(0.0652722), nd(0.037737), nd(1.341219), nd(0.064453), nd(0.040976), nd(1.241059), nd(0.057517), nd(0.061016), nd(1.493283), nd(0.093944), nd(0.071102) },
{ "Jun", "1990", nd(1.4122136), nd(0.03512628), nd(0.025128), nd(1.376324), nd(0.0294378), nd(0.024726), nd(1.381453), nd(0.029239), nd(0.022779), nd(1.320624), nd(0.014194), nd(0.0143), nd(1.525414), nd(0.058471), nd(0.039013) },
{ "Jul", "1990", nd(1.4042587), nd(0.0225105), nd(0.032772), nd(1.375825), nd(0.0229913), nd(0.031662), nd(1.376962), nd(0.025457), nd(0.033226), nd(1.310847), nd(0.021653), nd(0.023401), nd(1.516259), nd(0.081424), nd(0.047214) },
{ "Aug", "1990", nd(1.2622211), nd(0.09473938), nd(0.120054), nd(1.269736), nd(0.0879301), nd(0.090516), nd(1.258199), nd(0.091149), nd(0.095666), nd(1.210105), nd(0.067115), nd(0.089004), nd(1.268262), nd(0.149461), nd(0.185192) },
{ "Sep", "1990", nd(1.2019008), nd(0.05381924), nd(0.030752), nd(1.213558), nd(0.0563856), nd(0.031578), nd(1.197780), nd(0.059327), nd(0.032263), nd(1.137790), nd(0.052522), nd(0.049441), nd(1.127762), nd(0.138769), nd(0.070352) },
{ "Oct", "1990", nd(1.1738578), nd(0.04038039), nd(0.030371), nd(1.175994), nd(0.0409347), nd(0.031774), nd(1.151408), nd(0.040231), nd(0.036481), nd(1.138641), nd(0.034197), nd(0.055425), nd(1.121873), nd(0.168778), nd(0.073046) },
{ "Nov", "1990", nd(1.1915244), nd(0.02829825), nd(0.019878), nd(1.205194), nd(0.0332559), nd(0.026856), nd(1.180507), nd(0.035416), nd(0.027952), nd(1.135902), nd(0.027679), nd(0.040116), nd(1.104802), nd(0.046472), nd(0.044526) },
{ "Dec", "1990", nd(1.2385166), nd(0.02435828), nd(0.012078), nd(1.257316), nd(0.0181979), nd(0.008394), nd(1.235911), nd(0.020306), nd(0.009142), nd(1.173407), nd(0.008996), nd(0.011782), nd(1.120819), nd(0.090392), nd(0.051672) },
{ "Jan", "1991", nd(1.2455829), nd(0.05560718), nd(0.080383), nd(1.245459), nd(0.0490279), nd(0.067277), nd(1.227630), nd(0.049809), nd(0.073148), nd(1.140905), nd(0.027019), nd(0.028007), nd(1.103550), nd(0.045782), nd(0.030877) },
{ "Feb", "1991", nd(1.3827324), nd(0.06176506), nd(0.022766), nd(1.385056), nd(0.0736494), nd(0.024321), nd(1.376386), nd(0.074442), nd(0.024038), nd(1.235534), nd(0.067558), nd(0.061714), nd(1.186454), nd(0.095034), nd(0.060787) },
{ "Mar", "1991", nd(1.3971475), nd(0.02932798), nd(0.033952), nd(1.425106), nd(0.0209071), nd(0.014642), nd(1.421290), nd(0.020830), nd(0.015091), nd(1.343496), nd(0.041206), nd(0.028449), nd(1.247008), nd(0.027160), nd(0.032478) },
{ "Apr", "1991", nd(1.4092807), nd(0.02593832), nd(0.036315), nd(1.453550), nd(0.0301069), nd(0.038473), nd(1.456909), nd(0.033149), nd(0.038717), nd(1.371896), nd(0.025782), nd(0.0182), nd(1.246823), nd(0.021044), nd(0.024814) },
{ "May", "1991", nd(1.4171757), nd(0.02791607), nd(0.049671), nd(1.448012), nd(0.0337360), nd(0.042471), nd(1.448227), nd(0.033370), nd(0.042516), nd(1.358338), nd(0.018214), nd(0.024685), nd(1.220509), nd(0.023798), nd(0.027969) },
{ "Jun", "1991", nd(1.4352209), nd(0.04448865), nd(0.039056), nd(1.450770), nd(0.0287264), nd(0.034045), nd(1.450742), nd(0.032313), nd(0.035977), nd(1.352241), nd(0.042382), nd(0.024092), nd(1.156334), nd(0.058587), nd(0.064977) },
{ "Jul", "1991", nd(1.4320448), nd(0.01938606), nd(0.021346), nd(1.456446), nd(0.0255849), nd(0.029489), nd(1.454886), nd(0.026714), nd(0.030482), nd(1.363250), nd(0.040960), nd(0.034144), nd(1.094720), nd(0.049514), nd(0.042137) },
{ "Aug", "1991", nd(1.4451684), nd(0.05403085), nd(0.020246), nd(1.492878), nd(0.0454323), nd(0.026856), nd(1.496231), nd(0.044739), nd(0.028201), nd(1.404857), nd(0.032911), nd(0.026186), nd(1.071310), nd(0.060012), nd(0.063284) },
{ "Sep", "1991", nd(1.4423965), nd(0.01694394), nd(0.009819), nd(1.488260), nd(0.0146423), nd(0.017198), nd(1.493733), nd(0.014505), nd(0.016425), nd(1.428311), nd(0.019174), nd(0.02016), nd(1.086430), nd(0.030548), nd(0.043297) },
{ "Oct", "1991", nd(1.4697955), nd(0.04357283), nd(0.032596), nd(1.491250), nd(0.0360361), nd(0.024076), nd(1.498916), nd(0.037721), nd(0.027011), nd(1.404677), nd(0.032697), nd(0.034263), nd(1.160646), nd(0.036046), nd(0.028129) },
{ "Nov", "1991", nd(1.4600340), nd(0.04298452), nd(0.042114), nd(1.490629), nd(0.0380752), nd(0.044500), nd(1.500756), nd(0.039564), nd(0.047368), nd(1.365232), nd(0.046619), nd(0.035862), nd(1.124342), nd(0.055043), nd(0.056041) },
{ "Dec", "1991", nd(1.4577276), nd(0.05233721), nd(0.105120), nd(1.501110), nd(0.0418379), nd(0.104488), nd(1.511838), nd(0.040907), nd(0.107886), nd(1.303551), nd(0.033331), nd(0.036212), nd(1.049856), nd(0.036383), nd(0.033413) }
};
setDataVector(data, columnNames);
}
private Double nd(double d) { return new Double(d); }
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());
HighLowPlot bipGraphSample = new HighLowPlot ();
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);
}
}