Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <svg id="test"></svg>
  
</body>
</html>
 
svg { width: 300px; height: 100px; }
path,line { stroke: black; fill: transparent;}
 
var svg = d3.select("svg");
var scale = d3.scale.linear()
    .range([20, 280])
    .domain([0, 100])
var axis = d3.svg.axis().scale(scale).orient("bottom").ticks(9);
svg.call(axis);
console.log("all the points", axis.scale().ticks(axis.ticks()[0]));
svg.selectAll(".tick").each(function(data) {
  var tick = d3.select(this);
  var transform = d3.transform(tick.attr("transform")).translate;
  
  // passed in "data" is the value of the tick, transform[0] holds the X value
  console.log("each tick", data, transform);
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
gnarfpro
0viewers