]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
make charts dependent on calculated width
authorJon Rowe <hello@jonrowe.co.uk>
Wed, 19 Jun 2013 05:00:37 +0000 (15:00 +1000)
committerJon Rowe <hello@jonrowe.co.uk>
Mon, 26 Jan 2015 09:15:04 +0000 (20:15 +1100)
Chart.js

index e34e08a486effeea4d478616d24f9c26530d86b8..fb8fb0c5416696b8b00fd0582abd3a53e05982f2 100644 (file)
--- a/Chart.js
+++ b/Chart.js
                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');
                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);