]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Doughnut/Pie accurate radii
authorTanner Linsley <tannerlinsley@gmail.com>
Tue, 16 Jun 2015 04:43:24 +0000 (22:43 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Tue, 16 Jun 2015 04:43:24 +0000 (22:43 -0600)
src/controllers/controller.doughnut.js

index 21ae0c96a30e6e7d7a0425b066270125d6a267ec..110b2b5c721a4d21614cfd48528c42b6d8b94bda 100644 (file)
@@ -75,7 +75,7 @@
                        }, this);
 
                        this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index);
-                       this.innerRadius = this.chart.outerRadius - this.chart.radiusLength;
+                       this.innerRadius = this.outerRadius - this.chart.radiusLength;
 
                        helpers.each(this.getDataset().metaData, function(arc, index) {
 
 
 
 
-               setHoverStyle: function(rectangle) {
-                       var dataset = this.chart.data.datasets[rectangle._datasetIndex];
-                       var index = rectangle._index;
+               setHoverStyle: function(arc) {
+                       var dataset = this.chart.data.datasets[arc._datasetIndex];
+                       var index = arc._index;
 
-                       rectangle._model.backgroundColor = rectangle.custom && rectangle.custom.hoverBackgroundColor ? rectangle.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(rectangle._model.backgroundColor).saturate(0.5).darken(0.1).rgbString());
-                       rectangle._model.borderColor = rectangle.custom && rectangle.custom.hoverBorderColor ? rectangle.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(rectangle._model.borderColor).saturate(0.5).darken(0.1).rgbString());
-                       rectangle._model.borderWidth = rectangle.custom && rectangle.custom.hoverBorderWidth ? rectangle.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, rectangle._model.borderWidth);
+                       arc._model.backgroundColor = arc.custom && arc.custom.hoverBackgroundColor ? arc.custom.hoverBackgroundColor : helpers.getValueAtIndexOrDefault(dataset.hoverBackgroundColor, index, helpers.color(arc._model.backgroundColor).saturate(0.5).darken(0.1).rgbString());
+                       arc._model.borderColor = arc.custom && arc.custom.hoverBorderColor ? arc.custom.hoverBorderColor : helpers.getValueAtIndexOrDefault(dataset.hoverBorderColor, index, helpers.color(arc._model.borderColor).saturate(0.5).darken(0.1).rgbString());
+                       arc._model.borderWidth = arc.custom && arc.custom.hoverBorderWidth ? arc.custom.hoverBorderWidth : helpers.getValueAtIndexOrDefault(dataset.borderWidth, index, arc._model.borderWidth);
                },
 
-               removeHoverStyle: function(rectangle) {
-                       // TODO
+               removeHoverStyle: function(arc) {
+                       var dataset = this.chart.data.datasets[arc._datasetIndex];
+                       var index = arc._index;
+
+                       arc._model.backgroundColor = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor);
+                       arc._model.borderColor = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.arc.borderColor);
+                       arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth);
                },
 
                calculateCircumference: function(value) {