Skip to content

Instantly share code, notes, and snippets.

@nsonnad
Last active December 11, 2015 02:08
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 nsonnad/4528060 to your computer and use it in GitHub Desktop.
Save nsonnad/4528060 to your computer and use it in GitHub Desktop.
D3 axis grid lines
{"description":"An inlet to Tributary","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.6328125,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false}
var w = 300,
h = 300,
x = d3.scale.linear().range([0, w])
y = d3.scale.linear().range([h, 0])
var svg =
d3.select("svg")
.attr("width", w)
.attr("height", h)
var xAxis =
d3.svg.axis()
.scale(x)
.tickSize(-h, 0, 0)
.orient("bottom")
var yAxis =
d3.svg.axis()
.scale(y)
.tickSize(-w, 0, 0)
.orient("left")
svg.append("g")
.attr("transform", "translate(50," + (h + 20) + ")")
.call(xAxis)
svg.append("g")
.attr("transform", "translate(50, 20)")
.call(yAxis)
body { font:10px sans-serif;}
line.tick { stroke: #cccccc; fill:none; shape-rendering: crispEdges;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment