SAS Graphics for Java: Examples Using SAS Appdev Studio and the Output Delivery System 159047693X, 978-1-59047-693-2

Jump-start your SAS graph skills! Here, in one convenient source, is all the information you need to create your own SAS

285 22 6MB

English Pages 359 Year 2007

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

SAS Graphics for Java: Examples Using SAS Appdev Studio and the Output Delivery System
 159047693X, 978-1-59047-693-2

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

SAS Graphics for Java ®

®

Examples Using SAS AppDev Studio and the Output Delivery System

Wendy Bohnenkamp Jackie Iverson



The correct bibliographic citation for this manual is as follows: Bohnenkamp, Wendy, and Jackie Iverson. 2007. SAS® Graphics for Java: Examples Using SAS® AppDev Studio™ and the Output Delivery System. Cary, NC: SAS Institute Inc. SAS® Graphics for Java: Examples Using SAS® AppDev Studio™ and the Output Delivery System Copyright © 2007, SAS Institute Inc., Cary, NC, USA ISBN 978-1-59047-693-2 All rights reserved. Produced in the United States of America. For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc. For a Web download or e-book: Your use of this publication shall be governed by the terms established by the vendor at the time you acquire this publication. U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987). SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513. 1st printing, May 2007 SAS® Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hardcopy books, visit the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228. ® SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Other brand and product names are registered trademarks or trademarks of their respective companies.

Contents Acknowledgments Introduction

ix

xi

Part 1

SAS AppDevStudio

1

Chapter 1

Getting Started with SAS AppDev Studio

3

1.1 Tag Libraries for SAS AppDev Studio 3 1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project 8 1.3 Your Data 10 1.3.1 Tips and Information 11

Chapter 2

SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 13 2.1 SAS AppDev Studio 2 Tags 15 2.1.1 sasads:Bar 15 2.1.2 sasads:Combination 16 2.1.3 sasads:Pie 16 2.1.4 sasads:Scatter 17 2.1.5 sasads:SegmentedBar 17 2.2 SAS AppDev Studio 3 Tags 18 2.2.1 sas:BarChart 18 2.2.2 sas:BarLineChart 19 2.2.3 sas:LineChart 20 2.2.4 sas:LinePlot 21 2.2.5 sas:PieChart 22 2.2.6 sas:RadarChart 23 2.2.7 sas:ScatterPlot 24 2.3 Common Attributes 25

iv Contents

Chapter 3

SAS AppDev Studio 3 Graph Model Tags 39 3.1 3.2 3.3 3.4 3.5 3.6 3.7

Chapter 4

BarChartModel 40 BarLineChartModel 50 LineChartModel 64 LinePlotModel 67 PieChartModel 74 RadarChartModel 87 ScatterPlotModel 92 3.7.1 Baselines 97

Nested Tags for Graph Models

99

4.1 Axis Models 100 4.1.1 Response Axis Baseline Models 107 4.1.2 Corresponding Graph Models 108 4.1.3 Column and Row Axis Models 110 4.2 Legends 111 4.2.1 Corresponding Graph Models 113 4.3 Line Style Tags 113 4.3.1 Corresponding Graph Models 116 4.4 Text Style Tags 116 4.4.1 Corresponding Graph Models 117 4.5 AxisWallModel 118 4.6 BackgroundFillStyle 119 4.6.1 Corresponding Graph Models 122 4.7 DataElementStyle 123 4.8 DataTipModel 123 4.9 SubgroupLabelModel 124

Chapter 5

Supporting Tags

125

5.1 Fill Tags 126 5.2 Line Tags 130 5.2.1 AxisLineStyle, GridLineStyle, StrokeLineStyle, FrameLineStyle, and OutlineLineStyle 5.2.2 BasicStroke 133

Contents v

5.3 Text Tags 133 5.3.1 Font 133 5.3.2 LabelTextStyle and ValueTextStyle 134 5.3.3 TextStyle 136 5.3.4 ShadowStyle 136 5.4 Tick Mark Tags 136 5.5 Miscellaneous Tags 137 5.5.1 DiscreteFillColor 137 5.5.2 MarkerStyle 137 5.5.3 ReferenceLineModel 140

