victory-core 36.9.2 → 37.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/victory-core.js +4371 -5749
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-accessible-group/victory-accessible-group.js +9 -15
  5. package/es/victory-animation/util.js +28 -47
  6. package/es/victory-animation/victory-animation.js +51 -67
  7. package/es/victory-clip-container/victory-clip-container.js +153 -229
  8. package/es/victory-container/victory-container.js +157 -216
  9. package/es/victory-label/victory-label.js +246 -323
  10. package/es/victory-portal/portal-context.js +1 -2
  11. package/es/victory-portal/portal.js +30 -76
  12. package/es/victory-portal/victory-portal.js +47 -104
  13. package/es/victory-primitives/arc.js +44 -47
  14. package/es/victory-primitives/background.js +14 -17
  15. package/es/victory-primitives/border.js +20 -24
  16. package/es/victory-primitives/circle.js +13 -27
  17. package/es/victory-primitives/clip-path.js +3 -7
  18. package/es/victory-primitives/line-segment.js +20 -24
  19. package/es/victory-primitives/line.js +13 -27
  20. package/es/victory-primitives/path.js +13 -27
  21. package/es/victory-primitives/point.js +36 -40
  22. package/es/victory-primitives/rect.js +13 -27
  23. package/es/victory-primitives/text.js +15 -28
  24. package/es/victory-primitives/tspan.js +13 -26
  25. package/es/victory-primitives/whisker.js +43 -47
  26. package/es/victory-theme/grayscale.js +22 -22
  27. package/es/victory-theme/material.js +46 -46
  28. package/es/victory-theme/victory-theme.js +3 -3
  29. package/es/victory-transition/victory-transition.js +126 -206
  30. package/es/victory-util/add-events.js +263 -374
  31. package/es/victory-util/axis.js +126 -222
  32. package/es/victory-util/collection.js +13 -41
  33. package/es/victory-util/data.js +159 -214
  34. package/es/victory-util/default-transitions.js +33 -51
  35. package/es/victory-util/domain.js +122 -171
  36. package/es/victory-util/events.js +168 -258
  37. package/es/victory-util/helpers.js +153 -178
  38. package/es/victory-util/hooks/use-animation-state.js +61 -99
  39. package/es/victory-util/hooks/use-previous-props.js +2 -2
  40. package/es/victory-util/immutable.js +6 -8
  41. package/es/victory-util/label-helpers.js +128 -130
  42. package/es/victory-util/line-helpers.js +29 -41
  43. package/es/victory-util/log.js +1 -1
  44. package/es/victory-util/point-path-helpers.js +89 -49
  45. package/es/victory-util/scale.js +24 -42
  46. package/es/victory-util/selection.js +39 -40
  47. package/es/victory-util/style.js +8 -13
  48. package/es/victory-util/textsize.js +80 -154
  49. package/es/victory-util/timer-context.js +2 -2
  50. package/es/victory-util/timer.js +40 -76
  51. package/es/victory-util/transitions.js +110 -150
  52. package/es/victory-util/type-helpers.js +2 -3
  53. package/es/victory-util/user-props.js +24 -49
  54. package/es/victory-util/wrapper.js +184 -247
  55. package/lib/index.js +0 -30
  56. package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
  57. package/lib/victory-animation/util.js +28 -63
  58. package/lib/victory-animation/victory-animation.js +54 -83
  59. package/lib/victory-clip-container/victory-clip-container.js +156 -243
  60. package/lib/victory-container/victory-container.js +160 -232
  61. package/lib/victory-label/victory-label.js +248 -344
  62. package/lib/victory-portal/portal-context.js +1 -6
  63. package/lib/victory-portal/portal.js +31 -81
  64. package/lib/victory-portal/victory-portal.js +50 -116
  65. package/lib/victory-primitives/arc.js +48 -57
  66. package/lib/victory-primitives/background.js +16 -28
  67. package/lib/victory-primitives/border.js +22 -34
  68. package/lib/victory-primitives/circle.js +16 -36
  69. package/lib/victory-primitives/clip-path.js +3 -11
  70. package/lib/victory-primitives/index.js +0 -28
  71. package/lib/victory-primitives/line-segment.js +22 -34
  72. package/lib/victory-primitives/line.js +16 -36
  73. package/lib/victory-primitives/path.js +16 -36
  74. package/lib/victory-primitives/point.js +38 -52
  75. package/lib/victory-primitives/rect.js +16 -36
  76. package/lib/victory-primitives/text.js +15 -33
  77. package/lib/victory-primitives/tspan.js +13 -31
  78. package/lib/victory-primitives/whisker.js +45 -57
  79. package/lib/victory-theme/grayscale.js +23 -24
  80. package/lib/victory-theme/material.js +47 -48
  81. package/lib/victory-theme/victory-theme.js +2 -7
  82. package/lib/victory-transition/victory-transition.js +129 -224
  83. package/lib/victory-util/add-events.js +263 -380
  84. package/lib/victory-util/axis.js +128 -241
  85. package/lib/victory-util/collection.js +13 -50
  86. package/lib/victory-util/data.js +160 -239
  87. package/lib/victory-util/default-transitions.js +33 -54
  88. package/lib/victory-util/domain.js +123 -193
  89. package/lib/victory-util/events.js +167 -274
  90. package/lib/victory-util/helpers.js +156 -207
  91. package/lib/victory-util/hooks/index.js +0 -2
  92. package/lib/victory-util/hooks/use-animation-state.js +63 -113
  93. package/lib/victory-util/hooks/use-previous-props.js +2 -7
  94. package/lib/victory-util/immutable.js +6 -18
  95. package/lib/victory-util/index.js +2 -51
  96. package/lib/victory-util/label-helpers.js +130 -141
  97. package/lib/victory-util/line-helpers.js +31 -49
  98. package/lib/victory-util/log.js +1 -2
  99. package/lib/victory-util/point-path-helpers.js +91 -63
  100. package/lib/victory-util/scale.js +26 -57
  101. package/lib/victory-util/selection.js +41 -49
  102. package/lib/victory-util/style.js +8 -16
  103. package/lib/victory-util/textsize.js +80 -157
  104. package/lib/victory-util/timer-context.js +2 -8
  105. package/lib/victory-util/timer.js +40 -76
  106. package/lib/victory-util/transitions.js +110 -152
  107. package/lib/victory-util/type-helpers.js +2 -9
  108. package/lib/victory-util/user-props.js +25 -59
  109. package/lib/victory-util/wrapper.js +186 -281
  110. package/package.json +2 -2
@@ -12,88 +12,116 @@ exports.square = square;
12
12
  exports.star = star;
13
13
  exports.triangleDown = triangleDown;
14
14
  exports.triangleUp = triangleUp;
15
-
16
15
  var Helpers = _interopRequireWildcard(require("./helpers"));
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
22
18
  /* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 2.5, 3] }]*/
19
+
23
20
  function circle(x, y, size) {
24
- return "M ".concat(x, ", ").concat(y, "\n m ").concat(-size, ", 0\n a ").concat(size, ", ").concat(size, " 0 1,0 ").concat(size * 2, ",0\n a ").concat(size, ", ").concat(size, " 0 1,0 ").concat(-size * 2, ",0");
21
+ return `M ${x}, ${y}
22
+ m ${-size}, 0
23
+ a ${size}, ${size} 0 1,0 ${size * 2},0
24
+ a ${size}, ${size} 0 1,0 ${-size * 2},0`;
25
25
  }
26
-
27
26
  function square(x, y, size) {
28
- var baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
29
-
30
- var x0 = x - baseSize;
31
- var y1 = y + baseSize;
32
- var distance = x + baseSize - x0;
33
- return "M ".concat(x0, ", ").concat(y1, "\n h").concat(distance, "\n v-").concat(distance, "\n h-").concat(distance, "\n z");
27
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
28
+ const x0 = x - baseSize;
29
+ const y1 = y + baseSize;
30
+ const distance = x + baseSize - x0;
31
+ return `M ${x0}, ${y1}
32
+ h${distance}
33
+ v-${distance}
34
+ h-${distance}
35
+ z`;
34
36
  }
35
-
36
37
  function diamond(x, y, size) {
37
- var baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
38
-
39
- var length = Math.sqrt(2 * (baseSize * baseSize));
40
- return "M ".concat(x, ", ").concat(y + length, "\n l ").concat(length, ", -").concat(length, "\n l -").concat(length, ", -").concat(length, "\n l -").concat(length, ", ").concat(length, "\n l ").concat(length, ", ").concat(length, "\n z");
38
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
39
+ const length = Math.sqrt(2 * (baseSize * baseSize));
40
+ return `M ${x}, ${y + length}
41
+ l ${length}, -${length}
42
+ l -${length}, -${length}
43
+ l -${length}, ${length}
44
+ l ${length}, ${length}
45
+ z`;
41
46
  }
42
-
43
47
  function triangleDown(x, y, size) {
44
- var height = size / 2 * Math.sqrt(3);
45
- var x0 = x - size;
46
- var x1 = x + size;
47
- var y0 = y - size;
48
- var y1 = y + height;
49
- return "M ".concat(x0, ", ").concat(y0, "\n L ").concat(x1, ", ").concat(y0, "\n L ").concat(x, ", ").concat(y1, "\n z");
48
+ const height = size / 2 * Math.sqrt(3);
49
+ const x0 = x - size;
50
+ const x1 = x + size;
51
+ const y0 = y - size;
52
+ const y1 = y + height;
53
+ return `M ${x0}, ${y0}
54
+ L ${x1}, ${y0}
55
+ L ${x}, ${y1}
56
+ z`;
50
57
  }
51
-
52
58
  function triangleUp(x, y, size) {
53
- var height = size / 2 * Math.sqrt(3);
54
- var x0 = x - size;
55
- var x1 = x + size;
56
- var y0 = y - height;
57
- var y1 = y + size;
58
- return "M ".concat(x0, ", ").concat(y1, "\n L ").concat(x1, ", ").concat(y1, "\n L ").concat(x, ", ").concat(y0, "\n z");
59
+ const height = size / 2 * Math.sqrt(3);
60
+ const x0 = x - size;
61
+ const x1 = x + size;
62
+ const y0 = y - height;
63
+ const y1 = y + size;
64
+ return `M ${x0}, ${y1}
65
+ L ${x1}, ${y1}
66
+ L ${x}, ${y0}
67
+ z`;
59
68
  }
60
-
61
69
  function plus(x, y, size) {
62
- var baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
63
-
64
- var distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
65
-
66
- return "\n M ".concat(x - distance / 2, ", ").concat(y + baseSize, "\n v-").concat(distance, "\n h-").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h-").concat(distance, "\n v").concat(distance, "\n z");
70
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
71
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
72
+ return `
73
+ M ${x - distance / 2}, ${y + baseSize}
74
+ v-${distance}
75
+ h-${distance}
76
+ v-${distance}
77
+ h${distance}
78
+ v-${distance}
79
+ h${distance}
80
+ v${distance}
81
+ h${distance}
82
+ v${distance}
83
+ h-${distance}
84
+ v${distance}
85
+ z`;
67
86
  }
68
-
69
87
  function cross(x, y, size) {
70
- var baseSize = 0.8 * size; // eslint-disable-line no-magic-numbers
71
-
72
- var distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
73
-
74
- return "\n M ".concat(x - distance / 2, ", ").concat(y + baseSize + distance, "\n v-").concat(distance * 2, "\n h-").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v-").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h").concat(distance, "\n v").concat(distance, "\n h-").concat(distance, "\n v").concat(distance * 2, "\n z");
88
+ const baseSize = 0.8 * size; // eslint-disable-line no-magic-numbers
89
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
90
+ return `
91
+ M ${x - distance / 2}, ${y + baseSize + distance}
92
+ v-${distance * 2}
93
+ h-${distance}
94
+ v-${distance}
95
+ h${distance}
96
+ v-${distance}
97
+ h${distance}
98
+ v${distance}
99
+ h${distance}
100
+ v${distance}
101
+ h-${distance}
102
+ v${distance * 2}
103
+ z`;
75
104
  }
