mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
change way that linear scales calculate min and max (#10591)
This commit is contained in:
parent
bd29fcbf67
commit
c74260b745
@ -13,6 +13,7 @@ A number of changes were made to the configuration options passed to the `Chart`
|
||||
* The radialLinear grid indexable and scriptable options don't decrease the index of the specified grid line anymore.
|
||||
* The `destroy` plugin hook has been removed and replaced with `afterDestroy`.
|
||||
* Ticks callback on time scale now receives timestamp instead of a formatted label.
|
||||
* Linear scales now add and subtracts `5%` of the max value to the range if the min and max are the same instead of `1`.
|
||||
* If the tooltip callback returns `undefined`, then the default callback will be used.
|
||||
|
||||
#### Type changes
|
||||
|
||||
@ -194,15 +194,7 @@ export default class LinearScaleBase extends Scale {
|
||||
}
|
||||
|
||||
if (min === max) {
|
||||
let offset = 1;
|
||||
if (max >= Number.MAX_SAFE_INTEGER || min <= Number.MIN_SAFE_INTEGER) {
|
||||
// In this case, the magnitude of the number is so large that
|
||||
// max === max + 1 due to how IEEE754 doubles work. We need to increase
|
||||
// the range by a larger number. Let's be safe and make this 5% of the number
|
||||
//
|
||||
// TODO - V4, make this the new default behaviour and eliminate +1 in other cases
|
||||
offset = Math.abs(max * 0.05);
|
||||
}
|
||||
let offset = max === 0 ? 1 : Math.abs(max * 0.05);
|
||||
|
||||
setMax(max + offset);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user