Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
Scatter 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 Scatter Control.
One of the actions is Pick, which causes the control to store the clicked marker'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 Scatter control's actionMode attribute is set to Pick, and that the markers represent the population figures for a set of countries. If you click on the marker 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 marker, 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 scatter1, the following code gets items from the pickList attribute:
/* Make an empty list */ mylist = makelist(); /* Fill it with information from the picked marker */ scatter1._getPickList(mylist); /* The list is a list of lists, each */ /* containing info about a marker */ sublist = getiteml(mylist,1); /* Check on the type of the variable, */ /* in case the type changes */ idx = nameditem(sublist,"X"); if itemtype(sublist,idx) = 'C' then xc = getnitemc(sublist,"X"); else x = getnitemn(sublist,"X"); idx = nameditem(sublist,"Y"); if itemtype(sublist,idx) = 'C' then yc = getnitemc(sublist,"Y"); else y = getnitemn(sublist,"Y"); /* and so forth for all the plot 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:
scatter1._getPickedItemCount(count); mylist = makelist(); scatter1._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 markers to highlight in a scatter plot, create a list of lists with variable values that identify each marker, 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 marker whose values are X=a and Y=66:
scatter1.actionMode='pick'; pklist=makelist(); sublist=makelist(); rc=insertc(sublist, 'a', -1); rc=insertn(sublist, 66, -1); rc=insertl(pklist, sublist); scatter1.pickList=pklist; /* clean memory */ rc=dellist(pklist, 'Y');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(); scatter1.pickList = listid;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.