Version

Working with Treemap Chart Data

This topic discusses useful information that will help you to ensure that your data is rendered properly in your treemap chart.

Data Requirements

While the Chart control allows you to easily set the chart’s data source to your own custom data, it is important that you supply the appropriate amount and type of data that the chart requires. If the data does not meet the minimum requirements based on the type of chart that you are using, an error will be generated.

Treemap charts supports a DataTable and a TreeMapSeries object as data sources.

The following is a list of data requirements for 2D treemap charts:

Mapping Data to a Treemap Chart

The treemap chart renders data using the following rules:

Using a DataTable as a data source:

  • Each DataRow represents a node in the chart.

  • When using a DataTable as your data source, the default behavior is that each string column is used as a category name.

  • The IndexOrder property determines if the chart should color nodes based on data values.

  • The ColorValueIndex property is the index of the DataColumn which contains numeric values. This property is used to set the colors of the leaf nodes in the treemap chart. If you do not set the ColorValueIndex, it defaults to the first numeric column in your DataTable. The ColorValueIndex property is a zero based index. For more information on the ColorValueIndex property, see Map a Leaf Node’s Color to a Specific Column in a DataTable.

  • The SizeValueIndex property is the index of the DataColumn which contains numeric values. This property is used to set the size of the nodes in your treemap chart. If you do not set the SizeValueIndex, it defaults to the first numeric column in the DataTable. The SizeValueIndex property is a zero based index.

Using a TreeMapSeries object as a data source

See below for an example data set, along with the rendered 2D treemap chart.

Category Name Units Price Yearly Sales

Fruit

Apples

3

200

Fruit

Bananas

2

100

Fruit

Oranges

1

50

Diary

Milk

4

20

Diary

Cheese

5

10

Meat

Steak

10

150

Meat

Chicken

8

35

Shows a Treemap Chart based on the data listed in the table above.