Service Packs for the SAS9 Platform." />
SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 26108: Create a dial meter indicator for a dashboard

DetailsCodeOutputDownloadsAboutRate It

This example uses the Annotate facility and the GANNO procedure in the SAS/GRAPH software to create a single dial meter indicator for use in a dashboard. For a sample of a complete dashboard, see Create a dashboard with multiple dial meter indicators.

The gauge in this sample is created by specifying the values for the start-angle, end-angle, and color for each range and segment, and the value of the gauge pointer or arrow. Here are the values that are specified in a data set:

   data my_data2;
   length grtype color $ 8;
   input  grtype color start end;
   cards;
   segment cxff0000  0  50
   segment cx00cd00 50 100
   arrow   black     11 11
   ;

Here is the definition of the variables that are used in the data set:

GRTYPE
specifies the graphic type, which can be segment or arrow.
COLOR
specifies the color of the graphic as a SAS color or a HEX code color.
START
specifies the starting value for the color range.
END
specifies the ending value for the color range.

This data set is passed to the %DO_GAUGE macro along with several other parameters that control the look of the custom gauge chart. No error checking is done on these parameters. To keep this sample simple, short, and understandable, all values are assumed to be valid. Here is the syntax of the %DO_GAUGE macro:

%do_gauge(mydata, major_tick_by, minor_tick_by, titletext, foottext, pltname)

Here is a description of the macro parameters:

mydata
specifies the name of the data set that describes the color ranges and marker values.
major_tick_by
specifies the major tick mark increment.
minor_tick_by
specifies the minor tick mark increment.
titletext
specifies the text of the title above the gauge.
foottext
specifies the text of the footnote below the gauge.
pltname
specifies a name for the GRSEG in which the graph is stored temporarily.

Here is an example of a %DO_GAUGE macro call:

%do_gauge(my_data2,10,5,Scheduling,Percent Bid When Scheduled,sched1);

The %DO_GAUGE macro performs the following steps to draw the gauge:

  • To draw the gauge background, the macro annotates a pie for the outer ring of the gauge and fills the entire pie with a solid dark-blue color, which appears as the outer dark-blue ring around the outer edge. It then overlays a slightly smaller, lighter blue pie onto the dark-blue pie, which appears as the wider, lighter blue band just inside of the outer dark-blue ring. Finally, it overlays a smaller dark-blue pie and a gray circle onto the light-blue pie, which appears as the inner, narrow, dark-blue ring and the gray dial background.
  • To draw the ranges, the macro annotates the color ranges as pie slices whose start and end angles correspond to the values of their slice. For the gauge in this sample, the minimum segment must start at an angle of 240 degrees and progress in a clockwise fashion to a maximum of angle of 300 degrees. Also, the user must be allowed to set the minimum gauge segment to a value other than zero. To meet these requirements, the macro uses several equations to normalize the values and map them to the appropriate annotated pie angles.
  • To draw the major and minor tick marks, the macro uses the Annotate pie slice mode to position the cursor for each tick mark, and then draws a line through through the pie slice to the center of the gauge. After it draws all of the tick-mark lines, it then draws a slightly smaller annotated gray pie that covers the interior part of the range slices and the tick-mark lines. This results in a gray interior for the gauge chart and tick marks on the scale.
  • To draw the gauge needle, the macro uses the same process that it used to draw the tick-mark lines, except that it draws only one line and it does not draw the gray pie. Unlike the tick-mark lines, the needle line must extend to the gauge hub.
  • Finally, to draw the hub on which the gauge needle is connected, the macro draws a small white pie in the center of the gauge.

For additional information about creating dashboard applications with SAS/GRAPH software, see SAS/GRAPH Dashboard Samples.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.