Skip to content

Instantly share code, notes, and snippets.

@michael
Created July 16, 2010 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michael/477787 to your computer and use it in GitHub Desktop.
Save michael/477787 to your computer and use it in GitHub Desktop.
// 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