nnnick/Chart.js — pull request #539 by lencioni (2014-08-14 18:03:06+00:00)
Title: Fix error when canvas has width or height of 0

At Brigade, we are using Chart.js to render some charts that are
dynamically sized to the dimensions of the canvas on initialization. In
normal browser scenarios this worked great, but in our Jasmine tests we
ran into the following error:

> Uncaught IndexSizeError: Failed to execute 'arc' on
> 'CanvasRenderingContext2D': The radius provided (-0.5) is negative.

This was happening because in the Jasmine testing context, the canvas
was invisible and therefore had a height and width of 0.

To fix this, we thought it made sense to default the width and height of
the Chart to 1 if it was falsey. This also prevents a division by 0 from
happening on the following line. We had considered using `Math.max`
instead, which would also protect against negative numbers, but that
feels a bit YAGNI at this point.

This is perhaps against the philosophy of failing hard and fast, but it
seems like enough of an edge case as to not really matter. Also, if the
intention is to fail hard and fast, this could be done with as a check
for acceptable values and a `throw` statement if the check is not
satisfied.

While I was in there, I removed some incidental trailing whitespace.