Part 2 Chapter 6

Output Delivery System

Important Concepts for Getting Started with ODS and Java 145 6.1 6.2 6.3 6.4 6.5

Chapter 7

143

Java Scriptlet Code 146 General JSP Structure 146 General JSP Requirements 148 Connecting and Data Extraction 148 A Few Last Notes about Data 151

Creating Graphs

153

7.1 Types of Bar Charts 154 7.1.1 Horizontal Bar Charts 154 7.1.2 Vertical Bar Charts 155 7.2 Types of Pie Charts 156 7.2.1 Pie Charts 157 7.2.2 Donut Charts 158 7.2.3 Star Charts 159 7.3 Contour Plots 159 7.4 Types of Maps 160 7.4.1 Block Maps 160 7.4.2 Choropleth Maps 161 7.4.3 Prism Maps 162 7.4.4 Surface Maps 163 7.5 Types of Plots 163 7.5.1 Bubble Plots 164 7.5.2 Plots 165

vi Contents

7.6 Three-Dimensional Graphs 166 7.6.1 Scatter Plots 166 7.6.2 Surface Plots 167

Chapter 8

Parameters for Colors 169 8.1 ODS Parameters 170 8.1.1 Non-supported parameters 181 8.2 GOPTIONS 182 8.2.1 Non-supported options 186 8.3 PROC GCHART 186 8.3.1 Summary 192 8.3.2 Non-supported parameters 193 8.4 PROC GCONTOUR 193 8.4.1 Summary 197 8.5 PROC GMAP 197 8.5.1 Summary 199 8.6 PROC GPLOT 199 8.6.1 Summary 204 8.7 PROC G3D 204 8.7.1 Summary 205 8.7.2 Non-supported parameters 205

Chapter 9

Parameters for Text

207

9.1 ODS Parameters 208 9.1.1 Non-supported parameters 213 9.2 GOPTIONS 214 9.2.1 Non-supported parameters 217 9.3 PROC GCHART 217 9.3.1 Summary 225 9.3.2 Non-supported parameters 226 9.4 PROC GCONTOUR 227 9.4.1 Summary 231 9.5 PROC GMAP 232 9.5.1 Summary 234 9.6 PROC GPLOT 234 9.6.1 Summary 238

Contents vii

9.7 PROC G3D 239 9.7.1 Summary 240

Chapter 10 Other Parameters

241

10.1 PROC GCHART 242 10.1.1 Summary 264 10.1.2 Non-supported parameters 10.2 PROC GCONTOUR 268 10.2.1 Non-supported parameters 10.3 PROC GMAP 273 10.3.1 Summary 277 10.3.2 Non-supported parameters 10.4 PROC GPLOT 278 10.4.1 Summary 289 10.4.2 Non-supported parameters 10.5 PROC G3D 290 10.5.1 Summary 298 10.5.2 Non-supported parameters

Part 3

Putting It Together

Chapter 11 Final Reports

267 272

278

289

298

299

301

11.1 Report 1: Using SAS AppDev Studio 3 Tags 301 11.2 Report 2: Using ODS 307 11.3 Conclusions 310

Appendix A

SAS/GRAPH Samples and WORK Data Sets

References

315

Index

317

313

viii

Acknowledgments Thanks to Aimee for inspiration, Andrew for support, Jackie for courage, Mom for believing, and the readers for their interest. Wendy Bohnenkamp

Until I started this, I never knew just how much time and effort go into writing a book. This is hard work, and I first have to say thank you to Wendy for putting up with me as a writing partner. Without her knowledge, skill, and drive, this book would never have been finished. Next, I need to thank my family for their encouragement and support. And finally, I have to say thanks to the people who buy this book. If the examples in this book make their job easier, then it will have been worth the effort. Jackie Iverson

x

