Merge pull request #142 from JonRowe/automatically_size_chart

Automatically size charts based upon the canvas size.
This commit is contained in:
Evert Timberg 2015-01-26 18:55:49 -05:00
commit a5550cef6b

21
Chart.js vendored
View File

@ -25,8 +25,25 @@
this.ctx = context;
//Variables global to the chart
var width = this.width = context.canvas.width;
var height = this.height = context.canvas.height;
var computeDimension = function(element,dimension)
{
if (element['offset'+dimension])
{
return element['offset'+dimension];
}
else
{
return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
}
}
var width = this.width = computeDimension(context.canvas,'Width');
var height = this.height = computeDimension(context.canvas,'Height');
// Firefox requires this to work correctly
context.canvas.width = width;
context.canvas.height = height;
this.aspectRatio = this.width / this.height;
//High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale.
helpers.retinaScale(this);