// SpecifyColumns:

    // To generate a WaterfallChart 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.waterfallchart.WaterfallChart;
       import com.sas.graphics.components.waterfallchart.WaterfallChartTableDataModel;
       import com.sas.graphics.components.AnalysisVariable;
       import com.sas.graphics.components.ClassificationVariable;
       import com.sas.graphics.components.GraphConstants;
       import javax.swing.table.DefaultTableModel;
       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;

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

         // Create a WaterfallChart and a data source
            WaterfallChart waterfallChart=new WaterfallChart();
            SampleData dataTable=new SampleData();

         // Set the bar label content
            waterfallChart.getGraphModel().setOutsideBarLabelContent(GraphConstants.DATA_LABEL_RESPONSE);

         // Create a data model and attach the data source
            WaterfallChartTableDataModel dataModel=
                      new WaterfallChartTableDataModel();
            dataModel.setModel(dataTable);

         // Generate a separate chart for each Year of transactions
            dataModel.setColumnVariable(
                     new ClassificationVariable("Year"));

         // Assign the variable roles and sort category values in descending order
            dataModel.setCategoryVariable(
                     new ClassificationVariable("Id", GraphConstants.SORT_DESCENDING));

         // Assign the Response variable role and apply the NLMNLUSD format so
         // that Transaction amounts in the output are displayed in an
         // internationalized representation of US dollars.
            dataModel.setResponseVariable(
                      new AnalysisVariable("Transaction", "nlmnlusd"));

         // Call the data model's setCategorySortVariable() method
         // to sort bars according to the values of the response variable
            dataModel.setCategorySortVariable(dataModel.getResponseVariable());

         // Assign the data model to the WaterfallChart
            waterfallChart.setDataModel(dataModel);

         // Set a graph title
            waterfallChart.getTitle1().setText("BIP Waterfall Chart");
            add(waterfallChart, BorderLayout.CENTER);
          }
       // Create the data source
          static private class SampleData extends DefaultTableModel {
            private static Class  columnClass[]={Double.class, String.class, String.class};
            private static String columnNames[]={  "Transaction"  ,  "Id" ,  "Year" };
              public SampleData() {
    	    super();
                Object data[][] = {
                                      {new Double(  23),"D","2004"}
                                    , {new Double(  85),"C","2004"}
                                    , {new Double(  27),"A","2004"}
                                    , {new Double( -20),"E","2004"}
                                    , {new Double( 125),"B","2004"}
                                    , {new Double(   3),"F","2004"}
                                    , {new Double(   6),"G","2004"}
                                    , {new Double( 142),"H","2004"}
                                    , {new Double(-117),"I","2004"}
                                    , {new Double(  26),"J","2004"}
                                    , {new Double(  73),"K","2004"}
                                    , {new Double(  16),"L","2004"}
                                    , {new Double( -82),"M","2004"}
                                    , {new Double(  93),"N","2004"}
                                    , {new Double( 126),"O","2004"}

                                    , {new Double(  13),"D","2003"}
                                    , {new Double(  65),"C","2003"}
                                    , {new Double(  27),"A","2003"}
                                    , {new Double( -25),"E","2003"}
                                    , {new Double( 110),"B","2003"}
                                    , {new Double(   4),"F","2003"}
                                    , {new Double(   4),"G","2003"}
                                    , {new Double( 122),"H","2003"}
                                    , {new Double(-121),"I","2003"}
                                    , {new Double(  20),"J","2003"}
                                    , {new Double(  70),"K","2003"}
                                    , {new Double(  19),"L","2003"}
                                    , {new Double( -89),"M","2003"}
                                    , {new Double(  85),"N","2003"}
                                    , {new Double( 112),"O","2003"}

                                    , {new Double(  20),"D","2002"}
                                    , {new Double(  45),"C","2002"}
                                    , {new Double(  19),"A","2002"}
                                    , {new Double( -24),"E","2002"}
                                    , {new Double(  95),"B","2002"}
                                    , {new Double(   2),"F","2002"}
                                    , {new Double(   5),"G","2002"}
                                    , {new Double( 101),"H","2002"}
                                    , {new Double(-126),"I","2002"}
                                    , {new Double(  16),"J","2002"}
                                    , {new Double(  60),"K","2002"}
                                    , {new Double(  17),"L","2002"}
                                    , {new Double( -85),"M","2002"}
                                    , {new Double(  80),"N","2002"}
                                    , {new Double(  98),"O","2002"}
                };
                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(1000,450);
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                         System.exit(0);
                  }
              } );
              frame.setVisible(true);
          }
       }