-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuse_sample.html
81 lines (80 loc) · 1.66 KB
/
use_sample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html>
<html>
<head>
<meta charset='utf-8'/>
<title>JQuery treemap sample</title>
<style>
#my-treemap {
float: left;
width: 800px;
height: 600px;
font-family: Arial;
font-size: 11px;
}
#data-box {
float: left;
width: 200px;
height: 100px;
border: 1px solid #999;
padding: 15px;
font-family: Arial;
color: #333;
font-size: 14px;
}
.minor {
background-color: red;
color: white;
}
.major {
background-color: green;
color: white;
}
</style>
</head>
<body>
<div id='my-treemap'></div>
<div id='data-box'></div>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script src='src/jquery-treemap.js'></script>
<script>
$('div#my-treemap').treemap([
{
label: 'Label 1',
value: 100,
data: 'label 1 data'
},
{
label: 'Label 2',
value: 70,
data: 'label 2 data'
},
{
label: 'Label 3',
value: 50,
data: 'label 3 data'
},
{
label: 'Label 4',
value: 30,
data: 'label 4 data'
},
{
label: 'Label 5',
value: 70,
data: 'label 5 data'
},
], {
nodeClass: function(node, box){
if(node.value <= 50){
return 'minor';
}
return 'major';
},
mouseenter: function (node, box) {
$('#data-box').html('<p>Label: ' + node.label + '</p><p>Data:' + node.data + '</p><p>Value:' + node.value + '</p>');
},
itemMargin: 2
});
</script>
</body>
</html>