Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active August 2, 2017 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d3indepth/21354e1a7c753624e0a76b7984ae65c1 to your computer and use it in GitHub Desktop.
Save d3indepth/21354e1a7c753624e0a76b7984ae65c1 to your computer and use it in GitHub Desktop.
Linear scale without nice
license: gpl-3.0
height: 110
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>Axis (without 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]);
var axis = d3.axisBottom(linearScale);
d3.select('.axis')
.call(axis);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment