score:1

Accepted answer

You only want to use .tickValues if some condition is met?

var xAxis = d3.axisBottom(x)
  .tickFormat(function (d, i) {
      if (interval_size === "15" || interval_size === "30") {
        return testStringArray[i];
      } else {
        return dateArray[i];
      }
  });

if (someCondition){
  xAxis.tickValues(x.domain().filter(function (d, i) { return !(i % 2); }));
}

Related Query

More Query from same tag