Search results

Data Label

Data labels are used to identify the name of items or groups in the tree map control. Data Labels will be shown by given specified path in the data source field.

The following options are available to customize labels in the tree map control.

Format

You can customize the labels for each item using the [labelFormat] property in leafItemSettings.

The label format is shown in the following code example.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
 dataSource: [{ Car:'Mustang', Brand:'Ford', count:232 },
                       { Car:'EcoSport', Brand:'Ford', count:121 },
                       { Car:'Swift', Brand:'Maruti', count:143 },
                       { Car:'Baleno', Brand:'Maruti', count:454 },
                       { Car:'Vitara Brezza', Brand:'Maruti', count:545 },
                       { Car:'A3 Cabriolet', Brand:'Audi',count:123 },
                       { car:'RS7 Sportback', Brand:'Audi', count:523 }
             ],
    weightValuePath: 'count',
    leafItemSettings: {
        labelPath: 'Car',
        labelFormat:'${Car}-${Brand}'
     }
}, '#container');
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 for Treemap </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Essential JS 2 for treemap UI Control">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

Template

The template supports customizing labels of each leaf node using the [labelTemplate] property. It uses Essential JS2 Template engine to render elements. You can position templates using the [templatePosition] property.

The template concepts are shown in the following code example.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
    dataSource: [
        { Car:'Mustang', Brand:'Ford', count:232 },
        { Car:'EcoSport', Brand:'Ford', count:121 },
        { Car:'Swift', Brand:'Maruti', count:143 },
        { Car:'Baleno', Brand:'Maruti', count:454 },
        { Car:'Vitara Brezza', Brand:'Maruti', count:545 },
        { Car:'A3 Cabriolet', Brand:'Audi',count:123 },
        { car:'RS7 Sportback', Brand:'Audi', count:523 }
    ],
    weightValuePath: 'count',
    leafItemSettings: {
        labelPath: 'Car',
        labelTemplate:'<div>{{:Car}}-{{:Brand}}</div>',
        templatePosition:'Center'
     }
}, '#container');
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 for Treemap </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Essential JS 2 for treemap UI Control">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

InterSectAction

You can avoid overlapping by customizing labels in each item when they exceed their actual size using the [interSectAction] property in leafItemSettings.

The intersect action concepts are illustrated in the following code example.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
    dataSource: [
        { Car:'Mustang', Brand:'Ford', count:232 },
        { Car:'EcoSport', Brand:'Ford', count:121 },
        { Car:'Swift', Brand:'Maruti', count:143 },
        { Car:'Baleno', Brand:'Maruti', count:454 },
        { Car:'Vitara Brezza', Brand:'Maruti', count:545 },
        { Car:'A3 Cabriolet Purvis Eureka LIoyd-Hartnett', Brand:'Audi',count:123 },
        { car:'RS7 Sportback', Brand:'Audi', count:523 }
             ],
    weightValuePath: 'count',
    leafItemSettings: {
        labelPath: 'Car',
        labelFormat:'${Car}-${Brand}',
        interSectAction:'WrapByWord'
     }
}, '#container');
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 for Treemap </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Essential JS 2 for treemap UI Control">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>