All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.graphics.components
Class Variable

    com.sas.graphics.components.Variable

Direct Known Subclasses:
  ClassificationVariable, RangeVariable, VariableList

    public class Variable

A Variable is used to identify a data column (in relational type data) to a graph. Graphs support different variable roles to enable the graph author to control how the data is interpreted by the graph. For instance the BarChart's ResponseVariable (designated via BarChartTableDataodel) will represent numeric values as bar heights. Where as the BarChart's ColumnVariable (also designated via BarChartTableDataodel) will represent values as separate horizontal bar groupings. Data columns are identified by either the column name or index (but not both). Note that the columnName and columnIndex properties are mutually exclusive. Setting the columnName will reset the columnIndex to its un-set value (i.e. -1). Likewise setting the columnIndex will reset the columnName to its un-set value (null).

Also note: the data column designations are not validated until the graph is actually trying to display. It is the graph author's responsibility to ensure that the proper data column designations have been set.

Just to be clear:

The terms columnName and columnIndex are use "column" to represent that these properties identify a data column in a relation data table. The columnName and columnIndex properties are in no way directly associated with the term "ColumnVariable" in the graph data models (the ColumnVariable is a Variable and hence will have columnName and columnIndex properties which is true of any Variable).

## Usage

You can designate a data column by either the data's column name or index.

Example

Suppose the third column in a dataset has the name "PRODUCT". You can attach a variable to the data column by one of the following:

     myVariable.setColumnName("PRODUCT");
     OR
     myVariable.setColumnIndex(3);

Note: setColumnName and setColumnIndex are mutually exclusive. The last one specified will designate how the chart will attempt to locate the column in the data source.

The Label property is used to override the default associate dataTip, axis or legend label. For example if you wanted to see the label "My Products" displayed in the chart's dataTip, axis or legend for this variable (where applicable depending upon the chart), you could use the following:

     myVariable.setLabel("My Products");

The Format property is used to specify how the data is to be represented in the graph. For example you may be using a BarChart to show sales in dollars. Use the "dollar" format to get the BarChart to represent the values as dollars on its response axis and in the data tips.

     BarChart barChart = new BarChart();
     TableModel tableModel = myTableModel();
     // <...set up tableModel...>
     BarChartTableDataModel barChartTableDataModel = new BarChartTableDataModel(tableModel);
     AnalysisVariable sales = new AnalysisVariable("ActualSales"));
     sales.setFormat("dollar");
     barChartTableDataModel.setResponseVariable(sales);
     barChart.setDataModel( barChartTableDataModel );

Note that the format is represented as a string. Acceptable values include any SAS predefined format (such as the "dollar" example). Custom formats can be made using the com.sas.text.SASUserDefinedFormat class to define the format.

Examples:

     com.sas.text.SASUserDefinedFormat.createFormat("value gender 1='Male' 2='Female' other='Invalid'");
     com.sas.text.SASUserDefinedFormat.createFormat("value $score 'A' = 'Excellent' 'B'='Good' 'C'='Fair' 'D'='Bad'");
     com.sas.text.SASUserDefinedFormat.createFormat("picture phone (default=14) other='999) 999-9999' (prefix='(')");

     AnalysisVariable salesVariable = new AnalysisVariable("ActualSales"));
     sasalesVariableles.setFormat("dollar");

     ClassificationVariable genderVariable = new ClassificationVariable("GenderType"));
     genderVariable.setFormat("gender");

     ClassificationVariable testScoresVariable = new AnalysisVariable("TestScores"));
     testScoresVariable.setFormat("$score");

     ClassificationVariable phoneVariable = new ClassificationVariable("PhoneNumber"));
     phoneVariable.setFormat("phone");

The part that is difficult to imagine above is the data that the format gets applied on. Consider that the ActualSales are numeric values, the GenderType is numerical values of 1 or 2, TestScores are String values of A, B, C or D and PhoneNumber was a numerical 10 digit number. Note: custom formats must be specified via the SASUserDefinedFormat prior to the graph using the format.

## Behavior

