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

Method updateElements

src/controllers/controller.scatter.js:121–161  ·  view source on GitHub ↗
(points, start, count, mode)

Source from the content-addressed store, hash-verified

119 }
120
121 updateElements(points, start, count, mode) {
122 const reset = mode === 'reset';
123 const {iScale, vScale, _stacked, _dataset} = this._cachedMeta;
124 const firstOpts = this.resolveDataElementOptions(start, mode);
125 const sharedOptions = this.getSharedOptions(firstOpts);
126 const includeOptions = this.includeOptions(mode, sharedOptions);
127 const iAxis = iScale.axis;
128 const vAxis = vScale.axis;
129 const {spanGaps, segment} = this.options;
130 const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
131 const directUpdate = this.chart._animationsDisabled || reset || mode === 'none';
132 let prevParsed = start > 0 && this.getParsed(start - 1);
133
134 for (let i = start; i < start + count; ++i) {
135 const point = points[i];
136 const parsed = this.getParsed(i);
137 const properties = directUpdate ? point : {};
138 const nullData = isNullOrUndef(parsed[vAxis]);
139 const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
140 const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);
141
142 properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
143 properties.stop = i > 0 && (Math.abs(parsed[iAxis] - prevParsed[iAxis])) > maxGapLength;
144 if (segment) {
145 properties.parsed = parsed;
146 properties.raw = _dataset.data[i];
147 }
148
149 if (includeOptions) {
150 properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);
151 }
152
153 if (!directUpdate) {
154 this.updateElement(point, i, properties, mode);
155 }
156
157 prevParsed = parsed;
158 }
159
160 this.updateSharedOptions(sharedOptions, mode, firstOpts);
161 }
162
163 /**
164 * @protected

Callers 1

updateMethod · 0.95

Calls 11

isNumberFunction · 0.85
isNullOrUndefFunction · 0.85
getSharedOptionsMethod · 0.80
includeOptionsMethod · 0.80
getParsedMethod · 0.80
applyStackMethod · 0.80
updateElementMethod · 0.80
updateSharedOptionsMethod · 0.80
getPixelForValueMethod · 0.65
getBasePixelMethod · 0.65

Tested by

no test coverage detected