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

Function doGuessOrdinal

src/data/helper/sourceHelper.ts:354–463  ·  view source on GitHub ↗
(
    data: Source['data'],
    sourceFormat: Source['sourceFormat'],
    seriesLayoutBy: Source['seriesLayoutBy'],
    dimensionsDefine: Source['dimensionsDefine'],
    startIndex: Source['startIndex'],
    dimIndex: DimensionIndex
)

Source from the content-addressed store, hash-verified

352// dimIndex may be overflow source data.
353// return {BE_ORDINAL}
354function doGuessOrdinal(
355 data: Source['data'],
356 sourceFormat: Source['sourceFormat'],
357 seriesLayoutBy: Source['seriesLayoutBy'],
358 dimensionsDefine: Source['dimensionsDefine'],
359 startIndex: Source['startIndex'],
360 dimIndex: DimensionIndex
361): BeOrdinalValue {
362 let result;
363 // Experience value.
364 const maxLoop = 5;
365
366 if (isTypedArray(data)) {
367 return BE_ORDINAL.Not;
368 }
369
370 // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
371 // always exists in source.
372 let dimName;
373 let dimType;
374 if (dimensionsDefine) {
375 const dimDefItem = dimensionsDefine[dimIndex];
376 if (isObject(dimDefItem)) {
377 dimName = dimDefItem.name;
378 dimType = dimDefItem.type;
379 }
380 else if (isString(dimDefItem)) {
381 dimName = dimDefItem;
382 }
383 }
384
385 if (dimType != null) {
386 return dimType === 'ordinal' ? BE_ORDINAL.Must : BE_ORDINAL.Not;
387 }
388
389 if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
390 const dataArrayRows = data as OptionSourceDataArrayRows;
391 if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
392 const sample = dataArrayRows[dimIndex];
393 for (let i = 0; i < (sample || []).length && i < maxLoop; i++) {
394 if ((result = detectValue(sample[startIndex + i])) != null) {
395 return result;
396 }
397 }
398 }
399 else {
400 for (let i = 0; i < dataArrayRows.length && i < maxLoop; i++) {
401 const row = dataArrayRows[startIndex + i];
402 if (row && (result = detectValue(row[dimIndex])) != null) {
403 return result;
404 }
405 }
406 }
407 }
408 else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
409 const dataObjectRows = data as OptionSourceDataObjectRows;
410 if (!dimName) {
411 return BE_ORDINAL.Not;

Callers 2

guessOrdinalFunction · 0.85

Calls 4

getDataItemValueFunction · 0.90
detectValueFunction · 0.85
isArrayFunction · 0.85
isObjectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…