We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to summarize the circular call-out display data in the Hierarchical level ejTreeMap?

Platform: JavaScript |
Control: ejTreeMap |
Published Date: May 12, 2015 |
Last Revised Date: June 25, 2019

To summarize the circular call-out display data in the Hierarchical level ejTreeMap, follow the steps given.

Step 1:

Create a TreeMap sample and include the necessary script files.

Step 2:

Include the sales_data to the HTML script tag in order to populate the TreeMap control.

 JS

<script>
 var sales_data = [
 { Country: "United States", Name: "New York", Sales: 2353, Expense: 2000 },
 { Country: "United States", Name: "Los Angeles", Sales: 3453, Expense: 3000 },
 { Country: "United States", Name: "San Francisco", Sales: 8456, Expense: 8000 },
 { Country: "United States", Name: "Chicago", Sales: 6785, Expense: 7000 },
 { Country: "United States", Name: "Miami", Sales: 7045, Expense: 6000 },
 { Country: "Canada", Name: "Toronto", Sales: 7045, Expense: 7000 },
 { Country: "Canada", Name: "Vancouver", Sales: 4352, Expense: 4000 },
 { Country: "Canada", Name: "Winnipeg", Sales: 7843, Expense: 7500 },
 { Country: "Mexico", Name: "Mexico City", Sales: 7843, Expense: 6500 },
 { Country: "Mexico", Name: "Cancun", Sales: 6683, Expense: 6000 },
 { Country: "Mexico", Name: "Acapulco", Sales: 2454, Expense: 2000 }
]
</script>

Step 3:

Summarize the circular call-out display data values by using the helper function and then the data that needs to be summarized can be passed to the path accessing it.

Provide values for Sales and Expenses, summarizing through the helper method called, ~addition, as given in the following code example.

JS

   <script id="labeltemplate" type="application/jsrender"> 
    <div align="center"  style="width:120px; height:120px;background-image:url('images/circle.png');">
   <table style="text-align:center;margin-left:-10px; margin-top:10px;" >
                  <div style="margin-top:16px;margin-left:0px;">
               <label style="color:white;font-size:16px;font-weight:normal;" id="Label2">Sales</label>
            </div>    
            <div style="margin-top:-5px;">
               <label style="color:white;font-size:15px;font-weight:normal;" id="Label5">{{:~addition(data,"Sales")}}</label>
            </div> 
            <div style="margin-top:8px;margin-left:2px;">
               <label style="color:white;font-size:16px;margin-top:-5px;font-weight:normal;" id="Label3">Expense</label>
            </div>
            <div style="margin-top:-5px;">
               <label style="color:white;font-size:15px;font-weight:normal;" id="Label4">{{:~addition(data,"Sales")}}</label>
            </div>
   </table>
</div>   
    </script>            

 

Helper function summarizes the data values of Sales and Expense as follows:

JS

$.views.helpers({
                addition: function (data,property) {    
       var sum=0;
       for(var index=0;index<data.length;index++)
       {
           sum += parseFloat(data[index][property]);
       }
        return sum;
    }
    });    

JS

<script type="text/javascript">
        jQuery(function ($) { 
              $("#container").ejTreeMap({
                   dataSource: sales_data, 
                     . . .                   
               levels: [                 
                            { groupPath:"Country", groupGap:3,                  showHeader:true,headerHeight:25, showLabels: true, labelTemplate: 'labeltemplate' }           
                        ]
                      . . .
                });
            }); 
   $.views.helpers({
                addition: function (data,property) {    
       var sum=0;
       for(var index=0;index<data.length;index++)
       {
           sum += parseFloat(data[index][property]);
       }
        return sum;
    }
    }); 
        </script>
                              . . .
   <script id="labeltemplate" type="application/jsrender"> 
    <div align="center"  style="width:120px; height:120px;background-image:url('images/circle.png');">
   <table style="text-align:center;margin-left:-10px; margin-top:10px;" >     
            <div style="margin-top:16px;margin-left:0px;">
               <label style="color:white;font-size:16px;font-weight:normal;" id="Label2">Sales</label>
            </div>         
            <div style="margin-top:-5px;">
               <label style="color:white;font-size:15px;font-weight:normal;" id="Label5">{{:~addition(data,"Sales")}}</label>
            </div>      
            <div style="margin-top:8px;margin-left:2px;">
               <label style="color:white;font-size:16px;margin-top:-5px;font-weight:normal;" id="Label3">Expense</label>
            </div>        
            <div style="margin-top:-5px;">
               <label style="color:white;font-size:15px;font-weight:normal;" id="Label4">{{:~addition(data,"Sales")}}</label>
            </div>       
   </table>
</div>   
    </script>                               

 

 

The following screenshot displays the summarized circular call-out display data values:

Treemap with summarized circular call out display data values

 

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/Hierarchical_TreeMap-29573981.zip

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon