Articles in this section
Category / Section

How to summarize circular call-out display in JavaScript TreeMap?

4 mins read

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:



Conclusion

I hope you enjoyed learning about how to summarize circular call-out display in JavaScript TreeMap.

You can refer to our JavaScript TreeMap feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.  You can also explore our JavaScript TreeMap example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied