From: chad Date: Thu, 13 Nov 2014 17:36:13 +0000 (-0600) Subject: prevent divide by zero error when calculating a circumference X-Git-Tag: v2.0-alpha~43^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7712e8c71aef8403836fbd27dc01995c033d4ac;p=thirdparty%2FChart.js.git prevent divide by zero error when calculating a circumference --- diff --git a/src/Chart.Doughnut.js b/src/Chart.Doughnut.js index 35de93c7f..5044be604 100644 --- a/src/Chart.Doughnut.js +++ b/src/Chart.Doughnut.js @@ -108,8 +108,12 @@ this.update(); } }, - calculateCircumference : function(value){ - return (Math.PI*2)*(value / this.total); + calculateCircumference : function(value) { + if ( this.total > 0 ) { + return (Math.PI*2)*(value / this.total); + } else { + return 0; + } }, calculateTotal : function(data){ this.total = 0; @@ -181,4 +185,4 @@ defaults : helpers.merge(defaultConfig,{percentageInnerCutout : 0}) }); -}).call(this); \ No newline at end of file +}).call(this);