Introduction The idea for this book started glimmering every time we would lament to each other about the lack of good examples. The conversation always ended with “someone should write a book.” This book is intended to be that source for examples. We walk you though the basics and ® help to get you familiar with things that may be new to you or new to SAS 9. The book can be used by programmers at all experience levels. This book covers only the graph objects in SAS AppDev Studio, and it is assumed that you already know how to use SAS AppDev Studio to create and deploy a JavaServer Page (JSP) or servlet application. A basic level of SAS ODS programming knowledge is also needed to understand the example code in Part 2. ®

SAS 9 and SAS AppDev Studio 3 were released while we were writing this book. All ® examples have been tested on SAS 9. SAS AppDev Studio contains both the older version of graph custom tags as well as the new versions. Therefore we briefly cover version 2 tags, but concentrate more on the version 3 tags. There are many parameters and attributes to cover, so the intent is to provide a reference tool to help you build your own graphs. We’ve focused on what we feel are the two main ® ways programmers are using SAS 9 to create graphs using Java. There are four main sections to this book. The first is what you are reading now. Just a “Hi how are you?” and a “Here’s the intent of this book.” The second section covers webAF and SAS AppDev Studio. It includes a brief how-to section on using webAF as an Interactive Development Environment (IDE) and briefly discusses SAS AppDev Studio 2 tags and their options. Then it covers the tags and the nesting properties of SAS AppDev Studio 3 tags. The third section is intended for SAS programmers who want to do some reporting but who are not that familiar with custom tags. This section covers using Output Delivery System (ODS) statements and the Java Device Driver to create graphs. Then we wrap everything up in the fourth section to include reference and appendix materials. This book is not intended to give you all the answers to all the questions about SAS graphs. It is also not a “best practice” type of cookbook. We are merely trying to put together a reference volume that enables you to see what you can and cannot do to make your graphs more visually appealing. For instance, when you are combining ODS and JSP files, you get a very diverse environment. We have decided to simplify our examples by putting everything in a single JSP instead of using servlets, macros, stored processes, etc. We wanted to focus on the attributes, parameters, and options that make graphs convey what you really want them to convey.

xii Introduction

Because we are focusing on the look of the graph, we chose data that helped to illustrate the specific graph attribute. This produced graphs that may not represent a real world situation. So don’t get hung up on trying to analyze the graph; just look at what it is trying to show. Appendix A contains data layouts of the SAS samples and WORK data sets that were used to produce the graphs. Most of the time we used data sets from the SAS/GRAPH samples library to make it easy for you to reproduce the graph. Part 3, “Putting It Together,” explains where to find the sample data sets. If we had to create or modify the data to get a particular attribute to show more clearly, we included the SAS code in Appendix A. Each sample that produces output has been tested in our local development environment. We have tried to provide you with information on what works and what may not. We included things that did not work for us, because in your environment or in future updates they could. If you see an option or parameter that you like, give it a try. SAS offers many opportunities for creativity. We hope to give you a jump start on the path to great graphs. Ready to tackle those SAS graphs?

P a r t

1

SAS AppDev Studio Chapter 1 Getting Started with SAS AppDev Studio 3 Chapter 2 SAS AppDev Studio Custom Tags and Attributes for Basic Graphics 13 Chapter 3 SAS AppDev Studio 3 Graph Model Tags 39 Chapter 4 Nested Tags for Graph Models 99 Chapter 5 Supporting Tags 125

2 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

C h a p t e r

1

Getting Started with SAS AppDev Studio 1.1 Tag Libraries for SAS AppDev Studio 3 1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project 8 1.3 Your Data 10 1.3.1 Tips and Information 11

1.1 Tag Libraries for SAS AppDev Studio In this section we are going to look at creating graphs in a JavaServer Page (JSP) using the SAS Custom Tag Library. This tag library comes with the SAS AppDev Studio product, which includes webAF as the development environment tool. You can use webAF or another Java Interactive Development Environment (IDE), such as Eclipse, to utilize the tag libraries and API components that come with SAS AppDev Studio.

4 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

SAS AppDev Studio 2.x and SAS AppDev Studio 3 use separate tag libraries. SAS AppDev Studio 3 introduced some major enhancements to the graphics components. We’ll look at the most commonly used graphs in each version. The easiest way to add graphs to your JSP or servlet project in SAS AppDev Studio is to use the Component Palette. The graph components are on the Graphics tab. You can change the palette by clicking the down arrow on the toolbar title bar.

