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

202
Views
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
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!