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
|
@@ -11,39 +11,39 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|
|
11
11
|
|
|
12
12
|
var fontDictionary = {
|
|
13
13
|
"American Typewriter": 2.09,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Baskerville: 2.51,
|
|
15
|
+
Georgia: 2.27,
|
|
16
16
|
"Hoefler Text": 2.39,
|
|
17
|
-
|
|
17
|
+
Palatino: 2.26,
|
|
18
18
|
"Times New Roman": 2.48,
|
|
19
|
-
|
|
19
|
+
Arial: 2.26,
|
|
20
20
|
"Gill Sans": 2.47,
|
|
21
21
|
"Gill Sans 300": 2.58,
|
|
22
22
|
"Helvetica Neue": 2.24,
|
|
23
23
|
"Lucida Grande": 2.05,
|
|
24
|
-
|
|
24
|
+
Tahoma: 2.25,
|
|
25
25
|
"Trebuchet MS": 2.2,
|
|
26
|
-
|
|
26
|
+
Verdana: 1.96,
|
|
27
27
|
"Courier New": 1.67,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
cursive: 1.84,
|
|
29
|
+
fantasy: 2.09,
|
|
30
|
+
monospace: 1.81,
|
|
31
|
+
serif: 2.04,
|
|
32
32
|
"sans-serif": 1.89
|
|
33
33
|
}; //https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
34
34
|
// Absolute sizes in pixels for obsolete measurement units.
|
|
35
35
|
|
|
36
36
|
var absoluteMeasurementUnitsToPixels = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
mm: 3.8,
|
|
38
|
+
sm: 38,
|
|
39
|
+
pt: 1.33,
|
|
40
|
+
pc: 16,
|
|
41
|
+
in: 96,
|
|
42
|
+
px: 1
|
|
43
43
|
};
|
|
44
44
|
var relativeMeasurementUnitsCoef = {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
em: 1,
|
|
46
|
+
ex: 0.5
|
|
47
47
|
};
|
|
48
48
|
var coefficients = {
|
|
49
49
|
averageFontConstant: 2.1675,
|
|
@@ -88,7 +88,7 @@ var _getSizeWithRotate = function (axisSize, dependentSize, angle) {
|
|
|
88
88
|
* @param {string} length Css length string value.
|
|
89
89
|
* @param {number} fontSize Current text font-size.
|
|
90
90
|
* @returns {number} Approximate Css length in pixels.
|
|
91
|
-
*/
|
|
91
|
+
*/
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
var convertLengthToPixels = function (length, fontSize) {
|
|
@@ -163,7 +163,7 @@ var _approximateTextHeightInternal = function (text, style) {
|
|
|
163
163
|
* @param {number} style.characterConstant Average pixels per glyph.
|
|
164
164
|
* @param {number} style.lineHeight Line height coefficient.
|
|
165
165
|
* @returns {number} Approximate text label height.
|
|
166
|
-
*/
|
|
166
|
+
*/
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
var approximateTextSize = function (text, style) {
|
|
@@ -129,10 +129,10 @@ function getInitialChildProps(animate, data) {
|
|
|
129
129
|
return _assign({}, datum, after(datum, idx, data));
|
|
130
130
|
})
|
|
131
131
|
};
|
|
132
|
-
}
|
|
132
|
+
} // eslint-disable-next-line max-params
|
|
133
|
+
|
|
133
134
|
|
|
134
135
|
function getChildBeforeLoad(animate, child, data, cb) {
|
|
135
|
-
// eslint-disable-line max-params
|
|
136
136
|
animate = _assign({}, animate, {
|
|
137
137
|
onEnd: cb
|
|
138
138
|
});
|
|
@@ -154,10 +154,10 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
154
154
|
data: data,
|
|
155
155
|
clipWidth: 0
|
|
156
156
|
};
|
|
157
|
-
}
|
|
157
|
+
} // eslint-disable-next-line max-params
|
|
158
|
+
|
|
158
159
|
|
|
159
160
|
function getChildOnLoad(animate, data, cb) {
|
|
160
|
-
// eslint-disable-line max-params
|
|
161
161
|
animate = _assign({}, animate, {
|
|
162
162
|
onEnd: cb
|
|
163
163
|
});
|
|
@@ -178,10 +178,10 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
178
178
|
animate: animate,
|
|
179
179
|
data: data
|
|
180
180
|
};
|
|
181
|
-
}
|
|
181
|
+
} // eslint-disable-next-line max-params, max-len
|
|
182
|
+
|
|
182
183
|
|
|
183
184
|
function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
184
|
-
// eslint-disable-line max-params, max-len
|
|
185
185
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
186
186
|
// transition for all children to have the same duration, delay, etc.
|
|
187
187
|
var onExit = animate && animate.onExit;
|
|
@@ -203,10 +203,10 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
203
203
|
animate: animate,
|
|
204
204
|
data: data
|
|
205
205
|
};
|
|
206
|
-
}
|
|
206
|
+
} // eslint-disable-next-line max-params,max-len
|
|
207
|
+
|
|
207
208
|
|
|
208
209
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
209
|
-
// eslint-disable-line max-params,max-len
|
|
210
210
|
if (enteringNodes) {
|
|
211
211
|
// Perform a normal animation here, except - when it finishes - trigger
|
|
212
212
|
// the transition for entering nodes.
|
|
@@ -227,10 +227,10 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
227
227
|
animate: animate,
|
|
228
228
|
data: data
|
|
229
229
|
};
|
|
230
|
-
}
|
|
230
|
+
} // eslint-disable-next-line max-params, max-len
|
|
231
|
+
|
|
231
232
|
|
|
232
233
|
function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
233
|
-
// eslint-disable-line max-params, max-len
|
|
234
234
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
235
235
|
// transition for all children to have the same duration, delay, etc.
|
|
236
236
|
var onEnter = animate && animate.onEnter;
|
|
@@ -302,19 +302,19 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
302
302
|
nodesDoneLoad: true
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
|
-
};
|
|
305
|
+
}; // eslint-disable-next-line max-params
|
|
306
|
+
|
|
306
307
|
|
|
307
308
|
var onExit = function (nodes, child, data, animate) {
|
|
308
|
-
// eslint-disable-line max-params
|
|
309
309
|
return getChildPropsOnExit(animate, child, data, nodes, function () {
|
|
310
310
|
setState({
|
|
311
311
|
nodesWillExit: false
|
|
312
312
|
});
|
|
313
313
|
});
|
|
314
|
-
};
|
|
314
|
+
}; // eslint-disable-next-line max-params
|
|
315
|
+
|
|
315
316
|
|
|
316
317
|
var onEnter = function (nodes, child, data, animate) {
|
|
317
|
-
// eslint-disable-line max-params
|
|
318
318
|
if (nodesShouldEnter) {
|
|
319
319
|
return getChildPropsOnEnter(animate, data, nodes, function () {
|
|
320
320
|
setState({
|
|
@@ -345,10 +345,10 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
345
345
|
} else {
|
|
346
346
|
return {};
|
|
347
347
|
}
|
|
348
|
-
};
|
|
348
|
+
}; // eslint-disable-next-line max-statements, complexity, max-len
|
|
349
|
+
|
|
349
350
|
|
|
350
351
|
return function getTransitionProps(child, index) {
|
|
351
|
-
// eslint-disable-line max-statements, complexity, max-len
|
|
352
352
|
var data = getChildData(child) || [];
|
|
353
353
|
|
|
354
354
|
var animate = _defaults({}, props.animate, child.props.animate);
|
|
@@ -128,14 +128,15 @@ export default {
|
|
|
128
128
|
getAllEvents: function (props) {
|
|
129
129
|
var components = ["groupComponent", "containerComponent", "labelComponent"];
|
|
130
130
|
this.componentEvents = Events.getComponentEvents(props, components);
|
|
131
|
+
var events = props.events;
|
|
131
132
|
|
|
132
133
|
if (Array.isArray(this.componentEvents)) {
|
|
133
134
|
var _componentEvents;
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
events = Array.isArray(props.events) ? (_componentEvents = this.componentEvents).concat.apply(_componentEvents, _toConsumableArray(props.events)) : this.componentEvents;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
return
|
|
139
|
+
return events || [];
|
|
139
140
|
},
|
|
140
141
|
getAnimationProps: function (props, child, index) {
|
|
141
142
|
var _this = this;
|
|
@@ -247,9 +248,10 @@ export default {
|
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
stack += 1;
|
|
250
|
-
return childData.map(function (datum) {
|
|
251
|
+
return childData.map(function (datum, index) {
|
|
251
252
|
return _assign({
|
|
252
|
-
stack: stack
|
|
253
|
+
stack: stack,
|
|
254
|
+
group: index
|
|
253
255
|
}, datum);
|
|
254
256
|
});
|
|
255
257
|
};
|
|
@@ -259,7 +261,7 @@ export default {
|
|
|
259
261
|
return c.type && c.type.role === "stack";
|
|
260
262
|
}).length;
|
|
261
263
|
var datasets = Helpers.reduceChildren(children, iteratee, props);
|
|
262
|
-
var group = stacked ? "
|
|
264
|
+
var group = stacked ? "group" : "stack";
|
|
263
265
|
return _values(_groupBy(datasets, group));
|
|
264
266
|
},
|
|
265
267
|
getColor: function (calculatedProps, child, index) {
|
|
@@ -335,7 +337,7 @@ export default {
|
|
|
335
337
|
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
336
338
|
return null;
|
|
337
339
|
} else {
|
|
338
|
-
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.
|
|
340
|
+
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
339
341
|
var categoryStrings = categories && categories.filter(function (val) {
|
|
340
342
|
return typeof val === "string";
|
|
341
343
|
});
|
|
@@ -345,7 +347,7 @@ export default {
|
|
|
345
347
|
|
|
346
348
|
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
|
|
347
349
|
},
|
|
348
|
-
getStringsFromData: function (childComponents
|
|
350
|
+
getStringsFromData: function (childComponents) {
|
|
349
351
|
var iteratee = function (child) {
|
|
350
352
|
var childProps = child.props || {};
|
|
351
353
|
var data;
|
|
@@ -358,27 +360,62 @@ export default {
|
|
|
358
360
|
data = Data.getData(childProps);
|
|
359
361
|
}
|
|
360
362
|
|
|
361
|
-
var attr = axis === "x" ? "xName" : "yName";
|
|
362
363
|
return data.map(function (d) {
|
|
363
|
-
return
|
|
364
|
-
|
|
364
|
+
return {
|
|
365
|
+
x: d.xName,
|
|
366
|
+
y: d.yName
|
|
367
|
+
};
|
|
368
|
+
});
|
|
365
369
|
};
|
|
366
370
|
|
|
367
|
-
|
|
371
|
+
var initialMemo = {
|
|
372
|
+
x: [],
|
|
373
|
+
y: []
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
var combine = function (memo, datum) {
|
|
377
|
+
var x = Array.isArray(datum) ? datum.map(function (d) {
|
|
378
|
+
return d.x;
|
|
379
|
+
}).filter(Boolean) : datum.x;
|
|
380
|
+
var y = Array.isArray(datum) ? datum.map(function (d) {
|
|
381
|
+
return d.y;
|
|
382
|
+
}).filter(Boolean) : datum.y;
|
|
383
|
+
return {
|
|
384
|
+
x: x !== undefined ? memo.x.concat(x) : memo.x,
|
|
385
|
+
y: y !== undefined ? memo.y.concat(y) : memo.y
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
return Helpers.reduceChildren(childComponents.slice(0), iteratee, {}, initialMemo, combine);
|
|
368
390
|
},
|
|
369
|
-
|
|
391
|
+
getCategoryAndAxisStringsFromChildren: function (props, axis, childComponents) {
|
|
370
392
|
var currentAxis = Helpers.getCurrentAxis(axis, props.horizontal);
|
|
371
|
-
childComponents = childComponents || React.Children.toArray(props.children);
|
|
372
393
|
var categories = _isPlainObject(props.categories) ? props.categories[axis] : props.categories;
|
|
373
394
|
var axisComponent = Axis.getAxisComponent(childComponents, currentAxis);
|
|
374
395
|
var axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
|
|
375
396
|
var categoryStrings = categories || this.getStringsFromCategories(childComponents, axis);
|
|
376
|
-
|
|
377
|
-
return _uniq(_flatten(_toConsumableArray(categoryStrings).concat(_toConsumableArray(dataStrings), _toConsumableArray(axisStrings))));
|
|
397
|
+
return _uniq(_flatten(_toConsumableArray(categoryStrings).concat(_toConsumableArray(axisStrings))));
|
|
378
398
|
},
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
var
|
|
382
|
-
|
|
399
|
+
getStringsFromChildren: function (props, childComponents) {
|
|
400
|
+
childComponents = childComponents || React.Children.toArray(props.children);
|
|
401
|
+
var xStrings = this.getCategoryAndAxisStringsFromChildren(props, "x", childComponents);
|
|
402
|
+
var yStrings = this.getCategoryAndAxisStringsFromChildren(props, "y", childComponents);
|
|
403
|
+
var dataStrings = this.getStringsFromData(childComponents);
|
|
404
|
+
return {
|
|
405
|
+
x: _uniq(_flatten(_toConsumableArray(xStrings).concat(_toConsumableArray(dataStrings.x)))),
|
|
406
|
+
y: _uniq(_flatten(_toConsumableArray(yStrings).concat(_toConsumableArray(dataStrings.y))))
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
getCategories: function (props) {
|
|
410
|
+
var xPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.x : props.categories;
|
|
411
|
+
var yPropCategories = props.categories && !Array.isArray(props.categories) ? props.categories.y : props.categories;
|
|
412
|
+
var fallbackRequired = !xPropCategories || !yPropCategories;
|
|
413
|
+
var fallbackProps = fallbackRequired ? this.getStringsFromChildren(props) : {};
|
|
414
|
+
var xCategories = xPropCategories || fallbackProps.x;
|
|
415
|
+
var yCategories = yPropCategories || fallbackProps.y;
|
|
416
|
+
return {
|
|
417
|
+
x: xCategories.length > 0 ? xCategories : undefined,
|
|
418
|
+
y: yCategories.length > 0 ? yCategories : undefined
|
|
419
|
+
};
|
|
383
420
|
}
|
|
384
421
|
};
|
|
@@ -15,6 +15,8 @@ var _util = require("./util");
|
|
|
15
15
|
|
|
16
16
|
var _timer = _interopRequireDefault(require("../victory-util/timer"));
|
|
17
17
|
|
|
18
|
+
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
19
|
+
|
|
18
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -82,31 +84,35 @@ function (_React$Component) {
|
|
|
82
84
|
this.traverseQueue();
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
/* lifecycle */
|
|
86
|
-
|
|
87
87
|
}, {
|
|
88
|
-
key: "
|
|
89
|
-
value: function
|
|
90
|
-
|
|
91
|
-
this.getTimer().unsubscribe(this.loopID);
|
|
92
|
-
/* If an object was supplied */
|
|
93
|
-
|
|
94
|
-
if (!Array.isArray(nextProps.data)) {
|
|
95
|
-
// Replace the tween queue. Could set `this.queue = [nextProps.data]`,
|
|
96
|
-
// but let's reuse the same array.
|
|
97
|
-
this.queue.length = 0;
|
|
98
|
-
this.queue.push(nextProps.data);
|
|
99
|
-
/* If an array was supplied */
|
|
100
|
-
} else {
|
|
101
|
-
var _queue;
|
|
88
|
+
key: "shouldComponentUpdate",
|
|
89
|
+
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
90
|
+
var equalProps = (0, _reactFastCompare.default)(this.props, nextProps);
|
|
102
91
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
if (!equalProps) {
|
|
93
|
+
/* cancel existing loop if it exists */
|
|
94
|
+
this.getTimer().unsubscribe(this.loopID);
|
|
95
|
+
/* If an object was supplied */
|
|
96
|
+
|
|
97
|
+
if (!Array.isArray(nextProps.data)) {
|
|
98
|
+
// Replace the tween queue. Could set `this.queue = [nextProps.data]`,
|
|
99
|
+
// but let's reuse the same array.
|
|
100
|
+
this.queue.length = 0;
|
|
101
|
+
this.queue.push(nextProps.data);
|
|
102
|
+
/* If an array was supplied */
|
|
103
|
+
} else {
|
|
104
|
+
var _queue;
|
|
107
105
|
|
|
106
|
+
/* Extend the tween queue */
|
|
107
|
+
(_queue = this.queue).push.apply(_queue, _toConsumableArray(nextProps.data));
|
|
108
|
+
}
|
|
109
|
+
/* Start traversing the tween queue */
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
this.traverseQueue();
|
|
113
|
+
}
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
return nextState.animationInfo.animating || !equalProps;
|
|
110
116
|
}
|
|
111
117
|
}, {
|
|
112
118
|
key: "componentWillUnmount",
|
|
@@ -129,11 +129,11 @@ function (_React$Component) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
return "".concat(child).split("\n");
|
|
132
|
-
}
|
|
132
|
+
} //eslint-disable-next-line max-params
|
|
133
|
+
|
|
133
134
|
}, {
|
|
134
135
|
key: "getDy",
|
|
135
136
|
value: function getDy(props, style, content, lineHeight) {
|
|
136
|
-
//eslint-disable-line max-params
|
|
137
137
|
style = Array.isArray(style) ? style[0] : style;
|
|
138
138
|
lineHeight = this.checkLineHeight(lineHeight, lineHeight[0], 1);
|
|
139
139
|
var fontSize = style.fontSize;
|
|
@@ -290,6 +290,12 @@ Object.defineProperty(VictoryLabel, "role", {
|
|
|
290
290
|
writable: true,
|
|
291
291
|
value: "label"
|
|
292
292
|
});
|
|
293
|
+
Object.defineProperty(VictoryLabel, "defaultStyles", {
|
|
294
|
+
configurable: true,
|
|
295
|
+
enumerable: true,
|
|
296
|
+
writable: true,
|
|
297
|
+
value: defaultStyles
|
|
298
|
+
});
|
|
293
299
|
Object.defineProperty(VictoryLabel, "propTypes", {
|
|
294
300
|
configurable: true,
|
|
295
301
|
enumerable: true,
|
|
@@ -64,9 +64,9 @@ var _default = {
|
|
|
64
64
|
var baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
|
|
65
65
|
|
|
66
66
|
var angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
|
|
67
|
+
// eslint-disable-next-line no-magic-numbers
|
|
67
68
|
|
|
68
69
|
var starCoords = (0, _range2.default)(10).map(function (index) {
|
|
69
|
-
// eslint-disable-line no-magic-numbers
|
|
70
70
|
var length = index % 2 === 0 ? baseSize : baseSize / 2;
|
|
71
71
|
return "".concat(length * Math.sin(angle * (index + 1)) + x, ",\n ").concat(length * Math.cos(angle * (index + 1)) + y);
|
|
72
72
|
});
|
|
@@ -27,6 +27,8 @@ var _timer = _interopRequireDefault(require("../victory-util/timer"));
|
|
|
27
27
|
|
|
28
28
|
var _transitions = _interopRequireDefault(require("../victory-util/transitions"));
|
|
29
29
|
|
|
30
|
+
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -74,14 +76,18 @@ function (_React$Component) {
|
|
|
74
76
|
}); //eslint-disable-line react/no-did-mount-set-state
|
|
75
77
|
}
|
|
76
78
|
}, {
|
|
77
|
-
key: "
|
|
78
|
-
value: function
|
|
79
|
+
key: "shouldComponentUpdate",
|
|
80
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
79
81
|
var _this2 = this;
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
84
|
+
this.getTimer().bypassAnimation();
|
|
85
|
+
this.setState(this.getTransitionState(this.props, nextProps), function () {
|
|
86
|
+
return _this2.getTimer().resumeAnimation();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return true;
|
|
85
91
|
}
|
|
86
92
|
}, {
|
|
87
93
|
key: "componentWillUnmount",
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
|
|
9
|
+
|
|
8
10
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
11
|
|
|
10
12
|
var _without2 = _interopRequireDefault(require("lodash/without"));
|
|
@@ -49,7 +51,11 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
49
51
|
|
|
50
52
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
var datumHasXandY = function (datum) {
|
|
55
|
+
return !(0, _isNil2.default)(datum._x) && !(0, _isNil2.default)(datum._y);
|
|
56
|
+
}; // used for checking state changes. Expected components can be passed in via options
|
|
57
|
+
|
|
58
|
+
|
|
53
59
|
var defaultComponents = [{
|
|
54
60
|
name: "parent",
|
|
55
61
|
index: "parent"
|
|
@@ -89,39 +95,39 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
89
95
|
_this.cacheValues(calculatedValues);
|
|
90
96
|
|
|
91
97
|
_this.externalMutations = _this.getExternalMutations(props);
|
|
98
|
+
_this.calculatedState = _this.getStateChanges(props, calculatedValues);
|
|
92
99
|
return _this;
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
_createClass(addEvents, [{
|
|
96
|
-
key: "
|
|
97
|
-
value: function
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
key: "shouldComponentUpdate",
|
|
104
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
105
|
+
var calculatedValues = this.getCalculatedValues(nextProps);
|
|
106
|
+
var externalMutations = this.getExternalMutations(nextProps);
|
|
107
|
+
var animating = this.props.animating || this.props.animate;
|
|
108
|
+
var newMutation = !(0, _reactFastCompare.default)(externalMutations, this.externalMutations);
|
|
109
|
+
|
|
110
|
+
if (animating || newMutation) {
|
|
111
|
+
this.cacheValues(calculatedValues);
|
|
101
112
|
this.externalMutations = externalMutations;
|
|
102
|
-
this.applyExternalMutations(
|
|
113
|
+
this.applyExternalMutations(nextProps, externalMutations);
|
|
114
|
+
return true;
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
key: "applyExternalMutations",
|
|
112
|
-
value: function applyExternalMutations(props, externalMutations) {
|
|
113
|
-
if (!(0, _isEmpty2.default)(externalMutations)) {
|
|
114
|
-
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
115
|
-
memo = (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
116
|
-
return memo;
|
|
117
|
-
}, []);
|
|
118
|
-
var compiledCallbacks = callbacks.length ? function () {
|
|
119
|
-
callbacks.forEach(function (c) {
|
|
120
|
-
return c();
|
|
121
|
-
});
|
|
122
|
-
} : undefined;
|
|
123
|
-
this.setState(externalMutations, compiledCallbacks);
|
|
116
|
+
|
|
117
|
+
var calculatedState = this.getStateChanges(nextProps, calculatedValues);
|
|
118
|
+
|
|
119
|
+
if (!(0, _reactFastCompare.default)(this.calculatedState, calculatedState)) {
|
|
120
|
+
this.calculatedState = calculatedState;
|
|
121
|
+
this.cacheValues(calculatedValues);
|
|
122
|
+
return true;
|
|
124
123
|
}
|
|
124
|
+
|
|
125
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
126
|
+
this.cacheValues(calculatedValues);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return false;
|
|
125
131
|
} // compile all state changes from own and parent state. Order doesn't matter, as any state
|
|
126
132
|
// state change should trigger a re-render
|
|
127
133
|
|
|
@@ -137,24 +143,40 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
137
143
|
return {};
|
|
138
144
|
}
|
|
139
145
|
|
|
140
|
-
options = options || {};
|
|
141
|
-
var components = options.components || defaultComponents;
|
|
142
|
-
|
|
143
146
|
var getState = function (key, type) {
|
|
144
|
-
var
|
|
145
|
-
return (0, _isEmpty2.default)(
|
|
147
|
+
var result = (0, _defaults2.default)({}, _this2.getEventState(key, type), getSharedEventState(key, type));
|
|
148
|
+
return (0, _isEmpty2.default)(result) ? undefined : result;
|
|
146
149
|
};
|
|
147
150
|
|
|
148
|
-
|
|
151
|
+
options = options || {};
|
|
152
|
+
var components = options.components || defaultComponents;
|
|
153
|
+
var stateChanges = components.map(function (component) {
|
|
149
154
|
if (!props.standalone && component.name === "parent") {
|
|
150
155
|
// don't check for changes on parent props for non-standalone components
|
|
151
156
|
return undefined;
|
|
152
157
|
} else {
|
|
153
158
|
return component.index !== undefined ? getState(component.index, component.name) : calculatedValues.dataKeys.map(function (key) {
|
|
154
159
|
return getState(key, component.name);
|
|
155
|
-
});
|
|
160
|
+
}).filter(Boolean);
|
|
156
161
|
}
|
|
157
162
|
}).filter(Boolean);
|
|
163
|
+
return stateChanges;
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "applyExternalMutations",
|
|
167
|
+
value: function applyExternalMutations(props, externalMutations) {
|
|
168
|
+
if (!(0, _isEmpty2.default)(externalMutations)) {
|
|
169
|
+
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
170
|
+
memo = (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
171
|
+
return memo;
|
|
172
|
+
}, []);
|
|
173
|
+
var compiledCallbacks = callbacks.length ? function () {
|
|
174
|
+
callbacks.forEach(function (c) {
|
|
175
|
+
return c();
|
|
176
|
+
});
|
|
177
|
+
} : undefined;
|
|
178
|
+
this.setState(externalMutations, compiledCallbacks);
|
|
179
|
+
}
|
|
158
180
|
}
|
|
159
181
|
}, {
|
|
160
182
|
key: "getCalculatedValues",
|
|
@@ -263,7 +285,8 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
263
285
|
}
|
|
264
286
|
}, {
|
|
265
287
|
key: "animateComponent",
|
|
266
|
-
value: function animateComponent(props,
|
|
288
|
+
value: function animateComponent(props, defaultAnimationWhitelist) {
|
|
289
|
+
var animationWhitelist = props.animate && props.animate.animationWhitelist ? props.animate.animationWhitelist : defaultAnimationWhitelist;
|
|
267
290
|
return _react.default.createElement(_victoryTransition.default, {
|
|
268
291
|
animate: props.animate,
|
|
269
292
|
animationWhitelist: animationWhitelist
|
|
@@ -297,14 +320,19 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
297
320
|
value: function renderData(props) {
|
|
298
321
|
var _this5 = this;
|
|
299
322
|
|
|
323
|
+
var shouldRenderDatum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : datumHasXandY;
|
|
300
324
|
var dataComponent = props.dataComponent,
|
|
301
325
|
labelComponent = props.labelComponent,
|
|
302
326
|
groupComponent = props.groupComponent;
|
|
303
|
-
var dataComponents = this.dataKeys.
|
|
327
|
+
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
304
328
|
var dataProps = _this5.getComponentProps(dataComponent, "data", index);
|
|
305
329
|
|
|
306
|
-
|
|
307
|
-
|
|
330
|
+
if (shouldRenderDatum(dataProps.datum)) {
|
|
331
|
+
validDataComponents.push(_react.default.cloneElement(dataComponent, dataProps));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return validDataComponents;
|
|
335
|
+
}, []);
|
|
308
336
|
var labelComponents = this.dataKeys.map(function (_dataKey, index) {
|
|
309
337
|
var labelProps = _this5.getComponentProps(labelComponent, "labels", index);
|
|
310
338
|
|