Search results

Print and Export

Print

The rendered tree map can be printed directly from the browser by calling the public method print. The ID of the tree map div element must be passed as argument to that method.

The following code example shows how to print the tree map.

tagHelper
print.cs
@{ 
   var border= new TreeMapBorder{ color='#000000', width=0.5}
}
@using Syncfusion.EJ2;
<div id="container">
   <button id="print" style="width: 100px">Print</button>
    <ejs-treemap id="container" load="load" height="350px" weightValuePath="GDP" >
	<e-treemap-leafitemsettings labelPath="State"  labelFormat= '${State}<br>${GDP} Trillion<br>(${percentage} %)' >
	<e-leafitemsettings-labelstyle color='#000000'></e-leafitemsettings-labelstyle>
	</e-treemap-leafitemsettings>
			<e-treemap-levels>
    </ejs-treemap>
</div>         
<script>
    function load(args)
    { 
        var data = [
    {State:"United States", GDP:17946, percentage:11.08, Rank:1},
    {State:"China", GDP:10866, percentage: 28.42, Rank:2},
    {State:"Japan", GDP:4123, percentage:-30.78, Rank:3},
    {State:"Germany", GDP:3355, percentage:-5.19, Rank:4},
    {State:"United Kingdom", GDP:2848, percentage:8.28, Rank:5},
    {State:"France", GDP:2421, percentage:-9.69, Rank:6},
    {State:"India", GDP:2073, percentage:13.65, Rank:7},
    {State:"Italy", GDP:1814, percentage:-12.45, Rank:8},
    {State:"Brazil", GDP:1774, percentage:-27.88, Rank:9},
    {State:"Canada", GDP:1550, percentage:-15.02, Rank:10}
        ];
        args.treemap.dataSource = data;
    };
	window.onload = function () {
        document.getElementById('print').onclick = () => {
            window.treemap.print();
        };
    }
	
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }
    }
}

Export

The rendered tree map can be exported to JPEG or PNG format using export method in tree map. The input parameters for this method are Export Type for format and fileName for result.

The following code example shows how to export the tree map.

tagHelper
export.cs
@{ 
   var border= new TreeMapBorder{ color='#000000', width=0.5}
}
@using Syncfusion.EJ2;
<div id="container">
    <button id="export" style="width: 100px">Export</button>
    <ejs-treemap id="container" load="load" height="350px" weightValuePath="GDP" >
	<e-treemap-leafitemsettings labelPath="State"  labelFormat= '${State}<br>${GDP} Trillion<br>(${percentage} %)' >
	<e-leafitemsettings-labelstyle color='#000000'></e-leafitemsettings-labelstyle>
	</e-treemap-leafitemsettings>
			<e-treemap-levels>
    </ejs-treemap>
</div>         
<script>
    function load(args)
    { 
        var data = [
    {State:"United States", GDP:17946, percentage:11.08, Rank:1},
    {State:"China", GDP:10866, percentage: 28.42, Rank:2},
    {State:"Japan", GDP:4123, percentage:-30.78, Rank:3},
    {State:"Germany", GDP:3355, percentage:-5.19, Rank:4},
    {State:"United Kingdom", GDP:2848, percentage:8.28, Rank:5},
    {State:"France", GDP:2421, percentage:-9.69, Rank:6},
    {State:"India", GDP:2073, percentage:13.65, Rank:7},
    {State:"Italy", GDP:1814, percentage:-12.45, Rank:8},
    {State:"Brazil", GDP:1774, percentage:-27.88, Rank:9},
    {State:"Canada", GDP:1550, percentage:-15.02, Rank:10}
        ];
        args.treemap.dataSource = data;
    };
	window.onload = function () {
        document.getElementById('export').onclick = () => {
            window.treemap.export('PNG', 'Maps');
        };
    }
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;

namespace EJ2_Core_Application.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }
    }
}
Contents
Contents