fix(scale): handle Number.MAX_VALUE in linear scale without overflow by jonathan-fulton · Pull Request #12185 · chartjs/Chart.js

Summary

Fixes #12184

When a dataset contains Number.MAX_VALUE, the linear scale's tick generation algorithm would overflow when computing "nice" tick values, causing the chart to crash or render incorrectly.

Changes

  • Added SAFE_MAX and SAFE_MIN constants (set to Number.MAX_VALUE / 2) to prevent overflow during calculations
  • Clamp the data range to safe values before computing nice tick bounds
  • Ensure niceMin and niceMax stay within safe bounds after rounding

Testing

Added test cases for both Number.MAX_VALUE and -Number.MAX_VALUE in datasets to ensure the chart renders without crashing and produces finite scale bounds.