Skip to content
Bug reportNov 8, 2026· 0:29· 14 views

Chart.js 4.6.1: logarithmic axis sets scale.min below data minimum (floating-point error in generateTicks)

0:29 total

Comments · 0

Be the first to comment.

Bug reportby SceneRecap AI

mediumLogarithmic scale tick generation (generateTicks in the logarithmic scale). The min value is floored after a floating-point computation (log10/pow) that yields 6.999... instead of 7. Floor with an epsilon tolerance or round before flooring.
os: macOSdpr: 1scale: logarithmic, default optionslocale: en-USbrowser: Chromium 151.0.7922.34library: Chart.js 4.6.1 (cdn.jsdelivr.net chart.umd.min.js)timezone: Europe/Berlinviewport: 1280x720

Repro steps

  1. 1.Load Chart.js 4.6.1 from cdn.jsdelivr.net on a page.
  2. 2.Create a line chart with a logarithmic y axis, default options, and data [7, 10].
  3. 3.Read chart.scales.y.min and the first ticks of the y axis.
  4. 4.As a control, create the same chart with data [70, 100] and read scale.min.

Expected

For data [7, 10], the logarithmic scale.min should equal the data minimum, 7. No tick should be generated below the data range. This matches the control case [70, 100], where scale.min is 70.

Actual

For data [7, 10], scale.min is 6.9. The output panel shows the first 4 ticks as ["","7.0","7.5","8.0"], so an extra tick sits below the data minimum. The control with data [70, 100] gives scale.min = 70 as expected.

Evidence

visualLeft chart label reads 'BUG: data [7, 10]: scale.min = 6.9 (should be 7)'. Its y ticks are 7.0, 7.5, 8.0, 9.0, 10.0.
visualOutput panel reads 'data [7, 10], scale.min=6.9, first 4 ticks: ["","7.0","7.5","8.0"]'.
visualControl: the right chart reads 'OK: data [70, 100]: scale.min = 70'. The output panel shows 'scale.min=70, first 4 ticks: ["","71","72","73"]'. The control works correctly.
visualPage subtitle states that generateTicks floors 6.999... to 6.9, so scale.min is one step too low for data [7,10] but correct for data [70,100].
visualA red callout on the bug chart reads 'scale.min = 6.9 ≠ 7'. It states that the data minimum is 7, generateTicks floors 6.999... to 6.9, and an extra '6.9' tick appears below the data range.
visualBoth charts and the output panel are unchanged from 11s to 23s. The result is stable and not transient.
consoleUnrelated warning: the parser-blocking cross-site script cdn.jsdelivr.net/npm/chart.js@4.6.1/dist/chart.umd.min.js is invoked via document.write. Chart.js still loaded and rendered.
Issue markdown (copy-paste ready)
## Chart.js 4.6.1: logarithmic axis sets scale.min below data minimum

Related: chartjs/Chart.js#12389

### Environment
- Chromium 151.0.7922.34, macOS, 1280x720, dpr 1
- Chart.js 4.6.1 (cdn.jsdelivr.net `chart.umd.min.js`)
- Logarithmic y axis, default options

### Steps to reproduce
1. Load Chart.js 4.6.1 (0s).
2. Create a line chart with a logarithmic y axis and data `[7, 10]` (1s).
3. Read `scale.min` and the first ticks (1s).
4. Control: same chart with data `[70, 100]` (1s).

### Expected
`scale.min` should be `7`, the data minimum. No tick should be generated below the data range. The control `[70, 100]` gives `scale.min = 70`, which is correct.

### Actual
- Data `[7, 10]`: `scale.min=6.9`. First 4 ticks: `["","7.0","7.5","8.0"]` (1s).
- Data `[70, 100]`: `scale.min=70`. First 4 ticks: `["","71","72","73"]` (1s). The control works correctly.

### Evidence
- 1s: the left chart label reads `scale.min = 6.9 (should be 7)`.
- 1s: the page subtitle states that generateTicks floors `6.999...` to `6.9`.
- 11s: an on-page callout reads `scale.min = 6.9 ≠ 7`. It notes an extra `6.9` tick below the data range.
- 11s to 23s: the output is unchanged, so the bug is stable.
- 0s: the console shows an unrelated document.write warning for the CDN script.

### Suspected area
Logarithmic scale `generateTicks`. A floating-point result of `6.999...` is floored to one decimal step, which gives `6.9`. Consider an epsilon-tolerant floor, or rounding to the significant digit before flooring.

*Recorded with SceneRecap.*

Your recordings could explain themselves too.

Free plan · silent recordings welcome · bug reports included.

Try SceneRecap free →
Chart.js 4.6.1: logarithmic axis sets scale.min below data minimum (floating-point error in generateTicks) · SceneRecap