* @param {string} mode
(mode)
| 206 | * @param {string} mode |
| 207 | */ |
| 208 | update(mode) { |
| 209 | const chart = this.chart; |
| 210 | const {chartArea} = chart; |
| 211 | const meta = this._cachedMeta; |
| 212 | const arcs = meta.data; |
| 213 | const spacing = this.getMaxBorderWidth() + this.getMaxOffset(arcs) + this.options.spacing; |
| 214 | const maxSize = Math.max((Math.min(chartArea.width, chartArea.height) - spacing) / 2, 0); |
| 215 | const cutout = Math.min(toPercentage(this.options.cutout, maxSize), 1); |
| 216 | const chartWeight = this._getRingWeight(this.index); |
| 217 | |
| 218 | // Compute the maximal rotation & circumference limits. |
| 219 | // If we only consider our dataset, this can cause problems when two datasets |
| 220 | // are both less than a circle with different rotations (starting angles) |
| 221 | const {circumference, rotation} = this._getRotationExtents(); |
| 222 | const {ratioX, ratioY, offsetX, offsetY} = getRatioAndOffset(rotation, circumference, cutout); |
| 223 | const maxWidth = (chartArea.width - spacing) / ratioX; |
| 224 | const maxHeight = (chartArea.height - spacing) / ratioY; |
| 225 | const maxRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); |
| 226 | const outerRadius = toDimension(this.options.radius, maxRadius); |
| 227 | const innerRadius = Math.max(outerRadius * cutout, 0); |
| 228 | const radiusLength = (outerRadius - innerRadius) / this._getVisibleDatasetWeightTotal(); |
| 229 | this.offsetX = offsetX * outerRadius; |
| 230 | this.offsetY = offsetY * outerRadius; |
| 231 | |
| 232 | meta.total = this.calculateTotal(); |
| 233 | |
| 234 | this.outerRadius = outerRadius - radiusLength * this._getRingWeightOffset(this.index); |
| 235 | this.innerRadius = Math.max(this.outerRadius - radiusLength * chartWeight, 0); |
| 236 | |
| 237 | this.updateElements(arcs, 0, arcs.length, mode); |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * @private |
nothing calls this directly
no test coverage detected