MCPcopy
hub / github.com/chartjs/Chart.js / updateElements

Method updateElements

src/controllers/controller.line.js:76–120  ·  src/controllers/controller.line.js::LineController.updateElements
(points, start, count, mode)

Source from the content-addressed store, hash-verified

74 }
75
76 updateElements(points, start, count, mode) {
77 const reset = mode === class="st">'reset';
78 const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
79 const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
80 const iAxis = iScale.axis;
81 const vAxis = vScale.axis;
82 const {spanGaps, segment} = this.options;
83 const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
84 const directUpdate = this.chart._animationsDisabled || reset || mode === class="st">'none';
85 const end = start + count;
86 const pointsCount = points.length;
87 let prevParsed = start > 0 && this.getParsed(start - 1);
88
89 for (let i = 0; i < pointsCount; ++i) {
90 const point = points[i];
91 const properties = directUpdate ? point : {};
92
93 if (i < start || i >= end) {
94 properties.skip = true;
95 continue;
96 }
97
98 const parsed = this.getParsed(i);
99 const nullData = isNullOrUndef(parsed[vAxis]);
100 const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
101 const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);
102
103 properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
104 properties.stop = i > 0 && (Math.abs(parsed[iAxis] - prevParsed[iAxis])) > maxGapLength;
105 if (segment) {
106 properties.parsed = parsed;
107 properties.raw = _dataset.data[i];
108 }
109
110 if (includeOptions) {
111 properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? class="st">'active' : mode);
112 }
113
114 if (!directUpdate) {
115 this.updateElement(point, i, properties, mode);
116 }
117
118 prevParsed = parsed;
119 }
120 }
121
122 /**
123 * @protected

Callers 1

updateMethod · 0.95

Calls 9

isNumberFunction · 0.85
isNullOrUndefFunction · 0.85
_getSharedOptionsMethod · 0.80
getParsedMethod · 0.80
applyStackMethod · 0.80
updateElementMethod · 0.80
getPixelForValueMethod · 0.65
getBasePixelMethod · 0.65

Tested by

no test coverage detected