Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda