Skip to content

Instantly share code, notes, and snippets.

@NPashaP
Created January 7, 2018 03:52
Show Gist options
  • Save NPashaP/faf8b18cc44ac1af17333f65e9cbd7fd to your computer and use it in GitHub Desktop.
Save NPashaP/faf8b18cc44ac1af17333f65e9cbd7fd to your computer and use it in GitHub Desktop.
Viz - Bar - ease duration
license: gpl-3.0
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<style>
.viz-bar .bar{
fill: steelblue;
}
</style>
<body>
<svg width="960" height="500">
<g transform="translate(50,50)"></g>
</svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="http://vizjs.org/viz.v1.3.0.min.js"></script>
<script>
var bar = viz.bar()
.data(Data())
.value0(d=>d.value0)
.value1(d=>d.value1)
d3.select("g").call(bar);
setInterval(function(){
bar.data(Data())
.valueScale(undefined)
.ease(d3.easeBounceOut)
.duration(1000)
.transition()
}, 2000);
function Data(){
return d3.range(10).map(function(d,i){
return {key:i, value0:(v0=Math.random()), value1:v0+Math.random()}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment