<%// ColorBars:%>


<%
// To set bar colors so that they represent a chart variable's values:
//    1) Call the data model's setStyleByVariable() to specify the
//       variable whose values will be represented by the colors
//    2) Call the graph model's setColorPaletteType() method to set
//       a three-color palette
//    3) Get the graph model's DataElementStyles to set start, end, and
//       neutral colors for the bars
%>
<%@page import="com.sas.servlet.tbeans.graphics.html.WaterfallChart,
        com.sas.graphics.components.waterfallchart.WaterfallChartTableDataModel,
        com.sas.graphics.components.AnalysisVariable,
        com.sas.graphics.components.ClassificationVariable,
        com.sas.graphics.components.GraphConstants,
        java.awt.Color,
        javax.swing.table.DefaultTableModel"
%>
<%
  // Create a WaterfallChart and a data source 
    WaterfallChart waterfallChart=new WaterfallChart();
%>

   <%@ include file="TransactionData.jsp" %>

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

  // 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("TransactionQ1", "nlmnlusd"));

  // 1) Specify the variable whose values will be represented by the colors
     dataModel.setStyleByVariable(dataModel.getResponseVariable());

  // 2) Set a three-color palette
     waterfallChart.getGraphModel().setColorPaletteType(GraphConstants.COLOR_PALETTE_THREE_COLOR_CONTINUOUS);

  // 3) Assign the data-element colors
     waterfallChart.getGraphModel().getDataElementStyles().setContinuousFillThreeColorStartColor(Color.red);
     waterfallChart.getGraphModel().getDataElementStyles().setContinuousFillThreeColorNeutralColor(Color.black);
     waterfallChart.getGraphModel().getDataElementStyles().setContinuousFillThreeColorEndColor(Color.green);

  // 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");

  // Set HTTP-specific response and request functionality
     waterfallChart.setResponse(response);
     waterfallChart.setRequest(request);

  // Set a graph size and write the chart to the display
     waterfallChart.setWidth(600);
     waterfallChart.setHeight(450);
     waterfallChart.write(out);
%>