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
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);
Editor's Note: Implementation details are not yet available.
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.
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"));
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 |
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.
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.
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.