-
-
Save nick3499/42d42ae7895c9977a5349a8660b2935b to your computer and use it in GitHub Desktop.
D3byEX 5.9: Range Bands with Padding (Adapted to D3.js v4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<meta charset=utf-8> | |
<head> | |
<meta name="description" content="D3.js v4, .scaleBand, .rangeRound, | |
.padding, ordinal scale range bands" /> | |
</head> | |
<body> | |
<script src="http://d3js.org/d3.v4.js"></script> | |
<script> | |
var bands = d3.scaleBand() // v4 | |
.domain([0, 1, 2]) | |
.rangeRound([0, 100]) | |
.padding([0.1]); | |
console.log(bands.range()); // [0, 100] | |
console.log(bands.bandwidth()); // 29 | |
console.log(bands.padding()); // 0.1 | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: D3: .scaleBand, .rangeRound: Ordinal Scale with Range Bands