MCPcopy Create free account
hub / github.com/chartjs/Chart.js / updateElements

Method updateElements

src/controllers/controller.doughnut.js:256–294  ·  view source on GitHub ↗
(arcs, start, count, mode)

Source from the content-addressed store, hash-verified

254 }
255
256 updateElements(arcs, start, count, mode) {
257 const reset = mode === 'reset';
258 const chart = this.chart;
259 const chartArea = chart.chartArea;
260 const opts = chart.options;
261 const animationOpts = opts.animation;
262 const centerX = (chartArea.left + chartArea.right) / 2;
263 const centerY = (chartArea.top + chartArea.bottom) / 2;
264 const animateScale = reset && animationOpts.animateScale;
265 const innerRadius = animateScale ? 0 : this.innerRadius;
266 const outerRadius = animateScale ? 0 : this.outerRadius;
267 const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
268 let startAngle = this._getRotation();
269 let i;
270
271 for (i = 0; i < start; ++i) {
272 startAngle += this._circumference(i, reset);
273 }
274
275 for (i = start; i < start + count; ++i) {
276 const circumference = this._circumference(i, reset);
277 const arc = arcs[i];
278 const properties = {
279 x: centerX + this.offsetX,
280 y: centerY + this.offsetY,
281 startAngle,
282 endAngle: startAngle + circumference,
283 circumference,
284 outerRadius,
285 innerRadius
286 };
287 if (includeOptions) {
288 properties.options = sharedOptions || this.resolveDataElementOptions(i, arc.active ? 'active' : mode);
289 }
290 startAngle += circumference;
291
292 this.updateElement(arc, i, properties, mode);
293 }
294 }
295
296 calculateTotal() {
297 const meta = this._cachedMeta;

Callers 1

updateMethod · 0.95

Calls 5

_getRotationMethod · 0.95
_circumferenceMethod · 0.95
_getSharedOptionsMethod · 0.80
updateElementMethod · 0.80

Tested by

no test coverage detected