-
Notifications
You must be signed in to change notification settings - Fork 0
/
pv.test.html
51 lines (45 loc) · 1.76 KB
/
pv.test.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Protovis Test Page</title>
<script type="text/javascript" src="protovis-d3.1.js"></script>
</head>
<body>
<h1>Protovis Test Page</h1>
<p><a href="http://vis.stanford.edu/protovis/">Protovis</a> is a javascript toolkit for data visualization in the browser by <a href="http://graphics.stanford.edu/~mbostock/">Michael Bostock</a> and <a href="http://hci.stanford.edu/jheer/">Jeffrey Heer</a> at Stanford's <a href="http://vis.stanford.edu/">visualization group</a>.</p>
<h2>Bar chart:</h2>
<script type="text/javascript+protovis">
var vis = new pv.Panel()
.width(150)
.height(150)
.top(30)
.left(5)
.right(30)
.bottom(30);
var bar = vis.add(pv.Bar)
.data([1, 1.2, 1.7, 1.5, .7, .3])
.width(20)
.height(function(d) d * 80)
.bottom(0)
.left(function() this.index * 25);
// clicking bar toggles selection turning selected bar(s) red
var selected = [false, false, false, false, false, false];
bar.fillStyle(function() selected[this.index] ? "#993333" : "#336699")
.event("click", function() {selected[this.index] = !selected[this.index]; vis.render()})
// add labels over top of bars
bar.anchor("top").add(pv.Label)
.textMargin(-14)
.text(function(d) d.toFixed(1));
vis.add(pv.Rule)
.bottom(-4)
.left(-4)
.right(0)
.lineWidth(2);
vis.add(pv.Rule)
.data(pv.range(1,150,30))
.bottom(function(d) d)
.strokeStyle('rgba(200, 200, 255, 0.2)');
vis.render();
</script>
</body>
</html>