TileChartTableDataModel: Basic Charts

The main responsibility of a TileChartTableDataModel is to determine which data variables are used in the tile chart and what role each variable plays. A TileChartTableDataModel's primary roles are

TileVariable
Specifies one or more classification variables whose values determine the number and arrangement of tiles in the chart. When multiple variables are are used in this role, there must be a hierarchical relationship among them. One tile is produced for each unique classification value. Because a tile chart needs to organize the Tile variable's data values into groups (typically called bins), the TileVariable role uses a ClassificationVariable, which is designed to manage and sort categorical values. Multiple variables are assigned the Tile role by listing the variables in a ClassificationVariableList and assigning the Tile role to the list rather than to an individual variable.
SizeVariable
Specifies an analysis variable whose values determine the size of each tile. The role uses an AnalysisVariable so that a statistical computation can be associated with the variable instance.
ColorVariable
Specifies an analysis variable whose values determine the color of each tile. Tile colors are derived from a color gradient that represents the ColorVariable's range of values. The role uses an AnalysisVariable so that a statistical computation can be associated with the variable instance.

The following code fragment assigns the Tile variable role to variables named Region, Product, and Subsidiary. It assigns the Size role to a variable named Inventory, and the Color role to a variable named Sales. The resulting TileChart shows regional inventory and sales data by product and subsidiary.

 
// Create a data source that must contain string columns named
// Region, Product, and Subsidiary, and numeric columns named
// Inventory and Sales
   javax.swing.table.TableModel dataTable = <...>;

// Create a data model and attach the data source to it
   TileChartTableDataModel dataModel =
     new TileChartTableDataModel();
   dataModel.setModel(dataTable);
     
// Assign the Tile variable role to Region, Product, and Subsidiary
   ClassificationVariableList multiTile=new ClassificationVariableList(
     new ClassificationVariable[] {
         new ClassificationVariable("Region"),
         new ClassificationVariable("Product"),
         new ClassificationVariable("Subsidiary")
     } );

// Assign the classification list to the Tile variable role
   dataModel.setTileVariable(multiTile);

// Assign the Size variable role
   dataModel.setSizeVariable(
     new AnalysisVariable("Inventory"));
 
// Assign the Color variable role
   dataModel.setColorVariable(
     new AnalysisVariable("Sales"));

// Create a TileChart and attach the data model to it
   TileChart tileChart = new TileChart(dataModel);

Examples
Basic Requirements for Creating a Tile Chart: Swing-based code, Servlet-based code
Multiple Tile Variables: Swing-based code, Servlet-based code
Set Color Variable: Swing-based code, Servlet-based code

See Also: Valid Variable Roles

TileChartTableDataModel: Data Summarization and Statistic Calculation

Editor's Note: Implementation details are not yet available.

When a data model is assigned to a TileChart, the chart summarizes the data before displaying it. During summarization

The following statistics are the default calculations:

The AnalysisVariable constructor can be used to specify a statistic to calcuate. The following code fragment specifies a mean:

 
AnalysisVariable response=new AnalysisVariable(
  "Var1"                            // column for Response role
  ,GraphConstants.STATISTIC_MEAN    // statistic to calculate
);
TileChartTableDataModel dataModel=new TileChartTableDataModel();
dataModel.setSizeVariable(response);

By default, a TileChart summarizes the data, even if the TableModel's data values have already been summarized. When the values in the data source have already been summarized, you can improve performance by turning off data summarization. Do this by setting the StatisticEnabled boolean to false as follows:

 
TileChartTableDataModel dataModel=new TileChartTableDataModel();
dataModel.setStatisticEnabled(false);

TileChartTableDataModel: Multiple Tile Variables

Multiple variables can be specified for the Tile role by adding the variables to a ClassificationVariableList and then assigning that list rather than an individual variable to the Tile role.

The following code fragment assigns the Tile role to variables named Region, Product, and Subsidiary:


// Define multiple Classification variables
   ClassificationVariableList multiTile=new ClassificationVariableList(
     new ClassificationVariable[] {
         new ClassificationVariable("Region"),
         new ClassificationVariable("Product"),
         new ClassificationVariable("Subsidiary")
   } );

// Assign the classification list to the Tile variable role
  dataModel.setTileVariable(multiTile);

The variables in the list must have a hierarchical relationship, and they must be specified in their hierarchical order. In the example code above, Product is listed second because products in the data are organized by region, and Subsidiary is listed third because subsidiaries in the data are organized by the products they sell.

TileChartTableDataModel: Multiple Response Variables

A TileChart always respresents the values of two response variables, using the Size variable role to determine tile size and the Color variable role to determine tile color. Optionally, you can specify the DataTip variable role to display the values of a third response variable in the chart's data tips.

Each response variable uses an AnalysisVariable so that you can specify a statistic to calculate for the assigned response role. The default statistic for each response role is SUM.

The following code fragment assigns all three response variable roles. The values of the Size and Color variables are represented in the graph, and the values of the DataTip variable are displayed in the chart data tips.

 
// Assign the Size variable role
   dataModel.setSizeVariable(
     new AnalysisVariable("Inventory"));
 
// Assign the Color variable role
   dataModel.setColorVariable(
     new AnalysisVariable("Sales"));
 
// Assign the DataTip variable role
   dataModel.setDataTipVariable(
     new AnalysisVariable("Stores"));
 

Example
Set ColorVariable: Swing-based code, Servlet-based code

TileChartTableDataModel: Valid Variable Roles

The following table summarizes the TileChartTableDataModel variable roles and the type of data each role supports.

Variable Role Class Type Numeric String Multiple Variables
DataTipVariable
Optional third response variable whose values are displayed in the data tips
AnalysisVariable Yes No No
ColorVariable*
Response variable that determines tile color
AnalysisVariable Yes No No
TileVariable*
Classification variable(s) that determines the number and arrangement of tiles
ClassificationVariable Yes Yes Yes
SizeVariable*
Response variable that determines tile size
AnalysisVariable Yes No No
* required variable

TileChartTableDataModel: Behavior

To generate a graph, a TileChart needs a data column for the TileVariable role. If the role is not assigned in the program code, a TileChart selects the first string column found in the TileChartTableDataModel and uses it as its Tile variable. If there is no string column in the data, then it selects the first numeric column.

A TileChart also needs data columns for the SizeVariable and ColorVariable roles. If these roles are not assigned in the program code, a TileChart selects the first numeric column that is not being used for the Id role and uses it as its Size variable. It selects the second unused numeric column and uses it as its Color variable.

This default behavior occurs only when the variable roles are not assigned. If a role is assigned to a variable that does not exist in the data, the TileChart cannot display a graph.

For response variabales used in the chart, the default statistic is SUM.

TileChartTableDataModel: Events

A TileChartTableDataModel fires property change events when

For example, if the name property is changed in the ClassificationVariable that has been assigned the TileVariable role, the TileChartTableDataModel fires a ProeprtyChangeEvent stating that the TileVariable has changed.

TileChartTableDataModel: Error Handling

When variable roles are assigned, the TileChartTableDataModel does not confirm that the variables exist in the TableModel. Thus, assigning a non-existent data column to a variable role may mean that the TileChart cannot display a graph. For example, if the SizeVariable role is assigned to a Sales column but the TableModel does not contain a Sales column, then the TileChart fails to produce a graph.