MCPcopy
hub / github.com/chartjs/Chart.js / getMinMax

Method getMinMax

src/core/core.datasetController.js:622–660  ·  view source on GitHub ↗

* @protected

(scale, canStack)

Source from the content-addressed store, hash-verified

620 * @protected
621 */
622 getMinMax(scale, canStack) {
623 const meta = this._cachedMeta;
624 const _parsed = meta._parsed;
625 const sorted = meta._sorted && scale === meta.iScale;
626 const ilen = _parsed.length;
627 const otherScale = this._getOtherScale(scale);
628 const stack = createStack(canStack, meta, this.chart);
629 const range = {min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY};
630 const {min: otherMin, max: otherMax} = getUserBounds(otherScale);
631 let i, parsed;
632
633 function _skip() {
634 parsed = _parsed[i];
635 const otherValue = parsed[otherScale.axis];
636 return !isFinite(parsed[scale.axis]) || otherMin > otherValue || otherMax < otherValue;
637 }
638
639 for (i = 0; i < ilen; ++i) {
640 if (_skip()) {
641 continue;
642 }
643 this.updateRangeFromParsed(range, scale, parsed, stack);
644 if (sorted) {
645 // if the data is sorted, we don't need to check further from this end of array
646 break;
647 }
648 }
649 if (sorted) {
650 // in the sorted case, find first non-skipped value from other end of array
651 for (i = ilen - 1; i >= 0; --i) {
652 if (_skip()) {
653 continue;
654 }
655 this.updateRangeFromParsed(range, scale, parsed, stack);
656 break;
657 }
658 }
659 return range;
660 }
661
662 getAllParsedValues(scale) {
663 const parsed = this._cachedMeta._parsed;

Callers

nothing calls this directly

Calls 4

_getOtherScaleMethod · 0.95
updateRangeFromParsedMethod · 0.95
createStackFunction · 0.85
getUserBoundsFunction · 0.85

Tested by

no test coverage detected