Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda