MCPcopy
hub / github.com/apache/echarts / _processFlatCoordsArray

Method _processFlatCoordsArray

src/chart/lines/LinesSeries.ts:256–304  ·  view source on GitHub ↗
(data: LinesSeriesOption['data'])

Source from the content-addressed store, hash-verified

254 }
255
256 _processFlatCoordsArray(data: LinesSeriesOption['data']) {
257 let startOffset = 0;
258 if (this._flatCoords) {
259 startOffset = this._flatCoords.length;
260 }
261 // Stored as a typed array. In format
262 // Points Count(2) | x | y | x | y | Points Count(3) | x | y | x | y | x | y |
263 if (isNumber(data[0])) {
264 const len = data.length;
265 // Store offset and len of each segment
266 const coordsOffsetAndLenStorage = new Uint32Arr(len) as Uint32Array;
267 const coordsStorage = new Float64Arr(len) as Float64Array;
268 let coordsCursor = 0;
269 let offsetCursor = 0;
270 let dataCount = 0;
271 for (let i = 0; i < len;) {
272 dataCount++;
273 const count = data[i++] as number;
274 // Offset
275 coordsOffsetAndLenStorage[offsetCursor++] = coordsCursor + startOffset;
276 // Len
277 coordsOffsetAndLenStorage[offsetCursor++] = count;
278 for (let k = 0; k < count; k++) {
279 const x = data[i++] as number;
280 const y = data[i++] as number;
281 coordsStorage[coordsCursor++] = x;
282 coordsStorage[coordsCursor++] = y;
283
284 if (i > len) {
285 if (__DEV__) {
286 throw new Error('Invalid data format.');
287 }
288 }
289 }
290 }
291
292 return {
293 flatCoordsOffset: new Uint32Array(coordsOffsetAndLenStorage.buffer, 0, offsetCursor),
294 flatCoords: coordsStorage,
295 count: dataCount
296 };
297 }
298
299 return {
300 flatCoordsOffset: null,
301 flatCoords: null,
302 count: data.length
303 };
304 }
305
306 getInitialData(option: LinesSeriesOption, ecModel: GlobalModel) {
307 if (__DEV__) {

Callers 3

initMethod · 0.95
mergeOptionMethod · 0.95
appendDataMethod · 0.95

Calls 1

isNumberFunction · 0.85

Tested by

no test coverage detected