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

Function createIntervalTicks

src/scale/Time.ts:472–738  ·  view source on GitHub ↗
(
    bottomUnitName: TimeUnit,
    approxInterval: number,
    isUTC: boolean,
    extent: number[],
    innermostSpan: number,
    brk: BreakScaleMapper | NullUndefined,
)

Source from the content-addressed store, hash-verified

470}
471
472function createIntervalTicks(
473 bottomUnitName: TimeUnit,
474 approxInterval: number,
475 isUTC: boolean,
476 extent: number[],
477 innermostSpan: number,
478 brk: BreakScaleMapper | NullUndefined,
479): TimeScaleTick[] {
480 // A fail-safe is required since `interval` can be user specified, or for the case
481 // that using dataZoom toolbox and zoom repeatedly.
482 const safeLimit = 3000;
483 const unitNames = timeUnits;
484 // const bottomPrimaryUnitName = getPrimaryTimeUnit(bottomUnitName);
485
486 interface InnerTimeTick {
487 value: TimeScaleTick['value']
488 notAdd?: boolean
489 }
490
491 let iter = 0;
492
493 function addTicksInSpan(
494 interval: number,
495 minTimestamp: number,
496 maxTimestamp: number,
497 getMethodName: JSDateGetterNames,
498 setMethodName: JSDateSetterNames,
499 isDate: boolean,
500 out: InnerTimeTick[]
501 ) {
502 const estimateNiceMultiple = createEstimateNiceMultiple(setMethodName, interval);
503
504 let dateTime = minTimestamp;
505 const date = new Date(dateTime);
506
507 // if (isDate) {
508 // d -= 1; // Starts with 0; PENDING
509 // }
510
511 while (dateTime < maxTimestamp && dateTime <= extent[1]) {
512 out.push({
513 value: dateTime
514 });
515
516 if (iter++ > safeLimit) {
517 if (__DEV__) {
518 warn('Exceed safe limit in TimeScale["getTicks"].');
519 }
520 break;
521 }
522
523 date[setMethodName](date[getMethodName]() + interval);
524 dateTime = date.getTime();
525
526 if (brk) {
527 const moreMultiple = brk.calcNiceTickMultiple(dateTime, estimateNiceMultiple);
528 if (moreMultiple > 0) {
529 date[setMethodName](date[getMethodName]() + moreMultiple * interval);

Callers 1

getTicksMethod · 0.85

Calls 5

getPrimaryTimeUnitFunction · 0.90
isPrimaryTimeUnitFunction · 0.90
getUnitFromValueFunction · 0.90
removeDuplicatesFunction · 0.90
addLevelTicksFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…