HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
anychart.data.loadJsonFile('https://gist.githubusercontent.com/shacheeswadia/17dc3b3d4ac9b63ac5ac6833944f3a94/raw/07c4bec103d22ec2824453a33d41868fd476db3d/dataPackedCircles.json',
3
function(data) {
4
5
// set data
6
var treeData = anychart.data.tree(data, 'as-table');
7
8
// create a circle packing chart instance
9
var chart = anychart.circlePacking(treeData);
10
11
// customize colors:
12
// chart design theme
13
anychart.theme('darkGlamour');
14
// background
15
chart.background('#333');
16
// fill
17
chart.fill('#333');
18
// stroke
19
chart.stroke(function () {
20
return {
21
thickness: 2,
22
color: this.sourceColor
23
};
24
});
25
26
// customize the tooltip
27
chart
28
.tooltip()
29
.useHtml(true)
30
.titleFormat('{%name}')
31
.format( function(){
32
let dataValue = this.item.ka;
33
if(this.depth == 2){
34
return '<span style = font-size:14px;">Popularity Value - ' + dataValue.value + '</span>' +
35
'<br/><span style = font-size:14px;">Artist - ' + dataValue.artist + '</span>' +
36
'<br/><span style = font-size:14px;">Year - ' + dataValue.year + '</span>'
37
}else{
38
return '<span style = "color: #fff; font-size:14px;">Popularity Value - ' + this.value + '</span>'
39
}
40
});
41
42
// add a chart title and customize it
43
chart
44
.title()
45
.enabled(true)
46
.useHtml(true)
47
.text(
48
'<span style = "color: #fff; font-size:20px;">Top 100 Most Streamed Songs On Spotify By Genre</span>' +
49
'<br/><span style="color:#1db954; font-size: 18px;">(based on the number of Spotify streams)</span>'
50
);
51
52
chart.container('container');
53
chart.draw();
54
55
}
56
);
57
});