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
|
<html>
<head>
<title>Test: Area interpolation and segmentation</title>
<script type="text/javascript" src="protovis-r3.3.js"></script>
</head>
<body>
<h1>Test: Area interpolation and segmentation</h1>
<script type="text/javascript">
data = pv.range(0, 10, 1).map(function(x) {
return {x:x, y:Math.sin(x) + 2};
});
p_w=200
p_h=150
w = 20+p_w*2
h = 20+p_h*4
x = pv.Scale.linear(data, function(d) {return d.x;}).range(0, p_w-30)
y = pv.Scale.linear(data, function(d) {return d.y;}).range(0, p_h-20);
color=pv.Colors.category19();
interpolations=["linear","step-before","step-after", "basis", "cardinal","monotone"]
vis = new pv.Panel()
.width(w)
.height(h)
.bottom(20)
.left(20)
.right(10)
.top(5)
for(var i=0; i<interpolations.length;i++) {
var inter=interpolations[i];
n=i%2
m=Math.floor(i/2)
panel=vis.add(pv.Panel).
left(n*(p_w+10)).
top(m*(p_h+10)).
width(p_w).
height(p_h)
panel.anchor('top').add(pv.Label).text(inter)
panel.add(pv.Area).data(data).
bottom(0).
segmented(true).
fillStyle(function() {return color(this.index);}).
left(function(d){return x(d.x)}).
height(function(d){ return y(d.y)}).
interpolate(inter);
}
vis.render()
</script>
</body>
</html>
|