src/utils.ts
changed.
Other files ignored by Codecov
tests/utils.test.js
has changed.
23 | 23 | export function getClosestPoint(val: number, { marks, step, min, max }) { |
|
24 | 24 | const points = Object.keys(marks).map(parseFloat); |
|
25 | 25 | if (step !== null) { |
|
26 | - | const maxSteps = Math.floor((max - min) / step); |
|
26 | + | const baseNum = 10 ** getPrecision(step); |
|
27 | + | const maxSteps = Math.floor((max * baseNum - min * baseNum) / (step * baseNum)); |
|
27 | 28 | const steps = Math.min((val - min) / step, maxSteps); |
|
28 | 29 | const closestStep = Math.round(steps) * step + min; |
|
29 | 30 | points.push(closestStep); |
Files | Coverage |
---|---|
src | 88.20% |
Project Totals (11 files) | 88.20% |