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

Method updateElements

src/controllers/controller.scatter.js:111–151  ·  src/controllers/controller.scatter.js::ScatterController.updateElements
(points, start, count, mode)

Source from the content-addressed store, hash-verified

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