source: node_modules/recharts/lib/state/selectors/combiners/combineCheckedDomain.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.combineCheckedDomain = void 0;
7var _isDomainSpecifiedByUser = require("../../../util/isDomainSpecifiedByUser");
8var _isWellBehavedNumber = require("../../../util/isWellBehavedNumber");
9/**
10 * This function validates and transforms the axis domain so that it is safe to use in the provided scale.
11 */
12var combineCheckedDomain = (realScaleType, axisDomain) => {
13 if (axisDomain == null) {
14 return undefined;
15 }
16 switch (realScaleType) {
17 case 'linear':
18 {
19 /*
20 * linear scale only reads the first two numbers in the domain, and ignores everything else.
21 * So if it happens that someone somehow gave us a bigger domain,
22 * let's pick the min and max from it.
23 */
24 if (!(0, _isDomainSpecifiedByUser.isWellFormedNumberDomain)(axisDomain)) {
25 var min, max;
26 for (var i = 0; i < axisDomain.length; i++) {
27 var value = axisDomain[i];
28 if (!(0, _isWellBehavedNumber.isWellBehavedNumber)(value)) {
29 continue;
30 }
31 if (min === undefined || value < min) {
32 min = value;
33 }
34 if (max === undefined || value > max) {
35 max = value;
36 }
37 }
38 if (min !== undefined && max !== undefined) {
39 return [min, max];
40 }
41 return undefined;
42 }
43 return axisDomain;
44 }
45 default:
46 return axisDomain;
47 }
48};
49exports.combineCheckedDomain = combineCheckedDomain;
Note: See TracBrowser for help on using the repository browser.