victory-core 35.11.4 → 36.2.1
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.
- package/dist/victory-core.js +4336 -978
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +9 -2
- package/es/victory-label/victory-label.js +3 -3
- package/es/victory-primitives/point.js +1 -1
- package/es/victory-util/hooks/index.js +2 -0
- package/es/victory-util/hooks/use-animation-state.js +130 -0
- package/es/victory-util/hooks/use-previous-props.js +8 -0
- package/es/victory-util/line-helpers.js +45 -0
- package/es/{victory-primitives/path-helpers.js → victory-util/point-path-helpers.js} +0 -0
- package/es/victory-util/wrapper.js +372 -457
- package/lib/index.d.ts +1 -0
- package/lib/index.js +20 -8
- package/lib/victory-label/victory-label.js +3 -3
- package/lib/victory-primitives/point.js +10 -10
- package/lib/victory-util/hooks/index.js +21 -0
- package/lib/victory-util/hooks/use-animation-state.js +151 -0
- package/lib/victory-util/hooks/use-previous-props.js +22 -0
- package/lib/victory-util/line-helpers.js +56 -0
- package/lib/{victory-primitives/path-helpers.js → victory-util/point-path-helpers.js} +0 -0
- package/lib/victory-util/wrapper.js +389 -446
- package/package.json +2 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -1
- package/src/victory-label/victory-label.js +3 -3
- package/src/victory-primitives/point.js +1 -1
- package/src/victory-util/hooks/index.js +2 -0
- package/src/victory-util/hooks/use-animation-state.js +123 -0
- package/src/victory-util/hooks/use-previous-props.js +9 -0
- package/src/victory-util/line-helpers.js +54 -0
- package/src/{victory-primitives/path-helpers.js → victory-util/point-path-helpers.js} +0 -0
- package/src/victory-util/transitions.js +0 -1
- package/src/victory-util/wrapper.js +422 -518
- package/LICENSE.txt +0 -30
|
@@ -3,7 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.addBinsToParentPropsIfHistogram = addBinsToParentPropsIfHistogram;
|
|
7
|
+
exports.getDataFromChildren = getDataFromChildren;
|
|
8
|
+
exports.getData = getData;
|
|
9
|
+
exports.getWidth = getWidth;
|
|
10
|
+
exports.getDefaultDomainPadding = getDefaultDomainPadding;
|
|
11
|
+
exports.getDomainFromChildren = getDomainFromChildren;
|
|
12
|
+
exports.getDomain = getDomain;
|
|
13
|
+
exports.getScale = getScale;
|
|
14
|
+
exports.getAllEvents = getAllEvents;
|
|
15
|
+
exports.getColor = getColor;
|
|
16
|
+
exports.getStyle = getStyle;
|
|
17
|
+
exports.getChildStyle = getChildStyle;
|
|
18
|
+
exports.getStringsFromCategories = getStringsFromCategories;
|
|
19
|
+
exports.getStringsFromData = getStringsFromData;
|
|
20
|
+
exports.getCategoryAndAxisStringsFromChildren = getCategoryAndAxisStringsFromChildren;
|
|
21
|
+
exports.getStringsFromChildren = getStringsFromChildren;
|
|
22
|
+
exports.getCategories = getCategories;
|
|
7
23
|
|
|
8
24
|
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
9
25
|
|
|
@@ -13,8 +29,6 @@ var _uniqBy2 = _interopRequireDefault(require("lodash/uniqBy"));
|
|
|
13
29
|
|
|
14
30
|
var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
|
|
15
31
|
|
|
16
|
-
var _some2 = _interopRequireDefault(require("lodash/some"));
|
|
17
|
-
|
|
18
32
|
var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
|
|
19
33
|
|
|
20
34
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
@@ -31,8 +45,6 @@ var Axis = _interopRequireWildcard(require("./axis"));
|
|
|
31
45
|
|
|
32
46
|
var Style = _interopRequireWildcard(require("./style"));
|
|
33
47
|
|
|
34
|
-
var Transitions = _interopRequireWildcard(require("./transitions"));
|
|
35
|
-
|
|
36
48
|
var Data = _interopRequireWildcard(require("./data"));
|
|
37
49
|
|
|
38
50
|
var Domain = _interopRequireWildcard(require("./domain"));
|
|
@@ -51,10 +63,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
51
63
|
|
|
52
64
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
65
|
|
|
54
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
66
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
59
67
|
|
|
60
68
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
@@ -63,493 +71,428 @@ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.
|
|
|
63
71
|
|
|
64
72
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
65
73
|
|
|
66
|
-
var
|
|
67
|
-
getData: function (props, childComponents) {
|
|
68
|
-
if (props.data) {
|
|
69
|
-
return Data.getData(props);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
73
|
-
return this.getDataFromChildren(childComponents);
|
|
74
|
-
},
|
|
75
|
-
getDefaultDomainPadding: function (props, axis, childComponents) {
|
|
76
|
-
if (props.polar || axis !== "x") {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
74
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
return child.type && child.type.role && child.type.role === "group";
|
|
82
|
-
});
|
|
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; }
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
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) {
|
|
84
|
+
return child.type && child.type.role === "histogram";
|
|
85
|
+
});
|
|
86
|
+
var allChildrenAreHistograms = someChildrenAreHistograms && children.length && children.every(function (child) {
|
|
87
|
+
return child.type && child.type.role === "histogram";
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (someChildrenAreHistograms && !allChildrenAreHistograms) {
|
|
91
|
+
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
|
+
|
|
95
|
+
|
|
96
|
+
if (!allChildrenAreHistograms) {
|
|
97
|
+
return parentProps;
|
|
98
|
+
}
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
offset = _groupComponent$0$pro.offset,
|
|
90
|
-
children = _groupComponent$0$pro.children;
|
|
100
|
+
var childBins = props.bins || childComponents[0].props.bins; // if we have explicit bins then we don't need to calculate them
|
|
91
101
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
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
|
|
95
112
|
|
|
96
|
-
var
|
|
113
|
+
var getFormattedHistogramData = children[0].type.getFormattedData;
|
|
114
|
+
childBins = getFormattedHistogramData({
|
|
115
|
+
data: combinedData,
|
|
116
|
+
bins: childBins
|
|
117
|
+
}).reduce(function (memo, _ref2, index) {
|
|
118
|
+
var x0 = _ref2.x0,
|
|
119
|
+
x1 = _ref2.x1;
|
|
120
|
+
return index === 0 ? memo.concat([x0, x1]) : memo.concat(x1);
|
|
121
|
+
}, []);
|
|
122
|
+
}
|
|
97
123
|
|
|
98
|
-
|
|
99
|
-
|
|
124
|
+
return _objectSpread({}, parentProps, {
|
|
125
|
+
bins: childBins
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
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
|
|
143
|
+
};
|
|
144
|
+
var stack = 0;
|
|
145
|
+
var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
146
|
+
parentProps = addBinsToParentPropsIfHistogram({
|
|
147
|
+
children: children,
|
|
148
|
+
props: props,
|
|
149
|
+
childComponents: childComponents,
|
|
150
|
+
parentProps: parentProps
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
var iteratee = function (child, childName, parent) {
|
|
154
|
+
var childProps = (0, _assign2.default)({}, child.props, parentProps);
|
|
155
|
+
var childData;
|
|
156
|
+
|
|
157
|
+
if (!Data.isDataComponent(child)) {
|
|
158
|
+
return null;
|
|
159
|
+
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
|
|
160
|
+
child = parent ? _react.default.cloneElement(child, parent.props) : child;
|
|
161
|
+
childData = child.type.getData(childProps);
|
|
162
|
+
} else {
|
|
163
|
+
childData = Data.getData(childProps);
|
|
100
164
|
}
|
|
101
165
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
barWidth = nestedChild.props.barWidth;
|
|
113
|
-
dataLength = firstChild.props.children.length;
|
|
114
|
-
}
|
|
166
|
+
stack += 1;
|
|
167
|
+
return childData.map(function (datum, index) {
|
|
168
|
+
return (0, _assign2.default)({
|
|
169
|
+
_stack: stack,
|
|
170
|
+
_group: index
|
|
171
|
+
}, datum);
|
|
172
|
+
});
|
|
173
|
+
};
|
|
115
174
|
|
|
116
|
-
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
getDomain: function (props, axis, childComponents) {
|
|
122
|
-
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
123
|
-
var propsDomain = Domain.getDomainFromProps(props, axis);
|
|
124
|
-
var domainPadding = this.getDefaultDomainPadding(props, axis, childComponents);
|
|
125
|
-
var domain;
|
|
126
|
-
|
|
127
|
-
if (propsDomain) {
|
|
128
|
-
domain = propsDomain;
|
|
129
|
-
} else {
|
|
130
|
-
var minDomain = Domain.getMinFromProps(props, axis);
|
|
131
|
-
var maxDomain = Domain.getMaxFromProps(props, axis);
|
|
132
|
-
var dataset = (props.data || props.y) && Data.getData(props);
|
|
133
|
-
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
|
|
134
|
-
var childDomain = this.getDomainFromChildren(props, axis, childComponents);
|
|
135
|
-
var min = minDomain || Collection.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
|
|
136
|
-
var max = maxDomain || Collection.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
|
|
137
|
-
domain = Domain.getDomainFromMinMax(min, max);
|
|
138
|
-
}
|
|
175
|
+
var stacked = children.filter(function (c) {
|
|
176
|
+
return c.type && c.type.role === "stack";
|
|
177
|
+
}).length;
|
|
139
178
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
getScale: function (props, axis, childComponents) {
|
|
145
|
-
if (props.data) {
|
|
146
|
-
return Scale.getBaseScale(props, axis);
|
|
147
|
-
}
|
|
179
|
+
var combine = function (memo, val) {
|
|
180
|
+
return memo.concat((0, _uniqBy2.default)(val, "_group"));
|
|
181
|
+
};
|
|
148
182
|
|
|
149
|
-
|
|
183
|
+
var datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
|
|
184
|
+
var group = stacked ? "_group" : "_stack";
|
|
185
|
+
return (0, _values2.default)((0, _groupBy2.default)(datasets, group));
|
|
186
|
+
}
|
|
150
187
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return Scale.getScaleType(sharedProps, axis);
|
|
156
|
-
};
|
|
188
|
+
function getData(props, childComponents) {
|
|
189
|
+
if (props.data) {
|
|
190
|
+
return Data.getData(props);
|
|
191
|
+
}
|
|
157
192
|
|
|
158
|
-
|
|
193
|
+
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
194
|
+
return getDataFromChildren(childComponents);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
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
|
+
seriesLength = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
|
|
203
|
+
groupLength = groupLength || datasets.length;
|
|
204
|
+
var bars = groupLength * seriesLength;
|
|
205
|
+
var barRatio = 0.5;
|
|
206
|
+
return Math.round(barRatio * extent / bars);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getDefaultDomainPadding(props, axis, childComponents) {
|
|
210
|
+
if (props.polar || axis !== "x") {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
159
213
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (!props.animate) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
214
|
+
var groupComponent = childComponents.filter(function (child) {
|
|
215
|
+
return child.type && child.type.role && child.type.role === "group";
|
|
216
|
+
});
|
|
166
217
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.setState((0, _defaults2.default)({
|
|
171
|
-
oldProps: oldProps,
|
|
172
|
-
nextProps: nextProps
|
|
173
|
-
}, props.animate.parentState));
|
|
174
|
-
} else {
|
|
175
|
-
var oldChildren = _react.default.Children.toArray(props.children);
|
|
218
|
+
if (groupComponent.length < 1) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
176
221
|
|
|
177
|
-
|
|
222
|
+
var _groupComponent$0$pro = groupComponent[0].props,
|
|
223
|
+
offset = _groupComponent$0$pro.offset,
|
|
224
|
+
children = _groupComponent$0$pro.children;
|
|
178
225
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
};
|
|
226
|
+
if (!offset) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
183
229
|
|
|
184
|
-
|
|
185
|
-
};
|
|
230
|
+
var firstChild = Array.isArray(children) && children[0];
|
|
186
231
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
232
|
+
if (!firstChild) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
190
235
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
194
|
-
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
195
|
-
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
196
|
-
|
|
197
|
-
this.setState({
|
|
198
|
-
nodesWillExit: _nodesWillExit,
|
|
199
|
-
nodesWillEnter: nodesWillEnter,
|
|
200
|
-
nodesShouldEnter: nodesShouldEnter,
|
|
201
|
-
childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
|
|
202
|
-
oldProps: _nodesWillExit ? props : null,
|
|
203
|
-
nextProps: nextProps,
|
|
204
|
-
continuous: continuous
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
getAllEvents: function (props) {
|
|
209
|
-
var components = ["groupComponent", "containerComponent", "labelComponent"];
|
|
210
|
-
this.componentEvents = Events.getComponentEvents(props, components);
|
|
211
|
-
var events = props.events;
|
|
236
|
+
var barWidth = firstChild.props.barWidth;
|
|
237
|
+
var dataLength = firstChild.props.data && firstChild.props.data.length || 1;
|
|
212
238
|
|
|
213
|
-
|
|
214
|
-
|
|
239
|
+
if (firstChild && firstChild.type.role === "stack") {
|
|
240
|
+
var nestedChild = firstChild.props.children && firstChild.props.children[0];
|
|
215
241
|
|
|
216
|
-
|
|
242
|
+
if (!nestedChild) {
|
|
243
|
+
return undefined;
|
|
217
244
|
}
|
|
218
245
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
var _this = this;
|
|
246
|
+
barWidth = nestedChild.props.barWidth;
|
|
247
|
+
dataLength = firstChild.props.children.length;
|
|
248
|
+
}
|
|
223
249
|
|
|
224
|
-
|
|
225
|
-
|
|
250
|
+
var width = barWidth || getWidth(props, children.length, dataLength);
|
|
251
|
+
return {
|
|
252
|
+
x: width * children.length / 2 + (offset - width * ((children.length - 1) / 2))
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function getDomainFromChildren(props, axis, childComponents) {
|
|
257
|
+
// 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, axis) : 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
|
|
275
|
+
};
|
|
276
|
+
var parentProps = parentData ? (0, _assign2.default)(baseParentProps, {
|
|
277
|
+
data: parentData
|
|
278
|
+
}) : baseParentProps;
|
|
279
|
+
|
|
280
|
+
var iteratee = function (child) {
|
|
281
|
+
var sharedProps = (0, _assign2.default)({}, child.props, parentProps);
|
|
282
|
+
|
|
283
|
+
if (!Domain.isDomainComponent(child)) {
|
|
284
|
+
return null;
|
|
285
|
+
} else if (child.type && (0, _isFunction2.default)(child.type.getDomain)) {
|
|
286
|
+
return child.props && child.type.getDomain(sharedProps, axis);
|
|
287
|
+
} else {
|
|
288
|
+
return Domain.getDomain(sharedProps, axis);
|
|
226
289
|
}
|
|
290
|
+
};
|
|
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);
|
|
295
|
+
return [min, max];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function getDomain(props, axis, childComponents) {
|
|
299
|
+
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
300
|
+
var propsDomain = Domain.getDomainFromProps(props, axis);
|
|
301
|
+
var domainPadding = getDefaultDomainPadding(props, axis, childComponents);
|
|
302
|
+
var domain;
|
|
303
|
+
|
|
304
|
+
if (propsDomain) {
|
|
305
|
+
domain = propsDomain;
|
|
306
|
+
} else {
|
|
307
|
+
var minDomain = Domain.getMinFromProps(props, axis);
|
|
308
|
+
var maxDomain = Domain.getMaxFromProps(props, axis);
|
|
309
|
+
var dataset = (props.data || props.y) && Data.getData(props);
|
|
310
|
+
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
|
|
311
|
+
var childDomain = getDomainFromChildren(props, axis, childComponents);
|
|
312
|
+
var min = minDomain || Collection.getMinValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
|
|
313
|
+
var max = maxDomain || Collection.getMaxValue(_toConsumableArray(dataDomain).concat(_toConsumableArray(childDomain)));
|
|
314
|
+
domain = Domain.getDomainFromMinMax(min, max);
|
|
315
|
+
}
|
|
227
316
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
childrenTransitions: childrenTransitions
|
|
233
|
-
}, _this.state);
|
|
234
|
-
};
|
|
317
|
+
return Domain.formatDomain(domain, (0, _assign2.default)({
|
|
318
|
+
domainPadding: domainPadding
|
|
319
|
+
}, props), axis);
|
|
320
|
+
}
|
|
235
321
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
322
|
+
function getScale(props, axis, childComponents) {
|
|
323
|
+
if (props.data) {
|
|
324
|
+
return Scale.getBaseScale(props, axis);
|
|
325
|
+
}
|
|
239
326
|
|
|
240
|
-
|
|
241
|
-
var getTransitionProps = Transitions.getTransitionPropsFactory(props, state, function (newState) {
|
|
242
|
-
return _this.setState(newState);
|
|
243
|
-
});
|
|
327
|
+
var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
244
328
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
329
|
+
var iteratee = function (child) {
|
|
330
|
+
var sharedProps = (0, _assign2.default)({}, child.props, {
|
|
331
|
+
horizontal: props.horizontal
|
|
332
|
+
});
|
|
333
|
+
return Scale.getScaleType(sharedProps, axis);
|
|
334
|
+
};
|
|
249
335
|
|
|
250
|
-
|
|
251
|
-
getTransitions: getTransitions,
|
|
252
|
-
parentState: parentState
|
|
253
|
-
}, props.animate, child.props.animate);
|
|
254
|
-
},
|
|
255
|
-
getDomainFromChildren: function (props, axis, childComponents) {
|
|
256
|
-
// eslint-disable-line max-statements, complexity, max-len
|
|
257
|
-
var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
258
|
-
var parentData = props.data ? Data.getData(props, axis) : undefined;
|
|
259
|
-
var polar = props.polar,
|
|
260
|
-
startAngle = props.startAngle,
|
|
261
|
-
endAngle = props.endAngle,
|
|
262
|
-
categories = props.categories,
|
|
263
|
-
minDomain = props.minDomain,
|
|
264
|
-
maxDomain = props.maxDomain,
|
|
265
|
-
horizontal = props.horizontal;
|
|
266
|
-
var baseParentProps = {
|
|
267
|
-
horizontal: horizontal,
|
|
268
|
-
polar: polar,
|
|
269
|
-
startAngle: startAngle,
|
|
270
|
-
endAngle: endAngle,
|
|
271
|
-
minDomain: minDomain,
|
|
272
|
-
maxDomain: maxDomain,
|
|
273
|
-
categories: categories
|
|
274
|
-
};
|
|
275
|
-
var parentProps = parentData ? (0, _assign2.default)(baseParentProps, {
|
|
276
|
-
data: parentData
|
|
277
|
-
}) : baseParentProps;
|
|
278
|
-
|
|
279
|
-
var iteratee = function (child) {
|
|
280
|
-
var sharedProps = (0, _assign2.default)({}, child.props, parentProps);
|
|
281
|
-
|
|
282
|
-
if (!Domain.isDomainComponent(child)) {
|
|
283
|
-
return null;
|
|
284
|
-
} else if (child.type && (0, _isFunction2.default)(child.type.getDomain)) {
|
|
285
|
-
return child.props && child.type.getDomain(sharedProps, axis);
|
|
286
|
-
} else {
|
|
287
|
-
return Domain.getDomain(sharedProps, axis);
|
|
288
|
-
}
|
|
289
|
-
};
|
|
336
|
+
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
|
|
290
337
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var max = childDomains.length === 0 ? 1 : Collection.getMaxValue(childDomains);
|
|
294
|
-
return [min, max];
|
|
295
|
-
},
|
|
296
|
-
addBinsToParentPropsIfHistogram: function (_ref) {
|
|
297
|
-
var children = _ref.children,
|
|
298
|
-
props = _ref.props,
|
|
299
|
-
childComponents = _ref.childComponents,
|
|
300
|
-
parentProps = _ref.parentProps;
|
|
301
|
-
var someChildrenAreHistograms = children.some(function (child) {
|
|
302
|
-
return child.type && child.type.role === "histogram";
|
|
303
|
-
});
|
|
304
|
-
var allChildrenAreHistograms = someChildrenAreHistograms && children.length && children.every(function (child) {
|
|
305
|
-
return child.type && child.type.role === "histogram";
|
|
306
|
-
});
|
|
338
|
+
return childScale.length > 1 ? Scale.getScaleFromName("linear") : Scale.getScaleFromName(childScale[0]);
|
|
339
|
+
}
|
|
307
340
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
341
|
+
function getAllEvents(props) {
|
|
342
|
+
var components = ["groupComponent", "containerComponent", "labelComponent"];
|
|
343
|
+
var componentEvents = Events.getComponentEvents(props, components);
|
|
344
|
+
var events = props.events;
|
|
312
345
|
|
|
346
|
+
if (Array.isArray(componentEvents)) {
|
|
347
|
+
events = Array.isArray(props.events) ? componentEvents.concat.apply(componentEvents, _toConsumableArray(props.events)) : componentEvents;
|
|
348
|
+
}
|
|
313
349
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
350
|
+
return events || [];
|
|
351
|
+
}
|
|
317
352
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return memo.concat(child.props.data.map(function (datum) {
|
|
324
|
-
return {
|
|
325
|
-
x: xAccessor(datum)
|
|
326
|
-
};
|
|
327
|
-
}));
|
|
328
|
-
}, []); // use the same function to generate bins as VictoryHistogram but with
|
|
329
|
-
// the combined data from above, then get explicit bins from that
|
|
330
|
-
|
|
331
|
-
var getFormattedHistogramData = children[0].type.getFormattedData;
|
|
332
|
-
childBins = getFormattedHistogramData({
|
|
333
|
-
data: combinedData,
|
|
334
|
-
bins: childBins
|
|
335
|
-
}).reduce(function (memo, _ref2, index) {
|
|
336
|
-
var x0 = _ref2.x0,
|
|
337
|
-
x1 = _ref2.x1;
|
|
338
|
-
return index === 0 ? memo.concat([x0, x1]) : memo.concat(x1);
|
|
339
|
-
}, []);
|
|
340
|
-
}
|
|
353
|
+
function getColor(calculatedProps, child, index) {
|
|
354
|
+
// check for styles first
|
|
355
|
+
var style = calculatedProps.style;
|
|
356
|
+
var colorScale = calculatedProps.colorScale,
|
|
357
|
+
color = calculatedProps.color;
|
|
341
358
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
},
|
|
346
|
-
getDataFromChildren: function (props, childComponents) {
|
|
347
|
-
var polar = props.polar,
|
|
348
|
-
startAngle = props.startAngle,
|
|
349
|
-
endAngle = props.endAngle,
|
|
350
|
-
categories = props.categories,
|
|
351
|
-
minDomain = props.minDomain,
|
|
352
|
-
maxDomain = props.maxDomain;
|
|
353
|
-
var parentProps = {
|
|
354
|
-
polar: polar,
|
|
355
|
-
startAngle: startAngle,
|
|
356
|
-
endAngle: endAngle,
|
|
357
|
-
categories: categories,
|
|
358
|
-
minDomain: minDomain,
|
|
359
|
-
maxDomain: maxDomain
|
|
360
|
-
};
|
|
361
|
-
var stack = 0;
|
|
362
|
-
var children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
363
|
-
parentProps = this.addBinsToParentPropsIfHistogram({
|
|
364
|
-
children: children,
|
|
365
|
-
props: props,
|
|
366
|
-
childComponents: childComponents,
|
|
367
|
-
parentProps: parentProps
|
|
368
|
-
});
|
|
359
|
+
if (style && style.data && style.data.fill) {
|
|
360
|
+
return style.data.fill;
|
|
361
|
+
}
|
|
369
362
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
var childData;
|
|
373
|
-
|
|
374
|
-
if (!Data.isDataComponent(child)) {
|
|
375
|
-
return null;
|
|
376
|
-
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
|
|
377
|
-
child = parent ? _react.default.cloneElement(child, parent.props) : child;
|
|
378
|
-
childData = child.type.getData(childProps);
|
|
379
|
-
} else {
|
|
380
|
-
childData = Data.getData(childProps);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
stack += 1;
|
|
384
|
-
return childData.map(function (datum, index) {
|
|
385
|
-
return (0, _assign2.default)({
|
|
386
|
-
_stack: stack,
|
|
387
|
-
_group: index
|
|
388
|
-
}, datum);
|
|
389
|
-
});
|
|
390
|
-
};
|
|
363
|
+
colorScale = child.props && child.props.colorScale ? child.props.colorScale : colorScale;
|
|
364
|
+
color = child.props && child.props.color ? child.props.color : color;
|
|
391
365
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
366
|
+
if (!colorScale && !color) {
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
395
369
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
370
|
+
var colors = Array.isArray(colorScale) ? colorScale : Style.getColorScale(colorScale);
|
|
371
|
+
return color || colors[index % colors.length];
|
|
372
|
+
}
|
|
399
373
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
getColor: function (calculatedProps, child, index) {
|
|
405
|
-
// check for styles first
|
|
406
|
-
var style = calculatedProps.style;
|
|
407
|
-
var colorScale = calculatedProps.colorScale,
|
|
408
|
-
color = calculatedProps.color;
|
|
409
|
-
|
|
410
|
-
if (style && style.data && style.data.fill) {
|
|
411
|
-
return style.data.fill;
|
|
412
|
-
}
|
|
374
|
+
function getStyle(theme, style, role) {
|
|
375
|
+
var defaultStyle = theme && theme[role] && theme[role].style ? theme[role].style : {};
|
|
376
|
+
return Helpers.getStyles(style, defaultStyle);
|
|
377
|
+
}
|
|
413
378
|
|
|
414
|
-
|
|
415
|
-
|
|
379
|
+
function getChildStyle(child, index, calculatedProps) {
|
|
380
|
+
var style = calculatedProps.style,
|
|
381
|
+
role = calculatedProps.role;
|
|
382
|
+
var childStyle = child.props.style || {};
|
|
416
383
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
384
|
+
if (Array.isArray(childStyle)) {
|
|
385
|
+
return childStyle;
|
|
386
|
+
}
|
|
420
387
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
388
|
+
var childRole = child.type && child.type.role;
|
|
389
|
+
var defaultFill = childRole === "stack" ? undefined : getColor(calculatedProps, child, index);
|
|
390
|
+
var defaultColor = childRole === "line" ? {
|
|
391
|
+
fill: "none",
|
|
392
|
+
stroke: defaultFill
|
|
393
|
+
} : {
|
|
394
|
+
fill: defaultFill
|
|
395
|
+
};
|
|
396
|
+
var dataWidth = role === "stack" ? {} : {
|
|
397
|
+
width: getWidth(calculatedProps)
|
|
398
|
+
};
|
|
399
|
+
var dataStyle = (0, _defaults2.default)({}, childStyle.data, (0, _assign2.default)({}, dataWidth, style.data, defaultColor));
|
|
400
|
+
var labelsStyle = (0, _defaults2.default)({}, childStyle.labels, style.labels);
|
|
401
|
+
return {
|
|
402
|
+
parent: style.parent,
|
|
403
|
+
data: dataStyle,
|
|
404
|
+
labels: labelsStyle
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function getStringsFromCategories(childComponents, axis) {
|
|
409
|
+
var iteratee = function (child) {
|
|
410
|
+
var childProps = child.props || {};
|
|
411
|
+
|
|
412
|
+
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
413
|
+
return null;
|
|
414
|
+
} else {
|
|
415
|
+
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
416
|
+
var categoryStrings = categories && categories.filter(function (val) {
|
|
417
|
+
return typeof val === "string";
|
|
418
|
+
});
|
|
419
|
+
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
446
420
|
}
|
|
421
|
+
};
|
|
447
422
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
var defaultColor = childRole === "line" ? {
|
|
451
|
-
fill: "none",
|
|
452
|
-
stroke: defaultFill
|
|
453
|
-
} : {
|
|
454
|
-
fill: defaultFill
|
|
455
|
-
};
|
|
456
|
-
var dataWidth = role === "stack" ? {} : {
|
|
457
|
-
width: this.getWidth(calculatedProps)
|
|
458
|
-
};
|
|
459
|
-
var dataStyle = (0, _defaults2.default)({}, childStyle.data, (0, _assign2.default)({}, dataWidth, style.data, defaultColor));
|
|
460
|
-
var labelsStyle = (0, _defaults2.default)({}, childStyle.labels, style.labels);
|
|
461
|
-
return {
|
|
462
|
-
parent: style.parent,
|
|
463
|
-
data: dataStyle,
|
|
464
|
-
labels: labelsStyle
|
|
465
|
-
};
|
|
466
|
-
},
|
|
467
|
-
getStringsFromCategories: function (childComponents, axis) {
|
|
468
|
-
var iteratee = function (child) {
|
|
469
|
-
var childProps = child.props || {};
|
|
470
|
-
|
|
471
|
-
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
472
|
-
return null;
|
|
473
|
-
} else {
|
|
474
|
-
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
475
|
-
var categoryStrings = categories && categories.filter(function (val) {
|
|
476
|
-
return typeof val === "string";
|
|
477
|
-
});
|
|
478
|
-
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
479
|
-
}
|
|
480
|
-
};
|
|
423
|
+
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
|
|
424
|
+
}
|
|
481
425
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
var
|
|
486
|
-
var childProps = child.props || {};
|
|
487
|
-
var data;
|
|
488
|
-
|
|
489
|
-
if (!Data.isDataComponent(child)) {
|
|
490
|
-
return null;
|
|
491
|
-
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
|
|
492
|
-
data = child.type.getData(childProps);
|
|
493
|
-
} else {
|
|
494
|
-
data = Data.getData(childProps);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return data.map(function (d) {
|
|
498
|
-
return {
|
|
499
|
-
x: d.xName,
|
|
500
|
-
y: d.yName
|
|
501
|
-
};
|
|
502
|
-
});
|
|
503
|
-
};
|
|
426
|
+
function getStringsFromData(childComponents) {
|
|
427
|
+
var iteratee = function (child) {
|
|
428
|
+
var childProps = child.props || {};
|
|
429
|
+
var data;
|
|
504
430
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
431
|
+
if (!Data.isDataComponent(child)) {
|
|
432
|
+
return null;
|
|
433
|
+
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
|
|
434
|
+
data = child.type.getData(childProps);
|
|
435
|
+
} else {
|
|
436
|
+
data = Data.getData(childProps);
|
|
437
|
+
}
|
|
509
438
|
|
|
510
|
-
|
|
511
|
-
var x = Array.isArray(datum) ? datum.map(function (d) {
|
|
512
|
-
return d.x;
|
|
513
|
-
}).filter(Boolean) : datum.x;
|
|
514
|
-
var y = Array.isArray(datum) ? datum.map(function (d) {
|
|
515
|
-
return d.y;
|
|
516
|
-
}).filter(Boolean) : datum.y;
|
|
439
|
+
return data.map(function (d) {
|
|
517
440
|
return {
|
|
518
|
-
x:
|
|
519
|
-
y:
|
|
441
|
+
x: d.xName,
|
|
442
|
+
y: d.yName
|
|
520
443
|
};
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
var dataStrings = this.getStringsFromData(childComponents);
|
|
537
|
-
return {
|
|
538
|
-
x: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
|
|
539
|
-
y: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
|
|
540
|
-
};
|
|
541
|
-
},
|
|
542
|
-
getCategories: function (props, childComponents, allStrings) {
|
|
543
|
-
var xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
|
|
544
|
-
var yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
|
|
545
|
-
var fallbackRequired = !xPropCategories || !yPropCategories;
|
|
546
|
-
var fallbackProps = fallbackRequired ? allStrings || this.getStringsFromChildren(props, childComponents) : {};
|
|
547
|
-
var xCategories = xPropCategories || fallbackProps.x;
|
|
548
|
-
var yCategories = yPropCategories || fallbackProps.y;
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
var initialMemo = {
|
|
448
|
+
x: [],
|
|
449
|
+
y: []
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
var combine = function (memo, datum) {
|
|
453
|
+
var x = Array.isArray(datum) ? datum.map(function (d) {
|
|
454
|
+
return d.x;
|
|
455
|
+
}).filter(Boolean) : datum.x;
|
|
456
|
+
var y = Array.isArray(datum) ? datum.map(function (d) {
|
|
457
|
+
return d.y;
|
|
458
|
+
}).filter(Boolean) : datum.y;
|
|
549
459
|
return {
|
|
550
|
-
x:
|
|
551
|
-
y:
|
|
460
|
+
x: x !== undefined ? memo.x.concat(x) : memo.x,
|
|
461
|
+
y: y !== undefined ? memo.y.concat(y) : memo.y
|
|
552
462
|
};
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
return Helpers.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
|
|
469
|
+
var categories = (0, _isPlainObject2.default)(props.categories) ? props.categories[axis] : props.categories;
|
|
470
|
+
var axisComponent = Axis.getAxisComponent(childComponents, axis);
|
|
471
|
+
var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
|
|
472
|
+
var categoryStrings = categories || getStringsFromCategories(childComponents, axis);
|
|
473
|
+
return (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function getStringsFromChildren(props, childComponents) {
|
|
477
|
+
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
478
|
+
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", childComponents);
|
|
479
|
+
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
|
|
480
|
+
var dataStrings = getStringsFromData(childComponents);
|
|
481
|
+
return {
|
|
482
|
+
x: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
|
|
483
|
+
y: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function getCategories(props, childComponents, allStrings) {
|
|
488
|
+
var xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
|
|
489
|
+
var yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
|
|
490
|
+
var fallbackRequired = !xPropCategories || !yPropCategories;
|
|
491
|
+
var fallbackProps = fallbackRequired ? allStrings || getStringsFromChildren(props, childComponents) : {};
|
|
492
|
+
var xCategories = xPropCategories || fallbackProps.x;
|
|
493
|
+
var yCategories = yPropCategories || fallbackProps.y;
|
|
494
|
+
return {
|
|
495
|
+
x: xCategories.length > 0 ? xCategories : undefined,
|
|
496
|
+
y: yCategories.length > 0 ? yCategories : undefined
|
|
497
|
+
};
|
|
498
|
+
}
|