An example of using an axis with no ticks, showing only the domain path.
forked from mbostock's block: Zero Ticks
license: gpl-3.0 |
An example of using an axis with no ticks, showing only the domain path.
forked from mbostock's block: Zero Ticks
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.axis path { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
</style> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var margin = {top: 100, right: 100, bottom: 100, left: 100}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var x = d3.scale.identity() | |
.domain([0, width]); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.ticks(0) | |
.orient("bottom"); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
svg.append("g") | |
.attr("class", "x axis") | |
.call(xAxis); | |
</script> |