-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.php
66 lines (61 loc) · 2.32 KB
/
box.php
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
<!DOCTYPE html>
<html>
<head>
<?php include 'meta.php'; ?>
<title>DPLA Visualizations</title>
<link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css" />
<style>
.node {
border: solid 1px white;
font: 10px sans-serif;
line-height: 12px;
overflow: hidden;
position: absolute;
text-indent: 2px;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript">
$(function() {
var width = 1200,
height = 800,
colors = d3.scale.category20c(),
valueAccessor = function(d) {
return d.count;
};
var svg = d3.select("body").append("div")
.style("position", "relative")
.style("width", (width) + "px")
.style("height", (height) + "px")
.style("left", 10 + "px")
.style("top", 10 + "px");
var treemap = d3.layout.treemap()
.round(false)
.size([width, height])
.sticky(true)
.value(valueAccessor);
d3.json("lang.json", function(error, root) {
var node = svg.datum(root).selectAll("div.node")
.data(treemap.nodes)
.enter().append("div")
.attr("class", "node")
.call(position)
.style("background", function(d) { return colors(d.lang); })
.text(function(d) { return d.lang; });
});
function position() {
this.style("left", function(d) { return d.x + "px"; })
.style("top", function(d) { return d.y + "px"; })
.style("width", function(d) { return Math.max(0, d.dx - 1) + "px"; })
.style("height", function(d) { return Math.max(0, d.dy - 1) + "px"; });
}
});
</script>
</head>
<body>
<?php include_once 'header.php'; ?>
<h1>DPLA Visualizations - Languages represented in the DPLA Bookshelf</h1>
</body>
</html>