Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
d3.timeFormat on domain has only 1 value

I am trying to replace dayofweek integer to its corresponding names.

My Heatmap so far

var y_label = [...new Set(data.map((item) => item.y))].sort(d3.descending); // [0 - 6]

// Build Y scales and axis:
const y = d3.scaleBand().range([height, 0]).domain(y_label).padding(0.01);
svg.append("g").call(d3.axisLeft(y));

Now I am adding .tickFormat(d3.timeFormat("%A"))

var y_label = [...new Set(data.map((item) => item.y))].sort(d3.descending); // [0 - 6]

// Build Y scales and axis:
const y = d3.scaleBand().range([height, 0]).domain(y_label).padding(0.01);
svg.append("g").call(d3.axisLeft(y).tickFormat(d3.timeFormat("%A")));

What I get is this:

Heatmap with same names

I dont even know where the Thursday comes from. How do I fix my code?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you construct a Date object from a number, it takes the value as number of milliseconds since Jan 1, 1970 00:00 (Thursday). Thus, any number from 0 to 6 is interpreted as very beginning of that day. Don't use d3.timeFormat. Instead just define:

const weekDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

....call(d3.axisLeft(y).tickFormat(d => weekDays[d.y]);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!