Skip to content

Instantly share code, notes, and snippets.

@bigandy
Last active January 10, 2018 17:00
Show Gist options
  • Save bigandy/63fdfa78a37d21f8d5756451b1268733 to your computer and use it in GitHub Desktop.
Save bigandy/63fdfa78a37d21f8d5756451b1268733 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 {
display: flex;
/* justify-content: center; */
align-items: center;
min-height: 100vh;
}
svg {
overflow: visible;
}
</style>
</head>
<body>
<svg>
<rect />
<rect />
<rect />
<rect />
<rect />
</svg>
<script>
var data = [10, 200, 150, 250, 150];
var rectWidth = 100;
var height = 100;
d3.selectAll('rect')
.data(data)
.attr('x', (d, i) => i * rectWidth)
.attr('y', d => {
console.log(height - d);
return height - d;
})
.attr('width', rectWidth)
.attr('height', d => d)
.attr('fill', 'blue')
.attr('stroke', 'white')
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment