Javascript scaleTime()上的滴答声不起作用

Javascript scaleTime()上的滴答声不起作用,javascript,d3.js,Javascript,D3.js,我正在尝试设置一个时间刻度,其中两个日期相隔40天。我的资料如下: [ { "date": "Wed Jul 06 2016 16:44:14 GMT-0400", "dailyVerified": 44, "totalVerified": 206 }, // other data would go here... { "date": "Sun Aug 14 2016 16:44:14 GMT-0400", "d

我正在尝试设置一个时间刻度,其中两个日期相隔40天。我的资料如下:

[
   {
      "date": "Wed Jul 06 2016 16:44:14 GMT-0400",
      "dailyVerified": 44,
      "totalVerified": 206
   },
   // other data would go here...
   {
      "date": "Sun Aug 14 2016 16:44:14 GMT-0400",
      "dailyVerified": 27,
      "totalVerified": 2109
   }
]
当尝试设置
scale.ticks(x)
时,它似乎没有任何作用。代码是:

var x = d3.scaleTime();

x
  .domain([firstDate, lastDate])
  .range([0, 600])
  .ticks(d3.timeDay.every(3))


我尝试每3天设置一次刻度,就像在api文档中一样,但它似乎没有任何作用-刻度仍然是按周分割的。你知道为什么吗?是因为我设置的域不正确吗?

我找到了答案。我试图在轴上而不是刻度上设置刻度。因此,不是:

x.ticks(d3.timeDay.every(5))
我需要做:

const xA = d3.axisBottom(x);
// set the ticks on the axis
xA.ticks(d3.axisBottom(x))

我想出来了。我试图在轴上而不是刻度上设置刻度。因此,不是:

x.ticks(d3.timeDay.every(5))
我需要做:

const xA = d3.axisBottom(x);
// set the ticks on the axis
xA.ticks(d3.axisBottom(x))