We will be working with graphs on the SAS JSP/Servlet (Version 3) and SAS JSP/Servlet (Version 2) palettes. The version 2 tag library is part of SAS AppDev Studio 3. When you create a new SAS AppDev Studio 3 project, you can choose to include the version 2 tag library so that these tags are available in the component palette. When you upgrade an existing webAF 2 project to use webAF 3 components, your old SAS AppDev Studio 2 tags (which have a sasads prefix) will still be in your project and will not be automatically updated to SAS AppDev Studio 3 tags (with a sas prefix). In other words, if you have a sasads:Bar chart in your project, it will not automatically be converted to a sas:BarChart if you move to webAF 3. Here is an overview and comparison of the graphs available in both versions. Remember that sasads tags are from SAS AppDev Studio 2, whereas sas tags are from the more recent SAS AppDev Studio 3. sasads:Bar

sas:BarChart

Chapter 1: Getting Started with SAS AppDev Studio 5

Here is a direct comparison of the default bar charts. Notice that the default for sasads:Bar is a three-dimensional chart, whereas the sas:BarChart is two-dimensional. Both have several options that can enhance the appearance. sasads:SegmentedBar

sasads:Combination

sas:BarLineChart

The sasads:SegmentedBar tag really does not have an equivalent in SAS AppDev Studio 3. However, you can mimic this graph by using the various model attributes with the sas:BarChart tag.

The sasads:Combination tag can be used in several different ways to perform similarly to a sas:BarLineChart, sas:LineChart, or sas:ScatterChart tag.

This sas:BarLineChart tag has no direct partner in SAS AppDev Studio 2 tags.

6 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

sas:LineChart

sasads:Pie

In SAS AppDev Studio 3, line charts can be created using the sas:LineChart tag. In SAS AppDev Studio 2, you might consider using the sasads:Combination tag.

sas:PieChart

As with the bar charts, sasads:Pie defaults to a three-dimensional chart, and sas:PieChart is two-dimensional. Both charts have loads of options to create a number of different looks. Additionally, the sas:PieChart tag can create a donut and subgroup data into concentric rings.

Chapter 1: Getting Started with SAS AppDev Studio 7

sasads:Scatter

sas:ScatterPlot

SAS AppDev Studio 2 includes the sasads:Scatter tag. The equivalent tag in SAS AppDev Studio 3 is sas:ScatterPlot.

sas:LinePlot

The sas:LinePlot tag could be compared to the previously shown SAS AppDev Studio 2 sasads:Combination tag.

8 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

sas:RadarChart

The sas:RadarChart tag is a brand-new graph type for SAS AppDev Studio 3.

1.2 Getting Ready to Add Graphs to Your SAS AppDev Studio Project There are a couple of things you need to consider before you can add graphs to your project. One is how to connect to the data. In your development environment, everything is local and easy to get to, but in normal production environments that usually isn’t the case. You need to plan your strategy for accessing your SAS server. Is security an issue? How many people will be accessing this application? How many people at the same time might need to grab the same data? All these questions should be discussed with both the Web server and SAS server administrators. These administrative roles may be filled by the same person or by people from different groups. Either way, you must plan and coordinate with them. There are so many variables and combinations of system setup that we can’t cover all of them in this book. For this book, we’ve taken a simple approach and used a basic Java Database Connectivity (JDBC) connection for SAS AppDev Studio 3 tags and SAS/CONNECT for all others. If you need something more elaborate for your environment, review the SAS documentation for SAS Integration Technologies. This resource will help you make decisions on setting up security, pooling, connection types, etc. Now that you have the connection, the next step is to create data models. Data models allow you to shape the data for graphing. For instance, you might need to sort the data alphabetically or by increasing values. Data models can also specify the columns, subset the data, and perform other functions.

Chapter 1: Getting Started with SAS AppDev Studio 9

