score:1

Accepted answer

You could set all the text in the axis to a particular class and then hide the ticks based on the number for example.

//Create the xAxis and assign x-axisticks class to the tick text
var xAxis = svg.append("g")
                .style("font-size", textSetter())
                .attr("class", "xAxis", "axis")
                .attr("transform", "translate(" + 0 + "," + heightTwo + ")")
                .call(d3.axisBottom(xScale)
                .selectAll('text')
                .attr('class', 'x-axisticks');

//remove the ticks which based on the multiples      
var xticks = d3.selectAll('.x-axisticks');
xticks.attr('class', function (d, i) {
      i = i + 1;
      if (i % 5 !== 0) d3.select(this).remove();
   });

Hope this helps. A more specific use-case answer would probably require some more code to be posted from your end so that I can tailor an answer, but this should work.


Related Query