<%// ChangeStyle:%>


<%
// Numerous pre-defined styles are available to all BIP graphs.
// The styles control visual characteristics of the graph, such
// as the fonts and color scheme it uses.
//
// To change a graph's style, call the PieChart's applyGraphStyle() method
%>

<%@page import="
  com.sas.servlet.tbeans.graphics.html.PieChart,
  com.sas.graphics.components.GraphStyle,
  com.sas.graphics.components.piechart.PieChartTableDataModel,
  com.sas.graphics.components.AnalysisVariable,
  com.sas.graphics.components.ClassificationVariable,
  com.sas.swing.models.TableModelAdapter,
  com.sas.models.SimpleTable"
%>

<%
 // Create a PieChart instance
    PieChart pieChart = new PieChart();

 // Create a simple SAS table and add data to it
    SimpleTable table = new SimpleTable();
%>

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

<% 
 // Convert a simple SAS table to a simple Java Swing table
    TableModelAdapter tma = new TableModelAdapter(table);
    tma.setFormattedDataUsed(false);

 // Create a data model and attach the data source
    PieChartTableDataModel dataModel=
      new PieChartTableDataModel(tma);

 // Assign the data model to the PieChart
    pieChart.setDataModel(dataModel);

 // Hide the legend
    pieChart.getGraphModel().getLegendModel().setVisible(false);

  // Override the default style
     pieChart.applyGraphStyle(
       new GraphStyle(GraphStyle.STYLE_ANALYSIS));


 // Assign the Category and Response variable roles
    dataModel.setCategoryVariable(
      new ClassificationVariable("EnergyType"));
    dataModel.setResponseVariable(
      new AnalysisVariable("Produced"));

 // Set a title
    pieChart.getTitle1().setText("Energy Production");

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

 // Write the chart to the display
    pieChart.write(out);
%>