In addition to designating the data column, the Variable class also provides the place where you can associate various display options related only to the designated data column such as a format or a user defined display label.
Variable won't be used directly by the user, but will be surfaced through it's subclasses: ClassificationVariable and AnalysisVariable.

Since:
  SAS 9.1
See Also:
  `VariableList`, `ClassificationVariable`, `ClassificationVariableList`, `AnalysisVariable`, `AnalysisVariableList`

Constructor Summary
`Variable(int columnIndex)` Constructor designating data column by index.
`Variable(int columnIndex, java.lang.String format, java.lang.String informat, java.lang.String label)` Constructor designating data column by index along with the names of the SAS format and SAS informat and label to be applied.
`Variable(int columnIndex, java.lang.String format, java.lang.String informat, java.lang.String label, com.sas.graphics.components.CategorizationModel categorizationModel, com.sas.graphics.components.SegmentedRangeStyle segmentedRangeStyle)`
`Variable(java.lang.String columnName)` Constructor designating data column by name.
`Variable(java.lang.String columnName, java.lang.String format)` Constructor designating data column by name along with the name of the SAS format to be applied.
`Variable(java.lang.String columnName, java.lang.String format, java.lang.String informat, java.lang.String label)` Constructor designating data column by name along with the names of the SAS format and SAS informat and label to be applied.
`Variable(java.lang.String columnName, java.lang.String format, java.lang.String informat, java.lang.String label, com.sas.graphics.components.CategorizationModel categorizationModel, com.sas.graphics.components.SegmentedRangeStyle segmentedRangeStyle)`
`Variable(Variable v)`

Method Summary
`boolean` | `equals(java.lang.Object obj)` Determines whether another object is equal to this `Variable`.
`com.sas.graphics.components.CategorizationModel` | `getCategorizationModel()` Returns the user specified categorization model.
`int` | `getColumnIndex()` Returns the data column index specified by the user.
`java.lang.String` | `getColumnName()` Returns the data column name specified by the user.
`java.lang.String` | `getFormat()` Returns the user-specified SAS format applied to the values in the data column designated by this variable.
`java.lang.String` | `getInformat()` Returns the user-specified SAS informat applied to the values in the data column designated by this variable.
`java.lang.String` | `getLabel()` Returns the user-specified label.
`com.sas.graphics.components.SegmentedRangeStyle` | `getSegmentedRangeStyle()` Returns the user specified segmented range style.
`int` | `hashCode()` Computes the hash code for this `Variable`.

Methods inherited from class com.sas.graphics.components.ModelBase
`addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, setContainedModel`

Constructor Detail

### Variable

    public Variable(java.lang.String columnName)

  Constructor designating data column by name.

  Parameters:
    `columnName` - the name identifying the data column

### Variable

    public Variable(java.lang.String columnName,
                    java.lang.String format)

  Constructor designating data column by name along with the name of the SAS format to be applied.

  Parameters:
    `columnName` - the name identifying the data column
    `format` - the name of the SAS format applied (by the graph) on the values found in this variable's data column

### Variable

    public Variable(java.lang.String columnName,
                    java.lang.String format,
                    java.lang.String informat,
                    java.lang.String label)

  Constructor designating data column by name along with the names of the SAS format and SAS informat and label to be applied.

  Parameters:
    `columnName` - the name identifying the data column
    `format` - the name of the SAS format applied (by the graph) on the values found in this variable's data column
    `informat` - the name of the SAS informat applied (by the graph) on the values found in this variable's data column
    `label` - the label the chart will display via data tips, axis labels and legend labels (where applicable)

    The supported informats are:

    - `DATE5. - "ddMMM"`
    - `DATE7. - "ddMMMyy"`
    - `DATE9. - "ddMMMyyyy"`
    - `DATETIME13. - "ddMMMyy:HH:mm"`
    - `DATETIME16. - "ddMMMyy:HH:mm:ss"`
    - `DATETIME18. - "ddMMMyyyy:HH:mm:ss"`
    - `DATETIME20. - "ddMMMyy:HH:mm:ss.SSS"`
    - `DATETIME22. - "ddMMMyyyy:HH:mm:ss.SSS"`
    - `TIME5. - "HH:mm"`
    - `TIME8. - "HH:mm:ss""`
    - `TIME12. - "HH:mm:ss.SSS"`

