Skip to content

Instantly share code, notes, and snippets.

@NPashaP
Last active December 15, 2016 20:25
Show Gist options
  • Save NPashaP/b269fb567f7ea6e6aacf594ee52c8a37 to your computer and use it in GitHub Desktop.
Save NPashaP/b269fb567f7ea6e6aacf594ee52c8a37 to your computer and use it in GitHub Desktop.
bar - value
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
rect{
fill:#42A5F5;
}
</style>
<body>
<svg width="960" height="500">
<g id="default" transform="translate(40, 50)"></g>
<g id="custom" transform="translate(520, 50)"></g>
</svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="http://vizjs.org/viz.v1.1.7.min.js"></script>
<script>
var data=[['A', 1, 3],['A', 3, 5],['B', 3, 2],['C', -5, -4],['D', 8, 6]];
//default
d3.select("#default").call(viz.bar().data(data));
//custom
var bar = viz.bar().data(data).value(function(d){ return d[2];});
d3.select("#custom").call(bar);
// adjust the bl.ocks frame dimension.
d3.select(self.frameElement).style("height", "500px").style("width", "960px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment