]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
handling negative values in doughnut charts
authorBen Dixon <bendxn@gmail.com>
Thu, 15 Jan 2015 19:40:08 +0000 (13:40 -0600)
committerBen Dixon <bendxn@gmail.com>
Thu, 15 Jan 2015 19:40:08 +0000 (13:40 -0600)
src/Chart.Doughnut.js

index 35de93c7fd606ad844f0ffc9f1c436f29868b546..a892b0efc6a7d11c32a9f62c7decf651b50b0638 100644 (file)
                        }
                },
                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(){