const DemoApp = angular.module('DemoApp', ['dx']);
DemoApp.controller('DemoController', ($scope) => {
$scope.treeMapOptions = {
dataSource: citiesPopulation,
title: 'The Most Populated Cities by Continents',
tooltip: {
enabled: true,
format: 'thousands',
customizeTooltip(arg) {
const { data } = arg.node;
let result = null;
if (arg.node.isLeaf()) {
result = `<span class='city'>${data.name}</span> (${
data.country})<br/>Population: ${arg.valueText}`;
}
return {
text: result,
};
},
},
};
});
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.2.6/css/dx.light.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script>
<script src="https://cdn3.devexpress.com/jslib/22.2.6/js/dx.all.js"></script>
<script src="data.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="index.js"></script>
</head>
<body class="dx-viewport">
<div class="demo-container" ng-app="DemoApp" ng-controller="DemoController">
<div id="treemap" dx-tree-map="treeMapOptions"></div>
</div>
</body>
</html>
#treemap {
height: 500px;
}
.city {
font-weight: 500;
}
const citiesPopulation = [{
name: 'Africa',
items: [{
value: 21324000,
name: 'Lagos',
country: 'Nigeria',
}, {
value: 9735000,
name: 'Kinshasa',
country: 'Democratic Republic of the Congo',
}, {
value: 9278441,
name: 'Cairo',
country: 'Egypt',
}],
}, {
name: 'Asia',
items: [{
value: 24256800,
name: 'Shanghai',
country: 'China',
}, {
value: 23500000,
name: 'Karachi',
country: 'Pakistan',
}, {
value: 21516000,
name: 'Beijing',
country: 'China',
}, {
value: 16787941,
name: 'Delhi',
country: 'India',
}, {
value: 15200000,
name: 'Tianjin',
country: 'China',
}],
}, {
name: 'Australia',
items: [{
value: 4840600,
name: 'Sydney',
country: 'Austraila',
}, {
value: 4440000,
name: 'Melbourne',
country: 'Austraila',
}],
}, {
name: 'Europe',
items: [{
value: 14160467,
name: 'Istanbul',
country: 'Turkey',
}, {
value: 12197596,
name: 'Moscow',
country: 'Russia',
}, {
value: 8538689,
name: 'London',
country: 'United Kingdom',
}, {
value: 5191690,
name: 'Saint Petersburg',
country: 'Russia',
}, {
value: 4470800,
name: 'Ankara',
country: 'Turkey',
}, {
value: 3517424,
name: 'Berlin',
country: 'Germany',
}],
}, {
name: 'North America',
items: [{
value: 8874724,
name: 'Mexico City',
country: 'Mexico',
}, {
value: 8550405,
name: 'New York City',
country: 'United States',
}, {
value: 3884307,
name: 'Los Angeles',
country: 'United States',
}, {
value: 2808503,
name: 'Toronto',
country: 'Canada',
}],
}, {
name: 'South America',
items: [{
value: 11895893,
name: 'São Paulo',
country: 'Brazil',
}, {
value: 8693387,
name: 'Lima',
country: 'Peru',
}, {
value: 7776845,
name: 'Bogotá',
country: 'Colombia',
}, {
value: 6429923,
name: 'Rio de Janeiro',
country: 'Brazil',
}],
}];