Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript d3.时间周,一周的第一天_Javascript_Date_D3.js - Fatal编程技术网

Javascript d3.时间周,一周的第一天

Javascript d3.时间周,一周的第一天,javascript,date,d3.js,Javascript,Date,D3.js,我对D3.timeWeek有一个问题,我用它来指定x轴上的刻度: plotXaxis: function (svg) { var x = d3scaleTime() .domain( d3extent(this.series, function (d) { return d.date; }) ) .range([0, this.width]); svg .append("g")

我对D3.timeWeek有一个问题,我用它来指定x轴上的刻度:

    plotXaxis: function (svg) {
  var x = d3scaleTime()
    .domain(
      d3extent(this.series, function (d) {
        return d.date;
      })
    )
    .range([0, this.width]);

  svg
    .append("g")
    .attr("transform", "translate(0," + this.height + ")")
    .call(
      d3axisBottom(x)
        .ticks(d3timeWeek.every(1))
        .tickFormat(d3timeFormat("%d. %b"))
    );
这给了我一个非常好的x轴,数据中每周都有一个记号。问题是D3意味着一周从周日开始,因此我的x轴上的日期都是周日-像2021年03月07日,而不是2021年03月08日

我希望它在周一开始,以适应丹麦的文化,我曾希望在d3上设置一些文化背景。timeWeek?

只需使用:

const svg=d3.选择(“svg”);
const now=新日期;
常量x=d3.scaleTime()
.domain([d3.timeMonth.floor(现在),d3.timeMonth.ceil(现在)])
.范围([20480]);
svg.append(“g”)
.attr(“变换”、“平移(0,50)”)
.call(d3.axisBottom(x)
.滴答声(d3.时间周一。每(1)次)
.tickFormat(d3.timeFormat(“%d.%b”))
);


请提供一把小提琴或一段代码Gerardo-非常感谢-它解决了这个问题。