Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using a Pick List in a Histogram Control

Histogram controls have an actionMode attribute that determines what action is taken when you click on the control. For information on setting the action mode, see Setting the Action Mode in a Histogram Control.

One of the actions is Pick, which causes the control to store the clicked bar's values in the control's pickList attribute. The pickList attribute contains an SCL list of lists, any of which can be a named list.

For example, assume a Histogram control's actionMode attribute is set to Pick, and that the bars represent the population figures for a set of countries. If you click on the bar representing France, the pickList attribute stores the value identifying the country as France, and it stores France's population value. If, pressing the multiple selection key on the keyboard, you click on France, England, and Germany, the pickList attribute's list stores three lists; the first list identifies France and its population, the second identifies England and its population, and the third identifies Germany and its population.

To get the items from the pickList attribute, use the _getPickList method. The SCL list that is returned is a named SCL list. The named SCL list contains a named entry for every variable associated with the graph. Using SCL's getnitemn() and getnitemc() routines, you can extract the variable values for the picked bar, assuming the variable has been assigned in the control. If the variable has not been assigned, there is no entry for it in the list. You can use the following names in the getnitemn() and getnitemc() routines:

For a control named histogram1, the following code gets items from the pickList attribute:

/* Make an empty list */
mylist = makelist();

/* Fill it with information from the picked bar */
histogram1._getPickList(mylist);

/* The list is a list of lists, each */
/* containing info about a bar    */

sublist = getiteml(mylist,1);
  x = getnitemn(sublist,"Xmax");
  y = getnitemn(sublist,"Ymax");

/* and so forth for all the variables */


Extending a Pick List

To collect information on multiple picks in a graph, first determine how many items are picked by using the _getPickedItemCount method. This returns a count of all the items in the current pick list. The following code shows how to nest into a loop structure the code that is shown in the previous section. This code iterates through the loop once for each picked item:

histogram1._getPickedItemCount(count);
mylist = makelist();
histogram1._getPickList(mylist);

/* Loop through the sublists */
do i = 1 to count;
  sublist = getiteml(mylist,i);

  /* Process a sublist... */
end;


Setting a Pick List

To specify a list of bars to highlight in a histogram, create a list of lists with variable values that identify each bar, and assign that list to the pickList attribute. The sub-lists do not have to contain named items, but if they are not named items, each sub-list should contain the following values in the order that they are listed here:

For example, the following code highlights a bar where X=11:

histogram1.dataSet='sashelp.class';
histogram1.xVariable='age';
histogram1.faceColorMode='all';
histogram1.pickHighlightMode='filled';
histogram1.actionMode='pick';
histogram1._update();

pickList = makelist();
subList = makelist();
rc = insertn(subList,11, -1);

rc = insertl(pickList, subList);
histogram1.pickList=pickList;
To determine the highlight color, use the highlightColor attribute.

The pick-list operations are additive. Successive calls do not replace what was in the pick list, they add to it. Thus, you may want to clear pick-list items between pickList settings. To clear all the picked items, pass an empty list to pickList:

listid = makelist();
histogram1.pickList = listid;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.