victory-core 30.6.1 → 31.2.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/README.md +13 -12
- package/dist/victory-core.js +1083 -842
- package/dist/victory-core.min.js +1 -1
- package/es/victory-animation/victory-animation.js +26 -21
- package/es/victory-label/victory-label.js +8 -2
- package/es/victory-primitives/path-helpers.js +1 -1
- package/es/victory-transition/victory-transition.js +11 -6
- package/es/victory-util/add-events.js +66 -38
- package/es/victory-util/axis.js +35 -9
- package/es/victory-util/data.js +24 -9
- package/es/victory-util/domain.js +15 -7
- package/es/victory-util/events.js +1 -1
- package/es/victory-util/helpers.js +17 -5
- package/es/victory-util/label-helpers.js +3 -5
- package/es/victory-util/textsize.js +20 -20
- package/es/victory-util/transitions.js +16 -16
- package/es/victory-util/wrapper.js +56 -19
- package/lib/victory-animation/victory-animation.js +27 -21
- package/lib/victory-label/victory-label.js +8 -2
- package/lib/victory-primitives/path-helpers.js +1 -1
- package/lib/victory-transition/victory-transition.js +12 -6
- package/lib/victory-util/add-events.js +66 -38
- package/lib/victory-util/axis.js +36 -9
- package/lib/victory-util/data.js +25 -9
- package/lib/victory-util/domain.js +16 -8
- package/lib/victory-util/events.js +1 -1
- package/lib/victory-util/helpers.js +17 -5
- package/lib/victory-util/label-helpers.js +3 -5
- package/lib/victory-util/textsize.js +20 -20
- package/lib/victory-util/transitions.js +16 -16
- package/lib/victory-util/wrapper.js +56 -19
- package/package.json +1 -1
- package/src/victory-animation/util.js +47 -45
- package/src/victory-animation/victory-animation.js +66 -38
- package/src/victory-clip-container/victory-clip-container.js +44 -31
- package/src/victory-container/victory-container.js +35 -21
- package/src/victory-label/victory-label.js +55 -71
- package/src/victory-portal/portal.js +1 -1
- package/src/victory-portal/victory-portal.js +10 -7
- package/src/victory-primitives/arc.js +15 -4
- package/src/victory-primitives/border.js +26 -5
- package/src/victory-primitives/circle.js +14 -3
- package/src/victory-primitives/clip-path.js +2 -7
- package/src/victory-primitives/line-segment.js +28 -5
- package/src/victory-primitives/line.js +15 -2
- package/src/victory-primitives/path-helpers.js +6 -7
- package/src/victory-primitives/point.js +30 -11
- package/src/victory-primitives/rect.js +19 -3
- package/src/victory-primitives/text.js +21 -11
- package/src/victory-primitives/tspan.js +6 -4
- package/src/victory-primitives/whisker.js +13 -6
- package/src/victory-theme/grayscale.js +153 -128
- package/src/victory-theme/material.js +178 -149
- package/src/victory-transition/victory-transition.js +31 -25
- package/src/victory-util/add-events.js +113 -75
- package/src/victory-util/axis.js +89 -35
- package/src/victory-util/collection.js +3 -8
- package/src/victory-util/common-props.js +42 -36
- package/src/victory-util/data.js +78 -43
- package/src/victory-util/domain.js +68 -46
- package/src/victory-util/events.js +129 -112
- package/src/victory-util/helpers.js +36 -16
- package/src/victory-util/immutable.js +12 -7
- package/src/victory-util/label-helpers.js +34 -18
- package/src/victory-util/prop-types.js +11 -23
- package/src/victory-util/scale.js +2 -3
- package/src/victory-util/selection.js +4 -5
- package/src/victory-util/style.js +17 -10
- package/src/victory-util/textsize.js +35 -31
- package/src/victory-util/transitions.js +53 -35
- package/src/victory-util/wrapper.js +112 -56
package/lib/victory-util/axis.js
CHANGED
|
@@ -19,6 +19,8 @@ var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
|
|
|
19
19
|
|
|
20
20
|
var _invert2 = _interopRequireDefault(require("lodash/invert"));
|
|
21
21
|
|
|
22
|
+
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
23
|
+
|
|
22
24
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
23
25
|
|
|
24
26
|
var _identity2 = _interopRequireDefault(require("lodash/identity"));
|
|
@@ -229,8 +231,10 @@ function stringTicks(props) {
|
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
function getDefaultTickFormat(props) {
|
|
232
|
-
var tickValues = props.tickValues
|
|
233
|
-
|
|
234
|
+
var tickValues = props.tickValues;
|
|
235
|
+
var axis = getAxis(props);
|
|
236
|
+
var currentAxis = getCurrentAxis(axis, props.horizontal);
|
|
237
|
+
var stringMap = props.stringMap && props.stringMap[currentAxis];
|
|
234
238
|
var fallbackFormat = tickValues && !_collection.default.containsDates(tickValues) ? function (x) {
|
|
235
239
|
return x;
|
|
236
240
|
} : undefined;
|
|
@@ -256,8 +260,10 @@ function getDefaultTickFormat(props) {
|
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
function getTickFormat(props, scale) {
|
|
259
|
-
var tickFormat = props.tickFormat
|
|
260
|
-
|
|
263
|
+
var tickFormat = props.tickFormat;
|
|
264
|
+
var axis = getAxis(props);
|
|
265
|
+
var currentAxis = getCurrentAxis(axis, props.horizontal);
|
|
266
|
+
var stringMap = props.stringMap && props.stringMap[currentAxis];
|
|
261
267
|
|
|
262
268
|
if (!tickFormat) {
|
|
263
269
|
var defaultTickFormat = getDefaultTickFormat(props);
|
|
@@ -287,8 +293,9 @@ function getTickFormat(props, scale) {
|
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
function getStringTicks(props) {
|
|
290
|
-
var stringMap = props.stringMap;
|
|
291
296
|
var axis = getAxis(props);
|
|
297
|
+
var currentAxis = getCurrentAxis(axis, props.horizontal);
|
|
298
|
+
var stringMap = props.stringMap && props.stringMap[currentAxis];
|
|
292
299
|
var categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis];
|
|
293
300
|
var ticksFromCategories = categories && _collection.default.containsOnlyStrings(categories) ? categories.map(function (tick) {
|
|
294
301
|
return stringMap[tick];
|
|
@@ -299,8 +306,10 @@ function getStringTicks(props) {
|
|
|
299
306
|
|
|
300
307
|
function getTickArray(props) {
|
|
301
308
|
var tickValues = props.tickValues,
|
|
302
|
-
tickFormat = props.tickFormat
|
|
303
|
-
|
|
309
|
+
tickFormat = props.tickFormat;
|
|
310
|
+
var axis = getAxis(props);
|
|
311
|
+
var currentAxis = getCurrentAxis(axis, props.horizontal);
|
|
312
|
+
var stringMap = props.stringMap && props.stringMap[currentAxis];
|
|
304
313
|
|
|
305
314
|
var getTicksFromFormat = function () {
|
|
306
315
|
if (!tickFormat || !Array.isArray(tickFormat)) {
|
|
@@ -327,7 +336,6 @@ function getTickArray(props) {
|
|
|
327
336
|
var tickArray = ticks ? (0, _uniq2.default)(ticks) : getTicksFromFormat(props);
|
|
328
337
|
|
|
329
338
|
var filterArray = function (arr) {
|
|
330
|
-
var axis = getAxis(props);
|
|
331
339
|
var domain = props.domain && props.domain[axis] || props.domain;
|
|
332
340
|
return Array.isArray(domain) ? arr.filter(function (t) {
|
|
333
341
|
return t >= Math.min.apply(Math, _toConsumableArray(domain)) && t <= Math.max.apply(Math, _toConsumableArray(domain));
|
|
@@ -427,6 +435,24 @@ function getDomain(props, axis) {
|
|
|
427
435
|
return _domain.default.createDomainFunction(getDomainFromData)(props, inherentAxis);
|
|
428
436
|
}
|
|
429
437
|
|
|
438
|
+
function getAxisValue(props, axis) {
|
|
439
|
+
if (!props.axisValue) {
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
var scaleAxis = axis === "x" ? "y" : "x";
|
|
444
|
+
var scale = (0, _isObject2.default)(props.scale) && (0, _isFunction2.default)(props.scale[scaleAxis]) ? props.scale[scaleAxis] : undefined;
|
|
445
|
+
|
|
446
|
+
if (!scale) {
|
|
447
|
+
return undefined;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
var stringMapAxis = getCurrentAxis(axis, props.horizontal) === "x" ? "y" : "x";
|
|
451
|
+
var stringMap = (0, _isObject2.default)(props.stringMap) && props.stringMap[stringMapAxis];
|
|
452
|
+
var axisValue = stringMap && typeof props.axisValue === "string" ? stringMap[props.axisValue] : props.axisValue;
|
|
453
|
+
return scale(axisValue);
|
|
454
|
+
}
|
|
455
|
+
|
|
430
456
|
var _default = {
|
|
431
457
|
getTicks: getTicks,
|
|
432
458
|
getTickFormat: getTickFormat,
|
|
@@ -440,6 +466,7 @@ var _default = {
|
|
|
440
466
|
getOriginSign: getOriginSign,
|
|
441
467
|
getDomain: getDomain,
|
|
442
468
|
isVertical: isVertical,
|
|
443
|
-
stringTicks: stringTicks
|
|
469
|
+
stringTicks: stringTicks,
|
|
470
|
+
getAxisValue: getAxisValue
|
|
444
471
|
};
|
|
445
472
|
exports.default = _default;
|
package/lib/victory-util/data.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _includes2 = _interopRequireDefault(require("lodash/includes"));
|
|
9
9
|
|
|
10
|
+
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
|
+
|
|
10
12
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
11
13
|
|
|
12
14
|
var _orderBy2 = _interopRequireDefault(require("lodash/orderBy"));
|
|
@@ -127,12 +129,19 @@ function getEventKey(key) {
|
|
|
127
129
|
|
|
128
130
|
|
|
129
131
|
function addEventKeys(props, data) {
|
|
132
|
+
var hasEventKeyAccessor = !!props.eventKey;
|
|
130
133
|
var eventKeyAccessor = getEventKey(props.eventKey);
|
|
131
|
-
return data.map(function (datum
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
return data.map(function (datum) {
|
|
135
|
+
if (datum.eventKey !== undefined) {
|
|
136
|
+
return datum;
|
|
137
|
+
} else if (hasEventKeyAccessor) {
|
|
138
|
+
var eventKey = eventKeyAccessor(datum);
|
|
139
|
+
return eventKey !== undefined ? (0, _assign2.default)({
|
|
140
|
+
eventKey: eventKey
|
|
141
|
+
}, datum) : datum;
|
|
142
|
+
} else {
|
|
143
|
+
return datum;
|
|
144
|
+
}
|
|
136
145
|
});
|
|
137
146
|
} // Exported Functions
|
|
138
147
|
|
|
@@ -199,7 +208,8 @@ function formatData(dataset, props, expectedKeys) {
|
|
|
199
208
|
return [];
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
|
|
211
|
+
var defaultKeys = ["x", "y", "y0"];
|
|
212
|
+
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys;
|
|
203
213
|
var stringMap = {
|
|
204
214
|
x: expectedKeys.indexOf("x") !== -1 ? createStringMap(props, "x") : undefined,
|
|
205
215
|
y: expectedKeys.indexOf("y") !== -1 ? createStringMap(props, "y") : undefined,
|
|
@@ -214,7 +224,8 @@ function formatData(dataset, props, expectedKeys) {
|
|
|
214
224
|
memo[type] = createAccessor(type);
|
|
215
225
|
return memo;
|
|
216
226
|
}, {});
|
|
217
|
-
var
|
|
227
|
+
var preformattedData = (0, _isEqual2.default)(expectedKeys, defaultKeys) && props.x === "_x" && props.y === "_y" && props.y0 === "_y0";
|
|
228
|
+
var data = preformattedData ? dataset : dataset.reduce(function (dataArr, datum, index) {
|
|
218
229
|
// eslint-disable-line complexity
|
|
219
230
|
datum = parseDatum(datum);
|
|
220
231
|
var fallbackValues = {
|
|
@@ -348,9 +359,14 @@ function getStringsFromData(props, axis) {
|
|
|
348
359
|
|
|
349
360
|
var key = props[axis] === undefined ? axis : props[axis];
|
|
350
361
|
|
|
351
|
-
var accessor = _helpers.default.createAccessor(key);
|
|
362
|
+
var accessor = _helpers.default.createAccessor(key); // support immutable data
|
|
363
|
+
|
|
352
364
|
|
|
353
|
-
var
|
|
365
|
+
var data = props.data.reduce(function (memo, d) {
|
|
366
|
+
memo.push(parseDatum(d));
|
|
367
|
+
return memo;
|
|
368
|
+
}, []);
|
|
369
|
+
var sortedData = sortData(data, props.sortKey, props.sortOrder);
|
|
354
370
|
var dataStrings = sortedData.reduce(function (dataArr, datum) {
|
|
355
371
|
datum = parseDatum(datum);
|
|
356
372
|
dataArr.push(accessor(datum));
|
|
@@ -333,28 +333,36 @@ function getDomainWithZero(props, axis) {
|
|
|
333
333
|
return propsDomain;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
+
var dataset = _data.default.getData(props);
|
|
337
|
+
|
|
338
|
+
var y0Min = dataset.reduce(function (min, datum) {
|
|
339
|
+
return datum._y0 < min ? datum._y0 : min;
|
|
340
|
+
}, Infinity);
|
|
341
|
+
|
|
336
342
|
var ensureZero = function (domain) {
|
|
337
343
|
var currentAxis = _helpers.default.getCurrentAxis(axis, props.horizontal);
|
|
338
344
|
|
|
339
|
-
var minDomain = getMinFromProps(props, axis);
|
|
340
|
-
var maxDomain = getMaxFromProps(props, axis);
|
|
341
|
-
|
|
342
345
|
if (currentAxis === "x") {
|
|
343
346
|
return domain;
|
|
344
347
|
}
|
|
345
348
|
|
|
346
|
-
var defaultMin =
|
|
347
|
-
var
|
|
348
|
-
var
|
|
349
|
-
var max =
|
|
349
|
+
var defaultMin = y0Min !== Infinity ? y0Min : 0;
|
|
350
|
+
var maxDomainProp = getMaxFromProps(props, axis);
|
|
351
|
+
var minDomainProp = getMinFromProps(props, axis);
|
|
352
|
+
var max = maxDomainProp !== undefined ? maxDomainProp : _collection.default.getMaxValue(domain, defaultMin);
|
|
353
|
+
var min = minDomainProp !== undefined ? minDomainProp : _collection.default.getMinValue(domain, defaultMin);
|
|
350
354
|
return getDomainFromMinMax(min, max);
|
|
351
355
|
};
|
|
352
356
|
|
|
357
|
+
var getDomainFunction = function () {
|
|
358
|
+
return getDomainFromData(props, axis, dataset);
|
|
359
|
+
};
|
|
360
|
+
|
|
353
361
|
var formatDomainFunction = function (domain) {
|
|
354
362
|
return formatDomain(ensureZero(domain), props, axis);
|
|
355
363
|
};
|
|
356
364
|
|
|
357
|
-
return createDomainFunction(
|
|
365
|
+
return createDomainFunction(getDomainFunction, formatDomainFunction)(props, axis);
|
|
358
366
|
}
|
|
359
367
|
/**
|
|
360
368
|
* Returns the maxDomain from props if it exists
|
|
@@ -427,7 +427,7 @@ var _default = {
|
|
|
427
427
|
|
|
428
428
|
/* Returns an array of defaultEvents from sub-components of a given component.
|
|
429
429
|
* i.e. any static `defaultEvents` on `labelComponent` will be returned
|
|
430
|
-
|
|
430
|
+
*/
|
|
431
431
|
getComponentEvents: function (props, components) {
|
|
432
432
|
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
|
|
433
433
|
var _memo;
|
|
@@ -177,11 +177,11 @@ function evaluateStyle(style, data, active) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
function degreesToRadians(degrees) {
|
|
180
|
-
return degrees * (Math.PI / 180);
|
|
180
|
+
return typeof degrees === "number" ? degrees * (Math.PI / 180) : degrees;
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
function radiansToDegrees(radians) {
|
|
184
|
-
return radians / (Math.PI / 180);
|
|
184
|
+
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
function getRadius(props) {
|
|
@@ -262,12 +262,21 @@ function getCurrentAxis(axis, horizontal) {
|
|
|
262
262
|
* @param {Array} children: an array of child components
|
|
263
263
|
* @param {Function} iteratee: a function with arguments "child", "childName", and "parent"
|
|
264
264
|
* @param {Object} parentProps: props from the parent that are applied to children
|
|
265
|
+
* @param {any} initialMemo: The object in which the iteration results are combined.
|
|
266
|
+
* @param {Function} combine: Combines the result of the iteratee with the current memo
|
|
267
|
+
* to the memo for the next iteration step
|
|
265
268
|
* @returns {Array} returns an array of results from calling the iteratee on all nested children
|
|
266
269
|
*/
|
|
267
270
|
|
|
271
|
+
/* eslint-disable max-params */
|
|
272
|
+
|
|
268
273
|
|
|
269
274
|
function reduceChildren(children, iteratee) {
|
|
270
275
|
var parentProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
276
|
+
var initialMemo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
277
|
+
var combine = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function (memo, item) {
|
|
278
|
+
return memo.concat(item);
|
|
279
|
+
};
|
|
271
280
|
var sharedProps = ["data", "domain", "categories", "polar", "startAngle", "endAngle", "minDomain", "maxDomain"];
|
|
272
281
|
|
|
273
282
|
var traverseChildren = function (childArray, names, parent) {
|
|
@@ -287,14 +296,17 @@ function reduceChildren(children, iteratee) {
|
|
|
287
296
|
});
|
|
288
297
|
|
|
289
298
|
var nestedResults = traverseChildren(nestedChildren, _childNames, child);
|
|
290
|
-
memo = memo
|
|
299
|
+
memo = combine(memo, nestedResults);
|
|
291
300
|
} else {
|
|
292
301
|
var result = iteratee(child, childName, parent);
|
|
293
|
-
|
|
302
|
+
|
|
303
|
+
if (result) {
|
|
304
|
+
memo = combine(memo, result);
|
|
305
|
+
}
|
|
294
306
|
}
|
|
295
307
|
|
|
296
308
|
return memo;
|
|
297
|
-
},
|
|
309
|
+
}, initialMemo);
|
|
298
310
|
};
|
|
299
311
|
|
|
300
312
|
var childNames = children.map(function (c, i) {
|
|
@@ -111,14 +111,12 @@ function getLabelPlacement(props) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
function getPolarOrientation(degrees) {
|
|
114
|
+
// eslint-disable-next-line no-magic-numbers
|
|
114
115
|
if (degrees < 45 || degrees > 315) {
|
|
115
|
-
// eslint-disable-line no-magic-numbers
|
|
116
|
-
return "right";
|
|
116
|
+
return "right"; // eslint-disable-next-line no-magic-numbers
|
|
117
117
|
} else if (degrees >= 45 && degrees <= 135) {
|
|
118
|
-
// eslint-disable-line no-magic-numbers
|
|
119
|
-
return "top";
|
|
118
|
+
return "top"; // eslint-disable-next-line no-magic-numbers
|
|
120
119
|
} else if (degrees > 135 && degrees < 225) {
|
|
121
|
-
// eslint-disable-line no-magic-numbers
|
|
122
120
|
return "left";
|
|
123
121
|
} else {
|
|
124
122
|
return "bottom";
|
|
@@ -21,39 +21,39 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|
|
21
21
|
|
|
22
22
|
var fontDictionary = {
|
|
23
23
|
"American Typewriter": 2.09,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
Baskerville: 2.51,
|
|
25
|
+
Georgia: 2.27,
|
|
26
26
|
"Hoefler Text": 2.39,
|
|
27
|
-
|
|
27
|
+
Palatino: 2.26,
|
|
28
28
|
"Times New Roman": 2.48,
|
|
29
|
-
|
|
29
|
+
Arial: 2.26,
|
|
30
30
|
"Gill Sans": 2.47,
|
|
31
31
|
"Gill Sans 300": 2.58,
|
|
32
32
|
"Helvetica Neue": 2.24,
|
|
33
33
|
"Lucida Grande": 2.05,
|
|
34
|
-
|
|
34
|
+
Tahoma: 2.25,
|
|
35
35
|
"Trebuchet MS": 2.2,
|
|
36
|
-
|
|
36
|
+
Verdana: 1.96,
|
|
37
37
|
"Courier New": 1.67,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
cursive: 1.84,
|
|
39
|
+
fantasy: 2.09,
|
|
40
|
+
monospace: 1.81,
|
|
41
|
+
serif: 2.04,
|
|
42
42
|
"sans-serif": 1.89
|
|
43
43
|
}; //https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
44
44
|
// Absolute sizes in pixels for obsolete measurement units.
|
|
45
45
|
|
|
46
46
|
var absoluteMeasurementUnitsToPixels = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
mm: 3.8,
|
|
48
|
+
sm: 38,
|
|
49
|
+
pt: 1.33,
|
|
50
|
+
pc: 16,
|
|
51
|
+
in: 96,
|
|
52
|
+
px: 1
|
|
53
53
|
};
|
|
54
54
|
var relativeMeasurementUnitsCoef = {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
em: 1,
|
|
56
|
+
ex: 0.5
|
|
57
57
|
};
|
|
58
58
|
var coefficients = {
|
|
59
59
|
averageFontConstant: 2.1675,
|
|
@@ -98,7 +98,7 @@ var _getSizeWithRotate = function (axisSize, dependentSize, angle) {
|
|
|
98
98
|
* @param {string} length Css length string value.
|
|
99
99
|
* @param {number} fontSize Current text font-size.
|
|
100
100
|
* @returns {number} Approximate Css length in pixels.
|
|
101
|
-
*/
|
|
101
|
+
*/
|
|
102
102
|
|
|
103
103
|
|
|
104
104
|
var convertLengthToPixels = function (length, fontSize) {
|
|
@@ -171,7 +171,7 @@ var _approximateTextHeightInternal = function (text, style) {
|
|
|
171
171
|
* @param {number} style.characterConstant Average pixels per glyph.
|
|
172
172
|
* @param {number} style.lineHeight Line height coefficient.
|
|
173
173
|
* @returns {number} Approximate text label height.
|
|
174
|
-
*/
|
|
174
|
+
*/
|
|
175
175
|
|
|
176
176
|
|
|
177
177
|
var approximateTextSize = function (text, style) {
|
|
@@ -141,10 +141,10 @@ function getInitialChildProps(animate, data) {
|
|
|
141
141
|
return (0, _assign2.default)({}, datum, after(datum, idx, data));
|
|
142
142
|
})
|
|
143
143
|
};
|
|
144
|
-
}
|
|
144
|
+
} // eslint-disable-next-line max-params
|
|
145
|
+
|
|
145
146
|
|
|
146
147
|
function getChildBeforeLoad(animate, child, data, cb) {
|
|
147
|
-
// eslint-disable-line max-params
|
|
148
148
|
animate = (0, _assign2.default)({}, animate, {
|
|
149
149
|
onEnd: cb
|
|
150
150
|
});
|
|
@@ -166,10 +166,10 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
166
166
|
data: data,
|
|
167
167
|
clipWidth: 0
|
|
168
168
|
};
|
|
169
|
-
}
|
|
169
|
+
} // eslint-disable-next-line max-params
|
|
170
|
+
|
|
170
171
|
|
|
171
172
|
function getChildOnLoad(animate, data, cb) {
|
|
172
|
-
// eslint-disable-line max-params
|
|
173
173
|
animate = (0, _assign2.default)({}, animate, {
|
|
174
174
|
onEnd: cb
|
|
175
175
|
});
|
|
@@ -190,10 +190,10 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
190
190
|
animate: animate,
|
|
191
191
|
data: data
|
|
192
192
|
};
|
|
193
|
-
}
|
|
193
|
+
} // eslint-disable-next-line max-params, max-len
|
|
194
|
+
|
|
194
195
|
|
|
195
196
|
function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
196
|
-
// eslint-disable-line max-params, max-len
|
|
197
197
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
198
198
|
// transition for all children to have the same duration, delay, etc.
|
|
199
199
|
var onExit = animate && animate.onExit;
|
|
@@ -215,10 +215,10 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
215
215
|
animate: animate,
|
|
216
216
|
data: data
|
|
217
217
|
};
|
|
218
|
-
}
|
|
218
|
+
} // eslint-disable-next-line max-params,max-len
|
|
219
|
+
|
|
219
220
|
|
|
220
221
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
221
|
-
// eslint-disable-line max-params,max-len
|
|
222
222
|
if (enteringNodes) {
|
|
223
223
|
// Perform a normal animation here, except - when it finishes - trigger
|
|
224
224
|
// the transition for entering nodes.
|
|
@@ -239,10 +239,10 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
239
239
|
animate: animate,
|
|
240
240
|
data: data
|
|
241
241
|
};
|
|
242
|
-
}
|
|
242
|
+
} // eslint-disable-next-line max-params, max-len
|
|
243
|
+
|
|
243
244
|
|
|
244
245
|
function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
245
|
-
// eslint-disable-line max-params, max-len
|
|
246
246
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
247
247
|
// transition for all children to have the same duration, delay, etc.
|
|
248
248
|
var onEnter = animate && animate.onEnter;
|
|
@@ -314,19 +314,19 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
314
314
|
nodesDoneLoad: true
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
|
-
};
|
|
317
|
+
}; // eslint-disable-next-line max-params
|
|
318
|
+
|
|
318
319
|
|
|
319
320
|
var onExit = function (nodes, child, data, animate) {
|
|
320
|
-
// eslint-disable-line max-params
|
|
321
321
|
return getChildPropsOnExit(animate, child, data, nodes, function () {
|
|
322
322
|
setState({
|
|
323
323
|
nodesWillExit: false
|
|
324
324
|
});
|
|
325
325
|
});
|
|
326
|
-
};
|
|
326
|
+
}; // eslint-disable-next-line max-params
|
|
327
|
+
|
|
327
328
|
|
|
328
329
|
var onEnter = function (nodes, child, data, animate) {
|
|
329
|
-
// eslint-disable-line max-params
|
|
330
330
|
if (nodesShouldEnter) {
|
|
331
331
|
return getChildPropsOnEnter(animate, data, nodes, function () {
|
|
332
332
|
setState({
|
|
@@ -357,10 +357,10 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
357
357
|
} else {
|
|
358
358
|
return {};
|
|
359
359
|
}
|
|
360
|
-
};
|
|
360
|
+
}; // eslint-disable-next-line max-statements, complexity, max-len
|
|
361
|
+
|
|
361
362
|
|
|
362
363
|
return function getTransitionProps(child, index) {
|
|
363
|
-
// eslint-disable-line max-statements, complexity, max-len
|
|
364
364
|
var data = getChildData(child) || [];
|
|
365
365
|
var animate = (0, _defaults2.default)({}, props.animate, child.props.animate);
|
|
366
366
|
var defaultTransitions = child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
@@ -163,14 +163,15 @@ var _default = {
|
|
|
163
163
|
getAllEvents: function (props) {
|
|
164
164
|
var components = ["groupComponent", "containerComponent", "labelComponent"];
|
|
165
165
|
this.componentEvents = _events.default.getComponentEvents(props, components);
|
|
166
|
+
var events = props.events;
|
|
166
167
|
|
|
167
168
|
if (Array.isArray(this.componentEvents)) {
|
|
168
169
|
var _componentEvents;
|
|
169
170
|
|
|
170
|
-
|
|
171
|
+
events = Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
return
|
|
174
|
+
return events || [];
|
|
174
175
|
},
|
|
175
176
|
getAnimationProps: function (props, child, index) {
|
|
176
177
|
var _this = this;
|
|
@@ -284,9 +285,10 @@ var _default = {
|
|
|
284
285
|
}
|
|
285
286
|
|
|
286
287
|
stack += 1;
|
|
287
|
-
return childData.map(function (datum) {
|
|
288
|
+
return childData.map(function (datum, index) {
|
|
288
289
|
return (0, _assign2.default)({
|
|
289
|
-
stack: stack
|
|
290
|
+
stack: stack,
|
|
291
|
+
group: index
|
|
290
292
|
}, datum);
|
|
291
293
|
});
|
|
292
294
|
};
|
|
@@ -298,7 +300,7 @@ var _default = {
|
|
|
298
300
|
|
|
299
301
|
var datasets = _helpers.default.reduceChildren(children, iteratee, props);
|
|
300
302
|
|
|
301
|
-
var group = stacked ? "
|
|
303
|
+
var group = stacked ? "group" : "stack";
|
|
302
304
|
return (0, _values2.default)((0, _groupBy2.default)(datasets, group));
|
|
303
305
|
},
|
|
304
306
|
getColor: function (calculatedProps, child, index) {
|
|
@@ -371,7 +373,7 @@ var _default = {
|
|
|
371
373
|
if (!_domain.default.isDomainComponent(child) || !childProps.categories) {
|
|
372
374
|
return null;
|
|
373
375
|
} else {
|
|
374
|
-
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.
|
|
376
|
+
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
375
377
|
var categoryStrings = categories && categories.filter(function (val) {
|
|
376
378
|
return typeof val === "string";
|
|
377
379
|
});
|
|
@@ -381,7 +383,7 @@ var _default = {
|
|
|
381
383
|
|
|
382
384
|
return _helpers.default.reduceChildren(childComponents.slice(0), iteratee);
|
|
383
385
|
},
|
|
384
|
-
getStringsFromData: function (childComponents
|
|
386
|
+
getStringsFromData: function (childComponents) {
|
|
385
387
|
var iteratee = function (child) {
|
|
386
388
|
var childProps = child.props || {};
|
|
387
389
|
var data;
|
|
@@ -394,31 +396,66 @@ var _default = {
|
|
|
394
396
|
data = _data.default.getData(childProps);
|
|
395
397
|
}
|
|
396
398
|
|
|
397
|
-
var attr = axis === "x" ? "xName" : "yName";
|
|
398
399
|
return data.map(function (d) {
|
|
399
|
-
return
|
|
400
|
-
|
|
400
|
+
return {
|
|
401
|
+
x: d.xName,
|
|
402
|
+
y: d.yName
|
|
403
|
+
};
|
|
404
|
+
});
|
|
401
405
|
};
|
|
402
406
|
|
|
403
|
-
|
|
407
|
+
var initialMemo = {
|
|
408
|
+
x: [],
|
|
409
|
+
y: []
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
var combine = function (memo, datum) {
|
|
413
|
+
var x = Array.isArray(datum) ? datum.map(function (d) {
|
|
414
|
+
return d.x;
|
|
415
|
+
}).filter(Boolean) : datum.x;
|
|
416
|
+
var y = Array.isArray(datum) ? datum.map(function (d) {
|
|
417
|
+
return d.y;
|
|
418
|
+
}).filter(Boolean) : datum.y;
|
|
419
|
+
return {
|
|
420
|
+
x: x !== undefined ? memo.x.concat(x) : memo.x,
|
|
421
|
+
y: y !== undefined ? memo.y.concat(y) : memo.y
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
return _helpers.default.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
|
|
404
426
|
},
|
|
405
|
-
|
|
427
|
+
getCategoryAndAxisStringsFromChildren: function (props, axis, childComponents) {
|
|
406
428
|
var currentAxis = _helpers.default.getCurrentAxis(axis, props.horizontal);
|
|
407
429
|
|
|
408
|
-
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
409
430
|
var categories = (0, _isPlainObject2.default)(props.categories) ? props.categories[axis] : props.categories;
|
|
410
431
|
|
|
411
432
|
var axisComponent = _axis.default.getAxisComponent(childComponents, currentAxis);
|
|
412
433
|
|
|
413
434
|
var axisStrings = axisComponent ? _data.default.getStringsFromAxes(axisComponent.props, axis) : [];
|
|
414
435
|
var categoryStrings = categories || this.getStringsFromCategories(childComponents, axis);
|
|
415
|
-
|
|
416
|
-
return (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(categoryStrings).concat(_toConsumableArray(dataStrings), _toConsumableArray(axisStrings))));
|
|
436
|
+
return (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));
|
|
417
437
|
},
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
var
|
|
421
|
-
|
|
438
|
+
getStringsFromChildren: function (props, childComponents) {
|
|
439
|
+
childComponents = childComponents || _react.default.Children.toArray(props.children);
|
|
440
|
+
var xStrings = this.getCategoryAndAxisStringsFromChildren(props, "x", childComponents);
|
|
441
|
+
var yStrings = this.getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
|
|
442
|
+
var dataStrings = this.getStringsFromData(childComponents);
|
|
443
|
+
return {
|
|
444
|
+
x: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
|
|
445
|
+
y: (0, _uniq2.default)((0, _flatten2.default)(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
|
|
446
|
+
};
|
|
447
|
+
},
|
|
448
|
+
getCategories: function (props) {
|
|
449
|
+
var xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
|
|
450
|
+
var yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
|
|
451
|
+
var fallbackRequired = !xPropCategories || !yPropCategories;
|
|
452
|
+
var fallbackProps = fallbackRequired ? this.getStringsFromChildren(props) : {};
|
|
453
|
+
var xCategories = xPropCategories || fallbackProps.x;
|
|
454
|
+
var yCategories = yPropCategories || fallbackProps.y;
|
|
455
|
+
return {
|
|
456
|
+
x: xCategories.length > 0 ? xCategories : undefined,
|
|
457
|
+
y: yCategories.length > 0 ? yCategories : undefined
|
|
458
|
+
};
|
|
422
459
|
}
|
|
423
460
|
};
|
|
424
461
|
exports.default = _default;
|