Skip to content

Instantly share code, notes, and snippets.

@silently
Last active September 9, 2019 12:46
Show Gist options
  • Save silently/6c133690bd6b5ab292e1f1085f70ff48 to your computer and use it in GitHub Desktop.
Save silently/6c133690bd6b5ab292e1f1085f70ff48 to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
let svg = d3.select("body")
.append("svg")
.attr("width", 500)
.attr("height", 500);
let data = [1000, 100, 70, 90, 50];
let scale = d3.scaleLinear().domain([20, 1000]).range([0, 100]);
data.forEach((d, i) => {
svg.append("rect")
.attr("x", 10 + 40 * i)
.attr("y", 100 + (100 - scale(d)))
.attr("width", 20)
.attr("height", scale(d))
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment