Skip to content

Instantly share code, notes, and snippets.

@justinjhendrick
Last active December 19, 2015 14:09
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 justinjhendrick/5967670 to your computer and use it in GitHub Desktop.
Save justinjhendrick/5967670 to your computer and use it in GitHub Desktop.
answer a question about how many bars d3 could handle.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>bars</title>
</head>
<body>
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
<script>
dat = [];//generate lots of random data
for(var i = 0; i < 10000; i++) {
dat[i] = Math.random();
}
svgW = 10010;
svgH = window.innerHeight;
var svg = d3.select("body").append("svg") //create svg
.attr("width", svgW)
.attr("height", svgH)
;
var bars = svg.selectAll("rect")
.data(dat)
.enter().append("rect") //place rects
.attr("x", function(d, i) {return i;})
.attr("y", function(d, i) {return (1 - d) * svgH;})
.attr("width", .8)
.attr("height", function(d, i) {return d * svgH;})
;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment