-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues #4572 and #4703 #4959
Conversation
- issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory" - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
me.max = DEFAULT_MAX; | ||
} | ||
} | ||
if (me.min === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the case of me.min === null
and me.max === null
will be covered in the previous if
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, it would be caught in if (me.min === me.max) {
and would result in {min: 1, max: 10, minNotZero: 1}
.
|
||
describe('when', function() { | ||
var config = [ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to test ticks.min == 0
and ticks.max == 0
at the same time? or is that covered in another test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The determineDataLimits
function would generate {min: 1, max: 10, minNotZero: 1}
values. However the core.ticks.js#137 would create lastTick = 0
in this case causing the ticks to be: [0,1,2,3,4,5,6,7,8,9,0]
. The same would happen with other invalid input.
The better question would be. Should Chart.js have a checking function for the configuration as it would allow invalid input ticks: {min: 10, max: 0}
and this would bubble through the determineDataLimits
and would cause problems in the tick generator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK to not handle that case. The user would have had to explicitly set it that way which would not make sense.
In terms of general strategy, I'm not sure how much checking we want to do here. @simonbrunel @benmccann thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, although the explicitly set option might be the result of some other function. Sanitizing the data and config, could make the code not having to deal with such situations.
@etimberg is anything missing in this PR that prevents merging? |
@jcopperfield it looks good to me. Would love to get @simonbrunel to take a look too. |
- issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory" - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
- issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory" - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
Fixes issues #4572 and #4703
The endless loop that the browser ended up in was caused by the
minNotZero
beingnull
.The new
determineDataLimits
code should catch the edge cases.Removed the
options.relativePoints
, as it is undocumented and didn't do anything useful. The same options is present in the file scales/scale.linear.js#L84; I doubt it does anything useful other than setting themax
to 100.