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

Function addLevelTicks

src/scale/Time.ts:543–640  ·  view source on GitHub ↗
(
        unitName: TimeUnit,
        lastLevelTicks: InnerTimeTick[],
        levelTicks: InnerTimeTick[]
    )

Source from the content-addressed store, hash-verified

541 }
542
543 function addLevelTicks(
544 unitName: TimeUnit,
545 lastLevelTicks: InnerTimeTick[],
546 levelTicks: InnerTimeTick[]
547 ) {
548 const newAddedTicks: ScaleTick[] = [];
549 const isFirstLevel = !lastLevelTicks.length;
550
551 if (isPrimaryUnitValueAndGreaterSame(getPrimaryTimeUnit(unitName), extent[0], extent[1], isUTC)) {
552 return;
553 }
554
555 if (isFirstLevel) {
556 lastLevelTicks = [{
557 value: getFirstTimestampOfUnit(extent[0], unitName, isUTC),
558 }, {
559 value: extent[1]
560 }];
561 }
562
563 for (let i = 0; i < lastLevelTicks.length - 1; i++) {
564 const startTick = lastLevelTicks[i].value;
565 const endTick = lastLevelTicks[i + 1].value;
566 if (startTick === endTick) {
567 continue;
568 }
569
570 let interval: number;
571 let getterName: JSDateGetterNames;
572 let setterName: JSDateSetterNames;
573 let isDate = false;
574
575 switch (unitName) {
576 case 'year':
577 interval = Math.max(1, Math.round(approxInterval / ONE_DAY / 365));
578 getterName = fullYearGetterName(isUTC);
579 setterName = fullYearSetterName(isUTC);
580 break;
581 case 'half-year':
582 case 'quarter':
583 case 'month':
584 interval = getMonthInterval(approxInterval);
585 getterName = monthGetterName(isUTC);
586 setterName = monthSetterName(isUTC);
587 break;
588 case 'week': // PENDING If week is added. Ignore day.
589 case 'half-week':
590 case 'day':
591 interval = getDateInterval(approxInterval, 31); // Use 32 days and let interval been 16
592 getterName = dateGetterName(isUTC);
593 setterName = dateSetterName(isUTC);
594 isDate = true;
595 break;
596 case 'half-day':
597 case 'quarter-day':
598 case 'hour':
599 interval = getHourInterval(approxInterval);
600 getterName = hoursGetterName(isUTC);

Callers 1

createIntervalTicksFunction · 0.85

Calls 15

getPrimaryTimeUnitFunction · 0.90
fullYearGetterNameFunction · 0.90
fullYearSetterNameFunction · 0.90
monthGetterNameFunction · 0.90
monthSetterNameFunction · 0.90
dateGetterNameFunction · 0.90
dateSetterNameFunction · 0.90
hoursGetterNameFunction · 0.90
hoursSetterNameFunction · 0.90
minutesGetterNameFunction · 0.90
minutesSetterNameFunction · 0.90
secondsGetterNameFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…