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
@@ -20,141 +20,105 @@ exports.getStringsFromChildren = getStringsFromChildren;
20
20
  exports.getStringsFromData = getStringsFromData;
21
21
  exports.getStyle = getStyle;
22
22
  exports.getWidth = getWidth;
23
-
24
23
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
25
-
26
24
  var _uniqBy2 = _interopRequireDefault(require("lodash/uniqBy"));
27
-
28
25
  var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
29
-
30
26
  var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
31
-
32
27
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
33
-
34
28
  var _react = _interopRequireDefault(require("react"));
35
-
36
29
  var Axis = _interopRequireWildcard(require("./axis"));
37
-
38
30
  var Style = _interopRequireWildcard(require("./style"));
39
-
40
31
  var Data = _interopRequireWildcard(require("./data"));
41
-
42
32
  var Domain = _interopRequireWildcard(require("./domain"));
43
-
44
33
  var Events = _interopRequireWildcard(require("./events"));
45
-
46
34
  var Collection = _interopRequireWildcard(require("./collection"));
47
-
48
35
  var Helpers = _interopRequireWildcard(require("./helpers"));
49
-
50
36
  var Scale = _interopRequireWildcard(require("./scale"));
51
-
52
37
  var Log = _interopRequireWildcard(require("./log"));