In SAS AppDev Studio 2, one common method is to use a sasads:DataSet tag. This allows us to use the connection, specify the data, and shape it. Here’s an example:

In this example, we use the bbuConnection object to connect to our SAS server. Then the dataSet attribute is used to define the data set we want to use. Here we are using the Grains data set from the Samples library. Then, to help shape the data, we use the displayedColumns attribute. This allows us to specify only the columns we will be needing for the graph. When using the SAS AppDev Studio 3 tags, we need to use different types of models. These may seem more complicated than simply using the sasads:DataSet tag, but they are more flexible. For sas:BarChart you use a com.sas.graphics.components.barchart.BarChartTableDataModel. Here’s an example:



This snippet of code shows the configuration of a data model. It references a JDBCTableModelAdapter and sets properties for the data model, such as the category and response variables to use. See Chapter 11, “Final Reports,” for a complete example with SAS AppDev Studio 3 tags.

10 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

1.3 Your Data When you are using SAS data sets in SAS graphs, there are specific terms used to describe the types of variables. For instance, you may think in terms of an X axis and Y axis. However, because we are looking at statistical or computed variable data, most of the time each variable has a role. On the X axis you may actually be charting data by a category variable. Below are some terms that may help you along the way. Category variable A variable that determines the number and arrangement of bars, slices, lines, etc. Response variable The variable you are trying to understand, explain, or model. Midpoint The value associated with a bar on a bar or block chart or the slice on a pie chart. This is the category variable. Chart variable The data column to be charted. This variable can be character or numeric. Chart statistic Most commonly, the sum of a numeric variable or the frequency (count) of a character variable. Other common statistics are percentages and means. The statistics available vary by type of graph. Midpoint axis The axis that shows the categories of data. Response axis The axis that shows the range of values for the chart statistic. Contiguous variables Variables that contain a range of numeric values that are represented on the chart. For example, dollars or quantities are contiguous variables.

Chapter 1: Getting Started with SAS AppDev Studio 11

Discrete variables Variables that contain a finite number of specific values that are represented on the chart. For example, years, geographical areas, and company divisions are discrete variables. X Used in plots (vertical) to identify the variable on the horizontal axis. Y Used in plots (vertical) to identify the variable on the vertical axis. Z Used in plots (vertical) to identify the depth variable. For more information on terminology and graphing basics, see the SAS OnlineDoc documentation.

1.3.1 Tips and Information Here are a few tips on how to organize your data for maximum performance.

ƒ ƒ

ƒ ƒ

Usually, you should presummarize large data sets to improve performance. If you have a large number of different categories, you might want to subset or group the data to control the number of bars or pie slices shown in the chart. Depending on the size of your chart, it is easy to get so many bars that you cannot read the labels. When there are too many values to represent in a pie chart, the smaller values are automatically grouped into one slice labeled “Other.” By creating your own “Other” grouping, you can prevent a smaller, but important, category from being hidden. When you are accessing SAS data, the system often puts a lock on the data set you are using. For this reason, be sure to close all connection to the data once you are done. Or consider making your connection read-only and investigate how to set up workspace pooling or connection sharing techniques.

In short, the saying “Garbage in, garbage out” is so true. You need to be careful of how your data is constructed and formatted before you base critical decisions on your output.

12 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

C h a p t e r

2

SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 2.1 SAS AppDev Studio 2 Tags 15 2.1.1 sasads:Bar 15 2.1.2 sasads:Combination 16 2.1.3 sasads:Pie 16 2.1.4 sasads:Scatter 17 2.1.5 sasads:SegmentedBar 17 2.2 SAS AppDev Studio 3 Tags 18 2.2.1 sas:BarChart 18 2.2.2 sas:BarLineChart 19 2.2.3 sas:LineChart 20 2.2.4 sas:LinePlot 21 2.2.5 sas:PieChart 22 2.2.6 sas:RadarChart 23 2.2.7 sas:ScatterPlot 24 2.3 Common Attributes 25

14 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

SAS AppDev Studio gives the user a number of graphing custom tags to use with JSP pages. The tags available in SAS AppDev Studio 2 have been updated in SAS AppDev Studio 3. Although SAS AppDev Studio 2 tags are easier to use because they are not nested, they are limited in what they can and cannot display. You might be tempted at first to run with the SAS AppDev Studio 2 tags, but once you get the hang of SAS AppDev Studio 3 tags, we think you’ll jump right in with both feet. In general, the standard convention for SAS AppDev Studio 3 tags looks like this:

However, if there are no nested tags, you could use the following convention. The difference is that the tag is closed using a single backslash at the end of the invocation of the tag.

Be very careful not to use both conventions at the same time. If you accidently use /> and then have nested tags, the compiler won’t recognize the nested tags as being part of that tag group. If you need to nest tags, use the following convention and insert the nested tags where shown.



Each graph tag has three required attributes. The id attribute gives the object a name. Each object in your scope must have a unique identifier or name. The model attribute specifies the data model. The scope attribute defines the limit of the object’s availability, such as session, request, page, or application.

Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 15

2.1 SAS AppDev Studio 2 Tags The following graph examples illustrate the basics of the different graphing custom tags available from SAS AppDev Studio 2. These older tags are still available with SAS AppDev Studio 3. However, as stated before, you might want to convert to the newer SAS AppDev Studio 3 tags. The main difference in syntax between the two is the prefix used for the tags. The prefix “sasads:” denotes AppDev Studio 2 tags, whereas “sas:” denotes SAS AppDev Studio 3 tags.

2.1.1 sasads:Bar To create a bar chart using the SAS AppDev Studio 2 tags, use the sasads:Bar tag.

16 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

2.1.2 sasads:Combination A combination of a bar and line chart can be created using the sasads:Combination tag. Because combination charts handle many different variables, the tag requires a few more attributes by default to produce a readable graph. These attributes are categoryVariableName, responseVariableName, and subGroupVariableName.

2.1.3 sasads:Pie The sasads:Pie tag creates a pie chart.

Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 17

2.1.4 sasads:Scatter You can create a scatter chart using the sasads:Scatter tag.

2.1.5 sasads:SegmentedBar You can create a stacked bar chart using the sasads:SegmentedBar tag. As with the combination chart, there are more variables to define with a segmented bar chart. The attributes used to define these variables are categoryVariableName, responseVariableName, and subGroupVariableName.

18 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

2.2 SAS AppDev Studio 3 Tags In SAS AppDev Studio 2, you only need a DataSetInterface or sasads:DataSet tag to define your data. However, with SAS AppDev Studio 3, each chart type can be built using its own data model. Therefore, in each example of a basic graph we have included the code that builds the table data model for each graph type. For instance, with the sas:BarChart tag the corresponding table data model is the com.sas.graphics.components.barchart.BarChartTableDataModel class. Using this code allows you to customize your data more than you can by using the sasads:DataSet tag.

2.2.1 sas:BarChart The sas:BarChart tag creates a basic bar chart. By customizing the table data model, you can also transform the basic bar chart into a stacked bar chart to represent different subgroups of data.





Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 19

2.2.2 sas:BarLineChart The sas:BarLineChart tag can create bar charts that have a corresponding line chart attached. This enables you to see two different types of data per category.





20 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

2.2.3 sas:LineChart The sas:LineChart tag creates a line chart. A line chart shows the relationship of one variable to another. Typically these variables have only one corresponding value on the vertical axis. This type of chart is best suited to business-oriented graphs that plot values against other discrete categorical values.





Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 21

2.2.4 sas:LinePlot You can create a line plot using the sas:LinePlot tag. A line plot is typically used to plot x and y variables, one of which may have contiguous values. In this example, the population (POPDEN) is a contiguous value, and the territories (IDNAME) are discrete values.





22 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

2.2.5 sas:PieChart The newer sas:PieChart tags can create three-dimensional pie charts, ringed pie charts, and donut charts. Section 3.5 explains how to use attributes to create the various types of pie charts.





Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 23

2.2.6 sas:RadarChart The sas:RadarChart tag is new to SAS AppDev Studio. The spokes that radiate from the center of the chart can be used to show the frequency of data measures. These charts are often used in quality control and market research.





