MCPcopy Index your code
hub / github.com/apache/echarts / normalizeDimensionsOption

Function normalizeDimensionsOption

src/data/Source.ts:415–458  ·  view source on GitHub ↗
(dimensionsDefine: DimensionDefinitionLoose[])

Source from the content-addressed store, hash-verified

413// which is reasonable. But dimension name is duplicated.
414// Returns undefined or an array contains only object without null/undefined or string.
415function normalizeDimensionsOption(dimensionsDefine: DimensionDefinitionLoose[]): DimensionDefinition[] {
416 if (!dimensionsDefine) {
417 // The meaning of null/undefined is different from empty array.
418 return;
419 }
420 const nameMap = createHashMap<{ count: number }, string>();
421 return map(dimensionsDefine, function (rawItem, index) {
422 rawItem = isObject(rawItem) ? rawItem : { name: rawItem };
423 // Other fields will be discarded.
424 const item: DimensionDefinition = {
425 name: rawItem.name,
426 displayName: rawItem.displayName,
427 type: rawItem.type
428 };
429
430 // User can set null in dimensions.
431 // We don't auto specify name, otherwise a given name may
432 // cause it to be referred unexpectedly.
433 if (item.name == null) {
434 return item;
435 }
436
437 // Also consider number form like 2012.
438 item.name += '';
439 // User may also specify displayName.
440 // displayName will always exists except user not
441 // specified or dim name is not specified or detected.
442 // (A auto generated dim name will not be used as
443 // displayName).
444 if (item.displayName == null) {
445 item.displayName = item.name;
446 }
447
448 const exist = nameMap.get(item.name);
449 if (!exist) {
450 nameMap.set(item.name, {count: 1});
451 }
452 else {
453 item.name += '-' + exist.count++;
454 }
455
456 return item;
457 });
458}
459
460function arrayRowsTravelFirst(
461 cb: (val: OptionDataValue, idx: number) => void,

Callers 1

Calls 2

isObjectFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…