victory-core 37.3.2 → 37.3.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 +16 -0
- package/dist/victory-core.js +423 -371
- package/dist/victory-core.min.js +1 -1
- package/es/types/callbacks.d.ts +11 -11
- package/es/types/prop-types.d.ts +28 -28
- package/es/victory-animation/util.js +6 -6
- package/es/victory-animation/victory-animation.d.ts +3 -3
- package/es/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/es/victory-clip-container/victory-clip-container.js +20 -12
- package/es/victory-container/victory-container.js +2 -2
- package/es/victory-label/victory-label.d.ts +3 -3
- package/es/victory-label/victory-label.js +12 -16
- package/es/victory-portal/victory-portal.js +4 -4
- package/es/victory-primitives/arc.js +2 -2
- package/es/victory-primitives/background.js +2 -2
- package/es/victory-primitives/border.js +2 -2
- package/es/victory-primitives/line-segment.js +2 -2
- package/es/victory-primitives/point.js +2 -2
- package/es/victory-primitives/tspan.d.ts +0 -1
- package/es/victory-primitives/types.d.ts +1 -1
- package/es/victory-primitives/whisker.d.ts +1 -1
- package/es/victory-primitives/whisker.js +2 -2
- package/es/victory-theme/types.d.ts +11 -11
- package/es/victory-transition/victory-transition.d.ts +1 -1
- package/es/victory-transition/victory-transition.js +7 -7
- package/es/victory-util/add-events.d.ts +8 -8
- package/es/victory-util/add-events.js +13 -13
- package/es/victory-util/axis.js +11 -11
- package/es/victory-util/data.js +16 -16
- package/es/victory-util/domain.js +13 -13
- package/es/victory-util/events.d.ts +4 -4
- package/es/victory-util/events.js +14 -14
- package/es/victory-util/helpers.d.ts +94 -19
- package/es/victory-util/helpers.js +95 -49
- package/es/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/es/victory-util/hooks/use-animation-state.js +4 -4
- package/es/victory-util/label-helpers.d.ts +4 -3
- package/es/victory-util/label-helpers.js +3 -2
- package/es/victory-util/line-helpers.d.ts +1 -1
- package/es/victory-util/log.js +3 -2
- package/es/victory-util/merge-refs.d.ts +1 -1
- package/es/victory-util/scale.js +2 -2
- package/es/victory-util/selection.d.ts +3 -3
- package/es/victory-util/textsize.js +7 -5
- package/es/victory-util/timer.d.ts +1 -1
- package/es/victory-util/transitions.d.ts +1 -1
- package/es/victory-util/transitions.js +12 -12
- package/es/victory-util/type-helpers.d.ts +0 -1
- package/es/victory-util/type-helpers.js +0 -5
- package/es/victory-util/user-props.d.ts +2 -2
- package/es/victory-util/wrapper.js +12 -12
- package/lib/types/callbacks.d.ts +11 -11
- package/lib/types/prop-types.d.ts +28 -28
- package/lib/victory-animation/util.js +6 -6
- package/lib/victory-animation/victory-animation.d.ts +3 -3
- package/lib/victory-clip-container/victory-clip-container.d.ts +6 -1
- package/lib/victory-clip-container/victory-clip-container.js +20 -12
- package/lib/victory-container/victory-container.js +3 -3
- package/lib/victory-label/victory-label.d.ts +3 -3
- package/lib/victory-label/victory-label.js +12 -16
- package/lib/victory-portal/victory-portal.js +5 -5
- package/lib/victory-primitives/arc.js +2 -2
- package/lib/victory-primitives/background.js +2 -2
- package/lib/victory-primitives/border.js +2 -2
- package/lib/victory-primitives/line-segment.js +2 -2
- package/lib/victory-primitives/point.js +2 -2
- package/lib/victory-primitives/tspan.d.ts +0 -1
- package/lib/victory-primitives/types.d.ts +1 -1
- package/lib/victory-primitives/whisker.d.ts +1 -1
- package/lib/victory-primitives/whisker.js +2 -2
- package/lib/victory-theme/types.d.ts +11 -11
- package/lib/victory-transition/victory-transition.d.ts +1 -1
- package/lib/victory-transition/victory-transition.js +7 -7
- package/lib/victory-util/add-events.d.ts +8 -8
- package/lib/victory-util/add-events.js +13 -13
- package/lib/victory-util/axis.js +11 -11
- package/lib/victory-util/data.js +16 -16
- package/lib/victory-util/domain.js +13 -13
- package/lib/victory-util/events.d.ts +4 -4
- package/lib/victory-util/events.js +14 -14
- package/lib/victory-util/helpers.d.ts +94 -19
- package/lib/victory-util/helpers.js +96 -50
- package/lib/victory-util/hooks/use-animation-state.d.ts +2 -2
- package/lib/victory-util/hooks/use-animation-state.js +4 -4
- package/lib/victory-util/label-helpers.d.ts +4 -3
- package/lib/victory-util/label-helpers.js +3 -3
- package/lib/victory-util/line-helpers.d.ts +1 -1
- package/lib/victory-util/log.js +3 -2
- package/lib/victory-util/merge-refs.d.ts +1 -1
- package/lib/victory-util/scale.js +2 -2
- package/lib/victory-util/selection.d.ts +3 -3
- package/lib/victory-util/textsize.js +5 -5
- package/lib/victory-util/timer.d.ts +1 -1
- package/lib/victory-util/transitions.d.ts +1 -1
- package/lib/victory-util/transitions.js +12 -12
- package/lib/victory-util/type-helpers.d.ts +0 -1
- package/lib/victory-util/type-helpers.js +0 -6
- package/lib/victory-util/user-props.d.ts +2 -2
- package/lib/victory-util/wrapper.js +12 -12
- package/package.json +2 -30
- package/src/victory-animation/util.ts +3 -1
- package/src/victory-clip-container/victory-clip-container.tsx +26 -11
- package/src/victory-container/victory-container.tsx +1 -1
- package/src/victory-label/victory-label.tsx +5 -3
- package/src/victory-portal/victory-portal.tsx +3 -1
- package/src/victory-primitives/arc.tsx +1 -1
- package/src/victory-primitives/background.tsx +1 -1
- package/src/victory-primitives/border.tsx +1 -1
- package/src/victory-primitives/line-segment.tsx +1 -1
- package/src/victory-primitives/point.tsx +1 -1
- package/src/victory-primitives/whisker.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +4 -2
- package/src/victory-util/add-events.tsx +5 -2
- package/src/victory-util/axis.tsx +7 -3
- package/src/victory-util/data.ts +9 -10
- package/src/victory-util/domain.ts +8 -4
- package/src/victory-util/events.ts +4 -1
- package/src/victory-util/helpers.ts +155 -39
- package/src/victory-util/hooks/use-animation-state.ts +1 -1
- package/src/victory-util/label-helpers.ts +1 -1
- package/src/victory-util/log.ts +3 -2
- package/src/victory-util/scale.ts +1 -1
- package/src/victory-util/textsize.ts +2 -1
- package/src/victory-util/transitions.ts +3 -1
- package/src/victory-util/type-helpers.ts +0 -5
- package/src/victory-util/user-props.ts +1 -1
- package/src/victory-util/wrapper.tsx +5 -1
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CallbackArgs } from "../types/callbacks";
|
|
3
2
|
import { ValueOrAccessor } from "../types/prop-types";
|
|
3
|
+
export type ElementPadding = {
|
|
4
|
+
top: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
left: number;
|
|
7
|
+
right: number;
|
|
8
|
+
};
|
|
9
|
+
export type MaybePointData = {
|
|
10
|
+
x?: number;
|
|
11
|
+
x0?: number;
|
|
12
|
+
x1?: number;
|
|
13
|
+
y?: number;
|
|
14
|
+
y0?: number;
|
|
15
|
+
y1?: number;
|
|
16
|
+
_x?: number;
|
|
17
|
+
_x0?: number;
|
|
18
|
+
_x1?: number;
|
|
19
|
+
_y?: number;
|
|
20
|
+
_y0?: number;
|
|
21
|
+
_y1?: number;
|
|
22
|
+
_voronoiX?: number;
|
|
23
|
+
_voronoiY?: number;
|
|
24
|
+
};
|
|
4
25
|
/**
|
|
5
26
|
* Creates an object composed of the inverted keys and values of object.
|
|
6
27
|
* If object contains duplicate values, subsequent values overwrite property assignments of previous values.
|
|
@@ -14,32 +35,83 @@ export declare function invert(original: Record<string, string | number>): {};
|
|
|
14
35
|
* @returns {Object} new object with same properties as originalObject
|
|
15
36
|
*/
|
|
16
37
|
export declare function omit<T, Keys extends keyof T>(originalObject: T, ks?: Array<Keys>): Omit<T, Keys>;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export declare function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Coalesce the x and y values from a data point
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPoint(datum: MaybePointData): MaybePointData;
|
|
42
|
+
/**
|
|
43
|
+
* Scale a point based on the origin, direction, and given scale function
|
|
44
|
+
*/
|
|
45
|
+
export declare function scalePoint(props: {
|
|
46
|
+
scale: {
|
|
47
|
+
x: (x?: number) => number;
|
|
48
|
+
y: (y?: number) => number;
|
|
49
|
+
};
|
|
50
|
+
polar?: boolean;
|
|
51
|
+
horizontal?: boolean;
|
|
52
|
+
origin?: {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
};
|
|
56
|
+
}, datum: MaybePointData): {
|
|
57
|
+
x: number;
|
|
58
|
+
x0: number;
|
|
59
|
+
y: number;
|
|
60
|
+
y0: number;
|
|
29
61
|
};
|
|
30
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Returns a padding value from a number or partial padding values
|
|
64
|
+
*/
|
|
65
|
+
export declare function getPadding(padding?: number | Partial<ElementPadding>): ElementPadding;
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if the component is defined as a tooltip
|
|
68
|
+
*/
|
|
69
|
+
export declare function isTooltip(component?: {
|
|
70
|
+
type?: {
|
|
71
|
+
role?: string;
|
|
72
|
+
};
|
|
73
|
+
}): boolean;
|
|
31
74
|
export declare function getDefaultStyles(props: any, role: any): any;
|
|
32
75
|
export declare function getStyles(style: any, defaultStyles: any): any;
|
|
33
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Returns the value of a prop or accessor function with the given props
|
|
78
|
+
*/
|
|
79
|
+
export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, Record<string, any>>, props: Record<string, any>): TValue;
|
|
34
80
|
export declare function evaluateStyle(style: any, props: any): any;
|
|
35
81
|
export declare function degreesToRadians(degrees: any): any;
|
|
36
82
|
export declare function radiansToDegrees(radians: any): any;
|
|
37
|
-
|
|
38
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Get the maximum radius that will fit in the container
|
|
85
|
+
*/
|
|
86
|
+
export declare function getRadius(options: {
|
|
87
|
+
height: number;
|
|
88
|
+
width: number;
|
|
89
|
+
padding: ElementPadding;
|
|
90
|
+
}): number;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the origin for a polar chart within the padded area
|
|
93
|
+
*/
|
|
94
|
+
export declare function getPolarOrigin(props: {
|
|
95
|
+
height: number;
|
|
96
|
+
width: number;
|
|
97
|
+
padding: ElementPadding;
|
|
98
|
+
}): {
|
|
39
99
|
x: number;
|
|
40
100
|
y: number;
|
|
41
101
|
};
|
|
42
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Determine the range of an axis based on the given props
|
|
104
|
+
*/
|
|
105
|
+
export declare function getRange(props: {
|
|
106
|
+
range?: [number, number];
|
|
107
|
+
polar?: boolean;
|
|
108
|
+
innerRadius?: number;
|
|
109
|
+
startAngle?: number;
|
|
110
|
+
endAngle?: number;
|
|
111
|
+
height: number;
|
|
112
|
+
width: number;
|
|
113
|
+
padding: number | Partial<ElementPadding>;
|
|
114
|
+
}, axis: "x" | "y"): any;
|
|
43
115
|
/**
|
|
44
116
|
* Checks if `value` is `null` or `undefined`.
|
|
45
117
|
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
@@ -93,5 +165,8 @@ export declare function reduceChildren<TChildren extends React.ReactNode, TItem,
|
|
|
93
165
|
* @returns {Boolean} returns true if the props object contains `horizontal: true` of if any
|
|
94
166
|
* children or nested children are horizontal
|
|
95
167
|
*/
|
|
96
|
-
export declare function isHorizontal(props:
|
|
168
|
+
export declare function isHorizontal(props: {
|
|
169
|
+
horizontal?: boolean;
|
|
170
|
+
children?: React.ReactNode;
|
|
171
|
+
}): any;
|
|
97
172
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -27,35 +27,40 @@ exports.radiansToDegrees = radiansToDegrees;
|
|
|
27
27
|
exports.range = range;
|
|
28
28
|
exports.reduceChildren = reduceChildren;
|
|
29
29
|
exports.scalePoint = scalePoint;
|
|
30
|
-
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
31
|
-
var _property2 = _interopRequireDefault(require("lodash/property"));
|
|
32
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
33
30
|
var _react = _interopRequireWildcard(require("react"));
|
|
31
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
32
|
+
var _property = _interopRequireDefault(require("lodash/property"));
|
|
33
|
+
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
35
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
35
36
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function getCartesianRange(
|
|
40
|
-
|
|
41
|
-
const vertical = axis !== "x";
|
|
42
|
-
const padding = getPadding(props);
|
|
37
|
+
/**
|
|
38
|
+
* Determine the range of a cartesian axis
|
|
39
|
+
*/
|
|
40
|
+
function getCartesianRange(options) {
|
|
41
|
+
const vertical = options.axis !== "x";
|
|
43
42
|
if (vertical) {
|
|
44
|
-
return [
|
|
43
|
+
return [options.height - options.padding.bottom, options.padding.top];
|
|
45
44
|
}
|
|
46
|
-
return [padding.left,
|
|
45
|
+
return [options.padding.left, options.width - options.padding.right];
|
|
47
46
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Determine the range of a polar axis in radians
|
|
50
|
+
*/
|
|
51
|
+
function getPolarRange(options) {
|
|
52
|
+
if (options.axis === "x") {
|
|
53
|
+
const startAngle = degreesToRadians(options.startAngle || 0);
|
|
54
|
+
const endAngle = degreesToRadians(options.endAngle || 360);
|
|
52
55
|
return [startAngle, endAngle];
|
|
53
56
|
}
|
|
54
|
-
return [
|
|
57
|
+
return [options.innerRadius || 0, getRadius({
|
|
58
|
+
height: options.height,
|
|
59
|
+
width: options.width,
|
|
60
|
+
padding: options.padding
|
|
61
|
+
})];
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
// Exported Functions
|
|
58
|
-
|
|
59
64
|
/**
|
|
60
65
|
* Creates an object composed of the inverted keys and values of object.
|
|
61
66
|
* If object contains duplicate values, subsequent values overwrite property assignments of previous values.
|
|
@@ -92,8 +97,11 @@ function omit(originalObject, ks) {
|
|
|
92
97
|
}
|
|
93
98
|
return newObject;
|
|
94
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Coalesce the x and y values from a data point
|
|
103
|
+
*/
|
|
95
104
|
function getPoint(datum) {
|
|
96
|
-
const exists = val => val !== undefined;
|
|
97
105
|
const {
|
|
98
106
|
_x,
|
|
99
107
|
_x1,
|
|
@@ -104,16 +112,20 @@ function getPoint(datum) {
|
|
|
104
112
|
_y0,
|
|
105
113
|
_voronoiY
|
|
106
114
|
} = datum;
|
|
107
|
-
const defaultX =
|
|
108
|
-
const defaultY =
|
|
115
|
+
const defaultX = _x1 ?? _x;
|
|
116
|
+
const defaultY = _y1 ?? _y;
|
|
109
117
|
const point = {
|
|
110
|
-
x:
|
|
111
|
-
x0:
|
|
112
|
-
y:
|
|
113
|
-
y0:
|
|
118
|
+
x: _voronoiX ?? defaultX,
|
|
119
|
+
x0: _x0 ?? _x,
|
|
120
|
+
y: _voronoiY ?? defaultY,
|
|
121
|
+
y0: _y0 ?? _y
|
|
114
122
|
};
|
|
115
|
-
return (0,
|
|
123
|
+
return (0, _defaults.default)({}, point, datum);
|
|
116
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Scale a point based on the origin, direction, and given scale function
|
|
128
|
+
*/
|
|
117
129
|
function scalePoint(props, datum) {
|
|
118
130
|
const {
|
|
119
131
|
scale,
|
|
@@ -136,11 +148,11 @@ function scalePoint(props, datum) {
|
|
|
136
148
|
y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
|
|
137
149
|
};
|
|
138
150
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns a padding value from a number or partial padding values
|
|
154
|
+
*/
|
|
155
|
+
function getPadding(padding) {
|
|
144
156
|
const paddingVal = typeof padding === "number" ? padding : 0;
|
|
145
157
|
const paddingObj = typeof padding === "object" ? padding : {};
|
|
146
158
|
return {
|
|
@@ -150,6 +162,10 @@ function getPadding(props, name) {
|
|
|
150
162
|
right: paddingObj.right || paddingVal
|
|
151
163
|
};
|
|
152
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Returns true if the component is defined as a tooltip
|
|
168
|
+
*/
|
|
153
169
|
function isTooltip(component) {
|
|
154
170
|
const labelRole = component && component.type && component.type.role;
|
|
155
171
|
return labelRole === "tooltip";
|
|
@@ -164,8 +180,8 @@ function getDefaultStyles(props, role) {
|
|
|
164
180
|
return defaultStyles;
|
|
165
181
|
}
|
|
166
182
|
const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
|
|
167
|
-
const labelStyle = (0,
|
|
168
|
-
return (0,
|
|
183
|
+
const labelStyle = (0, _defaults.default)({}, tooltipStyle, defaultStyles.labels);
|
|
184
|
+
return (0, _defaults.default)({}, {
|
|
169
185
|
labels: labelStyle
|
|
170
186
|
}, defaultStyles);
|
|
171
187
|
}
|
|
@@ -173,7 +189,7 @@ function getStyles(style, defaultStyles) {
|
|
|
173
189
|
const width = "100%";
|
|
174
190
|
const height = "100%";
|
|
175
191
|
if (!style) {
|
|
176
|
-
return (0,
|
|
192
|
+
return (0, _defaults.default)({
|
|
177
193
|
parent: {
|
|
178
194
|
height,
|
|
179
195
|
width
|
|
@@ -189,14 +205,18 @@ function getStyles(style, defaultStyles) {
|
|
|
189
205
|
const defaultLabels = defaultStyles && defaultStyles.labels || {};
|
|
190
206
|
const defaultData = defaultStyles && defaultStyles.data || {};
|
|
191
207
|
return {
|
|
192
|
-
parent: (0,
|
|
208
|
+
parent: (0, _defaults.default)({}, parent, defaultParent, {
|
|
193
209
|
width,
|
|
194
210
|
height
|
|
195
211
|
}),
|
|
196
|
-
labels: (0,
|
|
197
|
-
data: (0,
|
|
212
|
+
labels: (0, _defaults.default)({}, labels, defaultLabels),
|
|
213
|
+
data: (0, _defaults.default)({}, data, defaultData)
|
|
198
214
|
};
|
|
199
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the value of a prop or accessor function with the given props
|
|
219
|
+
*/
|
|
200
220
|
function evaluateProp(prop, props) {
|
|
201
221
|
return isFunction(prop) ? prop(props) : prop;
|
|
202
222
|
}
|
|
@@ -218,19 +238,28 @@ function degreesToRadians(degrees) {
|
|
|
218
238
|
function radiansToDegrees(radians) {
|
|
219
239
|
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
|
|
220
240
|
}
|
|
221
|
-
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Get the maximum radius that will fit in the container
|
|
244
|
+
*/
|
|
245
|
+
function getRadius(options) {
|
|
246
|
+
const {
|
|
247
|
+
width,
|
|
248
|
+
height,
|
|
249
|
+
padding
|
|
250
|
+
} = options;
|
|
222
251
|
const {
|
|
223
252
|
left,
|
|
224
253
|
right,
|
|
225
254
|
top,
|
|
226
255
|
bottom
|
|
227
|
-
} =
|
|
228
|
-
const {
|
|
229
|
-
width,
|
|
230
|
-
height
|
|
231
|
-
} = props;
|
|
256
|
+
} = padding;
|
|
232
257
|
return Math.min(width - left - right, height - top - bottom) / 2;
|
|
233
258
|
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns the origin for a polar chart within the padded area
|
|
262
|
+
*/
|
|
234
263
|
function getPolarOrigin(props) {
|
|
235
264
|
const {
|
|
236
265
|
width,
|
|
@@ -241,7 +270,7 @@ function getPolarOrigin(props) {
|
|
|
241
270
|
bottom,
|
|
242
271
|
left,
|
|
243
272
|
right
|
|
244
|
-
} = getPadding(props);
|
|
273
|
+
} = getPadding(props.padding);
|
|
245
274
|
const radius = Math.min(width - left - right, height - top - bottom) / 2;
|
|
246
275
|
const offsetWidth = width / 2 + left - right;
|
|
247
276
|
const offsetHeight = height / 2 + top - bottom;
|
|
@@ -250,13 +279,30 @@ function getPolarOrigin(props) {
|
|
|
250
279
|
y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
|
|
251
280
|
};
|
|
252
281
|
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Determine the range of an axis based on the given props
|
|
285
|
+
*/
|
|
253
286
|
function getRange(props, axis) {
|
|
254
287
|
if (props.range && props.range[axis]) {
|
|
255
288
|
return props.range[axis];
|
|
256
289
|
} else if (props.range && Array.isArray(props.range)) {
|
|
257
290
|
return props.range;
|
|
258
291
|
}
|
|
259
|
-
return props.polar ? getPolarRange(
|
|
292
|
+
return props.polar ? getPolarRange({
|
|
293
|
+
axis,
|
|
294
|
+
innerRadius: props.innerRadius,
|
|
295
|
+
startAngle: props.startAngle,
|
|
296
|
+
endAngle: props.endAngle,
|
|
297
|
+
height: props.height,
|
|
298
|
+
width: props.width,
|
|
299
|
+
padding: getPadding(props.padding)
|
|
300
|
+
}) : getCartesianRange({
|
|
301
|
+
axis,
|
|
302
|
+
height: props.height,
|
|
303
|
+
width: props.width,
|
|
304
|
+
padding: getPadding(props.padding)
|
|
305
|
+
});
|
|
260
306
|
}
|
|
261
307
|
|
|
262
308
|
/**
|
|
@@ -288,7 +334,7 @@ function createAccessor(key) {
|
|
|
288
334
|
return x => x;
|
|
289
335
|
}
|
|
290
336
|
// otherwise, assume it is an array index, property key or path (_.property handles all three)
|
|
291
|
-
return (0,
|
|
337
|
+
return (0, _property.default)(key);
|
|
292
338
|
}
|
|
293
339
|
function modifyProps(props, fallbackProps, role) {
|
|
294
340
|
const theme = props.theme && props.theme[role] ? props.theme[role] : {};
|
|
@@ -297,7 +343,7 @@ function modifyProps(props, fallbackProps, role) {
|
|
|
297
343
|
const defaultObject = horizontal === undefined ? {} : {
|
|
298
344
|
horizontal
|
|
299
345
|
};
|
|
300
|
-
return (0,
|
|
346
|
+
return (0, _defaults.default)(defaultObject, props, themeProps, fallbackProps);
|
|
301
347
|
}
|
|
302
348
|
|
|
303
349
|
/**
|
|
@@ -384,9 +430,9 @@ initialMemo, combine) {
|
|
|
384
430
|
const childRole = child.type && child.type.role;
|
|
385
431
|
const childName = child.props.name || `${childRole}-${names[index]}`;
|
|
386
432
|
if (child.props && child.props.children) {
|
|
387
|
-
const childProps = Object.assign({}, child.props, (0,
|
|
433
|
+
const childProps = Object.assign({}, child.props, (0, _pick.default)(parentProps, sharedProps));
|
|
388
434
|
const nestedChildren = child.type && child.type.role === "stack" && isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : _react.default.Children.toArray(child.props.children).map(c => {
|
|
389
|
-
const nestedChildProps = Object.assign({}, c.props, (0,
|
|
435
|
+
const nestedChildProps = Object.assign({}, c.props, (0, _pick.default)(childProps, sharedProps));
|
|
390
436
|
return /*#__PURE__*/_react.default.cloneElement(c, nestedChildProps);
|
|
391
437
|
});
|
|
392
438
|
const childNames = nestedChildren.map((c, i) => `${childName}-${i}`);
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimationState = void 0;
|
|
7
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
9
9
|
var Collection = _interopRequireWildcard(require("../collection"));
|
|
10
10
|
var Transitions = _interopRequireWildcard(require("../transitions"));
|
|
11
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -38,7 +38,7 @@ const useAnimationState = function (initialState) {
|
|
|
38
38
|
const getFilteredState = () => {
|
|
39
39
|
let childrenTransitions = state && state.childrenTransitions;
|
|
40
40
|
childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
|
|
41
|
-
return (0,
|
|
41
|
+
return (0, _defaults.default)({
|
|
42
42
|
childrenTransitions
|
|
43
43
|
}, state);
|
|
44
44
|
};
|
|
@@ -49,7 +49,7 @@ const useAnimationState = function (initialState) {
|
|
|
49
49
|
const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
|
|
50
50
|
getTransitions = childComponent => getTransitionProps(childComponent, index);
|
|
51
51
|
}
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, _defaults.default)({
|
|
53
53
|
getTransitions,
|
|
54
54
|
parentState
|
|
55
55
|
}, props.animate, child.props.animate);
|
|
@@ -63,7 +63,7 @@ const useAnimationState = function (initialState) {
|
|
|
63
63
|
if (props.animate.parentState) {
|
|
64
64
|
const nodesWillExit = props.animate.parentState.nodesWillExit;
|
|
65
65
|
const oldProps = nodesWillExit ? props : null;
|
|
66
|
-
const newState = (0,
|
|
66
|
+
const newState = (0, _defaults.default)({
|
|
67
67
|
oldProps,
|
|
68
68
|
nextProps
|
|
69
69
|
}, props.animate.parentState);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { VictoryLabelProps } from "../victory-label/victory-label";
|
|
2
|
+
export declare function getText(props: any, datum: VictoryLabelProps["datum"], index: any): any;
|
|
2
3
|
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
3
4
|
export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
4
5
|
export declare function getPolarAngle(props: any, baseAngle?: any): number;
|
|
@@ -16,8 +17,8 @@ export declare function getProps(props: any, index: any): {
|
|
|
16
17
|
text: any;
|
|
17
18
|
textAnchor: any;
|
|
18
19
|
verticalAnchor: any;
|
|
19
|
-
x:
|
|
20
|
-
y:
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
21
22
|
dx: number | undefined;
|
|
22
23
|
dy: number | undefined;
|
|
23
24
|
width: any;
|
|
@@ -9,11 +9,11 @@ exports.getPolarTextAnchor = getPolarTextAnchor;
|
|
|
9
9
|
exports.getPolarVerticalAnchor = getPolarVerticalAnchor;
|
|
10
10
|
exports.getProps = getProps;
|
|
11
11
|
exports.getText = getText;
|
|
12
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
13
12
|
var Helpers = _interopRequireWildcard(require("./helpers"));
|
|
13
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
// Private Functions
|
|
18
18
|
|
|
19
19
|
function getVerticalAnchor(props, datum) {
|
|
@@ -241,5 +241,5 @@ function getProps(props, index) {
|
|
|
241
241
|
return labelProps;
|
|
242
242
|
}
|
|
243
243
|
const tooltipTheme = theme && theme.tooltip || {};
|
|
244
|
-
return (0,
|
|
244
|
+
return (0, _defaults.default)({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
|
|
245
245
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as d3Shape from "victory-vendor/d3-shape";
|
|
2
|
-
export
|
|
2
|
+
export type CurveName = "basis" | "cardinal" | "bumpX" | "bumpY" | "bundle" | "catmullRom" | "linear" | "monotoneX" | "monotoneY" | "step" | "stepAfter" | "stepBefore" | "natural";
|
|
3
3
|
export declare const getInterpolationFunction: (props: any) => any;
|
|
4
4
|
export declare const getLineFunction: (props: any) => d3Shape.LineRadial<[number, number]> | d3Shape.Line<[number, number]>;
|
|
5
5
|
//# sourceMappingURL=line-helpers.d.ts.map
|
package/lib/victory-util/log.js
CHANGED
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warn = warn;
|
|
7
|
-
/* global console */
|
|
7
|
+
/* global console process */
|
|
8
8
|
/* eslint-disable no-console */
|
|
9
9
|
|
|
10
|
-
// TODO: Use "warning" npm module like React is switching to.
|
|
11
10
|
function warn(message) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
+
// @ts-ignore - Webpack DefinePlugin will replace process.env.NODE_ENV
|
|
12
13
|
if (process.env.NODE_ENV !== "production") {
|
|
13
14
|
if (console && console.warn) {
|
|
14
15
|
console.warn(message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
|
|
3
3
|
/**
|
|
4
4
|
* Used to merge multiple React refs into a single callback ref.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ exports.getScaleFromProps = getScaleFromProps;
|
|
|
10
10
|
exports.getScaleType = getScaleType;
|
|
11
11
|
exports.getType = getType;
|
|
12
12
|
exports.validScale = validScale;
|
|
13
|
-
var
|
|
13
|
+
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
14
14
|
var Helpers = _interopRequireWildcard(require("./helpers"));
|
|
15
15
|
var Collection = _interopRequireWildcard(require("./collection"));
|
|
16
16
|
var d3Scale = _interopRequireWildcard(require("victory-vendor/d3-scale"));
|
|
@@ -66,7 +66,7 @@ function getScaleTypeFromData(props, axis) {
|
|
|
66
66
|
}
|
|
67
67
|
const accessor = Helpers.createAccessor(props[axis]);
|
|
68
68
|
const axisData = props.data.map(datum => {
|
|
69
|
-
const processedData = (0,
|
|
69
|
+
const processedData = (0, _isPlainObject.default)(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
|
|
70
70
|
return processedData !== undefined ? processedData : datum[axis];
|
|
71
71
|
});
|
|
72
72
|
return Collection.containsDates(axisData) ? "time" : "linear";
|
|
@@ -9,15 +9,15 @@ export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "sc
|
|
|
9
9
|
};
|
|
10
10
|
export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
|
|
11
11
|
export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
|
|
12
|
-
export
|
|
12
|
+
export type SVGCoordinateType = {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type SVGCoordinateBounds = {
|
|
17
17
|
x: readonly [number, number];
|
|
18
18
|
y: readonly [number, number];
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type ComputedCommonProps = {
|
|
21
21
|
scale: ScaleXYPropType;
|
|
22
22
|
x1: number;
|
|
23
23
|
x2: number;
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertLengthToPixels = exports.approximateTextSize = exports._approximateTextSizeInternal = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
8
|
+
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
// http://www.pearsonified.com/2012/01/characters-per-line.php
|
|
11
11
|
/* eslint-disable no-magic-numbers */
|
|
@@ -189,7 +189,7 @@ const convertLengthToPixels = (length, fontSize) => {
|
|
|
189
189
|
exports.convertLengthToPixels = convertLengthToPixels;
|
|
190
190
|
const _prepareParams = (inputStyle, index) => {
|
|
191
191
|
const lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
|
|
192
|
-
const style = (0,
|
|
192
|
+
const style = (0, _defaults.default)({}, lineStyle, defaultStyle);
|
|
193
193
|
return Object.assign({}, style, {
|
|
194
194
|
fontFamily: style.fontFamily,
|
|
195
195
|
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
|
|
@@ -237,7 +237,7 @@ const _approximateDimensionsInternal = (text, style) => {
|
|
|
237
237
|
height: heightWithRotate * coefficients.heightOverlapCoef
|
|
238
238
|
};
|
|
239
239
|
};
|
|
240
|
-
const _getMeasurementContainer = (0,
|
|
240
|
+
const _getMeasurementContainer = (0, _memoize.default)(() => {
|
|
241
241
|
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
242
242
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
243
243
|
element.setAttribute("width", "300");
|
|
@@ -258,7 +258,7 @@ const styleToKeyComponent = style => {
|
|
|
258
258
|
}
|
|
259
259
|
return `${style.angle}:${style.fontFamily}:${style.fontSize}:${style.letterSpacing}:${style.lineHeight}`;
|
|
260
260
|
};
|
|
261
|
-
const _measureDimensionsInternal = (0,
|
|
261
|
+
const _measureDimensionsInternal = (0, _memoize.default)((text, style) => {
|
|
262
262
|
let containerElement = _getMeasurementContainer();
|
|
263
263
|
if (!containerElement.isConnected) {
|
|
264
264
|
_getMeasurementContainer.cache.clear?.();
|
|
@@ -21,7 +21,7 @@ export declare function getInitialTransitionState(oldChildren: any, nextChildren
|
|
|
21
21
|
childrenTransitions: any;
|
|
22
22
|
nodesShouldEnter: boolean;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type TransitionProps = {
|
|
25
25
|
data: any;
|
|
26
26
|
animate?: AnimatePropTypeInterface;
|
|
27
27
|
clipWidth?: number;
|