Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
Chart 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 Chart 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 Chart 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 chart1, the following code gets items from the pickList attribute:
/* Make an empty list */ mylist = makelist(); /* Fill it with information from the picked bar */ chart1._getPickList(mylist); /* The list is a list of lists, each */ /* containing info about a bar */ 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 chart 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:
chart1._getPickedItemCount(count); mylist = makelist(); chart1._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 chart, 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 whose values are X=a and Y=66:
chart1.actionMode='pick'; pklist=makelist(); sublist=makelist(); rc=insertc(sublist, 'a', -1); rc=insertn(sublist, 66, -1); rc=insertl(pklist, sublist); chart1.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(); chart1.pickList = listid;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.