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

170
Visualizações
Trying to understand how log scale in d3.js works

I am trying to understand why the equation doesn't give the desired result.

I am unable to decode how this returns 90.96? Even with using the equation log y = m log x + log k I can't get the same result. using ∆log y divided by ∆log x to get m.

const logScale = d3.scaleLog()
                   .domain([1, 1000])
                   .range([10, 100]);

console.log(logScale(500)); // returns 90.96
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Log scales have the form y = m log(x) + b. By default it's a base 10 log. With your scale

const logScale = d3.scaleLog()
  .domain([1, 1000])
  .range([10, 100]);

m = 30 and b = 10. So you can think of it as

function logScale(x) {
  return 30 * Math.log10(x) + 10;
}

Edit: explaining how I got the b = 10 and m = 30

From the domain and range, we know that logScale(1) === 10. We also know that Math.log10(1) === 0. Therefore, when x is 1 and y is 10, the equation y = m * log(x) + b becomes 10 = m * 0 + b, so we know that b is 10. Now we can plug another (x, y) pair in to get m. For example, we can choose the max values from the domain and range: 100 = m * log(1000) + 10. Thus, m = 90 / log(1000), which is 30.

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