score:1

Accepted answer

first, separate the code of axis from its parts:

const axisbottom = d3.axisbottom(x)
  .tickformat(d3.timeformat("%b"));

const axisbottomg = svg.append("g")
  .attr("transform", "translate(0," + height + ")")
  .call(axisbottom);

axisbottomg.classed('axisgrey', true);

axisbottomg.selectall("text")
  .attr("y", 0)
  .attr("x", 9)
  .attr("dy", ".35em")
  .attr("transform", "rotate(45)")
  .style("text-anchor", "start");

then, inspect (f12) axis <g> element to make sure it has axisgrey class and has the class styles as well.


Related Query