-
Notifications
You must be signed in to change notification settings - Fork 19
/
example-5.html
45 lines (34 loc) · 1.52 KB
/
example-5.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
<html>
<head>
<!-- just usingjquery for the $(document).ready() - we don't need it for charting -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- need the raphael vector library -->
<script type="text/javascript" src="raphael-min.js"></script>
<!-- our treemapping library-->
<script type="text/javascript" src="../min/treemap-squared-0.5.min.js"></script>
</head>
<body>
<div id="example-5"></div>
<script type="text/javascript">
$(document).ready(function () {
var data = [[60000, 60000, 40000], [30000, 20000, 10000]];
var labels = [["Paris", "London", "New York"], ["Moscow", "Berlin", "Tokyo"]];
var boxFormatter = function (coordinates, index) {
// so in this case an index of [1,1] would refer to "London" and [2,1] to "Berlin"
// coordinates are in the form [x1,y1,x2,y2]
var datapoint,i, color;
// get the value of the data point using the index to find it
datapoint = data;
for (i=0; i<index.length; i++){
datapoint = datapoint[index[i]];
}
var saturation = ((datapoint / 60000)*0.6) + 0.4;
var brightness = ((datapoint / 60000)*0.3) + 0.2;
color = "hsb(0.2," + saturation + "," + brightness + ")";
return{ "fill" : color };
};
Treemap.draw("example-5", 600, 200, data, labels, {'box' : boxFormatter});
});
</script>
</body>
</html>