Skip to content

Instantly share code, notes, and snippets.

@nick3499
Forked from d3byex/index.html
Last active March 2, 2017 18:14
Show Gist options
  • Save nick3499/daf874a42655218e918b171d01040046 to your computer and use it in GitHub Desktop.
Save nick3499/daf874a42655218e918b171d01040046 to your computer and use it in GitHub Desktop.
D3byEX 5.8: Range Bands (Adapted to D3.js v4)
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<head>
<meta name="description"
content="D3.js v4, .scaleBand, .rangeRound,
ordinal scale with range bands" />
</head>
<body>
<script src="http://d3js.org/d3.v4.js"></script>
<script>
var bands = d3.scaleBand()
.domain([0, 1, 2])
.rangeRound([0, 100]);
console.log(bands.range());
console.log(bands.bandwidth()); // 33
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment