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
@@ -16,41 +16,17 @@ exports.getTicks = getTicks;
16
16
  exports.isVertical = isVertical;
17
17
  exports.modifyProps = modifyProps;
18
18
  exports.stringTicks = stringTicks;
19
-
20
19
  var _orderBy2 = _interopRequireDefault(require("lodash/orderBy"));
21
-
22
20
  var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
23
-
24
21
  var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
25
-
26
22
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
27
-
28
23
  var _react = _interopRequireDefault(require("react"));
29
-
30
24
  var Collection = _interopRequireWildcard(require("./collection"));
31
-
32
25
  var Domain = _interopRequireWildcard(require("./domain"));
33
-
34
26
  var Helpers = _interopRequireWildcard(require("./helpers"));
35
-
36
- 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); }
37
-
38
- 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; }
39
-
27
+ 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); }
28
+ 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; }
40
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
-
42
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
43
-
44
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
45
-
46
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
47
-
48
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
49
-
50
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
51
-
52
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
53
-
54
30
  /**
55
31
  * Returns the first argument it receives
56
32
  * @param value The value to return
@@ -59,59 +35,55 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
59
35
  function identity(value) {
60
36
  return value;
61
37
  }
38
+
62
39
  /**
63
40
  * Returns the axis (x or y) of a particular axis component
64
41
  * @param {Object} props: the props object.
65
42
  * @param {Boolean} horizontal: true for horizontal charts
66
43
  * @returns {String} the dimension appropriate for the axis given its props
67
44
  */
68
-
69
-
70
45
  function getAxis(props) {
71
- var dependentAxis = props.dependentAxis;
46
+ const {
47
+ dependentAxis
48
+ } = props;
72
49
  return dependentAxis ? "y" : "x";
73
50
  }
51
+
74
52
  /**
75
53
  * Returns all axis components that pass a given predicate
76
54
  * @param {Array} childComponents: an array of children
77
55
  * @param {Function} predicate: a predicate function that will be called with each
78
56
  * @returns {Array} all axis components that pass the given predicate or []
79
57
  */