### Variable

    public Variable(java.lang.String columnName,
                    java.lang.String format,
                    java.lang.String informat,
                    java.lang.String label,
                    com.sas.graphics.components.CategorizationModel categorizationModel,
                    com.sas.graphics.components.SegmentedRangeStyle segmentedRangeStyle)

### Variable

    public Variable(int columnIndex)

  Constructor designating data column by index.

  Parameters:
    `columnIndex` - the index identifying the data column

### Variable

    public Variable(int columnIndex,
                    java.lang.String format,
                    java.lang.String informat,
                    java.lang.String label)

  Constructor designating data column by index along with the names of the SAS format and SAS informat and label to be applied.

  Parameters:
    `columnIndex` - the index identifying the data column
    `format` - the name of the SAS format applied (by the graph) on the values found in this variable's data column
    `informat` - the name of the SAS informat applied (by the graph) on the values found in this variable's data column
    `label` - the label the chart will display via data tips, axis labels and legend labels (where applicable)

    The supported informats are:

    - `DATE5. - "ddMMM"`
    - `DATE7. - "ddMMMyy"`
    - `DATE9. - "ddMMMyyyy"`
    - `DATETIME13. - "ddMMMyy:HH:mm"`
    - `DATETIME16. - "ddMMMyy:HH:mm:ss"`
    - `DATETIME18. - "ddMMMyyyy:HH:mm:ss"`
    - `DATETIME20. - "ddMMMyy:HH:mm:ss.SSS"`
    - `DATETIME22. - "ddMMMyyyy:HH:mm:ss.SSS"`
    - `TIME5. - "HH:mm"`
    - `TIME8. - "HH:mm:ss""`
    - `TIME12. - "HH:mm:ss.SSS"`

### Variable

    public Variable(int columnIndex,
                    java.lang.String format,
                    java.lang.String informat,
                    java.lang.String label,
                    com.sas.graphics.components.CategorizationModel categorizationModel,
                    com.sas.graphics.components.SegmentedRangeStyle segmentedRangeStyle)

### Variable

    public Variable(Variable v)

Method Detail

### getColumnName

    public java.lang.String getColumnName()

  Returns the data column name specified by the user. The default value is `null`.

  Returns:
    data column name
  See Also:
    `getColumnIndex()`

### getColumnIndex

    public int getColumnIndex()

  Returns the data column index specified by the user. The default value is `-1`.

  Returns:
    data column index
  See Also:
    `getColumnIndex()`

### getLabel

    public java.lang.String getLabel()

  Returns the user-specified label.

  Returns:
    user-specified label

### getFormat

    public java.lang.String getFormat()

  Returns the user-specified SAS format applied to the values in the data column designated by this variable.

  Returns:
    user-specified SAS format

### getInformat

    public java.lang.String getInformat()

  Returns the user-specified SAS informat applied to the values in the data column designated by this variable.

  Returns:
    user-specified SAS informat

### getCategorizationModel

    public com.sas.graphics.components.CategorizationModel getCategorizationModel()

  Returns the user specified categorization model.

  Returns:
    user-specified categorization model

### getSegmentedRangeStyle

    public com.sas.graphics.components.SegmentedRangeStyle getSegmentedRangeStyle()

  Returns the user specified segmented range style. Note: The segmentedRange style is only applicable with a non-null categorization model.

  Returns:
    user-specified categorization model

### equals

    public boolean equals(java.lang.Object obj)

  Determines whether another object is equal to this `Variable`.

  The result is `true` if and only if the argument is not `null` and is a `Variable` object that has the same property values as this object.

  Overrides:
    `equals` in class `ModelBase`
  Parameters:
    `obj` - the object to test for equality with this `Variable`
  Returns:
    `true` if the objects are the same; `false` otherwise.

### hashCode

    public int hashCode()

  Computes the hash code for this `Variable`.

  Overrides:
    `hashCode` in class `ModelBase`
  Returns:
    a hash code value for this object.

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.