victory-core 37.3.1 → 37.3.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 +20 -0
- package/dist/victory-core.js +436 -405
- 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 +7 -7
- 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 +5 -5
- 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 +8 -8
- package/es/victory-util/add-events.d.ts +8 -8
- package/es/victory-util/add-events.js +14 -14
- package/es/victory-util/axis.js +12 -12
- package/es/victory-util/data.js +16 -20
- package/es/victory-util/domain.js +13 -16
- package/es/victory-util/events.d.ts +5 -5
- package/es/victory-util/events.js +17 -23
- package/es/victory-util/helpers.d.ts +94 -19
- package/es/victory-util/helpers.js +95 -50
- 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 -3
- 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 +2 -2
- package/es/victory-util/scale.js +2 -3
- 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 +15 -19
- 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 -13
- package/lib/types/callbacks.d.ts +11 -11
- package/lib/types/prop-types.d.ts +28 -28
- package/lib/victory-animation/util.js +7 -7
- 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 +6 -6
- 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 +8 -8
- package/lib/victory-util/add-events.d.ts +8 -8
- package/lib/victory-util/add-events.js +14 -14
- package/lib/victory-util/axis.js +12 -12
- package/lib/victory-util/data.js +16 -21
- package/lib/victory-util/domain.js +13 -17
- package/lib/victory-util/events.d.ts +5 -5
- package/lib/victory-util/events.js +17 -24
- package/lib/victory-util/helpers.d.ts +94 -19
- package/lib/victory-util/helpers.js +96 -52
- 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 -5
- 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 +2 -2
- package/lib/victory-util/scale.js +2 -4
- 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 +15 -19
- 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 -13
- package/package.json +6 -38
- package/src/victory-animation/util.ts +4 -2
- package/src/victory-clip-container/victory-clip-container.tsx +26 -11
- package/src/victory-container/victory-container.tsx +4 -4
- 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 +3 -3
- package/src/victory-primitives/whisker.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +5 -3
- package/src/victory-util/add-events.tsx +6 -3
- package/src/victory-util/axis.tsx +8 -4
- package/src/victory-util/common-props.tsx +3 -3
- package/src/victory-util/data.ts +9 -13
- package/src/victory-util/domain.ts +8 -6
- package/src/victory-util/events.ts +18 -13
- package/src/victory-util/helpers.ts +155 -40
- package/src/victory-util/hooks/use-animation-state.ts +1 -1
- package/src/victory-util/label-helpers.ts +1 -2
- package/src/victory-util/log.ts +3 -2
- package/src/victory-util/merge-refs.ts +2 -0
- package/src/victory-util/scale.ts +1 -2
- package/src/victory-util/textsize.ts +2 -1
- package/src/victory-util/transitions.ts +6 -6
- 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 -2
|
@@ -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
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import _pick from "lodash/pick";
|
|
2
|
-
import _property from "lodash/property";
|
|
3
|
-
import _defaults from "lodash/defaults";
|
|
4
|
-
/* eslint-disable no-use-before-define */
|
|
5
1
|
import React, { isValidElement } from "react";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import property from "lodash/property";
|
|
4
|
+
import pick from "lodash/pick";
|
|
5
|
+
/**
|
|
6
|
+
* Determine the range of a cartesian axis
|
|
7
|
+
*/
|
|
8
|
+
function getCartesianRange(options) {
|
|
9
|
+
const vertical = options.axis !== "x";
|
|
12
10
|
if (vertical) {
|
|
13
|
-
return [
|
|
11
|
+
return [options.height - options.padding.bottom, options.padding.top];
|
|
14
12
|
}
|
|
15
|
-
return [padding.left,
|
|
13
|
+
return [options.padding.left, options.width - options.padding.right];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determine the range of a polar axis in radians
|
|
18
|
+
*/
|
|
19
|
+
function getPolarRange(options) {
|
|
20
|
+
if (options.axis === "x") {
|
|
21
|
+
const startAngle = degreesToRadians(options.startAngle || 0);
|
|
22
|
+
const endAngle = degreesToRadians(options.endAngle || 360);
|
|
21
23
|
return [startAngle, endAngle];
|
|
22
24
|
}
|
|
23
|
-
return [
|
|
25
|
+
return [options.innerRadius || 0, getRadius({
|
|
26
|
+
height: options.height,
|
|
27
|
+
width: options.width,
|
|
28
|
+
padding: options.padding
|
|
29
|
+
})];
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
// Exported Functions
|
|
27
|
-
|
|
28
32
|
/**
|
|
29
33
|
* Creates an object composed of the inverted keys and values of object.
|
|
30
34
|
* If object contains duplicate values, subsequent values overwrite property assignments of previous values.
|
|
@@ -61,8 +65,11 @@ export function omit(originalObject, ks) {
|
|
|
61
65
|
}
|
|
62
66
|
return newObject;
|
|
63
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Coalesce the x and y values from a data point
|
|
71
|
+
*/
|
|
64
72
|
export function getPoint(datum) {
|
|
65
|
-
const exists = val => val !== undefined;
|
|
66
73
|
const {
|
|
67
74
|
_x,
|
|
68
75
|
_x1,
|
|
@@ -73,16 +80,20 @@ export function getPoint(datum) {
|
|
|
73
80
|
_y0,
|
|
74
81
|
_voronoiY
|
|
75
82
|
} = datum;
|
|
76
|
-
const defaultX =
|
|
77
|
-
const defaultY =
|
|
83
|
+
const defaultX = _x1 ?? _x;
|
|
84
|
+
const defaultY = _y1 ?? _y;
|
|
78
85
|
const point = {
|
|
79
|
-
x:
|
|
80
|
-
x0:
|
|
81
|
-
y:
|
|
82
|
-
y0:
|
|
86
|
+
x: _voronoiX ?? defaultX,
|
|
87
|
+
x0: _x0 ?? _x,
|
|
88
|
+
y: _voronoiY ?? defaultY,
|
|
89
|
+
y0: _y0 ?? _y
|
|
83
90
|
};
|
|
84
|
-
return
|
|
91
|
+
return defaults({}, point, datum);
|
|
85
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Scale a point based on the origin, direction, and given scale function
|
|
96
|
+
*/
|
|
86
97
|
export function scalePoint(props, datum) {
|
|
87
98
|
const {
|
|
88
99
|
scale,
|
|
@@ -105,11 +116,11 @@ export function scalePoint(props, datum) {
|
|
|
105
116
|
y0: polar ? -y0 * Math.sin(x0) + origin.x : y0
|
|
106
117
|
};
|
|
107
118
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns a padding value from a number or partial padding values
|
|
122
|
+
*/
|
|
123
|
+
export function getPadding(padding) {
|
|
113
124
|
const paddingVal = typeof padding === "number" ? padding : 0;
|
|
114
125
|
const paddingObj = typeof padding === "object" ? padding : {};
|
|
115
126
|
return {
|
|
@@ -119,6 +130,10 @@ export function getPadding(props, name) {
|
|
|
119
130
|
right: paddingObj.right || paddingVal
|
|
120
131
|
};
|
|
121
132
|
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns true if the component is defined as a tooltip
|
|
136
|
+
*/
|
|
122
137
|
export function isTooltip(component) {
|
|
123
138
|
const labelRole = component && component.type && component.type.role;
|
|
124
139
|
return labelRole === "tooltip";
|
|
@@ -133,8 +148,8 @@ export function getDefaultStyles(props, role) {
|
|
|
133
148
|
return defaultStyles;
|
|
134
149
|
}
|
|
135
150
|
const tooltipStyle = theme.tooltip && theme.tooltip.style || {};
|
|
136
|
-
const labelStyle =
|
|
137
|
-
return
|
|
151
|
+
const labelStyle = defaults({}, tooltipStyle, defaultStyles.labels);
|
|
152
|
+
return defaults({}, {
|
|
138
153
|
labels: labelStyle
|
|
139
154
|
}, defaultStyles);
|
|
140
155
|
}
|
|
@@ -142,7 +157,7 @@ export function getStyles(style, defaultStyles) {
|
|
|
142
157
|
const width = "100%";
|
|
143
158
|
const height = "100%";
|
|
144
159
|
if (!style) {
|
|
145
|
-
return
|
|
160
|
+
return defaults({
|
|
146
161
|
parent: {
|
|
147
162
|
height,
|
|
148
163
|
width
|
|
@@ -158,14 +173,18 @@ export function getStyles(style, defaultStyles) {
|
|
|
158
173
|
const defaultLabels = defaultStyles && defaultStyles.labels || {};
|
|
159
174
|
const defaultData = defaultStyles && defaultStyles.data || {};
|
|
160
175
|
return {
|
|
161
|
-
parent:
|
|
176
|
+
parent: defaults({}, parent, defaultParent, {
|
|
162
177
|
width,
|
|
163
178
|
height
|
|
164
179
|
}),
|
|
165
|
-
labels:
|
|
166
|
-
data:
|
|
180
|
+
labels: defaults({}, labels, defaultLabels),
|
|
181
|
+
data: defaults({}, data, defaultData)
|
|
167
182
|
};
|
|
168
183
|
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns the value of a prop or accessor function with the given props
|
|
187
|
+
*/
|
|
169
188
|
export function evaluateProp(prop, props) {
|
|
170
189
|
return isFunction(prop) ? prop(props) : prop;
|
|
171
190
|
}
|
|
@@ -187,19 +206,28 @@ export function degreesToRadians(degrees) {
|
|
|
187
206
|
export function radiansToDegrees(radians) {
|
|
188
207
|
return typeof radians === "number" ? radians / (Math.PI / 180) : radians;
|
|
189
208
|
}
|
|
190
|
-
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get the maximum radius that will fit in the container
|
|
212
|
+
*/
|
|
213
|
+
export function getRadius(options) {
|
|
214
|
+
const {
|
|
215
|
+
width,
|
|
216
|
+
height,
|
|
217
|
+
padding
|
|
218
|
+
} = options;
|
|
191
219
|
const {
|
|
192
220
|
left,
|
|
193
221
|
right,
|
|
194
222
|
top,
|
|
195
223
|
bottom
|
|
196
|
-
} =
|
|
197
|
-
const {
|
|
198
|
-
width,
|
|
199
|
-
height
|
|
200
|
-
} = props;
|
|
224
|
+
} = padding;
|
|
201
225
|
return Math.min(width - left - right, height - top - bottom) / 2;
|
|
202
226
|
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Returns the origin for a polar chart within the padded area
|
|
230
|
+
*/
|
|
203
231
|
export function getPolarOrigin(props) {
|
|
204
232
|
const {
|
|
205
233
|
width,
|
|
@@ -210,7 +238,7 @@ export function getPolarOrigin(props) {
|
|
|
210
238
|
bottom,
|
|
211
239
|
left,
|
|
212
240
|
right
|
|
213
|
-
} = getPadding(props);
|
|
241
|
+
} = getPadding(props.padding);
|
|
214
242
|
const radius = Math.min(width - left - right, height - top - bottom) / 2;
|
|
215
243
|
const offsetWidth = width / 2 + left - right;
|
|
216
244
|
const offsetHeight = height / 2 + top - bottom;
|
|
@@ -219,13 +247,30 @@ export function getPolarOrigin(props) {
|
|
|
219
247
|
y: offsetHeight + radius > height ? radius + top - bottom : offsetHeight
|
|
220
248
|
};
|
|
221
249
|
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Determine the range of an axis based on the given props
|
|
253
|
+
*/
|
|
222
254
|
export function getRange(props, axis) {
|
|
223
255
|
if (props.range && props.range[axis]) {
|
|
224
256
|
return props.range[axis];
|
|
225
257
|
} else if (props.range && Array.isArray(props.range)) {
|
|
226
258
|
return props.range;
|
|
227
259
|
}
|
|
228
|
-
return props.polar ? getPolarRange(
|
|
260
|
+
return props.polar ? getPolarRange({
|
|
261
|
+
axis,
|
|
262
|
+
innerRadius: props.innerRadius,
|
|
263
|
+
startAngle: props.startAngle,
|
|
264
|
+
endAngle: props.endAngle,
|
|
265
|
+
height: props.height,
|
|
266
|
+
width: props.width,
|
|
267
|
+
padding: getPadding(props.padding)
|
|
268
|
+
}) : getCartesianRange({
|
|
269
|
+
axis,
|
|
270
|
+
height: props.height,
|
|
271
|
+
width: props.width,
|
|
272
|
+
padding: getPadding(props.padding)
|
|
273
|
+
});
|
|
229
274
|
}
|
|
230
275
|
|
|
231
276
|
/**
|
|
@@ -257,7 +302,7 @@ export function createAccessor(key) {
|
|
|
257
302
|
return x => x;
|
|
258
303
|
}
|
|
259
304
|
// otherwise, assume it is an array index, property key or path (_.property handles all three)
|
|
260
|
-
return
|
|
305
|
+
return property(key);
|
|
261
306
|
}
|
|
262
307
|
export function modifyProps(props, fallbackProps, role) {
|
|
263
308
|
const theme = props.theme && props.theme[role] ? props.theme[role] : {};
|
|
@@ -266,7 +311,7 @@ export function modifyProps(props, fallbackProps, role) {
|
|
|
266
311
|
const defaultObject = horizontal === undefined ? {} : {
|
|
267
312
|
horizontal
|
|
268
313
|
};
|
|
269
|
-
return
|
|
314
|
+
return defaults(defaultObject, props, themeProps, fallbackProps);
|
|
270
315
|
}
|
|
271
316
|
|
|
272
317
|
/**
|
|
@@ -353,9 +398,9 @@ initialMemo, combine) {
|
|
|
353
398
|
const childRole = child.type && child.type.role;
|
|
354
399
|
const childName = child.props.name || `${childRole}-${names[index]}`;
|
|
355
400
|
if (child.props && child.props.children) {
|
|
356
|
-
const childProps = Object.assign({}, child.props,
|
|
401
|
+
const childProps = Object.assign({}, child.props, pick(parentProps, sharedProps));
|
|
357
402
|
const nestedChildren = child.type && child.type.role === "stack" && isFunction(child.type.getChildren) ? child.type.getChildren(childProps) : React.Children.toArray(child.props.children).map(c => {
|
|
358
|
-
const nestedChildProps = Object.assign({}, c.props,
|
|
403
|
+
const nestedChildProps = Object.assign({}, c.props, pick(childProps, sharedProps));
|
|
359
404
|
return /*#__PURE__*/React.cloneElement(c, nestedChildProps);
|
|
360
405
|
});
|
|
361
406
|
const childNames = nestedChildren.map((c, i) => `${childName}-${i}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import * as Collection from "../collection";
|
|
4
4
|
import * as Transitions from "../transitions";
|
|
5
5
|
const INITIAL_STATE = {
|
|
@@ -29,7 +29,7 @@ export const useAnimationState = function (initialState) {
|
|
|
29
29
|
const getFilteredState = () => {
|
|
30
30
|
let childrenTransitions = state && state.childrenTransitions;
|
|
31
31
|
childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
|
|
32
|
-
return
|
|
32
|
+
return defaults({
|
|
33
33
|
childrenTransitions
|
|
34
34
|
}, state);
|
|
35
35
|
};
|
|
@@ -40,7 +40,7 @@ export const useAnimationState = function (initialState) {
|
|
|
40
40
|
const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
|
|
41
41
|
getTransitions = childComponent => getTransitionProps(childComponent, index);
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return defaults({
|
|
44
44
|
getTransitions,
|
|
45
45
|
parentState
|
|
46
46
|
}, props.animate, child.props.animate);
|
|
@@ -54,7 +54,7 @@ export const useAnimationState = function (initialState) {
|
|
|
54
54
|
if (props.animate.parentState) {
|
|
55
55
|
const nodesWillExit = props.animate.parentState.nodesWillExit;
|
|
56
56
|
const oldProps = nodesWillExit ? props : null;
|
|
57
|
-
const newState =
|
|
57
|
+
const newState = defaults({
|
|
58
58
|
oldProps,
|
|
59
59
|
nextProps
|
|
60
60
|
}, 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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
|
-
/* eslint-disable no-use-before-define */
|
|
3
1
|
import * as Helpers from "./helpers";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
|
|
4
4
|
// Private Functions
|
|
5
5
|
|
|
6
6
|
function getVerticalAnchor(props, datum) {
|
|
@@ -228,5 +228,5 @@ export function getProps(props, index) {
|
|
|
228
228
|
return labelProps;
|
|
229
229
|
}
|
|
230
230
|
const tooltipTheme = theme && theme.tooltip || {};
|
|
231
|
-
return
|
|
231
|
+
return defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
|
|
232
232
|
}
|
|
@@ -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/es/victory-util/log.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/* global console */
|
|
1
|
+
/* global console process */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
-
// TODO: Use "warning" npm module like React is switching to.
|
|
5
4
|
export function warn(message) {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore - Webpack DefinePlugin will replace process.env.NODE_ENV
|
|
6
7
|
if (process.env.NODE_ENV !== "production") {
|
|
7
8
|
if (console && console.warn) {
|
|
8
9
|
console.warn(message);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from "react";
|
|
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
|
*
|
package/es/victory-util/scale.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
/* eslint-disable no-use-before-define */
|
|
1
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
3
2
|
import * as Helpers from "./helpers";
|
|
4
3
|
import * as Collection from "./collection";
|
|
5
4
|
import * as d3Scale from "victory-vendor/d3-scale";
|
|
@@ -52,7 +51,7 @@ function getScaleTypeFromData(props, axis) {
|
|
|
52
51
|
}
|
|
53
52
|
const accessor = Helpers.createAccessor(props[axis]);
|
|
54
53
|
const axisData = props.data.map(datum => {
|
|
55
|
-
const processedData =
|
|
54
|
+
const processedData = isPlainObject(accessor(datum)) ? accessor(datum)[axis] : accessor(datum);
|
|
56
55
|
return processedData !== undefined ? processedData : datum[axis];
|
|
57
56
|
});
|
|
58
57
|
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;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import _defaults from "lodash/defaults"; // http://www.pearsonified.com/2012/01/characters-per-line.php
|
|
1
|
+
// http://www.pearsonified.com/2012/01/characters-per-line.php
|
|
3
2
|
/* eslint-disable no-magic-numbers */
|
|
3
|
+
import defaults from "lodash/defaults";
|
|
4
|
+
import memoize from "lodash/memoize";
|
|
5
|
+
|
|
4
6
|
// Based on measuring specific character widths
|
|
5
7
|
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
|
|
6
8
|
// For new fonts: pull gist, open index.html locally, add font files (if not generic), enter font name in `font-family` input
|
|
@@ -179,7 +181,7 @@ export const convertLengthToPixels = (length, fontSize) => {
|
|
|
179
181
|
};
|
|
180
182
|
const _prepareParams = (inputStyle, index) => {
|
|
181
183
|
const lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
|
|
182
|
-
const style =
|
|
184
|
+
const style = defaults({}, lineStyle, defaultStyle);
|
|
183
185
|
return Object.assign({}, style, {
|
|
184
186
|
fontFamily: style.fontFamily,
|
|
185
187
|
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
|
|
@@ -227,7 +229,7 @@ const _approximateDimensionsInternal = (text, style) => {
|
|
|
227
229
|
height: heightWithRotate * coefficients.heightOverlapCoef
|
|
228
230
|
};
|
|
229
231
|
};
|
|
230
|
-
const _getMeasurementContainer =
|
|
232
|
+
const _getMeasurementContainer = memoize(() => {
|
|
231
233
|
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
232
234
|
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
233
235
|
element.setAttribute("width", "300");
|
|
@@ -248,7 +250,7 @@ const styleToKeyComponent = style => {
|
|
|
248
250
|
}
|
|
249
251
|
return `${style.angle}:${style.fontFamily}:${style.fontSize}:${style.letterSpacing}:${style.lineHeight}`;
|
|
250
252
|
};
|
|
251
|
-
const _measureDimensionsInternal =
|
|
253
|
+
const _measureDimensionsInternal = memoize((text, style) => {
|
|
252
254
|
let containerElement = _getMeasurementContainer();
|
|
253
255
|
if (!containerElement.isConnected) {
|
|
254
256
|
_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;
|