Created
July 11, 2013 19:01
-
-
Save jcreedcmu/5978238 to your computer and use it in GitHub Desktop.
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> | |
<!-- Modification of http://bl.ocks.org/mbostock/5537697 to add a | |
.nice to the domain. Illustrates rounding error *not* causing the tick | |
on the far left to be lost --> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
.axis text { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="http://d3js.org/d3.v2.min.js"></script> | |
<script> | |
var margin = {top: 210, right: 20, bottom: 220, left: 20}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var x = d3.scale.log() | |
.domain([.0124123, 1230.4]) | |
.nice() | |
.range([0, width]); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom") | |
.ticks(20, d3.format(",.1s")) | |
.tickSize(6, 0); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.right + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
svg.append("g") | |
.attr("class", "x axis") | |
.call(xAxis); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment