Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
By default, a Pie control loads 16 distinct colors to represent the values of the slice variable. The purpose of the color is simply to make it easy to see the different slices:
To make color a response variable in the graph, you can specify a numeric variable whose values are indexed into the defined color range to determine the colors to use in the graph. To assign the color variable, use the colorVariable attribute. The colors can represent the Sum, Mean, or Frequency statistic for the dependent variables. To specify the statistic represented by the color variable, use the colorVariableStatistic attribute.
For a Pie control named pie1, the following code sets the colorVariable to Sales and the colorVariableStatistic to Sum:
pie1.colorVariable = 'sales'; pie1.colorVariableStatistic = 'sum';
The color is applied in a color range from yellow to red, with yellow representing the lowest values of the color variable and red representing the highest:
pieDefColor
To change the default color values that represent a color variable's values, you can define an alternative color range in either of two ways:
Creating a Color List in a Pie Control |
To supply your own color list of up to 64 colors:
In build mode, you can define a color list by selecting the colorList attribute, and then selecting the button that appears in the Value column. This opens the List Editor so that you can define the list of colors.
To define a color list in SCL code, make an SCL list, populate it with the list of color values, and then assign the list to the control's colorList attribute. Your code might resemble the following for a control named pie1:
/* Make the list */ clist = makelist(3); rc = setitemc(clist,'Red',1); rc = setitemc(clist,'Yellow',2); rc = setitemc(clist,'Green',3); /* varName is the color variable's name */ pie1.colorVariable='varName'; pie1.colorList=clist;
The colors in your specified list are distributed evenly across the range of values in the color variable. Thus, if you define three colors in the list, only three slice colors are used. The first color in the list represents the lowest third of the color variable's values, the second color in the list represents the middle third of the color variable's values, and the third color represents the highest third:
You can also create a list of blended colors. The following code creates a color series that ranges from red to blue:
rcolor= ' '; gcolor = ' '; bcolor = ' '; r = 255; g = 0; b = 0; fmt = 'hex2.'; clist = makelist(16); do i = 1 to 16; rcolor = putn(r,fmt); gcolor = putn(g, fmt); bcolor = putn(b, fmt); cval = 'CX' || rcolor || gcolor || bcolor; retc = setitemc(clist,cval,i); r = r - 14; b = b + 14; end; /* varName is the color variable's name */ pie1.colorVariable='varName'; pie1.colorList=clist;
The colors in the list are distributed evenly across the range of values in the color variable:
To return to using the default colors, assign an empty list to the colorList attribute:
clist = makelist(); /* varName is the color variable's name */ pie1.colorVariable='varName'; pie1.colorList=clist;
Using a Range Entry in a Pie Control |
You can use a Range entry as the color source for a Pie control. A Range entry is a catalog entry of type RANGE. The entry defines a range having up to 24 segments, each of which is assigned a numeric range, a color, and an attribute. For example, segment 1 might be assigned the numeric range from 0 to 5, the color Blue, and the attibute Blinking; segment 2 might be assigned the numeric range from 6 to 10, the color Green, and the attribute Highlight; and so on. A Pie control supports the numeric ranges and the colors assigned to the segments, but it does not support the attributes (Blinking, Highlight, Reverse, Underline, and Hirev).
When used with a Pie control, the numeric ranges that are defined in the Range entry's segments are indexed into the values of the color variable that is assigned to the Pie control. So, using the segments defined above, the values from 0 to 5 in the color variable will be represented by Blue in the graph, and the values from 6 to 10 will be represented by Green, and so on.
To use a Range entry, you must do all of the following:
To create a Range entry, use the Range Entry window, which you can open from the SAS command line. If you need help defining the segments, use the window's Help button to get help. The following command opens the Range Entry window to create a temporary Range entry in the WORK library:
build work.color.myrange.range
After creating the Range entry, you can use its color definitions as the color source in a Pie control. For example, if you used the command above to create a Range entry, the following code applies that entry's colors to a Pie control named pie1:
/* varName is the color variable's name */ pie1.colorVariable='varName'; pie1.colorSource='ColorRangeObject'; pie1.colorRangeObject='work.color.myrange.range';
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.