vendor/assets/javascripts/Chart.js in chartjs-ror-2.1.3 vs vendor/assets/javascripts/Chart.js in chartjs-ror-2.2.0
- old
+ new
@@ -1,9 +1,9 @@
/*!
* Chart.js
* http://chartjs.org/
- * Version: 1.0.1
+ * Version: 1.0.2
*
* Copyright 2015 Nick Downie
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
@@ -23,10 +23,29 @@
this.canvas = context.canvas;
this.ctx = context;
//Variables global to the chart
+ 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;
+
var width = this.width = context.canvas.width;
var height = this.height = 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);
@@ -823,11 +842,11 @@
clear(this.chart);
return this;
},
stop : function(){
// Stops any current animation loop occuring
- helpers.cancelAnimFrame.call(root, this.animationFrame);
+ cancelAnimFrame(this.animationFrame);
return this;
},
resize : function(callback){
this.stop();
var canvas = this.chart.canvas,
@@ -1366,11 +1385,10 @@
var halfHeight = this.height/2;
//Check to ensure the height will fit on the canvas
- //The three is to buffer form the very
if (this.y - halfHeight < 0 ){
this.y = halfHeight;
} else if (this.y + halfHeight > this.chart.height){
this.y = this.chart.height - halfHeight;
}
@@ -1573,11 +1591,11 @@
},
calculateX : function(index){
var isRotated = (this.xLabelRotation > 0),
// innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding,
innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight),
- valueWidth = innerWidth/(this.valuesCount - ((this.offsetGridLines) ? 0 : 1)),
+ valueWidth = innerWidth/Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1),
valueOffset = (valueWidth * index) + this.xScalePaddingLeft;
if (this.offsetGridLines){
valueOffset += (valueWidth/2);
}
@@ -2414,16 +2432,16 @@
this.reflow();
this.update();
}
},
calculateCircumference : function(value){
- return (Math.PI*2)*(value / this.total);
+ return (Math.PI*2)*(Math.abs(value) / this.total);
},
calculateTotal : function(data){
this.total = 0;
helpers.each(data,function(segment){
- this.total += segment.value;
+ this.total += Math.abs(segment.value);
},this);
},
update : function(){
this.calculateTotal(this.segments);
@@ -3059,9 +3077,11 @@
this.calculateTotal(this.segments);
helpers.each(this.segments,function(segment){
segment.save();
});
+
+ this.reflow();
this.render();
},
reflow : function(){
helpers.extend(this.SegmentArc.prototype,{
x : this.chart.width/2,
\ No newline at end of file