|
Last change
on this file since ba17441 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 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.combineCheckedDomain = void 0;
|
|---|
| 7 | var _isDomainSpecifiedByUser = require("../../../util/isDomainSpecifiedByUser");
|
|---|
| 8 | var _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 | */
|
|---|
| 12 | var 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 | };
|
|---|
| 49 | exports.combineCheckedDomain = combineCheckedDomain; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.