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

Method getMinMax

src/core/core.scale.js:303–330  ·  view source on GitHub ↗

* @param {boolean} canStack * @return {{min: number, max: number}} * @protected * @since 3.0

(canStack)

Source from the content-addressed store, hash-verified

301 * @since 3.0
302 */
303 getMinMax(canStack) {
304 let {min, max, minDefined, maxDefined} = this.getUserBounds();
305 let range;
306
307 if (minDefined && maxDefined) {
308 return {min, max};
309 }
310
311 const metas = this.getMatchingVisibleMetas();
312 for (let i = 0, ilen = metas.length; i < ilen; ++i) {
313 range = metas[i].controller.getMinMax(this, canStack);
314 if (!minDefined) {
315 min = Math.min(min, range.min);
316 }
317 if (!maxDefined) {
318 max = Math.max(max, range.max);
319 }
320 }
321
322 // Make sure min <= max when only min or max is defined by user and the data is outside that range
323 min = maxDefined && min > max ? max : min;
324 max = minDefined && min > max ? min : max;
325
326 return {
327 min: finiteOrDefault(min, finiteOrDefault(max, min)),
328 max: finiteOrDefault(max, finiteOrDefault(min, max))
329 };
330 }
331
332 /**
333 * Get the padding needed for the scale

Callers

nothing calls this directly

Calls 4

getUserBoundsMethod · 0.95
finiteOrDefaultFunction · 0.85
getMinMaxMethod · 0.65

Tested by

no test coverage detected