24 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

2.2.7 sas:ScatterPlot You can create a scatter plot using the sas:ScatterPlot tag. Scatter plots show a relationship between one variable and another. They can be very helpful in revealing trends in the data.





Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 25

2.3 Common Attributes The following are common attributes that affect the look and feel of SAS AppDev Studio 3 graph tags. These attributes can be applied to any of the base level graph tags. For each attribute we review the code that creates the output as well as the HTML that is generated. This way if you are familiar with HTML it will give you some idea of how the output is constructed.

alignment To adjust the alignment of a chart within the page you can use the alignment attribute. Valid values: Top Bottom Middle Left Right



This attribute is applied to the HTML image tag, so it does little to adjust the alignment on a page by itself. You can insert this tag into a HTML table to position the graph on the page.

26 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

alternateText The alternateText attribute enables you to define text that is displayed when the user hovers over graph areas where data points do not exist, such as the axis areas and labels. In the HTML source, this text is defined by the alt attribute applied to the HTML tag. Valid values:



Once this code is rendered, the compiled HTML code looks similar to this:

Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 27

appliedColorSchemeName To apply a predefined color scheme to your graph, you can use the appliedColorSchemeName attribute. This attribute is applied as a preprocessing event to create the image. Therefore no HTML tags are generated to apply the color scheme. Valid values: Autumn Carnival Grayscale Magellan Ocean Picnic Terra Woodland

Bright Commerce Industry Neon Pastel Pine Wheat



28 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

appliedGraphStyleName The appliedGraphStyleName attribute is very similar to the appliedColorSchemeName attribute. This attribute also applies predefined textures and modifies the look and feel of the graph with more than just colors. Valid values: Analysis Banker Convention Education Gears Money RSVP Sketch Torn

Astronomy Blockprint Curve Electronics Magnify Monochrome Science Statistical Watercolor



Have fun with these. You can find examples of the predefined graph styles at http://support.sas.com/rnd/gendoc/bi/api/Components/com/sas/graphics/components/docfiles/style-Grid.html.

Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 29

borderWidth To put a border around your graphics area you can use the borderWidth attribute. This attribute enables you to apply a border and control the thickness. Valid values:



When this tag is rendered, the border is actually applied to the HTML tag that produces the graph. Here is an example:

30 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

epilog You can add text to the graph area at the bottom by using the epilog attribute of the graph tag. Valid values:



The epilog is actually created after the image has been created. This is added as straight HTML text on your page.









Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 31

Epilog Text



Notice where the “Epilog Text” string is posted on the page after the image but before the map. The map was automatically generated by the graph tag. In this example, it provides hover text that shows the country name and amount.

galleryImageVisible The galleryImageVisible attribute enables you to control whether your graphs are resizable on the page. In Microsoft Internet Explorer there is a setting under Tools Î Internet Options Î Advanced Î Multimedia called “Enable Automatic Image Resizing.” This option, when checked, resizes images that may be too large to fit in the browser window area. The galleryImageVisible attribute sets this option on or off using a True or False value. Set to False, the graph image cannot be resized regardless of the user’s Internet Explorer browser settings. Valid values: Boolean (True/False)

32 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

height The graph’s height can be set using the height attribute. This attribute applies a height attribute to the HTML tag once it is rendered. Valid values:





Be aware that the radar chart does not resize the image, but rather allots the space to use for the graph area. Therefore the radar chart is the same size, but the height attribute may create more white space around the perimeter.

Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 33

horizontalSpace You can use the horizontalSpace attribute to provide padding or white space on the sides of the image. Valid values:



When the tag renders the image, it applies an hspace attribute to the HTML tag, similar to this:

image The image attribute allows you to set the source of the chart you are trying to display. Although this attribute sounds fairly straightforward, we have not found any practical uses for it.

34 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

prolog Similar to the epilog attribute, the prolog attribute applies text to the outside of the graph area. The difference is that the prolog is applied before the graph is resolved. Valid values:



The resulting HTML code looks similar to this: Prolog text







Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 35



Notice that the string “Prolog Text” is applied to the HTML stream before the image and map areas.

