<%// Change Axis:%>
<%
// 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 bar chart's axis characteristics,
// 1) Get the BarLineChart's graph model
// 2) Set the axis characteristics through the BarLineChartModel
%>
<%@page import="java.awt.Color,
com.sas.models.SimpleTable,
com.sas.swing.models.TableModelAdapter,
com.sas.servlet.tbeans.graphics.html.BarLineChart,
com.sas.graphics.components.barlinechart.BarLineChartModel,
com.sas.graphics.components.barlinechart.BarLineChartTableDataModel,
com.sas.graphics.components.AnalysisVariable,
com.sas.graphics.components.ClassificationVariable,
com.sas.graphics.components.GraphConstants"
%>
<%
// Create a BarLineChart instance
BarLineChart barLineChart = new BarLineChart();
// Create a simple SAS table and add data to it
SimpleTable table = new SimpleTable();
%>
<%@ include file="EnergyData.jsp" %>
<%
// 1) Get BarLineChart Model
BarLineChartModel barLineChartModel = barLineChart.getGraphModel();
// 2) Use the model to change the axis tick policy to interval and set the interval value
barLineChartModel.getResponseAxisModel().setContinuousMajorTickPositionPolicy(
GraphConstants.TICK_POSITION_INTERVAL);
barLineChartModel.getResponseAxisModel().setContinuousMajorTickInterval(100);
// 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
BarLineChartTableDataModel dataModel=
new BarLineChartTableDataModel(tma);
// Assign the Category variable role, and the
// BarResponse and LineResponse variable roles
dataModel.setCategoryVariable(
new ClassificationVariable("EnergyType"));
dataModel.setBarResponseVariable(
new AnalysisVariable("Produced"));
dataModel.setLineResponseVariable(
new AnalysisVariable("Consumed"));
// Assign the data model to the BarLineChart
barLineChart.setDataModel(dataModel);
// Set a graph title
barLineChart.getTitle1().setText("Energy Production");
// Set HTTP-specific response and request functionality
barLineChart.setResponse(response);
barLineChart.setRequest(request);
// Write the chart to the display
barLineChart.write(out);
%>