80
-
81
-
82
58
  function findAxisComponents(childComponents, predicate) {
83
- var predicateFunction = predicate || identity;
84
-
85
- var findAxes = function (children) {
86
- return children.reduce(function (memo, child) {
59
+ const predicateFunction = predicate || identity;
60
+ const findAxes = children => {
61
+ return children.reduce((memo, child) => {
87
62
  if (child.type && child.type.role === "axis" && predicateFunction(child)) {
88
63
  return memo.concat(child);
89
64
  } else if (child.props && child.props.children) {
90
65
  return memo.concat(findAxes(_react.default.Children.toArray(child.props.children)));
91
66
  }
92
-
93
67
  return memo;
94
68
  }, []);
95
69
  };
96
-
97
70
  return findAxes(childComponents);
98
71
  }
72
+
99
73
  /**
100
74
  * Returns a single axis component of the desired axis type (x or y)
101
75
  * @param {Array} childComponents: an array of children
102
76
  * @param {String} axis: desired axis either "x" or "y".
103
77
  * @returns {ReactComponent} an axis component of the desired axis or undefined
104
78
  */
105
-
106
-
107
79
  function getAxisComponent(childComponents, axis) {
108
- var matchesAxis = function (component) {
109
- var type = component.type.getAxis(component.props);
80
+ const matchesAxis = component => {
81
+ const type = component.type.getAxis(component.props);
110
82
  return type === axis;
111
83
  };
112
-
113
84
  return findAxisComponents(childComponents, matchesAxis)[0];
114
85
  }
86
+
115
87
  /**
116
88
  * Returns all axis components of the desired axis type (x or y) along with any
117
89
  * parent components excluding VictoryChart
@@ -119,58 +91,48 @@ function getAxisComponent(childComponents, axis) {
119
91
  * @param {String} type: desired axis either "dependent" or "independent".
120
92
  * @returns {ReactComponent} an axis component of the desired type or undefined
121
93
  */
122
-
123
-
124
94
  function getAxisComponentsWithParent(childComponents, type) {
125
- var matchesType = function (child) {
95
+ const matchesType = child => {
126
96
  return type === "dependent" ? child.props.dependentAxis : !child.props.dependentAxis;
127
97
  };
128
-
129
- var findComponents = function (children) {
130
- return children.reduce(function (memo, child) {
98
+ const findComponents = children => {
99
+ return children.reduce((memo, child) => {
131
100
  if (child.type && child.type.role === "axis" && matchesType(child)) {
132
101
  return memo.concat(child);
133
102
  } else if (child.props && child.props.children) {
134
- var childAxis = findComponents(_react.default.Children.toArray(child.props.children));
103
+ const childAxis = findComponents(_react.default.Children.toArray(child.props.children));
135
104
  return childAxis.length > 0 ? memo.concat(child) : memo;
136
105
  }
137
-
138
106
  return memo;
139
107
  }, []);
140
108
  };
141
-
142
109
  return findComponents(childComponents);
143
110
  }
144
-
145
111
  function getOrigin(domain) {
146
- var getSingleOrigin = function (d) {
147
- var domainMin = Math.min.apply(Math, _toConsumableArray(d));
148
- var domainMax = Math.max.apply(Math, _toConsumableArray(d));
112
+ const getSingleOrigin = d => {
113
+ const domainMin = Math.min(...d);
114
+ const domainMax = Math.max(...d);
149
115
  return domainMax < 0 ? domainMax : Math.max(0, domainMin);
150
116
  };
151
-
152
117
  return {
153
- x: Collection.containsDates(domain.x) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.x))) : getSingleOrigin(domain.x),
154
- y: Collection.containsDates(domain.y) ? new Date(Math.min.apply(Math, _toConsumableArray(domain.y))) : getSingleOrigin(domain.y)
118
+ x: Collection.containsDates(domain.x) ? new Date(Math.min(...domain.x)) : getSingleOrigin(domain.x),
119
+ y: Collection.containsDates(domain.y) ? new Date(Math.min(...domain.y)) : getSingleOrigin(domain.y)
155
120
  };
156
121
  }
157
-
158
122
  function getOriginSign(origin, domain) {
159
- var getSign = function () {
160
- return origin <= 0 && Math.max.apply(Math, _toConsumableArray(domain)) <= 0 ? "negative" : "positive";
123
+ const getSign = () => {
124
+ return origin <= 0 && Math.max(...domain) <= 0 ? "negative" : "positive";
161
125
  };
162
-
163
126
  return Collection.containsDates(domain) ? "positive" : getSign();
164
127
  }
128
+
165
129
  /**
166
130
  * @param {Object} props: axis component props
167
131
  * @returns {Boolean} true when the axis is vertical
168
132
  */
169
-
170
-
171
133
  function isVertical(props) {
172
- var orientation = props.orientation || (props.dependentAxis ? "left" : "bottom");
173
- var vertical = {
134
+ const orientation = props.orientation || (props.dependentAxis ? "left" : "bottom");
135
+ const vertical = {
174
136
  top: false,
175
137
  bottom: false,
176
138
  left: true,
@@ -178,206 +140,152 @@ function isVertical(props) {
178
140
  };
179
141
  return vertical[orientation];
180
142
  }
143
+
181
144
  /**
182
145
  * @param {Object} props: axis component props
183
146
  * @returns {Boolean} true when tickValues contain strings
184
147
  */
185
-
186
-
187
148
  function stringTicks(props) {
188
149
  return props.tickValues !== undefined && Collection.containsStrings(props.tickValues);
189
150
  }
190
-
191
151
  function getDefaultTickFormat(props) {
192
- var tickValues = props.tickValues;
193
- var axis = getAxis(props);
194
- var stringMap = props.stringMap && props.stringMap[axis];
195
- var fallbackFormat = tickValues && !Collection.containsDates(tickValues) ? function (x) {
196
- return x;
197
- } : undefined;
198
-
152
+ const {
153
+ tickValues
154
+ } = props;
155
+ const axis = getAxis(props);
156
+ const stringMap = props.stringMap && props.stringMap[axis];
157
+ const fallbackFormat = tickValues && !Collection.containsDates(tickValues) ? x => x : undefined;
199
158
  if (!stringMap) {
200
- return stringTicks(props) ? function (x, index) {
201
- return tickValues[index];
202
- } : fallbackFormat;
159
+ return stringTicks(props) ? (x, index) => tickValues[index] : fallbackFormat;
203
160
  }
204
-
205
- var invertedStringMap = stringMap && Helpers.invert(stringMap);
206
- var tickValueArray = (0, _orderBy2.default)(Object.values(stringMap), function (n) {
207
- return n;
208
- });
209
- var dataNames = tickValueArray.map(function (tick) {
210
- return invertedStringMap[tick];
211
- }); // string ticks should have one tick of padding at the beginning
212
-
213
- var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
214
- return function (x) {
215
- return dataTicks[x];
216
- };
161
+ const invertedStringMap = stringMap && Helpers.invert(stringMap);
162
+ const tickValueArray = (0, _orderBy2.default)(Object.values(stringMap), n => n);
163
+ const dataNames = tickValueArray.map(tick => invertedStringMap[tick]);
164
+ // string ticks should have one tick of padding at the beginning
165
+ const dataTicks = ["", ...dataNames, ""];
166
+ return x => dataTicks[x];
217
167
  }
218
-
219
168
  function getStringTicks(props) {
220
- var axis = getAxis(props);
221
- var stringMap = props.stringMap && props.stringMap[axis];
222
- var categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis];
223
- var ticksFromCategories = categories && Collection.containsOnlyStrings(categories) ? categories.map(function (tick) {
224
- return stringMap[tick];
225
- }) : undefined;
226
- var ticksFromStringMap = stringMap && Object.values(stringMap);
169
+ const axis = getAxis(props);
170
+ const stringMap = props.stringMap && props.stringMap[axis];
171
+ const categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis];
172
+ const ticksFromCategories = categories && Collection.containsOnlyStrings(categories) ? categories.map(tick => stringMap[tick]) : undefined;
173
+ const ticksFromStringMap = stringMap && Object.values(stringMap);
227
174
  return ticksFromCategories && ticksFromCategories.length !== 0 ? ticksFromCategories : ticksFromStringMap;
228
175
  }
229
-
230
176
  function getTickArray(props) {
231
- var tickValues = props.tickValues,
232
- tickFormat = props.tickFormat;
233
-
234
- if ((tickValues === null || tickValues === void 0 ? void 0 : tickValues.length) === 0) {
177
+ const {
178
+ tickValues,
179
+ tickFormat
180
+ } = props;
181
+ if (tickValues?.length === 0) {
235
182
  return [];
236
183
  }
237
-
238
- var axis = getAxis(props);
239
- var stringMap = props.stringMap && props.stringMap[axis];
240
-
241
- var getTicksFromFormat = function () {
184
+ const axis = getAxis(props);
185
+ const stringMap = props.stringMap && props.stringMap[axis];
186
+ const getTicksFromFormat = () => {
242
187
  if (!tickFormat || !Array.isArray(tickFormat)) {
243
188
  return undefined;
244
189
  }
245
-
246
- return Collection.containsStrings(tickFormat) ? tickFormat.map(function (t, i) {
247
- return i;
248
- }) : tickFormat;
190
+ return Collection.containsStrings(tickFormat) ? tickFormat.map((t, i) => i) : tickFormat;
249
191
  };
250
-
251
- var ticks = tickValues;
252
-
192
+ let ticks = tickValues;
253
193
  if (stringMap) {
254
194
  ticks = getStringTicks(props);
255
195
  }
256
-
257
196
  if (tickValues && Collection.containsStrings(tickValues)) {
258
- ticks = stringMap ? tickValues.map(function (tick) {
259
- return stringMap[tick];
260
- }) : Helpers.range(1, tickValues.length + 1);
197
+ ticks = stringMap ? tickValues.map(tick => stringMap[tick]) : Helpers.range(1, tickValues.length + 1);
261
198
  }
262
-
263
- var tickArray = ticks ? (0, _uniq2.default)(ticks) : getTicksFromFormat();
264
-
265
- var buildTickArray = function (arr) {
266
- var newTickArray = [];
267
- var domain = props.domain && props.domain[axis] || props.domain;
268
-
199
+ const tickArray = ticks ? (0, _uniq2.default)(ticks) : getTicksFromFormat();
200
+ const buildTickArray = arr => {
201
+ const newTickArray = [];
202
+ const domain = props.domain && props.domain[axis] || props.domain;
269
203
  if (arr) {
270
- arr.forEach(function (t, index) {
204
+ arr.forEach((t, index) => {
271
205
  if (Array.isArray(domain)) {
272
206
  if (t >= Collection.getMinValue(domain) && t <= Collection.getMaxValue(domain)) {
273
207
  newTickArray.push({
274
208
  value: t,
275
- index: index
209
+ index
276
210
  });
277
211
  }
278
212
  } else {
279
213
  newTickArray.push({
280
214
  value: t,
281
- index: index
215
+ index
282
216
  });
283
217
  }
284
218
  });
285
219
  return newTickArray;
286
220
  }
287
-
288
221
  return undefined;
289
222
  };
290
-
291
223
  return Array.isArray(tickArray) && tickArray.length ? buildTickArray(tickArray) : undefined;
292
224
  }
293
-
294
225
  function getTickFormat(props, scale) {
295
- var tickFormat = props.tickFormat;
296
- var axis = getAxis(props);
297
- var stringMap = props.stringMap && props.stringMap[axis];
298
-
226
+ const {
227
+ tickFormat
228
+ } = props;
229
+ const axis = getAxis(props);
230
+ const stringMap = props.stringMap && props.stringMap[axis];
299
231
  if (!tickFormat) {
300
- var defaultTickFormat = getDefaultTickFormat(props); // If there is no user-provided tick format, we use d3's tickFormat function
232
+ const defaultTickFormat = getDefaultTickFormat(props);
233
+ // If there is no user-provided tick format, we use d3's tickFormat function
301
234
  // by default. This changed the default formatting for some scale types when
302
235
  // we upgraded to d3-scale@4..
303
-
304
- var scaleTickFormat = scale.tickFormat && Helpers.isFunction(scale.tickFormat) ? scale.tickFormat() : function (x) {
305
- return x;
306
- };
236
+ const scaleTickFormat = scale.tickFormat && Helpers.isFunction(scale.tickFormat) ? scale.tickFormat() : x => x;
307
237
  return defaultTickFormat || scaleTickFormat;
308
238
  } else if (tickFormat && Array.isArray(tickFormat)) {
309
- var tickArray = getTickArray(props);
310
- var tickArrayIndices = tickArray === null || tickArray === void 0 ? void 0 : tickArray.map(function (v) {
311
- return v.index;
312
- });
313
- var filteredTickFormat = tickFormat.filter(function (t, index) {
314
- return tickArrayIndices === null || tickArrayIndices === void 0 ? void 0 : tickArrayIndices.includes(index);
315
- });
316
- return function (x, index) {
317
- return filteredTickFormat[index];
318
- };
239
+ const tickArray = getTickArray(props);
240
+ const tickArrayIndices = tickArray?.map(v => v.index);
241
+ const filteredTickFormat = tickFormat.filter((t, index) => tickArrayIndices?.includes(index));
242
+ return (x, index) => filteredTickFormat[index];
319
243
  } else if (tickFormat && Helpers.isFunction(tickFormat)) {
320
- var applyStringTicks = function (tick, index, ticks) {
321
- var invertedStringMap = Helpers.invert(stringMap);
322
- var stringTickArray = ticks.map(function (t) {
323
- return invertedStringMap[t];
324
- });
244
+ const applyStringTicks = (tick, index, ticks) => {
245
+ const invertedStringMap = Helpers.invert(stringMap);
246
+ const stringTickArray = ticks.map(t => invertedStringMap[t]);
325
247
  return props.tickFormat(invertedStringMap[tick], index, stringTickArray);
326
248
  };
327
-
328
249
  return stringMap ? applyStringTicks : tickFormat;
329
250
  }
330
-
331
- return function (x) {
332
- return x;
333
- };
251
+ return x => x;
334
252
  }
335
-
336
253
  function downsampleTicks(ticks, tickCount) {
337
254
  if (!tickCount || !Array.isArray(ticks) || ticks.length <= tickCount) {
338
255
  return ticks;
339
256
  }
340
-
341
- var k = Math.floor(ticks.length / tickCount);
342
- return ticks.filter(function (d, i) {
343
- return i % k === 0;
344
- });
257
+ const k = Math.floor(ticks.length / tickCount);
258
+ return ticks.filter((d, i) => i % k === 0);
345
259
  }
346
-
347
- function getTicks(props, scale) {
348
- var filterZero = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
349
- var tickCount = props.tickCount;
350
- var tickArray = getTickArray(props);
351
-
352
- if ((tickArray === null || tickArray === void 0 ? void 0 : tickArray.length) === 0) {
260
+ function getTicks(props, scale, filterZero) {
261
+ if (filterZero === void 0) {
262
+ filterZero = false;
263
+ }
264
+ const {
265
+ tickCount
266
+ } = props;
267
+ const tickArray = getTickArray(props);
268
+ if (tickArray?.length === 0) {
353
269
  return [""];
354
270
  }
355
-
356
- var tickValues = tickArray ? tickArray.map(function (v) {
357
- return v.value;
358
- }) : undefined;
359
-
271
+ const tickValues = tickArray ? tickArray.map(v => v.value) : undefined;
360
272
  if (tickValues) {
361
273
  return downsampleTicks(tickValues, tickCount);
362
274
  } else if (scale.ticks && Helpers.isFunction(scale.ticks)) {
363
275
  // eslint-disable-next-line no-magic-numbers
364
- var defaultTickCount = tickCount || 5;
365
- var scaleTicks = scale.ticks(defaultTickCount);
366
- var scaledTickArray = Array.isArray(scaleTicks) && scaleTicks.length ? scaleTicks : scale.domain();
367
- var ticks = downsampleTicks(scaledTickArray, tickCount);
368
-
276
+ const defaultTickCount = tickCount || 5;
277
+ const scaleTicks = scale.ticks(defaultTickCount);
278
+ const scaledTickArray = Array.isArray(scaleTicks) && scaleTicks.length ? scaleTicks : scale.domain();
279
+ const ticks = downsampleTicks(scaledTickArray, tickCount);
369
280
  if (filterZero) {
370
- var filteredTicks = ticks.filter(function (value) {
371
- return value !== 0;
372
- });
281
+ const filteredTicks = ticks.filter(value => value !== 0);
373
282
  return filteredTicks.length ? filteredTicks : ticks;
374
283
  }
375
-
376
284
  return ticks;
377
285
  }
378
-
379
286
  return scale.domain();
380
287
  }
288
+
381
289
  /**
382
290
  * Returns a domain based tickValues
383
291
  * @param {Object} props: the props object
@@ -385,94 +293,73 @@ function getTicks(props, scale) {
385
293
  * @returns {Array} returns a domain from tickValues
386
294
  */
387
295
  // eslint-disable-next-line max-statements
388
-
389
-
390
296
  function getDomainFromData(props, axis) {
391
- var polar = props.polar,
392
- _props$startAngle = props.startAngle,
393
- startAngle = _props$startAngle === void 0 ? 0 : _props$startAngle,
394
- _props$endAngle = props.endAngle,
395
- endAngle = _props$endAngle === void 0 ? 360 : _props$endAngle;
396
- var tickArray = getTickArray(props);
397
- var tickValues = tickArray && (tickArray === null || tickArray === void 0 ? void 0 : tickArray.length) !== 0 ? tickArray.map(function (v) {
398
- return v.value;
399
- }) : undefined;
400
-
297
+ const {
298
+ polar,
299
+ startAngle = 0,
300
+ endAngle = 360
301
+ } = props;
302
+ const tickArray = getTickArray(props);
303
+ const tickValues = tickArray && tickArray?.length !== 0 ? tickArray.map(v => v.value) : undefined;
401
304
  if (!Array.isArray(tickValues)) {
402
305
  return undefined;
403
306
  }
404
-
405
- var minDomain = Domain.getMinFromProps(props, axis);
406
- var maxDomain = Domain.getMaxFromProps(props, axis);
407
- var tickStrings = stringTicks(props);
408
- var ticks = tickValues.map(function (value) {
409
- return Number(value);
410
- });
411
- var defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
412
- var defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
413
- var min = minDomain !== undefined ? minDomain : defaultMin;
414
- var max = maxDomain !== undefined ? maxDomain : defaultMax;
415
- var initialDomain = Domain.getDomainFromMinMax(min, max);
416
- var domain = polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? Domain.getSymmetricDomain(initialDomain, ticks) : initialDomain;
417
-
307
+ const minDomain = Domain.getMinFromProps(props, axis);
308
+ const maxDomain = Domain.getMaxFromProps(props, axis);
309
+ const tickStrings = stringTicks(props);
310
+ const ticks = tickValues.map(value => Number(value));
311
+ const defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
312
+ const defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
313
+ const min = minDomain !== undefined ? minDomain : defaultMin;
314
+ const max = maxDomain !== undefined ? maxDomain : defaultMax;
315
+ const initialDomain = Domain.getDomainFromMinMax(min, max);
316
+ const domain = polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? Domain.getSymmetricDomain(initialDomain, ticks) : initialDomain;
418
317
  if (isVertical(props) && !polar) {
419
318
  domain.reverse();
420
319
  }
421
-
422
320
  return domain;
423
- } // exposed for use by VictoryChart
424
-
321
+ }
425
322
 
323
+ // exposed for use by VictoryChart
426
324
  function getDomain(props, axis) {
427
- var inherentAxis = getAxis(props);
428
-
325
+ const inherentAxis = getAxis(props);
429
326
  if (axis && axis !== inherentAxis) {
430
327
  return undefined;
431
328
  }
432
-
433
329
  return Domain.createDomainFunction(getDomainFromData)(props, inherentAxis);
434
330
  }
435
-
436
331
  function getAxisValue(props, axis) {
437
332
  if (!props.axisValue) {
438
333
  return undefined;
439
334
  }
440
-
441
- var scaleAxis = axis === "x" ? "y" : "x";
442
- var scale = (0, _isObject2.default)(props.scale) && Helpers.isFunction(props.scale[scaleAxis]) ? props.scale[scaleAxis] : undefined;
443
-
335
+ const scaleAxis = axis === "x" ? "y" : "x";
336
+ const scale = (0, _isObject2.default)(props.scale) && Helpers.isFunction(props.scale[scaleAxis]) ? props.scale[scaleAxis] : undefined;
444
337
  if (!scale) {
445
338
  return undefined;
446
339
  }
447
-
448
- var stringMapAxis = axis === "x" ? "y" : "x";
449
- var stringMap = (0, _isObject2.default)(props.stringMap) && props.stringMap[stringMapAxis];
450
- var axisValue = stringMap && typeof props.axisValue === "string" ? stringMap[props.axisValue] : props.axisValue;
340
+ const stringMapAxis = axis === "x" ? "y" : "x";
341
+ const stringMap = (0, _isObject2.default)(props.stringMap) && props.stringMap[stringMapAxis];
342
+ const axisValue = stringMap && typeof props.axisValue === "string" ? stringMap[props.axisValue] : props.axisValue;
451
343
  return scale(axisValue);
452
344
  }
453
-
454
345
  function modifyProps(props, fallbackProps) {
455
346
  if (!(0, _isObject2.default)(props.theme)) {
456
347
  return Helpers.modifyProps(props, fallbackProps, "axis");
457
348
  }
458
-
459
- var role = "axis";
460
-
349
+ let role = "axis";
461
350
  if (props.dependentAxis && props.theme.dependentAxis) {
462
351
  role = "dependentAxis";
463
352
  } else if (!props.dependentAxis && props.theme.independentAxis) {
464
353
  role = "independentAxis";
465
354
  }
466
-
467
355
  if (role === "axis") {
468
356
  return Helpers.modifyProps(props, fallbackProps, "axis");
469
357
  }
470
-
471
- var axisTheme = (0, _defaults2.default)({}, props.theme[role], props.theme.axis);
472
- var theme = Object.assign({}, props.theme, {
358
+ const axisTheme = (0, _defaults2.default)({}, props.theme[role], props.theme.axis);
359
+ const theme = Object.assign({}, props.theme, {
473
360
  axis: axisTheme
474
361
  });
475
362
  return Helpers.modifyProps(Object.assign({}, props, {
476
- theme: theme
363
+ theme
477
364
  }), fallbackProps, "axis");
478
365
  }