Search results

Tooltip

Tooltip is used to display details about the items in tree map when the mouse hovers over the item.

Default tooltip

By default, tooltip is not visible. You can enable the tooltip by setting the enable property to true.

The following example shows the default tooltip.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
      dataSource: [
         { fruit:'Apple', count:5000 },
         { fruit:'Mango', count:3000 },
         { fruit:'Orange', count:2300 },
         { fruit:'Banana', count:500 },
         { fruit:'Grape', count:4300 },
         { fruit:'Papaya', count:1200 },
         { fruit:'Melon', count:4500 }
      ],
      weightValuePath: 'count',
      tooltipSettings: {
         visible: true
      },
      leafItemSettings: {
         labelPath: 'fruit'
      }
}, '#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>

Format tooltip

By default, tooltip shows information about weight value of current item. In addition, to show more information in tooltip, format the tooltip as ${datafield} from data source.

The following example shows formatting the tooltip.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
       dataSource: [
              { fruit:'Apple', count:5000 },
              { fruit:'Mango', count:3000 },
              { fruit:'Orange', count:2300 },
              { fruit:'Banana', count:500 },
              { fruit:'Grape', count:4300 },
              { fruit:'Papaya', count:1200 },
              { fruit:'Melon', count:4500 }
       ],
       weightValuePath: 'count',
       tooltipSettings: {
              visible: true,
              format:'Name:${fruit} - TotalCount:${count}'
       },
       leafItemSettings: {
              labelPath: 'fruit'
       }
}, '#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>

Tooltip template

Any HTML element can be displayed in tooltip using the ‘template’ property. You can use ${datafield} as placeholder in HTML element to display the values from data source.

The following example shows tooltip template.

Source
Preview
index.js
index.html
var treemap = new ej.treemap.TreeMap({
        dataSource: [
                { fruit:'Apple', count:5000 },
                { fruit:'Mango', count:3000 },
                { fruit:'Orange', count:2300 },
                { fruit:'Banana', count:500 },
                { fruit:'Grape', count:4300 },
                { fruit:'Papaya', count:1200 },
                { fruit:'Melon', count:4500 }
        ],
        weightValuePath: 'count',
        tooltipSettings: {
            visible: true,
            template:'<div><p>Name: ${fruit}</p><p>Total Count: ${count}</p></div>'
        },
        leafItemSettings: {
                labelPath: 'fruit'
        }
}, '#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>