},
update: function update(reset) {
+ 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((helpers.min([this.chart.chart.width, this.chart.chart.height]) / 2) - this.chart.options.elements.arc.borderWidth / 2, 0);
+ this.chart.outerRadius = Math.max((minSize / 2) - this.chart.options.elements.arc.borderWidth / 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();
}, this);
},
updateElement: function(arc, index, reset) {
+ var centerX = (this.chart.chartArea.left + this.chart.chartArea.right) / 2;
+ var centerY = (this.chart.chartArea.top + this.chart.chartArea.bottom) / 2;
+
var resetModel = {
- x: this.chart.chart.width / 2,
- y: this.chart.chart.height / 2,
+ x: centerX,
+ y: centerY,
startAngle: Math.PI * -0.5, // use - PI / 2 instead of 3PI / 2 to make animations better. It means that we never deal with overflow during the transition function
circumference: (this.chart.options.animation.animateRotate) ? 0 : this.calculateCircumference(this.getDataset().data[index]),
outerRadius: (this.chart.options.animation.animateScale) ? 0 : this.outerRadius,
// Desired view properties
_model: reset ? resetModel : {
- x: this.chart.chart.width / 2,
- y: this.chart.chart.height / 2,
+ x: centerX,
+ y: centerY,
circumference: this.calculateCircumference(this.getDataset().data[index]),
outerRadius: this.outerRadius,
innerRadius: this.innerRadius,
it ('Should reset and update elements', function() {
var chart = {
- chart: {
- width: 100,
- height: 200,
+ chartArea: {
+ left: 0,
+ top: 0,
+ right: 100,
+ bottom: 200,
},
data: {
datasets: [{
it ('should draw all arcs', function() {
var chart = {
- chart: {
- width: 100,
- height: 200,
+ chartArea: {
+ left: 0,
+ top: 0,
+ right: 100,
+ bottom: 200,
},
data: {
datasets: [{
it ('should set the hover style of an arc', function() {
var chart = {
- chart: {
- width: 100,
- height: 200,
+ chartArea: {
+ left: 0,
+ top: 0,
+ right: 100,
+ bottom: 200,
},
data: {
datasets: [{
it ('should unset the hover style of an arc', function() {
var chart = {
- chart: {
- width: 100,
- height: 200,
+ chartArea: {
+ left: 0,
+ top: 0,
+ right: 100,
+ bottom: 200,
},
data: {
datasets: [{