score:5

Accepted answer

You can can pass an array of ticks to an axis, and the axis will then plot ticks at the points in an array.

Here is some sample code. An axis is created that runs between 0 and 100. Tick marks are plotted at 0, 50, 60 and 100, in accordance with the 'ticks' array.

svg = d3.select("svg")

var myScale = d3.scale.linear()
        .domain([0,100])
        .range([0,400]);


var ticks = [0,50,60,100];

var myAxis = d3.svg.axis()
  .scale(myScale)
  .tickValues(ticks);

svg.append("g")
.attr("class", "axis")
.call(myAxis)
.attr("transform","translate(100,100)");

Here is an interactive example: http://tributary.io/inlet/5207532


Related Query

More Query from same tag