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

Function splitNumber

src/component/visualMap/PiecewiseModel.ts:443–492  ·  view source on GitHub ↗
(outPieceList)

Source from the content-addressed store, hash-verified

441const resetMethods: Dictionary<ResetMethod> & ThisType<PiecewiseModel> = {
442
443 splitNumber(outPieceList) {
444 const thisOption = this.option;
445 let precision = Math.min(thisOption.precision, 20);
446 const dataExtent = this.getExtent();
447 let splitNumber = thisOption.splitNumber;
448 splitNumber = Math.max(parseInt(splitNumber as unknown as string, 10), 1);
449 thisOption.splitNumber = splitNumber;
450
451 let splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
452 // Precision auto-adaption
453 while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
454 precision++;
455 }
456 thisOption.precision = precision;
457 splitStep = +splitStep.toFixed(precision);
458
459 if (thisOption.minOpen) {
460 outPieceList.push({
461 interval: [-Infinity, dataExtent[0]],
462 close: [0, 0]
463 });
464 }
465
466 for (
467 let index = 0, curr = dataExtent[0];
468 index < splitNumber;
469 curr += splitStep, index++
470 ) {
471 const max = index === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
472
473 outPieceList.push({
474 interval: [curr, max],
475 close: [1, 1]
476 });
477 }
478
479 if (thisOption.maxOpen) {
480 outPieceList.push({
481 interval: [dataExtent[1], Infinity],
482 close: [0, 0]
483 });
484 }
485
486 reformIntervals(outPieceList as Required<InnerVisualPiece>[]);
487
488 zrUtil.each(outPieceList, function (piece, index) {
489 piece.index = index;
490 piece.text = this.formatValueText(piece.interval);
491 }, this);
492 },
493
494 categories(outPieceList) {
495 const thisOption = this.option;

Callers

nothing calls this directly

Calls 5

reformIntervalsFunction · 0.90
toFixedMethod · 0.80
formatValueTextMethod · 0.80
getExtentMethod · 0.65
eachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…