|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.graphics.components.Variable
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).
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.
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 |
---|
public Variable(java.lang.String columnName)
columnName
- the name identifying the data columnpublic Variable(java.lang.String columnName, java.lang.String format)
columnName
- the name identifying the data columnformat
- the name of the SAS format applied
(by the graph) on the values found in
this variable's data columnpublic Variable(java.lang.String columnName, java.lang.String format, java.lang.String informat, java.lang.String label)
columnName
- the name identifying the data columnformat
- the name of the SAS format applied
(by the graph) on the values found in
this variable's data columninformat
- the name of the SAS informat applied
(by the graph) on the values found in
this variable's data columnlabel
- 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"
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)
public Variable(int columnIndex)
columnIndex
- the index identifying the data columnpublic Variable(int columnIndex, java.lang.String format, java.lang.String informat, java.lang.String label)
columnIndex
- the index identifying the data columnformat
- the name of the SAS format applied
(by the graph) on the values found in
this variable's data columninformat
- the name of the SAS informat applied
(by the graph) on the values found in
this variable's data columnlabel
- 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"
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)
public Variable(Variable v)
Method Detail |
---|
public java.lang.String getColumnName()
null
.
getColumnIndex()
public int getColumnIndex()
-1
.
getColumnIndex()
public java.lang.String getLabel()
public java.lang.String getFormat()
public java.lang.String getInformat()
public com.sas.graphics.components.CategorizationModel getCategorizationModel()
public com.sas.graphics.components.SegmentedRangeStyle getSegmentedRangeStyle()
public boolean equals(java.lang.Object obj)
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.
equals
in class ModelBase
obj
- the object to test for equality with this
Variable
true
if the objects are the same;
false
otherwise.public int hashCode()
Variable
.
hashCode
in class ModelBase
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |