Created
July 16, 2010 01:13
-
-
Save michael/477787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create scene | |
var scene = new uv.Scene({ | |
width: 800, | |
height: 300 | |
}), | |
data = pv.range(20).map(function(d) { return Math.random() + .1; }), | |
colors = pv.Scale.linear(data).range('lightblue', 'darkblue'); | |
// add some actors to the scene | |
_.each(data, function(datum, index) { | |
var bar = new uv.Bar({ | |
x: 50+35*index, | |
y: 280, | |
width: 30, | |
height: -30+parseInt(-100*datum, 10), | |
fillStyle: function() { | |
return this.active ? 'orange' : colors(datum).color; | |
}, | |
interactive: true | |
}); | |
bar.add(new uv.Label({ | |
x: 15, | |
y: -10, | |
width: 30, | |
height: 20, | |
text: function() { return parseInt(this.parent.properties.height*-1) }, | |
textAlign: 'center', | |
fillStyle: 'white' | |
})); | |
scene.add(bar); | |
}); | |
// running on 60 frames per default | |
scene.start(); | |
// move it | |
setInterval(function() { | |
var data = pv.range(20).map(function(d) { return Math.random() + .1; }); | |
scene.all('children').each(function(index, child) { | |
child.updateHeight(-30+parseInt(-100*data[index], 10)); | |
}); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment