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