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

206
Vistas
D3.js scaleLinear is not returning the correct output for 0 value

I'm using d3js to draw some graphs in my awesome UI, here below the scales I'm calling.

import {ScaleLinear, scaleLinear } from 'd3';

Given the scale I have created below

const history = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const maxValue = Math.max(...history);
const localYScale: ScaleLinear<number, number> = scaleLinear().domain([0, maxValue]).range([0, 32]);

by calling localYScale(0) I would expect the returned value to be 0 but it's returning 16...

I did few tweaks to investigate and turns out that if I assign a fallback value that is very close from 0 the localYScale(0) method returns the expected value for some reasons...

const maxValue = Math.max(...history) || 0,001;

I'm I missing something here with d3?.... Thanks

about 4 years ago · Juan Pablo Isaza
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