76
-
77
105
  function minus(x, y, size) {
78
- var baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
79
-
80
- var lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
81
-
82
- var x0 = x - baseSize;
83
- var y1 = y + lineHeight / 2;
84
- var distance = x + baseSize - x0;
85
- return "M ".concat(x0, ", ").concat(y1, "\n h").concat(distance, "\n v-").concat(lineHeight, "\n h-").concat(distance, "\n z");
106
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
107
+ const lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
108
+ const x0 = x - baseSize;
109
+ const y1 = y + lineHeight / 2;
110
+ const distance = x + baseSize - x0;
111
+ return `M ${x0}, ${y1}
112
+ h${distance}
113
+ v-${lineHeight}
114
+ h-${distance}
115
+ z`;
86
116
  }
87
-
88
117
  function star(x, y, size) {
89
- var baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
90
-
91
- var angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
118
+ const baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
119
+ const angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
92
120
  // eslint-disable-next-line no-magic-numbers
93
-
94
- var starCoords = Helpers.range(10).map(function (index) {
95
- var length = index % 2 === 0 ? baseSize : baseSize / 2;
96
- return "".concat(length * Math.sin(angle * (index + 1)) + x, ",\n ").concat(length * Math.cos(angle * (index + 1)) + y);
121
+ const starCoords = Helpers.range(10).map(index => {
122
+ const length = index % 2 === 0 ? baseSize : baseSize / 2;
123
+ return `${length * Math.sin(angle * (index + 1)) + x},
124
+ ${length * Math.cos(angle * (index + 1)) + y}`;
97
125
  });
98
- return "M ".concat(starCoords.join("L"), " z");
126
+ return `M ${starCoords.join("L")} z`;
99
127
  }
@@ -10,145 +10,116 @@ exports.getScaleFromProps = getScaleFromProps;
10
10
  exports.getScaleType = getScaleType;
11
11
  exports.getType = getType;
12
12
  exports.validScale = validScale;
13
-
14
13
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
15
-
16
14
  var Helpers = _interopRequireWildcard(require("./helpers"));
17
-
18
15
  var Collection = _interopRequireWildcard(require("./collection"));
19
-
20
16
  var d3Scale = _interopRequireWildcard(require("victory-vendor/d3-scale"));
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ /* eslint-disable no-use-before-define */
27
21
 
28
- var supportedScaleStrings = ["linear", "time", "log", "sqrt"];
29
-
22
+ const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
30
23
  // Private Functions
24
+
31
25
  function toNewName(scale) {
32
26
  // d3 scale changed the naming scheme for scale from "linear" -> "scaleLinear" etc.
33
- var capitalize = function (s) {
34
- return s && s[0].toUpperCase() + s.slice(1);
35
- };
36
-
37
- return "scale".concat(capitalize(scale));
27
+ const capitalize = s => s && s[0].toUpperCase() + s.slice(1);
28
+ return `scale${capitalize(scale)}`;
38
29
  }
39
-
40
30
  function validScale(scale) {
41
31
  if (typeof scale === "function") {
42
32
  return Helpers.isFunction(scale.copy) && Helpers.isFunction(scale.domain) && Helpers.isFunction(scale.range);
43
33
  } else if (typeof scale === "string") {
44
34
  return supportedScaleStrings.includes(scale);
45
35
  }
46
-
47
36
  return false;
48
37
  }
49
-
50
38
  function isScaleDefined(props, axis) {
51
39
  if (!props.scale) {
52
40
  return false;
53
41
  } else if (props.scale.x || props.scale.y) {
54
42
  return !!props.scale[axis];
55
43
  }
56
-
57
44
  return true;
58
45
  }
59
-
60
46
  function getScaleTypeFromProps(props, axis) {
61
47
  if (!isScaleDefined(props, axis)) {
62
48
  return undefined;
63
49
  }
64
-
65
- var scale = props.scale[axis] || props.scale;
50
+ const scale = props.scale[axis] || props.scale;
66
51
  return typeof scale === "string" ? scale : getType(scale);
67
52
  }
68
-
69
53
  function getScaleFromDomain(props, axis) {
70
- var domain;
71
-
54
+ let domain;
72
55
  if (props.domain && props.domain[axis]) {
73
56
  domain = props.domain[axis];
74
57
  } else if (props.domain && Array.isArray(props.domain)) {
75
58
  domain = props.domain;
76
59
  }
77
-
78
60
  if (!domain) {
79
61
  return undefined;
80
62
  }
81
-
82
63
  return Collection.containsDates(domain) ? "time" : "linear";
83
64
  }
84
-
85
65
  function getScaleTypeFromData(props, axis) {
86
66
  if (!props.data) {
87
67
  return "linear";
88
68
  }
89
-
90
- var accessor = Helpers.createAccessor(props[axis]);
91
- var axisData = props.data.map(function (datum) {
92
- var processedData = (0, _isPlainObject2.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
69
+ const accessor = Helpers.createAccessor(props[axis]);
70
+ const axisData = props.data.map(datum => {
71
+ const processedData = (0, _isPlainObject2.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
93
72
  return processedData !== undefined ? processedData : datum[axis];
94
73
  });
95
74
  return Collection.containsDates(axisData) ? "time" : "linear";
96
- } // Exported Functions
75
+ }
97
76
 
77
+ // Exported Functions
98
78
 
99
79
  function getScaleFromName(name) {
100
80
  if (validScale(name)) {
101
- var methodName = toNewName(name); // @ts-expect-error scaleTime is not directly compatible with our D3Scale definition
102
-
81
+ const methodName = toNewName(name);
82
+ // @ts-expect-error scaleTime is not directly compatible with our D3Scale definition
103
83
  return d3Scale[methodName]();
104
84
  }
105
-
106
85
  return d3Scale.scaleLinear();
107
86
  }
108
-
109
87
  function getBaseScale(props, axis) {
110
- var scale = getScaleFromProps(props, axis);
111
-
88
+ const scale = getScaleFromProps(props, axis);
112
89
  if (scale) {
113
90
  return typeof scale === "string" ? getScaleFromName(scale) : scale;
114
91
  }
115
-
116
- var defaultScale = getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
92
+ const defaultScale = getScaleFromDomain(props, axis) || getScaleTypeFromData(props, axis);
117
93
  return getScaleFromName(defaultScale);
118
94
  }
119
-
120
95
  function getDefaultScale() {
121
96
  return d3Scale.scaleLinear();
122
97
  }
123
-
124
98
  function getScaleFromProps(props, axis) {
125
99
  if (!isScaleDefined(props, axis)) {
126
100
  return undefined;
127
101
  }
128
-
129
- var scale = props.scale[axis] || props.scale;
130
-
102
+ const scale = props.scale[axis] || props.scale;
131
103
  if (validScale(scale)) {
132
104
  return Helpers.isFunction(scale) ? scale : getScaleFromName(scale);
133
105
  }
134
-
135
106
  return undefined;
136
107
  }
137
-
138
108
  function getScaleType(props, axis) {
139
109
  // if the scale was not given in props, it will be set to linear or time depending on data
140
110
  return getScaleTypeFromProps(props, axis) || getScaleTypeFromData(props, axis);
141
- } // Ordered type inference off of function fields.
142
- // **Note**: Brittle because reliant on d3 internals.
143
-
111
+ }
144
112
 
145
- var DUCK_TYPES = [{
113
+ // Ordered type inference off of function fields.
114
+ // **Note**: Brittle because reliant on d3 internals.
115
+ const DUCK_TYPES = [{
146
116
  name: "quantile",
147
117
  method: "quantiles"
148
118
  }, {
149
119
  name: "log",
150
120
  method: "base"
151
- } // TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
121
+ }
122
+ // TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
152
123
  // do we need a different approach? (Multiple keys? Stringifying functions?)
153
124
  // https://github.com/FormidableLabs/victory/issues/2214
154
125
  // Below are matches that don't seem to otherwise occur in Victory code base.
@@ -156,13 +127,11 @@ var DUCK_TYPES = [{
156
127
  // { name: "pow-sqrt", method: "exponent" },
157
128
  // { name: "quantize-threshold", method: "invertExtent" }
158
129
  ];
159
-
160
130
  function getType(scale) {
161
131
  if (typeof scale === "string") {
162
132
  return scale;
163
133
  }
164
-
165
- var scaleType = DUCK_TYPES.filter(function (type) {
134
+ const scaleType = DUCK_TYPES.filter(type => {
166
135
  return scale[type.method] !== undefined;
167
136
  })[0];
168
137
  return scaleType ? scaleType.name : undefined;
@@ -8,52 +8,45 @@ exports.getDataCoordinates = getDataCoordinates;
8
8
  exports.getDomainCoordinates = getDomainCoordinates;
9
9
  exports.getParentSVG = getParentSVG;
10
10
  exports.getSVGEventCoordinates = getSVGEventCoordinates;
11
-
12
11
  var Collection = _interopRequireWildcard(require("./collection"));
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
14
  // Private Functions
15
+
19
16
  function transformTarget(target, matrix, dimension) {
20
- var a = matrix.a,
21
- d = matrix.d,
22
- e = matrix.e,
23
- f = matrix.f;
17
+ const {
18
+ a,
19
+ d,
20
+ e,
21
+ f
22
+ } = matrix;
24
23
  return dimension === "y" ? d * target + f : a * target + e;
25
24
  }
26
-
27
25
  function getTransformationMatrix(svg) {
28
26
  return svg.getScreenCTM().inverse();
29
27
  }
30
-
31
28
  function isNativeTouchEvent(nativeEvent) {
32
29
  return !!(nativeEvent && nativeEvent.identifier !== undefined);
33
30
  }
34
-
35
31
  function isReactTouchEvent(evt) {
36
32
  return evt.changedTouches && evt.changedTouches.length > 0;
37
- } // Exported Functions
33
+ }
38
34
 
35
+ // Exported Functions
39
36
 
40
37
  function getParentSVG(evt) {
41
38
  if (isNativeTouchEvent(evt.nativeEvent)) {
42
39
  // @ts-expect-error Seems like a superfluous check.
43
40
  return undefined;
44
41
  }
45
-
46
- var getParent = function (target) {
42
+ const getParent = target => {
47
43
  if (target.nodeName === "svg") {
48
44
  return target;
49
45
  }
50
-
51
46
  return target.parentNode ? getParent(target.parentNode) : target;
52
47
  };
53
-
54
48
  return getParent(evt.target);
55
49
  }
56
-
57
50
  function getSVGEventCoordinates(evt, svg) {
58
51
  if (isNativeTouchEvent(evt.nativeEvent)) {
59
52
  // react-native override. relies on the RN.View being the _exact_ same size as its child SVG.
@@ -63,20 +56,20 @@ function getSVGEventCoordinates(evt, svg) {
63
56
  y: evt.nativeEvent.locationY
64
57
  };
65
58
  }
66
-
67
- var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
68
- var matrix = getTransformationMatrix(svg || getParentSVG(location));
59
+ const location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
60
+ const matrix = getTransformationMatrix(svg || getParentSVG(location));
69
61
  return {
70
62
  x: transformTarget(location.clientX, matrix, "x"),
71
63
  y: transformTarget(location.clientY, matrix, "y")
72
64
  };
73
65
  }
74
-
75
66
  function getDomainCoordinates(props, domain) {
76
- var horizontal = props.horizontal;
77
- var scale = props.scale; // FIXME: add support for DomainTuple: [number, number]
78
-
79
- var domainObj = domain || {
67
+ const {
68
+ horizontal
69
+ } = props;
70
+ const scale = props.scale;
71
+ // FIXME: add support for DomainTuple: [number, number]
72
+ const domainObj = domain || {
80
73
  x: scale.x.domain(),
81
74
  y: scale.y.domain()
82
75
  };
@@ -84,47 +77,46 @@ function getDomainCoordinates(props, domain) {
84
77
  x: horizontal ? [scale.y(domainObj.y[0]), scale.y(domainObj.y[1])] : [scale.x(domainObj.x[0]), scale.x(domainObj.x[1])],
85
78
  y: horizontal ? [scale.x(domainObj.x[0]), scale.x(domainObj.x[1])] : [scale.y(domainObj.y[0]), scale.y(domainObj.y[1])]
86
79
  };
87
- } // eslint-disable-next-line max-params
88
-
80
+ }
89
81
 
82
+ // eslint-disable-next-line max-params
90
83
  function getDataCoordinates(props, scale, x, y) {
91
- var polar = props.polar,
92
- horizontal = props.horizontal;
93
-
84
+ const {
85
+ polar,
86
+ horizontal
87
+ } = props;
94
88
  if (!polar) {
95
89
  return {
96
90
  x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
97
91
  y: horizontal ? scale.y.invert(x) : scale.y.invert(y)
98
92
  };
99
93
  }
100
-
101
- var origin = props.origin || {
94
+ const origin = props.origin || {
102
95
  x: 0,
103
96
  y: 0
104
97
  };
105
- var baseX = x - origin.x;
106
- var baseY = y - origin.y;
107
- var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
108
- var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
98
+ const baseX = x - origin.x;
99
+ const baseY = y - origin.y;
100
+ const radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
101
+ const angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
109
102
  return {
110
103
  x: scale.x.invert(angle),
111
104
  y: scale.y.invert(radius)
112
105
  };
113
106
  }
114
-
115
107
  function getBounds(props) {
116
- var x1 = props.x1,
117
- x2 = props.x2,
118
- y1 = props.y1,
119
- y2 = props.y2,
120
- scale = props.scale;
121
- var point1 = getDataCoordinates(props, scale, x1, y1);
122
- var point2 = getDataCoordinates(props, scale, x2, y2);
123
-
124
- var makeBound = function (a, b) {
108
+ const {
109
+ x1,
110
+ x2,
111
+ y1,
112
+ y2,
113
+ scale
114
+ } = props;
115
+ const point1 = getDataCoordinates(props, scale, x1, y1);
116
+ const point2 = getDataCoordinates(props, scale, x2, y2);
117
+ const makeBound = (a, b) => {
125
118
  return [Collection.getMinValue([a, b]), Collection.getMaxValue([a, b])];
126
119
  };
127
-
128
120
  return {
129
121
  x: makeBound(point1.x, point2.x),
130
122
  y: makeBound(point1.y, point2.y)
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getColorScale = getColorScale;
7
7
  exports.toTransformString = void 0;
8
-
9
8
  /**
10
9
  * Given an object with CSS/SVG transform definitions, return the string value
11
10
  * for use with the `transform` CSS property or SVG attribute. Note that we
@@ -15,32 +14,28 @@ exports.toTransformString = void 0;
15
14
  * @param {Object} obj An object of transform definitions.
16
15
  * @returns {String} The generated transform string.
17
16
  */
18
- var toTransformString = function (obj) {
17
+ const toTransformString = function (obj) {
19
18
  for (var _len = arguments.length, more = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
20
19
  more[_key - 1] = arguments[_key];
21
20
  }
22
-
23
21
  if (more.length > 0) {
24
- return more.reduce(function (memo, currentObj) {
22
+ return more.reduce((memo, currentObj) => {
25
23
  return [memo, toTransformString(currentObj)].join(" ");
26
24
  }, toTransformString(obj)).trim();
27
25
  }
28
-
29
26
  if (obj === undefined || obj === null || typeof obj === "string") {
30
27
  return obj;
31
28
  }
32
-
33
- var transforms = [];
34
-
35
- for (var key in obj) {
29
+ const transforms = [];
30
+ for (const key in obj) {
36
31
  if (obj.hasOwnProperty(key)) {
37
- var value = obj[key];
38
- transforms.push("".concat(key, "(").concat(value, ")"));
32
+ const value = obj[key];
33
+ transforms.push(`${key}(${value})`);
39
34
  }
40
35
  }
41
-
42
36
  return transforms.join(" ").trim();
43
37
  };
38
+
44
39
  /**
45
40
  * Given the name of a color scale, getColorScale will return an array
46
41
  * of 5 hex string values in that color scale. If no 'name' parameter
@@ -48,12 +43,9 @@ var toTransformString = function (obj) {
48
43
  * @param {String} name The name of the color scale to return (optional).
49
44
  * @returns {Array} An array of 5 hex string values composing a color scale.
50
45
  */
51
-
52
-
53
46
  exports.toTransformString = toTransformString;
54
-
55
47
  function getColorScale(name) {
56
- var scales = {
48
+ const scales = {
57
49
  grayscale: ["#cccccc", "#969696", "#636363", "#252525"],
58
50
  qualitative: ["#334D5C", "#45B29D", "#EFC94C", "#E27A3F", "#DF5A49", "#4F7DA1", "#55DBC1", "#EFDA97", "#E2A37F", "#DF948A"],
59
51
  heatmap: ["#428517", "#77D200", "#D6D305", "#EC8E19", "#C92B05"],