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.
- package/CHANGELOG.md +6 -0
- package/dist/victory-core.js +4371 -5749
- package/dist/victory-core.min.js +1 -1
- package/es/victory-accessible-group/victory-accessible-group.js +9 -15
- package/es/victory-animation/util.js +28 -47
- package/es/victory-animation/victory-animation.js +51 -67
- package/es/victory-clip-container/victory-clip-container.js +153 -229
- package/es/victory-container/victory-container.js +157 -216
- package/es/victory-label/victory-label.js +246 -323
- package/es/victory-portal/portal-context.js +1 -2
- package/es/victory-portal/portal.js +30 -76
- package/es/victory-portal/victory-portal.js +47 -104
- package/es/victory-primitives/arc.js +44 -47
- package/es/victory-primitives/background.js +14 -17
- package/es/victory-primitives/border.js +20 -24
- package/es/victory-primitives/circle.js +13 -27
- package/es/victory-primitives/clip-path.js +3 -7
- package/es/victory-primitives/line-segment.js +20 -24
- package/es/victory-primitives/line.js +13 -27
- package/es/victory-primitives/path.js +13 -27
- package/es/victory-primitives/point.js +36 -40
- package/es/victory-primitives/rect.js +13 -27
- package/es/victory-primitives/text.js +15 -28
- package/es/victory-primitives/tspan.js +13 -26
- package/es/victory-primitives/whisker.js +43 -47
- package/es/victory-theme/grayscale.js +22 -22
- package/es/victory-theme/material.js +46 -46
- package/es/victory-theme/victory-theme.js +3 -3
- package/es/victory-transition/victory-transition.js +126 -206
- package/es/victory-util/add-events.js +263 -374
- package/es/victory-util/axis.js +126 -222
- package/es/victory-util/collection.js +13 -41
- package/es/victory-util/data.js +159 -214
- package/es/victory-util/default-transitions.js +33 -51
- package/es/victory-util/domain.js +122 -171
- package/es/victory-util/events.js +168 -258
- package/es/victory-util/helpers.js +153 -178
- package/es/victory-util/hooks/use-animation-state.js +61 -99
- package/es/victory-util/hooks/use-previous-props.js +2 -2
- package/es/victory-util/immutable.js +6 -8
- package/es/victory-util/label-helpers.js +128 -130
- package/es/victory-util/line-helpers.js +29 -41
- package/es/victory-util/log.js +1 -1
- package/es/victory-util/point-path-helpers.js +89 -49
- package/es/victory-util/scale.js +24 -42
- package/es/victory-util/selection.js +39 -40
- package/es/victory-util/style.js +8 -13
- package/es/victory-util/textsize.js +80 -154
- package/es/victory-util/timer-context.js +2 -2
- package/es/victory-util/timer.js +40 -76
- package/es/victory-util/transitions.js +110 -150
- package/es/victory-util/type-helpers.js +2 -3
- package/es/victory-util/user-props.js +24 -49
- package/es/victory-util/wrapper.js +184 -247
- package/lib/index.js +0 -30
- package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
- package/lib/victory-animation/util.js +28 -63
- package/lib/victory-animation/victory-animation.js +54 -83
- package/lib/victory-clip-container/victory-clip-container.js +156 -243
- package/lib/victory-container/victory-container.js +160 -232
- package/lib/victory-label/victory-label.js +248 -344
- package/lib/victory-portal/portal-context.js +1 -6
- package/lib/victory-portal/portal.js +31 -81
- package/lib/victory-portal/victory-portal.js +50 -116
- package/lib/victory-primitives/arc.js +48 -57
- package/lib/victory-primitives/background.js +16 -28
- package/lib/victory-primitives/border.js +22 -34
- package/lib/victory-primitives/circle.js +16 -36
- package/lib/victory-primitives/clip-path.js +3 -11
- package/lib/victory-primitives/index.js +0 -28
- package/lib/victory-primitives/line-segment.js +22 -34
- package/lib/victory-primitives/line.js +16 -36
- package/lib/victory-primitives/path.js +16 -36
- package/lib/victory-primitives/point.js +38 -52
- package/lib/victory-primitives/rect.js +16 -36
- package/lib/victory-primitives/text.js +15 -33
- package/lib/victory-primitives/tspan.js +13 -31
- package/lib/victory-primitives/whisker.js +45 -57
- package/lib/victory-theme/grayscale.js +23 -24
- package/lib/victory-theme/material.js +47 -48
- package/lib/victory-theme/victory-theme.js +2 -7
- package/lib/victory-transition/victory-transition.js +129 -224
- package/lib/victory-util/add-events.js +263 -380
- package/lib/victory-util/axis.js +128 -241
- package/lib/victory-util/collection.js +13 -50
- package/lib/victory-util/data.js +160 -239
- package/lib/victory-util/default-transitions.js +33 -54
- package/lib/victory-util/domain.js +123 -193
- package/lib/victory-util/events.js +167 -274
- package/lib/victory-util/helpers.js +156 -207
- package/lib/victory-util/hooks/index.js +0 -2
- package/lib/victory-util/hooks/use-animation-state.js +63 -113
- package/lib/victory-util/hooks/use-previous-props.js +2 -7
- package/lib/victory-util/immutable.js +6 -18
- package/lib/victory-util/index.js +2 -51
- package/lib/victory-util/label-helpers.js +130 -141
- package/lib/victory-util/line-helpers.js +31 -49
- package/lib/victory-util/log.js +1 -2
- package/lib/victory-util/point-path-helpers.js +91 -63
- package/lib/victory-util/scale.js +26 -57
- package/lib/victory-util/selection.js +41 -49
- package/lib/victory-util/style.js +8 -16
- package/lib/victory-util/textsize.js +80 -157
- package/lib/victory-util/timer-context.js +2 -8
- package/lib/victory-util/timer.js +40 -76
- package/lib/victory-util/transitions.js +110 -152
- package/lib/victory-util/type-helpers.js +2 -9
- package/lib/victory-util/user-props.js +25 -59
- package/lib/victory-util/wrapper.js +186 -281
- 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
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
101
|
-
|
|
65
|
+
// if we have explicit bins then we don't need to calculate them
|
|
102
66
|
if (!Array.isArray(childBins)) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return memo.concat(child.props.data.map(
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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(
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
88
|
+
return {
|
|
89
|
+
...parentProps,
|
|
125
90
|
bins: childBins
|
|
126
|
-
}
|
|
91
|
+
};
|
|
127
92
|
}
|
|
128
|
-
|
|
129
93
|
function getDataFromChildren(props, childComponents) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
145
|
-
|
|
110
|
+
let stack = 0;
|
|
111
|
+
const children = childComponents ? childComponents.slice(0) : _react.default.Children.toArray(props.children);
|
|
146
112
|
parentProps = addBinsToParentPropsIfHistogram({
|
|
147
|
-
children
|
|
148
|
-
props
|
|
149
|
-
childComponents
|
|
150
|
-
parentProps
|
|
113
|
+
children,
|
|
114
|
+
props,
|
|
115
|
+
childComponents,
|
|
116
|
+
parentProps
|
|
151
117
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
219
|
+
const parentProps = parentData ? Object.assign(baseParentProps, {
|
|
277
220
|
data: parentData
|
|
278
221
|
}) : baseParentProps;
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
293
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
|
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
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
390
|
-
|
|
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
|
-
|
|
323
|
+
const dataWidth = role === "stack" ? {} : {
|
|
398
324
|
width: getWidth(calculatedProps)
|
|
399
325
|
};
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return
|
|
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
|
-
|
|
411
|
-
|
|
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
|
-
|
|
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
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
454
|
-
|
|
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
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return (0, _uniq2.default)([
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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)([
|
|
485
|
-
y: (0, _uniq2.default)([
|
|
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
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|