]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Polar are controller needs a similar update to the doughnut controller
authorEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Dec 2015 15:19:09 +0000 (10:19 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Sun, 6 Dec 2015 15:19:09 +0000 (10:19 -0500)
src/controllers/controller.polarArea.js

index cca8a65b82a886cce616b6809c50789dae657c15..b8fae6f8769b60209de49e1a4f78301e8a96839b 100644 (file)
                },
 
                update: function update(reset) {
-                       this.chart.outerRadius = Math.max((helpers.min([this.chart.chart.width, this.chart.chart.height]) - this.chart.options.elements.arc.borderWidth / 2) / 2, 0);
+                       var minSize = Math.min(this.chart.chartArea.right - this.chart.chartArea.left, this.chart.chartArea.bottom - this.chart.chartArea.top);
+                       this.chart.outerRadius = Math.max((minSize - this.chart.options.elements.arc.borderWidth / 2) / 2, 0);
                        this.chart.innerRadius = Math.max(this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1, 0);
                        this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.getVisibleDatasetCount();
 
                },
                updateElement: function(arc, index, reset) {
                        var circumference = 1 / this.getDataset().data.length * 2;
+                       var centerX = (this.chart.chartArea.left + this.chart.chartArea.right) / 2;
+                       var centerY = (this.chart.chartArea.top + this.chart.chartArea.bottom) / 2;
+
                        var startAngle = (-0.5 * Math.PI) + (Math.PI * circumference) * index;
                        var endAngle = startAngle + (circumference * Math.PI);
 
                        var resetModel = {
-                               x: this.chart.chart.width / 2,
-                               y: this.chart.chart.height / 2,
+                               x: centerX,
+                               y: centerY,
                                innerRadius: 0,
                                outerRadius: this.chart.options.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]),
                                startAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : startAngle,
 
                                // Desired view properties
                                _model: reset ? resetModel : {
-                                       x: this.chart.chart.width / 2,
-                                       y: this.chart.chart.height / 2,
+                                       x: centerX,
+                                       y: centerY,
                                        innerRadius: 0,
                                        outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]),
                                        startAngle: startAngle,