victory-core 36.8.2 → 36.8.3
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 +12 -0
- package/dist/victory-core.js +177 -155
- 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 +13 -16
- 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 +13 -16
- 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 +15 -23
- 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
|
@@ -287,6 +287,7 @@ export function reduceChildren(children, iteratee) {
|
|
|
287
287
|
|
|
288
288
|
var traverseChildren = function (childArray, names, parent) {
|
|
289
289
|
return childArray.reduce(function (memo, child, index) {
|
|
290
|
+
var newMemo = memo;
|
|
290
291
|
var childRole = child.type && child.type.role;
|
|
291
292
|
var childName = child.props.name || "".concat(childRole, "-").concat(names[index]);
|
|
292
293
|
|
|
@@ -304,16 +305,16 @@ export function reduceChildren(children, iteratee) {
|
|
|
304
305
|
});
|
|
305
306
|
|
|
306
307
|
var nestedResults = traverseChildren(nestedChildren, _childNames, child);
|
|
307
|
-
|
|
308
|
+
newMemo = combine(newMemo, nestedResults);
|
|
308
309
|
} else {
|
|
309
310
|
var result = iteratee(child, childName, parent);
|
|
310
311
|
|
|
311
312
|
if (result) {
|
|
312
|
-
|
|
313
|
+
newMemo = combine(newMemo, result);
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
|
|
316
|
-
return
|
|
317
|
+
return newMemo;
|
|
317
318
|
}, initialMemo);
|
|
318
319
|
};
|
|
319
320
|
|
|
@@ -339,8 +340,7 @@ export function isHorizontal(props) {
|
|
|
339
340
|
var childProps = child.props || {};
|
|
340
341
|
|
|
341
342
|
if (memo || childProps.horizontal || !childProps.children) {
|
|
342
|
-
|
|
343
|
-
return memo;
|
|
343
|
+
return memo || childProps.horizontal;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
return traverseChildren(React.Children.toArray(childProps.children));
|
|
@@ -19,11 +19,13 @@ export function isMap(x) {
|
|
|
19
19
|
}
|
|
20
20
|
export function shallowToJS(x, whitelist) {
|
|
21
21
|
return isIterable(x) ? x.reduce(function (result, curr, key) {
|
|
22
|
+
var newCurr = curr;
|
|
23
|
+
|
|
22
24
|
if (whitelist && whitelist[key]) {
|
|
23
|
-
|
|
25
|
+
newCurr = shallowToJS(curr);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
result[key] =
|
|
28
|
+
result[key] = newCurr;
|
|
27
29
|
return result;
|
|
28
30
|
}, isList(x) ? [] : {}) : x;
|
|
29
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getText(props: any, datum: any, index: any): any;
|
|
1
|
+
export declare function getText(props: any, datum: Record<string, any> | undefined, index: any): any;
|
|
2
2
|
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
3
3
|
export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
4
4
|
export declare function getPolarAngle(props: any, baseAngle?: any): number;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import _defaults from "lodash/defaults";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-use-before-define */
|
|
4
2
|
import * as Helpers from "./helpers";
|
|
5
3
|
|
|
6
4
|
// Private Functions
|
|
7
|
-
function getVerticalAnchor(props
|
|
8
|
-
datum =
|
|
5
|
+
function getVerticalAnchor(props) {
|
|
6
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9
7
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
10
8
|
var labelStyle = props.style && props.style.labels || {};
|
|
11
9
|
|
|
@@ -18,8 +16,8 @@ function getVerticalAnchor(props, datum) {
|
|
|
18
16
|
return "middle";
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
function getTextAnchor(props
|
|
22
|
-
datum =
|
|
19
|
+
function getTextAnchor(props) {
|
|
20
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23
21
|
var style = props.style,
|
|
24
22
|
horizontal = props.horizontal;
|
|
25
23
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
@@ -34,14 +32,14 @@ function getTextAnchor(props, datum) {
|
|
|
34
32
|
return sign >= 0 ? "start" : "end";
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
function getAngle(props
|
|
38
|
-
datum =
|
|
35
|
+
function getAngle(props) {
|
|
36
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
37
|
var labelStyle = props.style && props.style.labels || {};
|
|
40
38
|
return datum.angle === undefined ? labelStyle.angle : datum.angle;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
function getPadding(props
|
|
44
|
-
datum =
|
|
41
|
+
function getPadding(props) {
|
|
42
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
43
|
var horizontal = props.horizontal,
|
|
46
44
|
style = props.style;
|
|
47
45
|
var labelStyle = style.labels || {};
|
|
@@ -120,8 +118,9 @@ function getPolarOrientation(degrees) {
|
|
|
120
118
|
} // Exported Functions
|
|
121
119
|
|
|
122
120
|
|
|
123
|
-
export function getText(props
|
|
124
|
-
datum =
|
|
121
|
+
export function getText(props) {
|
|
122
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
123
|
+
var index = arguments.length > 2 ? arguments[2] : undefined;
|
|
125
124
|
|
|
126
125
|
if (datum.label !== undefined) {
|
|
127
126
|
return datum.label;
|
|
@@ -49,8 +49,7 @@ export function getSVGEventCoordinates(evt, svg) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
|
|
52
|
-
|
|
53
|
-
var matrix = getTransformationMatrix(svg);
|
|
52
|
+
var matrix = getTransformationMatrix(svg || getParentSVG(location));
|
|
54
53
|
return {
|
|
55
54
|
x: transformTarget(location.clientX, matrix, "x"),
|
|
56
55
|
y: transformTarget(location.clientY, matrix, "y")
|
package/es/victory-util/timer.js
CHANGED
|
@@ -57,11 +57,10 @@ var Timer = /*#__PURE__*/function () {
|
|
|
57
57
|
}, {
|
|
58
58
|
key: "subscribe",
|
|
59
59
|
value: function subscribe(callback, duration) {
|
|
60
|
-
duration = this.shouldAnimate ? duration : 0;
|
|
61
60
|
var subscriptionID = this.subscribers.push({
|
|
62
61
|
startTime: now(),
|
|
63
62
|
callback: callback,
|
|
64
|
-
duration: duration
|
|
63
|
+
duration: this.shouldAnimate ? duration : 0
|
|
65
64
|
});
|
|
66
65
|
this.activeSubscriptions++;
|
|
67
66
|
this.start();
|
|
@@ -136,36 +136,38 @@ function getInitialChildProps(animate, data) {
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
function getChildBeforeLoad(animate, child, data, cb) {
|
|
139
|
-
|
|
139
|
+
var newAnimate = _assign({}, animate, {
|
|
140
140
|
onEnd: cb
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
if (
|
|
143
|
+
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
144
144
|
return {
|
|
145
|
-
animate:
|
|
145
|
+
animate: newAnimate,
|
|
146
146
|
data: data
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
var before =
|
|
150
|
+
var before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : _identity; // If nodes need to exit, transform them with the provided onLoad.before function.
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
var newData = data.map(function (datum, idx) {
|
|
153
153
|
return _assign({}, datum, before(datum, idx, data));
|
|
154
154
|
});
|
|
155
155
|
return {
|
|
156
|
-
animate:
|
|
157
|
-
data:
|
|
156
|
+
animate: newAnimate,
|
|
157
|
+
data: newData,
|
|
158
158
|
clipWidth: 0
|
|
159
159
|
};
|
|
160
160
|
} // eslint-disable-next-line max-params
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
function getChildOnLoad(animate, data, cb) {
|
|
164
|
-
|
|
164
|
+
var newAnimate = _assign({}, animate, {
|
|
165
165
|
onEnd: cb
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
var newData = data;
|
|
169
|
+
|
|
170
|
+
if (newAnimate && newAnimate.onLoad && !newAnimate.onLoad.duration) {
|
|
169
171
|
return {
|
|
170
172
|
animate: animate,
|
|
171
173
|
data: data
|
|
@@ -174,12 +176,12 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
174
176
|
|
|
175
177
|
var after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : _identity; // If nodes need to exit, transform them with the provided onLoad.after function.
|
|
176
178
|
|
|
177
|
-
|
|
179
|
+
newData = data.map(function (datum, idx) {
|
|
178
180
|
return _assign({}, datum, after(datum, idx, data));
|
|
179
181
|
});
|
|
180
182
|
return {
|
|
181
|
-
animate:
|
|
182
|
-
data:
|
|
183
|
+
animate: newAnimate,
|
|
184
|
+
data: newData
|
|
183
185
|
};
|
|
184
186
|
} // eslint-disable-next-line max-params, max-len
|
|
185
187
|
|
|
@@ -188,7 +190,10 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
188
190
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
189
191
|
// transition for all children to have the same duration, delay, etc.
|
|
190
192
|
var onExit = animate && animate.onExit;
|
|
191
|
-
|
|
193
|
+
|
|
194
|
+
var newAnimate = _assign({}, animate, onExit);
|
|
195
|
+
|
|
196
|
+
var newData = data;
|
|
192
197
|
|
|
193
198
|
if (exitingNodes) {
|
|
194
199
|
// After the exit transition occurs, trigger the animations for
|
|
@@ -196,39 +201,42 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
196
201
|
animate.onEnd = cb;
|
|
197
202
|
var before = animate.onExit && animate.onExit.before ? animate.onExit.before : _identity; // If nodes need to exit, transform them with the provided onExit.before function.
|
|
198
203
|
|
|
199
|
-
|
|
204
|
+
newData = data.map(function (datum, idx) {
|
|
200
205
|
var key = (datum.key || idx).toString();
|
|
201
206
|
return exitingNodes[key] ? _assign({}, datum, before(datum, idx, data)) : datum;
|
|
202
207
|
});
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
return {
|
|
206
|
-
animate:
|
|
207
|
-
data:
|
|
211
|
+
animate: newAnimate,
|
|
212
|
+
data: newData
|
|
208
213
|
};
|
|
209
214
|
} // eslint-disable-next-line max-params,max-len
|
|
210
215
|
|
|
211
216
|
|
|
212
217
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
218
|
+
var newAnimate = animate;
|
|
219
|
+
var newData = data;
|
|
220
|
+
|
|
213
221
|
if (enteringNodes) {
|
|
214
222
|
// Perform a normal animation here, except - when it finishes - trigger
|
|
215
223
|
// the transition for entering nodes.
|
|
216
|
-
|
|
224
|
+
newAnimate = _assign({}, animate, {
|
|
217
225
|
onEnd: cb
|
|
218
226
|
});
|
|
219
227
|
var before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : _identity; // We want the entering nodes to be included in the transition target
|
|
220
228
|
// domain. However, we may not want these nodes to be displayed initially,
|
|
221
229
|
// so perform the `onEnter.before` transformation on each node.
|
|
222
230
|
|
|
223
|
-
|
|
231
|
+
newData = data.map(function (datum, idx) {
|
|
224
232
|
var key = (datum.key || idx).toString();
|
|
225
233
|
return enteringNodes[key] ? _assign({}, datum, before(datum, idx, data)) : datum;
|
|
226
234
|
});
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
return {
|
|
230
|
-
animate:
|
|
231
|
-
data:
|
|
238
|
+
animate: newAnimate,
|
|
239
|
+
data: newData
|
|
232
240
|
};
|
|
233
241
|
} // eslint-disable-next-line max-params, max-len
|
|
234
242
|
|
|
@@ -237,23 +245,26 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
|
237
245
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
238
246
|
// transition for all children to have the same duration, delay, etc.
|
|
239
247
|
var onEnter = animate && animate.onEnter;
|
|
240
|
-
|
|
248
|
+
|
|
249
|
+
var newAnimate = _assign({}, animate, onEnter);
|
|
250
|
+
|
|
251
|
+
var newData = data;
|
|
241
252
|
|
|
242
253
|
if (enteringNodes) {
|
|
243
254
|
// Old nodes have been transitioned to their new values, and the
|
|
244
255
|
// domain should encompass the nodes that will now enter. So perform
|
|
245
256
|
// the `onEnter.after` transformation on each node.
|
|
246
|
-
|
|
247
|
-
var after =
|
|
248
|
-
|
|
257
|
+
newAnimate.onEnd = cb;
|
|
258
|
+
var after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : _identity;
|
|
259
|
+
newData = data.map(function (datum, idx) {
|
|
249
260
|
var key = getDatumKey(datum, idx);
|
|
250
261
|
return enteringNodes[key] ? _assign({}, datum, after(datum, idx, data)) : datum;
|
|
251
262
|
});
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
return {
|
|
255
|
-
animate:
|
|
256
|
-
data:
|
|
266
|
+
animate: newAnimate,
|
|
267
|
+
data: newData
|
|
257
268
|
};
|
|
258
269
|
}
|
|
259
270
|
/**
|
|
@@ -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
|
|
@@ -72,6 +72,18 @@ var testIfSafeProp = function (key) {
|
|
|
72
72
|
if (doesPropStartWith(key) || isExactMatch(key)) return true;
|
|
73
73
|
return false;
|
|
74
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
77
|
+
* @param value The value to assert
|
|
78
|
+
* @param message The error message to throw
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export function assert(value, message) {
|
|
83
|
+
if (value === undefined || value === null) {
|
|
84
|
+
throw new Error(message);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
75
87
|
/**
|
|
76
88
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
77
89
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -81,7 +93,6 @@ var testIfSafeProp = function (key) {
|
|
|
81
93
|
* @returns {Object}: object containing remaining acceptable props
|
|
82
94
|
*/
|
|
83
95
|
|
|
84
|
-
|
|
85
96
|
export var getSafeUserProps = function (props) {
|
|
86
97
|
var propsToFilter = _objectSpread({}, props);
|
|
87
98
|
|
|
@@ -114,12 +114,13 @@ export function getDataFromChildren(props, childComponents) {
|
|
|
114
114
|
var childProps = _assign({}, child.props, parentProps);
|
|
115
115
|
|
|
116
116
|
var childData;
|
|
117
|
+
var childElement = child;
|
|
117
118
|
|
|
118
119
|
if (!Data.isDataComponent(child)) {
|
|
119
120
|
return null;
|
|
120
121
|
} else if (child.type && _isFunction(child.type.getData)) {
|
|
121
|
-
|
|
122
|
-
childData =
|
|
122
|
+
childElement = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child;
|
|
123
|
+
childData = childElement.type.getData(childProps);
|
|
123
124
|
} else {
|
|
124
125
|
childData = Data.getData(childProps);
|
|
125
126
|
}
|
|
@@ -150,17 +151,16 @@ export function getData(props, childComponents) {
|
|
|
150
151
|
return Data.getData(props);
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
return getDataFromChildren(props, childComponents);
|
|
154
|
+
return getDataFromChildren(props, childComponents || React.Children.toArray(props.children));
|
|
155
155
|
}
|
|
156
156
|
export function getWidth(props, groupLength, seriesLength) {
|
|
157
157
|
var datasets = props.datasets,
|
|
158
158
|
horizontal = props.horizontal;
|
|
159
159
|
var range = horizontal ? Helpers.getRange(props, "y") : Helpers.getRange(props, "x");
|
|
160
160
|
var extent = Math.abs(range[1] - range[0]);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var bars =
|
|
161
|
+
var seriesLengthValue = seriesLength !== undefined ? seriesLength : Array.isArray(datasets[0]) && datasets[0].length || 1;
|
|
162
|
+
var groupLengthValue = groupLength || datasets.length;
|
|
163
|
+
var bars = groupLengthValue * seriesLengthValue;
|
|
164
164
|
var barRatio = 0.5;
|
|
165
165
|
return Math.round(barRatio * extent / bars);
|
|
166
166
|
}
|
|
@@ -252,9 +252,9 @@ export function getDomainFromChildren(props, axis, childComponents) {
|
|
|
252
252
|
return [min, max];
|
|
253
253
|
}
|
|
254
254
|
export function getDomain(props, axis, childComponents) {
|
|
255
|
-
|
|
255
|
+
var children = childComponents || React.Children.toArray(props.children);
|
|
256
256
|
var propsDomain = Domain.getDomainFromProps(props, axis);
|
|
257
|
-
var domainPadding = getDefaultDomainPadding(props, axis,
|
|
257
|
+
var domainPadding = getDefaultDomainPadding(props, axis, children);
|
|
258
258
|
var domain;
|
|
259
259
|
|
|
260
260
|
if (propsDomain) {
|
|
@@ -264,7 +264,7 @@ export function getDomain(props, axis, childComponents) {
|
|
|
264
264
|
var maxDomain = Domain.getMaxFromProps(props, axis);
|
|
265
265
|
var dataset = (props.data || props.y) && Data.getData(props);
|
|
266
266
|
var dataDomain = dataset ? Domain.getDomainFromData(props, axis, dataset) : [];
|
|
267
|
-
var childDomain = getDomainFromChildren(props, axis,
|
|
267
|
+
var childDomain = getDomainFromChildren(props, axis, children);
|
|
268
268
|
var min = minDomain || Collection.getMinValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
|
|
269
269
|
var max = maxDomain || Collection.getMaxValue([].concat(_toConsumableArray(dataDomain), _toConsumableArray(childDomain)));
|
|
270
270
|
domain = Domain.getDomainFromMinMax(min, max);
|
|
@@ -426,10 +426,10 @@ export function getCategoryAndAxisStringsFromChildren(props, axis, childComponen
|
|
|
426
426
|
return _uniq(_flatten([].concat(_toConsumableArray(categoryStrings), _toConsumableArray(axisStrings))));
|
|
427
427
|
}
|
|
428
428
|
export function getStringsFromChildren(props, childComponents) {
|
|
429
|
-
|
|
430
|
-
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x",
|
|
431
|
-
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y",
|
|
432
|
-
var dataStrings = getStringsFromData(
|
|
429
|
+
var children = childComponents || React.Children.toArray(props.children);
|
|
430
|
+
var xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
|
|
431
|
+
var yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
|
|
432
|
+
var dataStrings = getStringsFromData(children);
|
|
433
433
|
return {
|
|
434
434
|
x: _uniq(_flatten([].concat(_toConsumableArray(xStrings), _toConsumableArray(dataStrings.x)))),
|
|
435
435
|
y: _uniq(_flatten([].concat(_toConsumableArray(yStrings), _toConsumableArray(dataStrings.y))))
|
package/lib/types/callbacks.d.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
|
* This is the first parameter of a callback when a callback is used to
|
|
@@ -15,9 +15,9 @@ export interface CallbackArgs {
|
|
|
15
15
|
index?: ID;
|
|
16
16
|
x?: number;
|
|
17
17
|
y?: number;
|
|
18
|
-
scale?: {
|
|
19
|
-
x?: D3Scale;
|
|
20
|
-
y?: D3Scale;
|
|
18
|
+
scale?: ScalePropType | D3Scale | {
|
|
19
|
+
x?: ScalePropType | D3Scale;
|
|
20
|
+
y?: ScalePropType | D3Scale;
|
|
21
21
|
};
|
|
22
22
|
tick?: any;
|
|
23
23
|
ticks?: any;
|
|
@@ -34,11 +34,11 @@ export declare const interpolateFunction: (a: any, b: any) => (t: any) => any;
|
|
|
34
34
|
* differs in that it uses our custom interpolators when interpolating the value of each property in
|
|
35
35
|
* an object. This allows the correct interpolation of nested objects, including styles
|
|
36
36
|
*
|
|
37
|
-
* @param {any}
|
|
38
|
-
* @param {any}
|
|
37
|
+
* @param {any} startValue - Start value.
|
|
38
|
+
* @param {any} endValue - End value.
|
|
39
39
|
* @returns {Function} An interpolation function.
|
|
40
40
|
*/
|
|
41
|
-
export declare const interpolateObject: (
|
|
41
|
+
export declare const interpolateObject: (startValue: any, endValue: any) => (t: any) => {};
|
|
42
42
|
export declare const interpolateString: (a: any, b: any) => (t: number) => any;
|
|
43
43
|
/**
|
|
44
44
|
* By default, the list of interpolators used by `d3.interpolate` has a few
|
|
@@ -118,15 +118,15 @@ var interpolateFunction = function (a, b) {
|
|
|
118
118
|
* differs in that it uses our custom interpolators when interpolating the value of each property in
|
|
119
119
|
* an object. This allows the correct interpolation of nested objects, including styles
|
|
120
120
|
*
|
|
121
|
-
* @param {any}
|
|
122
|
-
* @param {any}
|
|
121
|
+
* @param {any} startValue - Start value.
|
|
122
|
+
* @param {any} endValue - End value.
|
|
123
123
|
* @returns {Function} An interpolation function.
|
|
124
124
|
*/
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
exports.interpolateFunction = interpolateFunction;
|
|
128
128
|
|
|
129
|
-
var interpolateObject = function (
|
|
129
|
+
var interpolateObject = function (startValue, endValue) {
|
|
130
130
|
var interpolateTypes = function (x, y) {
|
|
131
131
|
if (x === y || !isInterpolatable(x) || !isInterpolatable(y)) {
|
|
132
132
|
return interpolateImmediate(x, y);
|
|
@@ -151,6 +151,8 @@ var interpolateObject = function (a, b) {
|
|
|
151
151
|
|
|
152
152
|
var i = {};
|
|
153
153
|
var c = {};
|
|
154
|
+
var a = startValue;
|
|
155
|
+
var b = endValue;
|
|
154
156
|
var k;
|
|
155
157
|
|
|
156
158
|
if (a === null || typeof a !== "object") {
|
|
@@ -79,8 +79,8 @@ var VictoryAnimation = /*#__PURE__*/function (_React$Component) {
|
|
|
79
79
|
step can generate imprecise values, sometimes greater than 1
|
|
80
80
|
if this happens set the state to 1 and return, cancelling the timer
|
|
81
81
|
*/
|
|
82
|
-
|
|
83
|
-
var step =
|
|
82
|
+
var animationDuration = duration !== undefined ? duration : _this.props.duration;
|
|
83
|
+
var step = animationDuration ? elapsed / animationDuration : 1;
|
|
84
84
|
|
|
85
85
|
if (step >= 1) {
|
|
86
86
|
_this.setState({
|
|
@@ -119,8 +119,7 @@ var getStyles = function (style, props) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
var getSingleStyle = function (s) {
|
|
122
|
-
|
|
123
|
-
var baseStyles = Helpers.evaluateStyle(s, props);
|
|
122
|
+
var baseStyles = Helpers.evaluateStyle(s ? (0, _defaults2.default)({}, s, defaultStyles) : defaultStyles, props);
|
|
124
123
|
return (0, _assign2.default)({}, baseStyles, {
|
|
125
124
|
fontSize: getFontSize(baseStyles)
|
|
126
125
|
});
|
|
@@ -324,22 +323,19 @@ var getInlineXOffset = function (calculatedProps, textElements, index) {
|
|
|
324
323
|
switch (textAnchor) {
|
|
325
324
|
case "start":
|
|
326
325
|
return widths.reduce(function (memo, width, i) {
|
|
327
|
-
|
|
328
|
-
return memo;
|
|
326
|
+
return i < index ? memo + width : memo;
|
|
329
327
|
}, 0);
|
|
330
328
|
|
|
331
329
|
case "end":
|
|
332
330
|
return widths.reduce(function (memo, width, i) {
|
|
333
|
-
|
|
334
|
-
return memo;
|
|
331
|
+
return i > index ? memo - width : memo;
|
|
335
332
|
}, 0);
|
|
336
333
|
|
|
337
334
|
default:
|
|
338
335
|
// middle
|
|
339
336
|
return widths.reduce(function (memo, width, i) {
|
|
340
337
|
var offsetWidth = i < index ? width : 0;
|
|
341
|
-
|
|
342
|
-
return memo;
|
|
338
|
+
return i === index ? memo + width / 2 : memo + offsetWidth;
|
|
343
339
|
}, centerOffset);
|
|
344
340
|
}
|
|
345
341
|
};
|
|
@@ -542,8 +538,8 @@ var defaultProps = {
|
|
|
542
538
|
lineHeight: 1
|
|
543
539
|
};
|
|
544
540
|
|
|
545
|
-
var VictoryLabel = function (
|
|
546
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
541
|
+
var VictoryLabel = function (initialProps) {
|
|
542
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
547
543
|
|
|
548
544
|
if (props.text === null || props.text === undefined) {
|
|
549
545
|
return null;
|
|
@@ -564,7 +560,7 @@ var VictoryLabel = function (props) {
|
|
|
564
560
|
fontSize: currentStyle.fontSize || defaultStyles.fontSize,
|
|
565
561
|
capHeight: capHeightPx,
|
|
566
562
|
text: line,
|
|
567
|
-
//
|
|
563
|
+
// TODO: This looks like a bug:
|
|
568
564
|
textSize: TextSize.approximateTextSize(line, currentStyle),
|
|
569
565
|
lineHeight: currentLineHeight,
|
|
570
566
|
backgroundPadding: getSingleValue(backgroundPadding, i)
|
|
@@ -12,7 +12,7 @@ export interface ArcProps extends VictoryCommonPrimitiveProps {
|
|
|
12
12
|
startAngle?: number;
|
|
13
13
|
}
|
|
14
14
|
export declare const Arc: {
|
|
15
|
-
(
|
|
15
|
+
(initialProps: ArcProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
16
16
|
propTypes: {
|
|
17
17
|
closedPath: PropTypes.Requireable<boolean>;
|
|
18
18
|
cx: PropTypes.Requireable<number>;
|
|
@@ -85,8 +85,8 @@ var defaultProps = {
|
|
|
85
85
|
shapeRendering: "auto"
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
var Arc = function (
|
|
89
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
88
|
+
var Arc = function (initialProps) {
|
|
89
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
90
90
|
return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, {
|
|
91
91
|
"aria-label": props.ariaLabel,
|
|
92
92
|
d: getArcPath(props),
|
|
@@ -12,7 +12,7 @@ export interface BackgroundProps extends VictoryCommonPrimitiveProps {
|
|
|
12
12
|
y?: number;
|
|
13
13
|
}
|
|
14
14
|
export declare const Background: {
|
|
15
|
-
(
|
|
15
|
+
(initialProps: BackgroundProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
16
16
|
propTypes: {
|
|
17
17
|
circleComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
18
18
|
height: PropTypes.Requireable<number>;
|
|
@@ -49,8 +49,8 @@ var defaultProps = {
|
|
|
49
49
|
shapeRendering: "auto"
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
var Background = function (
|
|
53
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
52
|
+
var Background = function (initialProps) {
|
|
53
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
54
54
|
return props.polar ? /*#__PURE__*/_react.default.cloneElement(props.circleComponent, _objectSpread(_objectSpread({}, props.events), {}, {
|
|
55
55
|
style: props.style,
|
|
56
56
|
role: props.role,
|
|
@@ -9,7 +9,7 @@ export interface BorderProps extends VictoryCommonPrimitiveProps {
|
|
|
9
9
|
y?: number;
|
|
10
10
|
}
|
|
11
11
|
export declare const Border: {
|
|
12
|
-
(
|
|
12
|
+
(initialProps: BorderProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
13
13
|
propTypes: {
|
|
14
14
|
height: PropTypes.Requireable<number>;
|
|
15
15
|
rectComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
@@ -60,8 +60,8 @@ var defaultProps = {
|
|
|
60
60
|
shapeRendering: "auto"
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
var Border = function (
|
|
64
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
63
|
+
var Border = function (initialProps) {
|
|
64
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
65
65
|
return /*#__PURE__*/_react.default.cloneElement(props.rectComponent, _objectSpread(_objectSpread({}, props.events), {}, {
|
|
66
66
|
"aria-label": props.ariaLabel,
|
|
67
67
|
style: props.style,
|
|
@@ -10,7 +10,7 @@ export interface LineSegmentProps extends VictoryCommonPrimitiveProps {
|
|
|
10
10
|
y2?: number;
|
|
11
11
|
}
|
|
12
12
|
export declare const LineSegment: {
|
|
13
|
-
(
|
|
13
|
+
(initialProps: LineSegmentProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
14
14
|
propTypes: {
|
|
15
15
|
datum: PropTypes.Requireable<any>;
|
|
16
16
|
lineComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
@@ -60,8 +60,8 @@ var defaultProps = {
|
|
|
60
60
|
shapeRendering: "auto"
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
var LineSegment = function (
|
|
64
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
63
|
+
var LineSegment = function (initialProps) {
|
|
64
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
65
65
|
return /*#__PURE__*/_react.default.cloneElement(props.lineComponent, _objectSpread(_objectSpread({}, props.events), {}, {
|
|
66
66
|
"aria-label": props.ariaLabel,
|
|
67
67
|
style: props.style,
|