2021年3月18日星期四

d3.timeWeek ,1st day of the week

I have an issue with D3.timeWeek- that I use to specify ticks on my x-axis:

    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"))      );  

This gives me a very nice x-axis with a tick for each week in the data. The problem is that D3 means that a week starts on a Sunday, so the dates on my x-axis are all Sunday - like 07-03-2021 instead of 08-03-2021.

I want it to start on a Monday to fit the culture in Denmark, I had hoped for some culture setting on d3.timeWeek?

https://stackoverflow.com/questions/66690663/d3-timeweek-1st-day-of-the-week March 18, 2021 at 07:58PM

没有评论:

发表评论