render To disable or delay the display of a specific graph, you can use the render attribute. This takes a Boolean value (True or False). The default value is True. If it is set to False, the graph does not display with that particular invocation of the graph tag. However, if you reference the graph tag later in the HTML file, you can display the graph at that time by changing the render value to True. Valid values: Boolean (True/False)

This tag can be valuable in lots of applications. For example, you might want to display or not display the graph based on some passed parameter. Therefore you could do something like the following:

This code takes a parameter pulled from the session or request (isRendered) and applies that passed string directly to the tag. You should be careful when doing this to make sure the value is indeed a string representing a Boolean value (True or False).

36 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

verticalSpace The verticalSpace attribute is similar to the horizontalSpace attribute. The difference is that white space is applied to the top and bottom (vertical spaces) of the graph area. Valid values:



This padding is accomplished when the tag renders the image. It applies a vspace attribute to the HTML tag, similar to this:

width To adjust the width of the graphics area, you can use the width attribute with the graphics tag. Valid values:



Chapter 2: SAS AppDev Studio Custom Tags and Attributes for Basic Graphs 37

Here is the resulting HTML source:

Note that the width is applied directly to the HTML tag. This can cause you some problems. For instance, take one of the plots with longer labels. The labels will unfortunately be shortened automatically. This might not be the desired affect, as shown below.

38 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

C h a p t e r

3

SAS AppDev Studio 3 Graph Model Tags 3.1 BarChartModel 40 3.2 BarLineChartModel 50 3.3 LineChartModel 64 3.4 LinePlotModel 67 3.5 PieChartModel 74 3.6 RadarChartModel 87 3.7 ScatterPlotModel 92 3.7.1 Baselines 97

This chapter covers graph model tags. Graph model tags are used to control the data elements in the graph. This type of tag is nested inside the top-level graph tag. In the JSP, the nested tags look like this:



40 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

We have discussed the attributes of the top-level tag (in this case sas:BarChart). Now we want to discuss the attributes of the graph model. In these examples, we still show the output and the code, but there is no HTML source to review, because the nested tag works on the output before it is delivered to the screen. At the beginning of each graph model tag, we show you the tags in context. Then for each attribute we only show the nested tag portion.

3.1 BarChartModel The sas:BarChartModel tag is used within the sas:BarChart tag. Here is an example of the appropriate nesting syntax:



antialiasedGraphics The antialiasedGraphics attribute of the BarChartModel tag smooths the edges when set to True, which is the default. In some system environments, the difference is insignificant. For this reason, we do not provide an example of the output for any of the antialiased attributes. Valid values: Boolean (True/False)

Chapter 3: SAS AppDev Studio 3 Graph Model Tags 41

antialiasedText Similar to the antialiasedGraphics attribute, the antialiasedText attribute smooths the edges of text in the output. The default value is True. Valid values: Boolean (True/False)

barShape You can change the shape used to represent the bar using the barShape attribute. Currently only two shapes are available: a rectangle (which is the default) and a cylinder. This attribute can be changed only when the dimension attribute of the graph is set to 3D. Valid values: Rectangle Cylinder Requirements: dimension=“3D”

42 SAS Graphics for Java: Examples Using SAS AppDev Studio and the Output Delivery System

barWidth You can use the barWidth attribute to set the display property of the bars in the bar chart. If the graph becomes too crowded, the applet automatically resizes the bars to accommodate them. Valid values:

The value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in



barWidthSpace To set the width of the white space around each bar, you can use the barWidthSpace attribute. Valid values:

The value can be px (pixels), pt (points), cm (centimeters), or in (inches). Examples of valid values: 50px, 3cm, 1in

Chapter 3: SAS AppDev Studio 3 Graph Model Tags 43



dimension To set the aspect to 3D, you can use the dimension attribute. The default is 2D. The example shows the attribute set to 3D. Valid values: 2D 3D



insideBarLabelContent The insideBarLabelContent attribute enables you to set the type of information to be displayed inside the bar. Valid values: Automatic None Category Response Sum Mean Percent Subpercent