Binding TreeMap through Javascript

Hi,

I have bind the treemap initially using the controller. Now i have a requirement to redraw the treemap based on a value chosen in the UI dropdown. So, I call the below javascript function on changing the drop down. i get error .redraw is not available for Treemap, guess it's available for chart alone. I tried removing that line and run the application but the treemap is not updated. Can you please advise on how it can be achieved?

 <script type="text/javascript">
            function getfiltervalues(selectedbutton) {
                var param = selectedbutton;
                $.ajax({
                    url: '@Url.Action("FilterData", "TreeMap")',
          type: "Post",
          data: { 'filter': param },
          dataType: "json",
          success: function (data) {
              var treemap = $("#treemap").ejTreeMap("instance");
              treemap.model.dataSource = data;
              treemap.model.colorValuePath = "AppScore";
              treemap.model.weightValuePath = "WValue";
              treemap.redraw();
          },
      });
            }





    </script>

5 Replies

SK Saravana Kumar Kanagavel Syncfusion Team October 16, 2017 09:16 AM UTC

Hi Karthick, 
 
Thanks for contacting Syncfusion Support. 
 
We have analyzed your query and prepared a sample based on your requirement. In the sample, we have filter the data based on selecting the drop down box. 
Please find the code snippet below 
 
[JS] 
function getFilterValues(sender){ 
        var param = sender.value; 
        $.ajax({ 
            url: '@Url.Action("Filter","Home")', 
            type: "Post", 
            data: { 'filter': param }, 
            dataType: "json", 
            success: function (data) { 
                var TreeMap = $("#treemap").ejTreeMap("instance"); 
                TreeMap.model.dataSource = data; 
                TreeMap.refresh(); 
            }, 
        }); 
    } 
 
In the above code, we are getting the data from server using ajax and binding this data to the tree map and redrawing tree map once. 
And you can find the sample from the below location. 
 
  
Please find the output of the sample below 
 
 
 
Please let us know if you have any concern. 
 
Regards, 
Saravana Kumar K. 



KA Karthick October 17, 2017 09:25 AM UTC

Thanks a lot Saravana. It works for me. I couldn't find out Treemap.Refresh for binding it through javascript.



DD Dharanidharan Dharmasivam Syncfusion Team October 18, 2017 05:08 AM UTC

Hi Karthick, 

Thanks for your revert. 

We have analyzed your query. In the previously provided sample, in the ajax request we have obtained the instance of treemap and here we can able to get the refresh method. Using this refresh method, we have refreshed the treemap in order to take effect of modified data source. Also we would like to let you know that, in the client side scripts, you will not get intellisense. 

For more information in method in treemap, kindly find the help document. 

If your query is misunderstood at our end, kindly provide more information on your query. 

Thanks, 
Dharani. 



KA Karthick October 30, 2017 06:47 AM UTC

Thanks Saravana Kumar for your help. This issue is resolved for me.



SK Saravana Kumar Kanagavel Syncfusion Team October 31, 2017 08:50 AM UTC

Hi Karthick, 
 
Thanks for your update. 
 
Please let us know if you need any other assistance on this. 
 
Regards, 
Saravana Kumar K. 


Loader.
Up arrow icon