Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2016 02:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Log Axis
license: gpl-3.0

An example of the axis component with the log scale, here using an arbtirary hard-coded domain.

<!DOCTYPE html>
<meta charset="utf-8">
.axis text {
font: 10px sans-serif;
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
<script src="//"></script>
var margin = {top: 210, right: 20, bottom: 220, left: 20},
width = 960 - margin.left - margin.right,
height = 500 - - margin.bottom;
var x = d3.scale.log()
.domain([.0124123, 1230.4])
.range([0, width]);
var xAxis = d3.svg.axis()
.ticks(20, ",.1s")
.tickSize(6, 0);
var svg ="body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.right + margin.bottom)
.attr("transform", "translate(" + margin.left + "," + + ")");
.attr("class", "x axis")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment