An axis defined with scaleLinear (after .nice() called).
From D3 in Depth book by Peter Cook.
license: gpl-3.0 | |
height: 110 | |
border: no |
An axis defined with scaleLinear (after .nice() called).
From D3 in Depth book by Peter Cook.
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<head> | |
<title>Axis (with nice)</title> | |
</head> | |
<style> | |
body { | |
font-family: "Helvetica Neue", Helvetica, sans-serif; | |
font-size: 12px; | |
} | |
</style> | |
<body> | |
<svg width="700" height="100"> | |
<g class="axis" transform="translate(20, 40)"> | |
</g> | |
</svg> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script> | |
<script> | |
var data = [0.243, 0.584, 0.987, 0.153, 0.433]; | |
var extent = d3.extent(data); | |
var linearScale = d3.scaleLinear() | |
.domain(extent) | |
.range([0, 600]) | |
.nice(); | |
var axis = d3.axisBottom(linearScale); | |
d3.select('.axis') | |
.call(axis); | |
</script> | |
</body> | |
</html> |