53
-
54
- 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); }
55
-
56
- 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; }
57
-
38
+ 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); }
39
+ 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; }
58
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
59
-
60
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
61
-
62
- 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."); }
63
-
64
- 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); }
65
-
66
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
67
-
68
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
69
-
70
- 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; }
71
-
72
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
73
-
74
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
75
-
76
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
77
-
78
41
  function addBinsToParentPropsIfHistogram(_ref) {
79
- var children = _ref.children,
80
- props = _ref.props,
81
- childComponents = _ref.childComponents,
82
- parentProps = _ref.parentProps;
83
- var someChildrenAreHistograms = children.some(function (child) {
42
+ let {
43
+ children,
44
+ props,
45
+ childComponents,
46
+ parentProps
47
+ } = _ref;
48
+ const someChildrenAreHistograms = children.some(child => {
84
49
  return child.type && child.type.role === "histogram";
85
50
  });
86
- var allChildrenAreHistograms = someChildrenAreHistograms && children.length && children.every(function (child) {
51
+ const allChildrenAreHistograms = someChildrenAreHistograms && children.length && children.every(child => {
87
52
  return child.type && child.type.role === "histogram";
88
53
  });
89
-
90
54
  if (someChildrenAreHistograms && !allChildrenAreHistograms) {
91
55
  Log.warn("VictoryHistogram only supports being stacked with other VictoryHistogram components. Check to make sure that you are only passing VictoryHistogram components to VictoryStack");
92
- } // if we are stacking histograms, we need to generate explicit bins
93
- // or else each histogram may end up having different bins
94
-
56
+ }
95
57
 
58
+ // if we are stacking histograms, we need to generate explicit bins
59
+ // or else each histogram may end up having different bins
96
60
  if (!allChildrenAreHistograms) {
97
61
  return parentProps;
98
62
  }
63
+ let childBins = props.bins || childComponents[0].props.bins;
99
64
 
100
- var childBins = props.bins || childComponents[0].props.bins; // if we have explicit bins then we don't need to calculate them
101
-
65
+ // if we have explicit bins then we don't need to calculate them
102
66
  if (!Array.isArray(childBins)) {
103
- var combinedData = children.reduce(function (memo, child) {
104
- var xAccessor = Helpers.createAccessor(child.props.x || "x");
105
- return memo.concat(child.props.data.map(function (datum) {
106
- return {
107
- x: xAccessor(datum)
108
- };
109
- }));
110
- }, []); // use the same function to generate bins as VictoryHistogram but with
111
- // the combined data from above, then get explicit bins from that
67
+ const combinedData = children.reduce((memo, child) => {
68
+ const xAccessor = Helpers.createAccessor(child.props.x || "x");
69
+ return memo.concat(child.props.data.map(datum => ({
70
+ x: xAccessor(datum)
71
+ })));
72
+ }, []);
112
73
 
113
- var getFormattedHistogramData = children[0].type.getFormattedData;
74
+ // use the same function to generate bins as VictoryHistogram but with
75
+ // the combined data from above, then get explicit bins from that
76
+ const getFormattedHistogramData = children[0].type.getFormattedData;
114
77
  childBins = getFormattedHistogramData({
115
78
  data: combinedData,
116
79
  bins: childBins
117
- }).reduce(function (memo, _ref2, index) {
118
- var x0 = _ref2.x0,
119
- x1 = _ref2.x1;
80
+ }).reduce((memo, _ref2, index) => {
81
+ let {
82
+ x0,
83
+ x1
84
+ } = _ref2;
120
85
  return index === 0 ? memo.concat([x0, x1]) : memo.concat(x1);
121
86
  }, []);
122
87
  }
123
-
124
- return _objectSpread(_objectSpread({}, parentProps), {}, {
88
+ return {
89
+ ...parentProps,
125
90
  bins: childBins
126
- });
91
+ };
127
92
  }
128
-
129
93
  function getDataFromChildren(props, childComponents) {
130
- var polar = props.polar,
131
- startAngle = props.startAngle,
132
- endAngle = props.endAngle,
133
- categories = props.categories,
134
- minDomain = props.minDomain,
135
- maxDomain = props.maxDomain;
136
- var parentProps = {
137
- polar: polar,
138
- startAngle: startAngle,
139
- endAngle: endAngle,
140
- categories: categories,
141
- minDomain: minDomain,
142
- maxDomain: maxDomain
94
+ const {
95
+ polar,
96
+ startAngle,
97
+ endAngle,
98
+ categories,
99
+ minDomain,
100
+ maxDomain
101
+ } = props;
102
+ let parentProps = {
103
+ polar,
104
+ startAngle,
105
+ endAngle,
106
+ categories,
107
+ minDomain,
108
+ maxDomain
143
109
  };
144
- var stack = 0;
145
- var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
110
+ let stack = 0;
111
+ const children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
146
112
  parentProps = addBinsToParentPropsIfHistogram({
147
- children: children,
148
- props: props,
149
- childComponents: childComponents,
150
- parentProps: parentProps
113
+ children,
114
+ props,
115
+ childComponents,
116
+ parentProps
151
117
  });
152
-
153
- var iteratee = function (child, childName, parent) {
154
- var childProps = Object.assign({}, child.props, parentProps);
155
- var childData;
156
- var childElement = child;
157
-
118
+ const iteratee = (child, childName, parent) => {
119
+ const childProps = Object.assign({}, child.props, parentProps);
120
+ let childData;
121
+ let childElement = child;
158
122
  if (!Data.isDataComponent(child)) {
159
123
  return null;
160
124
  } else if (child.type && Helpers.isFunction(child.type.getData)) {
@@ -163,272 +127,227 @@ function getDataFromChildren(props, childComponents) {
163
127
  } else {
164
128
  childData = Data.getData(childProps);
165
129
  }
166
-
167
130
  stack += 1;
168
- return childData.map(function (datum, index) {
169
- return Object.assign({
170
- _stack: stack,
171
- _group: index
172
- }, datum);
173
- });
174
- };
175
-
176
- var stacked = children.filter(function (c) {
177
- return c.type && c.type.role === "stack";
178
- }).length;
179
-
180
- var combine = function (memo, val) {
181
- return memo.concat((0, _uniqBy2.default)(val, "_group"));
131
+ return childData.map((datum, index) => Object.assign({
132
+ _stack: stack,
133
+ _group: index
134
+ }, datum));
182
135
  };
183
-
184
- var datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
185
- var group = stacked ? "_group" : "_stack";
136
+ const stacked = children.filter(c => c.type && c.type.role === "stack").length;
137
+ const combine = (memo, val) => memo.concat((0, _uniqBy2.default)(val, "_group"));
138
+ const datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
139
+ const group = stacked ? "_group" : "_stack";
186
140
  return Object.values((0, _groupBy2.default)(datasets, group));
187
141
  }
188
-
189
142
  function getData(props, childComponents) {
190
143
  if (props.data) {
191
144
  return Data.getData(props);
192
145
  }
193
-
194
146
  return getDataFromChildren(props, childComponents || _react.default.Children.toArray(props.children));
195
147
  }
196
-
197
148
  function getWidth(props, groupLength, seriesLength) {
198
- var datasets = props.datasets,
199
- horizontal = props.horizontal;
200
- var range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
201
- var extent = Math.abs(range[1] - range[0]);
202
- var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
203
- var groupLengthValue = groupLength || datasets.length;
204
- var bars = groupLengthValue * seriesLengthValue;
205
- var barRatio = 0.5;
149
+ const {
150
+ datasets,
151
+ horizontal
152
+ } = props;
153
+ const range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
154
+ const extent = Math.abs(range[1] - range[0]);
155
+ const seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
156
+ const groupLengthValue = groupLength || datasets.length;
157
+ const bars = groupLengthValue * seriesLengthValue;
158
+ const barRatio = 0.5;
206
159
  return Math.round(barRatio * extent / bars);
207
160
  }
208
-
209
161
  function getDefaultDomainPadding(props, axis, childComponents) {
210
162
  if (props.polar || axis !== "x") {
211
163
  return undefined;
212
164
  }
213
-
214
- var groupComponent = childComponents.filter(function (child) {
165
+ const groupComponent = childComponents.filter(child => {
215
166
  return child.type && child.type.role && child.type.role === "group";
216
167
  });
217
-
218
168
  if (groupComponent.length < 1) {
219
169
  return undefined;
220
170
  }
221
-
222
- var _groupComponent$0$pro = groupComponent[0].props,
223
- offset = _groupComponent$0$pro.offset,
224
- children = _groupComponent$0$pro.children;
225
-
171
+ const {
172
+ offset,
173
+ children
174
+ } = groupComponent[0].props;
226
175
  if (!offset) {
227
176
  return undefined;
228
177
  }
229
-
230
- var firstChild = Array.isArray(children) && children[0];
231
-
178
+ const firstChild = Array.isArray(children) && children[0];
232
179
  if (!firstChild) {
233
180
  return undefined;
234
181
  }
235
-
236
- var barWidth = firstChild.props.barWidth;
237
- var dataLength = firstChild.props.data && firstChild.props.data.length || 1;
238
-
182
+ let barWidth = firstChild.props.barWidth;
183
+ let dataLength = firstChild.props.data && firstChild.props.data.length || 1;
239
184
  if (firstChild && firstChild.type.role === "stack") {
240
- var nestedChild = firstChild.props.children && firstChild.props.children[0];
241
-
185
+ const nestedChild = firstChild.props.children && firstChild.props.children[0];
242
186
  if (!nestedChild) {
243
187
  return undefined;
244
188
  }
245
-
246
189
  barWidth = nestedChild.props.barWidth;
247
190
  dataLength = firstChild.props.children.length;
248
191
  }
249
-
250
- var width = barWidth || getWidth(props, children.length, dataLength);
192
+ const width = barWidth || getWidth(props, children.length, dataLength);
251
193
  return {
252
194
  x: width * children.length / 2 + (offset - width * ((children.length - 1) / 2))
253
195
  };
254
196
  }
255
-
256
197
  function getDomainFromChildren(props, axis, childComponents) {
257
198
  // eslint-disable-line max-statements, complexity, max-len
258
- var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
259
- var parentData = props.data ? Data.getData(props) : undefined;
260
- var polar = props.polar,
261
- startAngle = props.startAngle,
262
- endAngle = props.endAngle,
263
- categories = props.categories,
264
- minDomain = props.minDomain,
265
- maxDomain = props.maxDomain,
266
- horizontal = props.horizontal;
267
- var baseParentProps = {
268
- horizontal: horizontal,
269
- polar: polar,
270
- startAngle: startAngle,
271
- endAngle: endAngle,
272
- minDomain: minDomain,
273
- maxDomain: maxDomain,
274
- categories: categories
199
+ const children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
200
+ const parentData = props.data ? Data.getData(props) : undefined;
201
+ const {
202
+ polar,
203
+ startAngle,
204
+ endAngle,
205
+ categories,
206
+ minDomain,
207
+ maxDomain,
208
+ horizontal
209
+ } = props;
210
+ const baseParentProps = {
211
+ horizontal,
212
+ polar,
213
+ startAngle,
214
+ endAngle,
215
+ minDomain,
216
+ maxDomain,
217
+ categories
275
218
  };
276
- var parentProps = parentData ? Object.assign(baseParentProps, {
219
+ const parentProps = parentData ? Object.assign(baseParentProps, {
277
220
  data: parentData
278
221
  }) : baseParentProps;
279
-
280
- var iteratee = function (child) {
281
- var sharedProps = Object.assign({}, child.props, parentProps);
282
-
222
+ const iteratee = child => {
223
+ const sharedProps = Object.assign({}, child.props, parentProps);
283
224
  if (!Domain.isDomainComponent(child)) {
284
225
  return null;
285
226
  } else if (child.type && Helpers.isFunction(child.type.getDomain)) {
286
227
  return child.props && child.type.getDomain(sharedProps, axis);
287
228
  }
288
-
289
229
  return Domain.getDomain(sharedProps, axis);
290
230
  };
291
-
292
- var childDomains = Helpers.reduceChildren(children, iteratee, props);
293
- var min = childDomains.length === 0 ? 0 : Collection.getMinValue(childDomains);
294
- var max = childDomains.length === 0 ? 1 : Collection.getMaxValue(childDomains);
231
+ const childDomains = Helpers.reduceChildren(children, iteratee, props);
232
+ const min = childDomains.length === 0 ? 0 : Collection.getMinValue(childDomains);
233
+ const max = childDomains.length === 0 ? 1 : Collection.getMaxValue(childDomains);
295
234
  return [min, max];
296
235
  }
297
-
298
236
  function getDomain(props, axis, childComponents) {
299
- var children = childComponents || _react.default.Children.toArray(props.children);
300
-
301
- var propsDomain = Domain.getDomainFromProps(props, axis);
302
- var domainPadding = getDefaultDomainPadding(props, axis, children);
303
- var domain;
304
-
237
+ const children = childComponents || _react.default.Children.toArray(props.children);
238
+ const propsDomain = Domain.getDomainFromProps(props, axis);
239
+ const domainPadding = getDefaultDomainPadding(props, axis, children);
240
+ let domain;
305
241
  if (propsDomain) {
306
242
  domain = propsDomain;
307
243
  } else {
308
- var minDomain = Domain.getMinFromProps(props, axis);
309
- var maxDomain = Domain.getMaxFromProps(props, axis);
310
- var dataset = (props.data || props.y) && Data.getData(props);
311
- var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
312
- var childDomain = getDomainFromChildren(props, axis, children);
313
- var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
314
- var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
244
+ const minDomain = Domain.getMinFromProps(props, axis);
245
+ const maxDomain = Domain.getMaxFromProps(props, axis);
246
+ const dataset = (props.data || props.y) && Data.getData(props);
247
+ const dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
248
+ const childDomain = getDomainFromChildren(props, axis, children);
249
+ const min = minDomain || Collection.getMinValue([...dataDomain, ...childDomain]);
250
+ const max = maxDomain || Collection.getMaxValue([...dataDomain, ...childDomain]);
315
251
  domain = Domain.getDomainFromMinMax(min, max);
316
252
  }
317
-
318
253
  return Domain.formatDomain(domain, Object.assign({
319
- domainPadding: domainPadding
254
+ domainPadding
320
255
  }, props), axis);
321
256
  }
322
-
323
257
  function getScale(props, axis, childComponents) {
324
258
  if (props.data) {
325
259
  return Scale.getBaseScale(props, axis);
326
260
  }
327
-
328
- var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
329
-
330
- var iteratee = function (child) {
331
- var sharedProps = Object.assign({}, child.props, {
261
+ const children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
262
+ const iteratee = child => {
263
+ const sharedProps = Object.assign({}, child.props, {
332
264
  horizontal: props.horizontal
333
265
  });
334
266
  return Scale.getScaleType(sharedProps, axis);
335
267
  };
268
+ const childScale = (0, _uniq2.default)(Helpers.reduceChildren(children, iteratee, props));
336
269
 
337
- var childScale = (0, _uniq2.default)(Helpers.reduceChildren(children, iteratee, props)); // default to linear scale if more than one uniq scale type is given by children
338
-
270
+ // default to linear scale if more than one uniq scale type is given by children
339
271
  return childScale.length > 1 ? Scale.getScaleFromName("linear") : Scale.getScaleFromName(childScale[0]);
340
272
  }
341
-
342
273
  function getAllEvents(props) {
343
- var components = ["groupComponent", "containerComponent", "labelComponent"];
344
- var componentEvents = Events.getComponentEvents(props, components);
345
- var events = props.events;
346
-
274
+ const components = ["groupComponent", "containerComponent", "labelComponent"];
275
+ const componentEvents = Events.getComponentEvents(props, components);
276
+ let events = props.events;
347
277
  if (Array.isArray(componentEvents)) {
348
- events = Array.isArray(props.events) ? componentEvents.concat.apply(componentEvents, _toConsumableArray(props.events)) : componentEvents;
278
+ events = Array.isArray(props.events) ? componentEvents.concat(...props.events) : componentEvents;
349
279
  }
350
-
351
280
  return events || [];
352
281
  }
353
-
354
282
  function getColor(calculatedProps, child, index) {
355
283
  // check for styles first
356
- var style = calculatedProps.style;
357
- var colorScale = calculatedProps.colorScale,
358
- color = calculatedProps.color;
359
-
284
+ const {
285
+ style
286
+ } = calculatedProps;
287
+ let {
288
+ colorScale,
289
+ color
290
+ } = calculatedProps;
360
291
  if (style && style.data && style.data.fill) {
361
292
  return style.data.fill;
362
293
  }
363
-
364
294
  colorScale = child.props && child.props.colorScale ? child.props.colorScale : colorScale;
365
295
  color = child.props && child.props.color ? child.props.color : color;
366
-
367
296
  if (!colorScale && !color) {
368
297
  return undefined;
369
298
  }
370
-
371
- var colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale);
299
+ const colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale);
372
300
  return color || colors[index % colors.length];
373
301
  }
374
-
375
302
  function getStyle(theme, style, role) {
376
- var defaultStyle = theme && theme[role] && theme[role].style ? theme[role].style : {};
303
+ const defaultStyle = theme && theme[role] && theme[role].style ? theme[role].style : {};
377
304
  return Helpers.getStyles(style, defaultStyle);
378
305
  }
379
-
380
306
  function getChildStyle(child, index, calculatedProps) {
381
- var style = calculatedProps.style,
382
- role = calculatedProps.role;
383
- var childStyle = child.props.style || {};
384
-
307
+ const {
308
+ style,
309
+ role
310
+ } = calculatedProps;
311
+ const childStyle = child.props.style || {};
385
312
  if (Array.isArray(childStyle)) {
386
313
  return childStyle;
387
314
  }
388
-
389
- var childRole = child.type && child.type.role;
390
- var defaultFill = childRole === "stack" ? undefined : getColor(calculatedProps, child, index);
391
- var defaultColor = childRole === "line" ? {
315
+ const childRole = child.type && child.type.role;
316
+ const defaultFill = childRole === "stack" ? undefined : getColor(calculatedProps, child, index);
317
+ const defaultColor = childRole === "line" ? {
392
318
  fill: "none",
393
319
  stroke: defaultFill
394
320
  } : {
395
321
  fill: defaultFill
396
322
  };
397
- var dataWidth = role === "stack" ? {} : {
323
+ const dataWidth = role === "stack" ? {} : {
398
324
  width: getWidth(calculatedProps)
399
325
  };
400
- var dataStyle = (0, _defaults2.default)({}, childStyle.data, Object.assign({}, dataWidth, style.data, defaultColor));
401
- var labelsStyle = (0, _defaults2.default)({}, childStyle.labels, style.labels);
402
- return _objectSpread(_objectSpread({}, childStyle), {}, {
326
+ const dataStyle = (0, _defaults2.default)({}, childStyle.data, Object.assign({}, dataWidth, style.data, defaultColor));
327
+ const labelsStyle = (0, _defaults2.default)({}, childStyle.labels, style.labels);
328
+ return {
329
+ ...childStyle,
403
330
  parent: style.parent,
404
331
  data: dataStyle,
405
332
  labels: labelsStyle
406
- });
333
+ };
407
334
  }
408
-
409
335
  function getStringsFromCategories(childComponents, axis) {
410
- var iteratee = function (child) {
411
- var childProps = child.props || {};
412
-
336
+ const iteratee = child => {
337
+ const childProps = child.props || {};
413
338
  if (!Domain.isDomainComponent(child) || !childProps.categories) {
414
339
  return null;
415
340
  }
416
-
417
- var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
418
- var categoryStrings = categories && categories.filter(function (val) {
419
- return typeof val === "string";
420
- });
341
+ const categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
342
+ const categoryStrings = categories && categories.filter(val => typeof val === "string");
421
343
  return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
422
344
  };
423
-
424
345
  return Helpers.reduceChildren(childComponents.slice(0), iteratee);
425
346
  }
426
-
427
347
  function getStringsFromData(childComponents) {
428
- var iteratee = function (child) {
429
- var childProps = child.props || {};
430
- var data;
431
-
348
+ const iteratee = child => {
349
+ const childProps = child.props || {};
350
+ let data;
432
351
  if (!Data.isDataComponent(child)) {
433
352
  return null;
434
353
  } else if (child.type && Helpers.isFunction(child.type.getData)) {
@@ -436,63 +355,49 @@ function getStringsFromData(childComponents) {
436
355
  } else {
437
356
  data = Data.getData(childProps);
438
357
  }
439
-
440
- return data.map(function (d) {
441
- return {
442
- x: d.xName,
443
- y: d.yName
444
- };
445
- });
358
+ return data.map(d => ({
359
+ x: d.xName,
360
+ y: d.yName
361
+ }));
446
362
  };
447
-
448
- var initialMemo = {
363
+ const initialMemo = {
449
364
  x: [],
450
365
  y: []
451
366
  };
452
-
453
- var combine = function (memo, datum) {
454
- var x = Array.isArray(datum) ? datum.map(function (d) {
455
- return d.x;
456
- }).filter(Boolean) : datum.x;
457
- var y = Array.isArray(datum) ? datum.map(function (d) {
458
- return d.y;
459
- }).filter(Boolean) : datum.y;
367
+ const combine = (memo, datum) => {
368
+ const x = Array.isArray(datum) ? datum.map(d => d.x).filter(Boolean) : datum.x;
369
+ const y = Array.isArray(datum) ? datum.map(d => d.y).filter(Boolean) : datum.y;
460
370
  return {
461
371
  x: x !== undefined ? memo.x.concat(x) : memo.x,
462
372
  y: y !== undefined ? memo.y.concat(y) : memo.y
463
373
  };
464
374
  };
465
-
466
375
  return Helpers.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
467
376
  }
468
-
469
377
  function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
470
- var categories = (0, _isPlainObject2.default)(props.categories) ? props.categories[axis] : props.categories;
471
- var axisComponent = Axis.getAxisComponent(childComponents, axis);
472
- var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
473
- var categoryStrings = categories || getStringsFromCategories(childComponents, axis);
474
- return (0, _uniq2.default)([].concat(_toConsumableArray(categoryStrings), _toConsumableArray(axisStrings)).flat());
378
+ const categories = (0, _isPlainObject2.default)(props.categories) ? props.categories[axis] : props.categories;
379
+ const axisComponent = Axis.getAxisComponent(childComponents, axis);
380
+ const axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
381
+ const categoryStrings = categories || getStringsFromCategories(childComponents, axis);
382
+ return (0, _uniq2.default)([...categoryStrings, ...axisStrings].flat());
475
383
  }
476
-
477
384
  function getStringsFromChildren(props, childComponents) {
478
- var children = childComponents || _react.default.Children.toArray(props.children);
479
-
480
- var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
481
- var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
482
- var dataStrings = getStringsFromData(children);
385
+ const children = childComponents || _react.default.Children.toArray(props.children);
386
+ const xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
387
+ const yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
388
+ const dataStrings = getStringsFromData(children);
483
389
  return {
484
- x: (0, _uniq2.default)([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)).flat()),
485
- y: (0, _uniq2.default)([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y)).flat())
390
+ x: (0, _uniq2.default)([...xStrings, ...dataStrings.x].flat()),
391
+ y: (0, _uniq2.default)([...yStrings, ...dataStrings.y].flat())
486
392
  };
487
393
  }
488
-
489
394
  function getCategories(props, childComponents, allStrings) {
490
- var xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
491
- var yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
492
- var fallbackRequired = !xPropCategories || !yPropCategories;
493
- var fallbackProps = fallbackRequired ? allStrings || getStringsFromChildren(props, childComponents) : {};
494
- var xCategories = xPropCategories || fallbackProps.x;
495
- var yCategories = yPropCategories || fallbackProps.y;
395
+ const xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
396
+ const yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
397
+ const fallbackRequired = !xPropCategories || !yPropCategories;
398
+ const fallbackProps = fallbackRequired ? allStrings || getStringsFromChildren(props, childComponents) : {};
399
+ const xCategories = xPropCategories || fallbackProps.x;
400
+ const yCategories = yPropCategories || fallbackProps.y;
496
401
  return {
497
402
  x: xCategories.length > 0 ? xCategories : undefined,
498
403
  y: yCategories.length > 0 ? yCategories : undefined