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