victory-core 36.8.2 → 36.8.4
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 +14 -0
- package/dist/victory-core.js +181 -159
- package/dist/victory-core.min.js +1 -1
- package/es/types/callbacks.d.ts +4 -4
- package/es/victory-animation/util.d.ts +3 -3
- package/es/victory-animation/util.js +5 -3
- package/es/victory-animation/victory-animation.js +2 -2
- package/es/victory-label/victory-label.d.ts +1 -1
- package/es/victory-label/victory-label.js +7 -11
- package/es/victory-primitives/arc.d.ts +1 -1
- package/es/victory-primitives/arc.js +2 -2
- package/es/victory-primitives/background.d.ts +1 -1
- package/es/victory-primitives/background.js +2 -2
- package/es/victory-primitives/border.d.ts +1 -1
- package/es/victory-primitives/border.js +2 -2
- package/es/victory-primitives/line-segment.d.ts +1 -1
- package/es/victory-primitives/line-segment.js +2 -2
- package/es/victory-primitives/point.d.ts +1 -1
- package/es/victory-primitives/point.js +2 -2
- package/es/victory-primitives/whisker.d.ts +1 -1
- package/es/victory-primitives/whisker.js +16 -17
- package/es/victory-util/add-events.js +7 -6
- package/es/victory-util/axis.js +2 -2
- package/es/victory-util/common-props.d.ts +1 -0
- package/es/victory-util/data.js +14 -9
- package/es/victory-util/domain.js +15 -15
- package/es/victory-util/events.d.ts +3 -3
- package/es/victory-util/events.js +17 -20
- package/es/victory-util/helpers.js +5 -5
- package/es/victory-util/immutable.js +4 -2
- package/es/victory-util/label-helpers.d.ts +1 -1
- package/es/victory-util/label-helpers.js +11 -12
- package/es/victory-util/selection.js +1 -2
- package/es/victory-util/timer.js +1 -2
- package/es/victory-util/transitions.js +37 -26
- package/es/victory-util/user-props.d.ts +6 -0
- package/es/victory-util/user-props.js +12 -1
- package/es/victory-util/wrapper.js +14 -14
- package/lib/types/callbacks.d.ts +4 -4
- package/lib/victory-animation/util.d.ts +3 -3
- package/lib/victory-animation/util.js +5 -3
- package/lib/victory-animation/victory-animation.js +2 -2
- package/lib/victory-label/victory-label.d.ts +1 -1
- package/lib/victory-label/victory-label.js +7 -11
- package/lib/victory-primitives/arc.d.ts +1 -1
- package/lib/victory-primitives/arc.js +2 -2
- package/lib/victory-primitives/background.d.ts +1 -1
- package/lib/victory-primitives/background.js +2 -2
- package/lib/victory-primitives/border.d.ts +1 -1
- package/lib/victory-primitives/border.js +2 -2
- package/lib/victory-primitives/line-segment.d.ts +1 -1
- package/lib/victory-primitives/line-segment.js +2 -2
- package/lib/victory-primitives/point.d.ts +1 -1
- package/lib/victory-primitives/point.js +2 -2
- package/lib/victory-primitives/whisker.d.ts +1 -1
- package/lib/victory-primitives/whisker.js +16 -17
- package/lib/victory-util/add-events.js +7 -6
- package/lib/victory-util/axis.js +2 -2
- package/lib/victory-util/common-props.d.ts +1 -0
- package/lib/victory-util/data.js +14 -9
- package/lib/victory-util/domain.js +15 -15
- package/lib/victory-util/events.d.ts +3 -3
- package/lib/victory-util/events.js +17 -20
- package/lib/victory-util/helpers.js +5 -5
- package/lib/victory-util/immutable.js +4 -2
- package/lib/victory-util/label-helpers.d.ts +1 -1
- package/lib/victory-util/label-helpers.js +11 -11
- package/lib/victory-util/selection.js +1 -2
- package/lib/victory-util/timer.js +1 -2
- package/lib/victory-util/transitions.js +32 -26
- package/lib/victory-util/user-props.d.ts +6 -0
- package/lib/victory-util/user-props.js +13 -0
- package/lib/victory-util/wrapper.js +16 -14
- package/package.json +2 -2
- package/src/types/callbacks.ts +8 -5
- package/src/victory-animation/util.ts +5 -3
- package/src/victory-animation/victory-animation.tsx +3 -2
- package/src/victory-label/victory-label.tsx +18 -17
- package/src/victory-primitives/arc.tsx +2 -2
- package/src/victory-primitives/background.tsx +2 -2
- package/src/victory-primitives/border.tsx +2 -2
- package/src/victory-primitives/line-segment.tsx +2 -2
- package/src/victory-primitives/point.tsx +2 -2
- package/src/victory-primitives/whisker.tsx +5 -5
- package/src/victory-util/add-events.tsx +10 -9
- package/src/victory-util/axis.tsx +6 -2
- package/src/victory-util/common-props.tsx +1 -0
- package/src/victory-util/data.ts +12 -8
- package/src/victory-util/domain.ts +15 -15
- package/src/victory-util/events.ts +23 -31
- package/src/victory-util/helpers.ts +5 -5
- package/src/victory-util/immutable.ts +3 -2
- package/src/victory-util/label-helpers.ts +6 -10
- package/src/victory-util/selection.ts +3 -2
- package/src/victory-util/timer.ts +1 -2
- package/src/victory-util/transitions.ts +31 -22
- package/src/victory-util/user-props.ts +14 -0
- package/src/victory-util/wrapper.tsx +17 -22
|
@@ -20,10 +20,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
/* eslint-disable no-use-before-define */
|
|
24
23
|
// Private Functions
|
|
25
|
-
function getVerticalAnchor(props
|
|
26
|
-
datum =
|
|
24
|
+
function getVerticalAnchor(props) {
|
|
25
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
26
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
28
27
|
var labelStyle = props.style && props.style.labels || {};
|
|
29
28
|
|
|
@@ -36,8 +35,8 @@ function getVerticalAnchor(props, datum) {
|
|
|
36
35
|
return "middle";
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
function getTextAnchor(props
|
|
40
|
-
datum =
|
|
38
|
+
function getTextAnchor(props) {
|
|
39
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
40
|
var style = props.style,
|
|
42
41
|
horizontal = props.horizontal;
|
|
43
42
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
@@ -52,14 +51,14 @@ function getTextAnchor(props, datum) {
|
|
|
52
51
|
return sign >= 0 ? "start" : "end";
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
function getAngle(props
|
|
56
|
-
datum =
|
|
54
|
+
function getAngle(props) {
|
|
55
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
57
56
|
var labelStyle = props.style && props.style.labels || {};
|
|
58
57
|
return datum.angle === undefined ? labelStyle.angle : datum.angle;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
function getPadding(props
|
|
62
|
-
datum =
|
|
60
|
+
function getPadding(props) {
|
|
61
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
62
|
var horizontal = props.horizontal,
|
|
64
63
|
style = props.style;
|
|
65
64
|
var labelStyle = style.labels || {};
|
|
@@ -138,8 +137,9 @@ function getPolarOrientation(degrees) {
|
|
|
138
137
|
} // Exported Functions
|
|
139
138
|
|
|
140
139
|
|
|
141
|
-
function getText(props
|
|
142
|
-
datum =
|
|
140
|
+
function getText(props) {
|
|
141
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
142
|
+
var index = arguments.length > 2 ? arguments[2] : undefined;
|
|
143
143
|
|
|
144
144
|
if (datum.label !== undefined) {
|
|
145
145
|
return datum.label;
|
|
@@ -65,8 +65,7 @@ function getSVGEventCoordinates(evt, svg) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
|
|
68
|
-
|
|
69
|
-
var matrix = getTransformationMatrix(svg);
|
|
68
|
+
var matrix = getTransformationMatrix(svg || getParentSVG(location));
|
|
70
69
|
return {
|
|
71
70
|
x: transformTarget(location.clientX, matrix, "x"),
|
|
72
71
|
y: transformTarget(location.clientY, matrix, "y")
|
|
@@ -64,11 +64,10 @@ var Timer = /*#__PURE__*/function () {
|
|
|
64
64
|
}, {
|
|
65
65
|
key: "subscribe",
|
|
66
66
|
value: function subscribe(callback, duration) {
|
|
67
|
-
duration = this.shouldAnimate ? duration : 0;
|
|
68
67
|
var subscriptionID = this.subscribers.push({
|
|
69
68
|
startTime: (0, _d3Timer.now)(),
|
|
70
69
|
callback: callback,
|
|
71
|
-
duration: duration
|
|
70
|
+
duration: this.shouldAnimate ? duration : 0
|
|
72
71
|
});
|
|
73
72
|
this.activeSubscriptions++;
|
|
74
73
|
this.start();
|
|
@@ -148,36 +148,37 @@ function getInitialChildProps(animate, data) {
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
function getChildBeforeLoad(animate, child, data, cb) {
|
|
151
|
-
|
|
151
|
+
var newAnimate = (0, _assign2.default)({}, animate, {
|
|
152
152
|
onEnd: cb
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
if (
|
|
155
|
+
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
156
156
|
return {
|
|
157
|
-
animate:
|
|
157
|
+
animate: newAnimate,
|
|
158
158
|
data: data
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
var before =
|
|
162
|
+
var before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity2.default; // If nodes need to exit, transform them with the provided onLoad.before function.
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
var newData = data.map(function (datum, idx) {
|
|
165
165
|
return (0, _assign2.default)({}, datum, before(datum, idx, data));
|
|
166
166
|
});
|
|
167
167
|
return {
|
|
168
|
-
animate:
|
|
169
|
-
data:
|
|
168
|
+
animate: newAnimate,
|
|
169
|
+
data: newData,
|
|
170
170
|
clipWidth: 0
|
|
171
171
|
};
|
|
172
172
|
} // eslint-disable-next-line max-params
|
|
173
173
|
|
|
174
174
|
|
|
175
175
|
function getChildOnLoad(animate, data, cb) {
|
|
176
|
-
|
|
176
|
+
var newAnimate = (0, _assign2.default)({}, animate, {
|
|
177
177
|
onEnd: cb
|
|
178
178
|
});
|
|
179
|
+
var newData = data;
|
|
179
180
|
|
|
180
|
-
if (
|
|
181
|
+
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
181
182
|
return {
|
|
182
183
|
animate: animate,
|
|
183
184
|
data: data
|
|
@@ -186,12 +187,12 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
186
187
|
|
|
187
188
|
var after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity2.default; // If nodes need to exit, transform them with the provided onLoad.after function.
|
|
188
189
|
|
|
189
|
-
|
|
190
|
+
newData = data.map(function (datum, idx) {
|
|
190
191
|
return (0, _assign2.default)({}, datum, after(datum, idx, data));
|
|
191
192
|
});
|
|
192
193
|
return {
|
|
193
|
-
animate:
|
|
194
|
-
data:
|
|
194
|
+
animate: newAnimate,
|
|
195
|
+
data: newData
|
|
195
196
|
};
|
|
196
197
|
} // eslint-disable-next-line max-params, max-len
|
|
197
198
|
|
|
@@ -200,7 +201,8 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
200
201
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
201
202
|
// transition for all children to have the same duration, delay, etc.
|
|
202
203
|
var onExit = animate && animate.onExit;
|
|
203
|
-
|
|
204
|
+
var newAnimate = (0, _assign2.default)({}, animate, onExit);
|
|
205
|
+
var newData = data;
|
|
204
206
|
|
|
205
207
|
if (exitingNodes) {
|
|
206
208
|
// After the exit transition occurs, trigger the animations for
|
|
@@ -208,39 +210,42 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
208
210
|
animate.onEnd = cb;
|
|
209
211
|
var before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity2.default; // If nodes need to exit, transform them with the provided onExit.before function.
|
|
210
212
|
|
|
211
|
-
|
|
213
|
+
newData = data.map(function (datum, idx) {
|
|
212
214
|
var key = (datum.key || idx).toString();
|
|
213
215
|
return exitingNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum;
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
return {
|
|
218
|
-
animate:
|
|
219
|
-
data:
|
|
220
|
+
animate: newAnimate,
|
|
221
|
+
data: newData
|
|
220
222
|
};
|
|
221
223
|
} // eslint-disable-next-line max-params,max-len
|
|
222
224
|
|
|
223
225
|
|
|
224
226
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
227
|
+
var newAnimate = animate;
|
|
228
|
+
var newData = data;
|
|
229
|
+
|
|
225
230
|
if (enteringNodes) {
|
|
226
231
|
// Perform a normal animation here, except - when it finishes - trigger
|
|
227
232
|
// the transition for entering nodes.
|
|
228
|
-
|
|
233
|
+
newAnimate = (0, _assign2.default)({}, animate, {
|
|
229
234
|
onEnd: cb
|
|
230
235
|
});
|
|
231
236
|
var before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity2.default; // We want the entering nodes to be included in the transition target
|
|
232
237
|
// domain. However, we may not want these nodes to be displayed initially,
|
|
233
238
|
// so perform the `onEnter.before` transformation on each node.
|
|
234
239
|
|
|
235
|
-
|
|
240
|
+
newData = data.map(function (datum, idx) {
|
|
236
241
|
var key = (datum.key || idx).toString();
|
|
237
242
|
return enteringNodes[key] ? (0, _assign2.default)({}, datum, before(datum, idx, data)) : datum;
|
|
238
243
|
});
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
return {
|
|
242
|
-
animate:
|
|
243
|
-
data:
|
|
247
|
+
animate: newAnimate,
|
|
248
|
+
data: newData
|
|
244
249
|
};
|
|
245
250
|
} // eslint-disable-next-line max-params, max-len
|
|
246
251
|
|
|
@@ -249,23 +254,24 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
|
249
254
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
250
255
|
// transition for all children to have the same duration, delay, etc.
|
|
251
256
|
var onEnter = animate && animate.onEnter;
|
|
252
|
-
|
|
257
|
+
var newAnimate = (0, _assign2.default)({}, animate, onEnter);
|
|
258
|
+
var newData = data;
|
|
253
259
|
|
|
254
260
|
if (enteringNodes) {
|
|
255
261
|
// Old nodes have been transitioned to their new values, and the
|
|
256
262
|
// domain should encompass the nodes that will now enter. So perform
|
|
257
263
|
// the `onEnter.after` transformation on each node.
|
|
258
|
-
|
|
259
|
-
var after =
|
|
260
|
-
|
|
264
|
+
newAnimate.onEnd = cb;
|
|
265
|
+
var after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity2.default;
|
|
266
|
+
newData = data.map(function (datum, idx) {
|
|
261
267
|
var key = getDatumKey(datum, idx);
|
|
262
268
|
return enteringNodes[key] ? (0, _assign2.default)({}, datum, after(datum, idx, data)) : datum;
|
|
263
269
|
});
|
|
264
270
|
}
|
|
265
271
|
|
|
266
272
|
return {
|
|
267
|
-
animate:
|
|
268
|
-
data:
|
|
273
|
+
animate: newAnimate,
|
|
274
|
+
data: newData
|
|
269
275
|
};
|
|
270
276
|
}
|
|
271
277
|
/**
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
declare type SafeAttribute = string;
|
|
3
|
+
/**
|
|
4
|
+
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
5
|
+
* @param value The value to assert
|
|
6
|
+
* @param message The error message to throw
|
|
7
|
+
*/
|
|
8
|
+
export declare function assert<T>(value: T, message?: string): asserts value is NonNullable<T>;
|
|
3
9
|
/**
|
|
4
10
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
5
11
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.assert = assert;
|
|
6
7
|
exports.withSafeUserProps = exports.getSafeUserProps = void 0;
|
|
7
8
|
|
|
8
9
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -84,6 +85,18 @@ var testIfSafeProp = function (key) {
|
|
|
84
85
|
if (doesPropStartWith(key) || isExactMatch(key)) return true;
|
|
85
86
|
return false;
|
|
86
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
90
|
+
* @param value The value to assert
|
|
91
|
+
* @param message The error message to throw
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function assert(value, message) {
|
|
96
|
+
if (value === undefined || value === null) {
|
|
97
|
+
throw new Error(message);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
87
100
|
/**
|
|
88
101
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
89
102
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -161,12 +161,13 @@ function getDataFromChildren(props, childComponents) {
|
|
|
161
161
|
var iteratee = function (child, childName, parent) {
|
|
162
162
|
var childProps = (0, _assign2.default)({}, child.props, parentProps);
|
|
163
163
|
var childData;
|
|
164
|
+
var childElement = child;
|
|
164
165
|
|
|
165
166
|
if (!Data.isDataComponent(child)) {
|
|
166
167
|
return null;
|
|
167
168
|
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) {
|
|
168
|
-
|
|
169
|
-
childData =
|
|
169
|
+
childElement = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child;
|
|
170
|
+
childData = childElement.type.getData(childProps);
|
|
170
171
|
} else {
|
|
171
172
|
childData = Data.getData(childProps);
|
|
172
173
|
}
|
|
@@ -198,8 +199,7 @@ function getData(props, childComponents) {
|
|
|
198
199
|
return Data.getData(props);
|
|
199
200
|
}
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
return getDataFromChildren(props, childComponents);
|
|
202
|
+
return getDataFromChildren(props, childComponents || _react.default.Children.toArray(props.children));
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function getWidth(props, groupLength, seriesLength) {
|
|
@@ -207,9 +207,9 @@ function getWidth(props, groupLength, seriesLength) {
|
|
|
207
207
|
horizontal = props.horizontal;
|
|
208
208
|
var range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
|
|
209
209
|
var extent = Math.abs(range[1] - range[0]);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var bars =
|
|
210
|
+
var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
|
|
211
|
+
var groupLengthValue = groupLength || datasets.length;
|
|
212
|
+
var bars = groupLengthValue * seriesLengthValue;
|
|
213
213
|
var barRatio = 0.5;
|
|
214
214
|
return Math.round(barRatio * extent / bars);
|
|
215
215
|
}
|
|
@@ -304,9 +304,10 @@ function getDomainFromChildren(props, axis, childComponents) {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
function getDomain(props, axis, childComponents) {
|
|
307
|
-
|
|
307
|
+
var children = childComponents || _react.default.Children.toArray(props.children);
|
|
308
|
+
|
|
308
309
|
var propsDomain = Domain.getDomainFromProps(props, axis);
|
|
309
|
-
var domainPadding = getDefaultDomainPadding(props, axis,
|
|
310
|
+
var domainPadding = getDefaultDomainPadding(props, axis, children);
|
|
310
311
|
var domain;
|
|
311
312
|
|
|
312
313
|
if (propsDomain) {
|
|
@@ -316,7 +317,7 @@ function getDomain(props, axis, childComponents) {
|
|
|
316
317
|
var maxDomain = Domain.getMaxFromProps(props, axis);
|
|
317
318
|
var dataset = (props.data || props.y) && Data.getData(props);
|
|
318
319
|
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
|
|
319
|
-
var childDomain = getDomainFromChildren(props, axis,
|
|
320
|
+
var childDomain = getDomainFromChildren(props, axis, children);
|
|
320
321
|
var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
|
|
321
322
|
var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
|
|
322
323
|
domain = Domain.getDomainFromMinMax(min, max);
|
|
@@ -482,10 +483,11 @@ function getCategoryAndAxisStringsFromChildren(props, axis, childComponents) {
|
|
|
482
483
|
}
|
|
483
484
|
|
|
484
485
|
function getStringsFromChildren(props, childComponents) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
var
|
|
488
|
-
var
|
|
486
|
+
var children = childComponents || _react.default.Children.toArray(props.children);
|
|
487
|
+
|
|
488
|
+
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
|
|
489
|
+
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
|
|
490
|
+
var dataStrings = getStringsFromData(children);
|
|
489
491
|
return {
|
|
490
492
|
x: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))),
|
|
491
493
|
y: (0, _uniq2.default)((0, _flatten2.default)([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y))))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.8.
|
|
3
|
+
"version": "36.8.4",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"prop-types": "^15.8.1",
|
|
25
25
|
"react-fast-compare": "^3.2.0",
|
|
26
|
-
"victory-vendor": "^36.8.
|
|
26
|
+
"victory-vendor": "^36.8.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": ">=16.6.0"
|
package/src/types/callbacks.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D3Scale, Datum, ID } from "./prop-types";
|
|
1
|
+
import { D3Scale, Datum, ID, ScalePropType } from "./prop-types";
|
|
2
2
|
import { BlockProps, OrientationTypes } from "../victory-theme/types";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -16,10 +16,13 @@ export interface CallbackArgs {
|
|
|
16
16
|
index?: ID;
|
|
17
17
|
x?: number;
|
|
18
18
|
y?: number;
|
|
19
|
-
scale?:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
scale?:
|
|
20
|
+
| ScalePropType
|
|
21
|
+
| D3Scale
|
|
22
|
+
| {
|
|
23
|
+
x?: ScalePropType | D3Scale;
|
|
24
|
+
y?: ScalePropType | D3Scale;
|
|
25
|
+
};
|
|
23
26
|
tick?: any;
|
|
24
27
|
ticks?: any;
|
|
25
28
|
text?: any;
|
|
@@ -97,11 +97,11 @@ export const interpolateFunction = function (a, b) {
|
|
|
97
97
|
* differs in that it uses our custom interpolators when interpolating the value of each property in
|
|
98
98
|
* an object. This allows the correct interpolation of nested objects, including styles
|
|
99
99
|
*
|
|
100
|
-
* @param {any}
|
|
101
|
-
* @param {any}
|
|
100
|
+
* @param {any} startValue - Start value.
|
|
101
|
+
* @param {any} endValue - End value.
|
|
102
102
|
* @returns {Function} An interpolation function.
|
|
103
103
|
*/
|
|
104
|
-
export const interpolateObject = function (
|
|
104
|
+
export const interpolateObject = function (startValue, endValue) {
|
|
105
105
|
const interpolateTypes = (x, y) => {
|
|
106
106
|
if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) {
|
|
107
107
|
return interpolateImmediate(x, y);
|
|
@@ -126,6 +126,8 @@ export const interpolateObject = function (a, b) {
|
|
|
126
126
|
|
|
127
127
|
const i = {};
|
|
128
128
|
const c = {};
|
|
129
|
+
let a = startValue;
|
|
130
|
+
let b = endValue;
|
|
129
131
|
let k;
|
|
130
132
|
|
|
131
133
|
if (a === null || typeof a !== "object") {
|
|
@@ -259,8 +259,9 @@ export class VictoryAnimation extends React.Component<
|
|
|
259
259
|
step can generate imprecise values, sometimes greater than 1
|
|
260
260
|
if this happens set the state to 1 and return, cancelling the timer
|
|
261
261
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
const animationDuration =
|
|
263
|
+
duration !== undefined ? duration : this.props.duration;
|
|
264
|
+
const step = animationDuration ? elapsed / animationDuration : 1;
|
|
264
265
|
if (step >= 1) {
|
|
265
266
|
this.setState({
|
|
266
267
|
data: this.interpolator!(1),
|
|
@@ -38,7 +38,7 @@ export interface VictoryLabelProps {
|
|
|
38
38
|
capHeight?: StringOrNumberOrCallback;
|
|
39
39
|
children?: StringOrNumberOrCallback;
|
|
40
40
|
className?: string;
|
|
41
|
-
datum?:
|
|
41
|
+
datum?: Record<string, any>;
|
|
42
42
|
data?: any[];
|
|
43
43
|
desc?: string;
|
|
44
44
|
direction?: string;
|
|
@@ -121,8 +121,10 @@ const getStyles = (style, props) => {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
const getSingleStyle = (s) => {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const baseStyles = Helpers.evaluateStyle(
|
|
125
|
+
s ? defaults({}, s, defaultStyles) : defaultStyles,
|
|
126
|
+
props,
|
|
127
|
+
);
|
|
126
128
|
return assign({}, baseStyles, { fontSize: getFontSize(baseStyles) });
|
|
127
129
|
};
|
|
128
130
|
|
|
@@ -320,21 +322,20 @@ const getInlineXOffset = (calculatedProps, textElements, index) => {
|
|
|
320
322
|
const centerOffset = -totalWidth / 2;
|
|
321
323
|
switch (textAnchor) {
|
|
322
324
|
case "start":
|
|
323
|
-
return widths.reduce(
|
|
324
|
-
memo
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
return widths.reduce(
|
|
326
|
+
(memo, width, i) => (i < index ? memo + width : memo),
|
|
327
|
+
0,
|
|
328
|
+
);
|
|
327
329
|
case "end":
|
|
328
|
-
return widths.reduce(
|
|
329
|
-
memo
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
return widths.reduce(
|
|
331
|
+
(memo, width, i) => (i > index ? memo - width : memo),
|
|
332
|
+
0,
|
|
333
|
+
);
|
|
332
334
|
default:
|
|
333
335
|
// middle
|
|
334
336
|
return widths.reduce((memo, width, i) => {
|
|
335
337
|
const offsetWidth = i < index ? width : 0;
|
|
336
|
-
|
|
337
|
-
return memo;
|
|
338
|
+
return i === index ? memo + width / 2 : memo + offsetWidth;
|
|
338
339
|
}, centerOffset);
|
|
339
340
|
}
|
|
340
341
|
};
|
|
@@ -584,8 +585,8 @@ const defaultProps = {
|
|
|
584
585
|
export const VictoryLabel: {
|
|
585
586
|
role: string;
|
|
586
587
|
defaultStyles: typeof defaultStyles;
|
|
587
|
-
} & React.FC<VictoryLabelProps> = (
|
|
588
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
588
|
+
} & React.FC<VictoryLabelProps> = (initialProps) => {
|
|
589
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
589
590
|
|
|
590
591
|
if (props.text === null || props.text === undefined) {
|
|
591
592
|
return null;
|
|
@@ -596,7 +597,7 @@ export const VictoryLabel: {
|
|
|
596
597
|
calculatedProps;
|
|
597
598
|
|
|
598
599
|
const tspanValues = (text as string[]).map((line, i) => {
|
|
599
|
-
const currentStyle = getSingleValue(style
|
|
600
|
+
const currentStyle = getSingleValue(style, i);
|
|
600
601
|
const capHeightPx = TextSize.convertLengthToPixels(
|
|
601
602
|
`${capHeight}em`,
|
|
602
603
|
currentStyle.fontSize as number,
|
|
@@ -607,7 +608,7 @@ export const VictoryLabel: {
|
|
|
607
608
|
fontSize: currentStyle.fontSize || defaultStyles.fontSize,
|
|
608
609
|
capHeight: capHeightPx,
|
|
609
610
|
text: line,
|
|
610
|
-
//
|
|
611
|
+
// TODO: This looks like a bug:
|
|
611
612
|
textSize: TextSize.approximateTextSize(line, currentStyle),
|
|
612
613
|
lineHeight: currentLineHeight,
|
|
613
614
|
backgroundPadding: getSingleValue(backgroundPadding, i),
|
|
@@ -68,8 +68,8 @@ const defaultProps = {
|
|
|
68
68
|
shapeRendering: "auto",
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
export const Arc = (
|
|
72
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
71
|
+
export const Arc = (initialProps: ArcProps) => {
|
|
72
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
73
73
|
|
|
74
74
|
return React.cloneElement(props.pathComponent!, {
|
|
75
75
|
...props.events,
|
|
@@ -37,8 +37,8 @@ const defaultProps = {
|
|
|
37
37
|
shapeRendering: "auto",
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const Background = (
|
|
41
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
40
|
+
export const Background = (initialProps: BackgroundProps) => {
|
|
41
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
42
42
|
|
|
43
43
|
return props.polar
|
|
44
44
|
? React.cloneElement(props.circleComponent!, {
|
|
@@ -43,8 +43,8 @@ const defaultProps = {
|
|
|
43
43
|
shapeRendering: "auto",
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
export const Border = (
|
|
47
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
46
|
+
export const Border = (initialProps: BorderProps) => {
|
|
47
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
48
48
|
|
|
49
49
|
return React.cloneElement(props.rectComponent!, {
|
|
50
50
|
...props.events,
|
|
@@ -44,8 +44,8 @@ const defaultProps = {
|
|
|
44
44
|
shapeRendering: "auto",
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export const LineSegment = (
|
|
48
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
47
|
+
export const LineSegment = (initialProps: LineSegmentProps) => {
|
|
48
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
49
49
|
|
|
50
50
|
return React.cloneElement(props.lineComponent!, {
|
|
51
51
|
...props.events,
|
|
@@ -72,8 +72,8 @@ const defaultProps = {
|
|
|
72
72
|
shapeRendering: "auto",
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
export const Point = (
|
|
76
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
75
|
+
export const Point = (initialProps: PointProps) => {
|
|
76
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
77
77
|
const userProps = UserProps.getSafeUserProps(props);
|
|
78
78
|
|
|
79
79
|
return React.cloneElement(props.pathComponent!, {
|
|
@@ -47,8 +47,8 @@ const defaultProps = {
|
|
|
47
47
|
shapeRendering: "auto",
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export const Whisker = (
|
|
51
|
-
props = evaluateProps({ ...defaultProps, ...
|
|
50
|
+
export const Whisker = (initialProps: WhiskerProps) => {
|
|
51
|
+
const props = evaluateProps({ ...defaultProps, ...initialProps });
|
|
52
52
|
const {
|
|
53
53
|
ariaLabel,
|
|
54
54
|
groupComponent,
|
|
@@ -77,9 +77,9 @@ export const Whisker = (props: WhiskerProps) => {
|
|
|
77
77
|
shapeRendering,
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
return React.cloneElement(groupComponent
|
|
80
|
+
return React.cloneElement(groupComponent, {}, [
|
|
81
81
|
React.cloneElement(
|
|
82
|
-
lineComponent
|
|
82
|
+
lineComponent,
|
|
83
83
|
assign(
|
|
84
84
|
{ key: "major-whisker", "aria-label": ariaLabel },
|
|
85
85
|
baseProps,
|
|
@@ -87,7 +87,7 @@ export const Whisker = (props: WhiskerProps) => {
|
|
|
87
87
|
),
|
|
88
88
|
),
|
|
89
89
|
React.cloneElement(
|
|
90
|
-
lineComponent
|
|
90
|
+
lineComponent,
|
|
91
91
|
assign(
|
|
92
92
|
{ key: "minor-whisker", "aria-label": ariaLabel },
|
|
93
93
|
baseProps,
|
|
@@ -270,12 +270,10 @@ export function addEvents<
|
|
|
270
270
|
applyExternalMutations(props, externalMutations) {
|
|
271
271
|
if (!isEmpty(externalMutations)) {
|
|
272
272
|
const callbacks = props.externalEventMutations.reduce(
|
|
273
|
-
(memo, mutation) =>
|
|
274
|
-
|
|
273
|
+
(memo, mutation) =>
|
|
274
|
+
isFunction(mutation.callback)
|
|
275
275
|
? memo.concat(mutation.callback)
|
|
276
|
-
: memo
|
|
277
|
-
return memo;
|
|
278
|
-
},
|
|
276
|
+
: memo,
|
|
279
277
|
[] as Array<() => void>,
|
|
280
278
|
);
|
|
281
279
|
const compiledCallbacks = callbacks.length
|
|
@@ -327,9 +325,9 @@ export function addEvents<
|
|
|
327
325
|
}
|
|
328
326
|
|
|
329
327
|
getBaseProps(props, getSharedEventState): this["baseProps"] {
|
|
330
|
-
|
|
328
|
+
const getSharedEventStateFunction =
|
|
331
329
|
getSharedEventState || this.getSharedEventState.bind(this);
|
|
332
|
-
const sharedParentState =
|
|
330
|
+
const sharedParentState = getSharedEventStateFunction("parent", "parent");
|
|
333
331
|
const parentState = this.getEventState("parent", "parent");
|
|
334
332
|
const baseParentProps = defaults({}, parentState, sharedParentState);
|
|
335
333
|
const parentPropsList = baseParentProps.parentControlledProps;
|
|
@@ -437,6 +435,7 @@ export function addEvents<
|
|
|
437
435
|
const { dataComponent, labelComponent, groupComponent } = props;
|
|
438
436
|
const dataKeys = without(this.dataKeys, "all");
|
|
439
437
|
const labelComponents = dataKeys.reduce((memo, key) => {
|
|
438
|
+
let newMemo = memo;
|
|
440
439
|
const labelProps = this.getComponentProps(
|
|
441
440
|
labelComponent,
|
|
442
441
|
"labels",
|
|
@@ -447,9 +446,11 @@ export function addEvents<
|
|
|
447
446
|
labelProps.text !== undefined &&
|
|
448
447
|
labelProps.text !== null
|
|
449
448
|
) {
|
|
450
|
-
|
|
449
|
+
newMemo = newMemo.concat(
|
|
450
|
+
React.cloneElement(labelComponent!, labelProps),
|
|
451
|
+
);
|
|
451
452
|
}
|
|
452
|
-
return
|
|
453
|
+
return newMemo;
|
|
453
454
|
}, [] as React.ReactElement[]);
|
|
454
455
|
|
|
455
456
|
const dataProps = this.getComponentProps(dataComponent, "data", "all");
|