Layout

You can decide on the visual representation of nodes belonging to all the treemap levels using the itemsLayoutMode property of the TreeMap.

There are four different TreeMap layouts such as

  • Squarified
  • SliceAndDiceAuto
  • SliceAndDiceHorizontal
  • SliceAndDiceVertical

Squarified

Squarified layout creates rectangles with best aspect ratio.

  • javascript
  • /// <reference path="../tsfiles/jquery.d.ts"></reference>
    /// <reference path="../tsfiles/ej.web.all.d.ts"></reference>
    
    module treeMapcomponent {
    
            $(function () {
    
               var treeMapSample = new ej.datavisualization.TreeMap($("#treeMap"), {
                    dataSource: population_data,
                    colorValuePath: "Growth",
                    weightValuePath: "Population",                
                    levels: [
                      { groupPath: "Continent", groupGap: 5 }
                    ],
                    itemsLayoutMode:"squarified"
                });
            });
    }

    Try it: Squarified

    SliceAndDiceAuto

    SliceAndDiceAuto layout creates rectangles with high aspect ratio and displays them sorted both horizontally and vertically.

  • javascript
  • $(function () {
    
               var treeMapSample = new ej.datavisualization.TreeMap($("#treeMap"), {
                    // ...             
                    itemsLayoutMode:"sliceanddiceauto",
                    // ...             
                });
            });

    Try it: SliceAndDiceAuto

    SliceAndDiceHorizontal

    SliceAndDiceHorizontal layout creates rectangles with high aspect ratio and displays them sorted horizontally.

  • javascript
  • $(function () {
    
              var treeMapSample = new ej.datavisualization.TreeMap($("#treeMap"), {
                    // ...   
                    itemsLayoutMode:"sliceanddicehorizontal",
                    // ...   
                });
            });

    Try it: SliceAndDiceHorizontal

    SliceAndDiceVertical

    SliceAndDiceVertical layout creates rectangles with high aspect ratio and displays them sorted vertical.

  • javascript
  • $(function () {
    
              var treeMapSample = new ej.datavisualization.TreeMap($("#treeMap"), {
                    // ...   
                    itemsLayoutMode:"sliceanddicevertical",
                    // ...   
                });
            });

    Try it: SliceAndDiceVertical