victory-core 36.5.1 → 36.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/victory-core.js +5188 -35122
- package/dist/victory-core.min.js +1 -2
- package/es/index.d.ts +1 -0
- package/es/victory-animation/victory-animation.js +1 -1
- package/es/victory-label/victory-label.js +19 -19
- package/es/victory-portal/portal.js +2 -2
- package/es/victory-primitives/arc.js +1 -1
- package/es/victory-primitives/circle.d.ts +1 -0
- package/es/victory-primitives/line.d.ts +1 -0
- package/es/victory-primitives/path.d.ts +1 -0
- package/es/victory-primitives/rect.d.ts +1 -0
- package/es/victory-primitives/tspan.d.ts +1 -0
- package/es/victory-state/victory-provider.d.ts +1 -0
- package/es/victory-state/victory-provider.js +8 -8
- package/es/victory-transition/victory-transition.js +22 -22
- package/es/victory-util/add-events.d.ts +5 -2
- package/es/victory-util/add-events.js +4 -5
- package/es/victory-util/axis.js +22 -20
- package/es/victory-util/collection.d.ts +2 -2
- package/es/victory-util/data.d.ts +1 -1
- package/es/victory-util/data.js +2 -2
- package/es/victory-util/domain.js +4 -4
- package/es/victory-util/events.js +2 -2
- package/es/victory-util/hooks/use-animation-state.d.ts +22 -0
- package/es/victory-util/hooks/use-animation-state.js +3 -3
- package/es/victory-util/label-helpers.js +12 -12
- package/es/victory-util/prop-types.js +2 -2
- package/es/victory-util/scale.js +1 -1
- package/es/victory-util/selection.d.ts +5 -1
- package/es/victory-util/selection.js +15 -15
- package/es/victory-util/style.js +12 -12
- package/es/victory-util/textsize.js +2 -2
- package/es/victory-util/transitions.js +2 -2
- package/es/victory-util/with-container.d.ts +1 -1
- package/es/victory-util/with-container.js +2 -1
- package/es/victory-util/wrapper.js +8 -8
- package/lib/index.d.ts +1 -0
- package/lib/victory-label/victory-label.js +19 -19
- package/lib/victory-portal/portal.js +2 -2
- package/lib/victory-primitives/circle.d.ts +1 -0
- package/lib/victory-primitives/line.d.ts +1 -0
- package/lib/victory-primitives/path.d.ts +1 -0
- package/lib/victory-primitives/rect.d.ts +1 -0
- package/lib/victory-primitives/tspan.d.ts +1 -0
- package/lib/victory-state/victory-provider.d.ts +1 -0
- package/lib/victory-state/victory-provider.js +7 -9
- package/lib/victory-transition/victory-transition.js +21 -21
- package/lib/victory-util/add-events.d.ts +5 -2
- package/lib/victory-util/add-events.js +4 -4
- package/lib/victory-util/axis.js +22 -20
- package/lib/victory-util/collection.d.ts +2 -2
- package/lib/victory-util/data.d.ts +1 -1
- package/lib/victory-util/data.js +2 -2
- package/lib/victory-util/domain.js +4 -4
- package/lib/victory-util/events.js +2 -2
- package/lib/victory-util/hooks/use-animation-state.d.ts +22 -0
- package/lib/victory-util/hooks/use-animation-state.js +3 -3
- package/lib/victory-util/label-helpers.js +12 -12
- package/lib/victory-util/prop-types.js +2 -2
- package/lib/victory-util/scale.js +1 -1
- package/lib/victory-util/selection.d.ts +5 -1
- package/lib/victory-util/selection.js +15 -15
- package/lib/victory-util/style.js +12 -12
- package/lib/victory-util/textsize.js +2 -2
- package/lib/victory-util/transitions.js +2 -2
- package/lib/victory-util/with-container.d.ts +1 -1
- package/lib/victory-util/with-container.js +5 -3
- package/lib/victory-util/wrapper.js +8 -8
- package/package.json +252 -7
- package/src/index.ts +1 -0
- package/src/victory-animation/victory-animation.tsx +1 -1
- package/src/victory-label/victory-label.tsx +20 -25
- package/src/victory-primitives/arc.tsx +1 -1
- package/src/victory-state/victory-provider.tsx +6 -11
- package/src/victory-transition/victory-transition.tsx +24 -26
- package/src/victory-util/add-events.tsx +14 -9
- package/src/victory-util/axis.tsx +12 -13
- package/src/victory-util/collection.tsx +13 -4
- package/src/victory-util/data.ts +2 -3
- package/src/victory-util/domain.ts +6 -6
- package/src/victory-util/events.ts +1 -2
- package/src/victory-util/hooks/{use-animation-state.js → use-animation-state.ts} +24 -9
- package/src/victory-util/label-helpers.ts +8 -12
- package/src/victory-util/point-path-helpers.ts +1 -1
- package/src/victory-util/prop-types.ts +1 -2
- package/src/victory-util/scale.ts +1 -1
- package/src/victory-util/selection.ts +12 -13
- package/src/victory-util/style.ts +10 -11
- package/src/victory-util/textsize.ts +3 -3
- package/src/victory-util/transitions.ts +1 -2
- package/src/victory-util/with-container.tsx +2 -5
- package/src/victory-util/wrapper.tsx +8 -10
- package/dist/victory-core.min.js.LICENSE.txt +0 -19
|
@@ -31,9 +31,9 @@ function getVerticalAnchor(props, datum) {
|
|
|
31
31
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
32
32
|
} else if (!props.horizontal) {
|
|
33
33
|
return sign >= 0 ? "end" : "start";
|
|
34
|
-
} else {
|
|
35
|
-
return "middle";
|
|
36
34
|
}
|
|
35
|
+
|
|
36
|
+
return "middle";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function getTextAnchor(props, datum) {
|
|
@@ -47,9 +47,9 @@ function getTextAnchor(props, datum) {
|
|
|
47
47
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
48
48
|
} else if (!horizontal) {
|
|
49
49
|
return "middle";
|
|
50
|
-
} else {
|
|
51
|
-
return sign >= 0 ? "start" : "end";
|
|
52
50
|
}
|
|
51
|
+
|
|
52
|
+
return sign >= 0 ? "start" : "end";
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function getAngle(props, datum) {
|
|
@@ -95,13 +95,13 @@ function getPosition(props, datum) {
|
|
|
95
95
|
x: x,
|
|
96
96
|
y: y
|
|
97
97
|
};
|
|
98
|
-
} else {
|
|
99
|
-
var polarPadding = getPolarPadding(props, datum);
|
|
100
|
-
return {
|
|
101
|
-
x: x + polarPadding.x,
|
|
102
|
-
y: y + polarPadding.y
|
|
103
|
-
};
|
|
104
98
|
}
|
|
99
|
+
|
|
100
|
+
var polarPadding = getPolarPadding(props, datum);
|
|
101
|
+
return {
|
|
102
|
+
x: x + polarPadding.x,
|
|
103
|
+
y: y + polarPadding.y
|
|
104
|
+
};
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
function getPolarPadding(props, datum) {
|
|
@@ -132,9 +132,9 @@ function getPolarOrientation(degrees) {
|
|
|
132
132
|
return "top"; // eslint-disable-next-line no-magic-numbers
|
|
133
133
|
} else if (degrees > 135 && degrees < 225) {
|
|
134
134
|
return "left";
|
|
135
|
-
} else {
|
|
136
|
-
return "bottom";
|
|
137
135
|
}
|
|
136
|
+
|
|
137
|
+
return "bottom";
|
|
138
138
|
} // Exported Functions
|
|
139
139
|
|
|
140
140
|
|
|
@@ -79,9 +79,9 @@ var getConstructor = function (value) {
|
|
|
79
79
|
return undefinedConstructor;
|
|
80
80
|
} else if (value === null) {
|
|
81
81
|
return nullConstructor;
|
|
82
|
-
} else {
|
|
83
|
-
return value.constructor;
|
|
84
82
|
}
|
|
83
|
+
|
|
84
|
+
return value.constructor;
|
|
85
85
|
};
|
|
86
86
|
/**
|
|
87
87
|
* Get the name of the constructor used to create `value`, using
|
|
@@ -3,7 +3,10 @@ import { VictoryCommonProps } from "./index";
|
|
|
3
3
|
import type { DomainPropType, ScaleXYPropType } from "../types/prop-types";
|
|
4
4
|
export declare function getParentSVG(evt: Pick<React.SyntheticEvent, "target"> & Partial<Pick<React.SyntheticEvent, "nativeEvent">>): SVGElement;
|
|
5
5
|
export declare function getSVGEventCoordinates(evt: React.SyntheticEvent, svg?: SVGElement): SVGCoordinateType;
|
|
6
|
-
export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType):
|
|
6
|
+
export declare function getDomainCoordinates(props: Pick<VictoryCommonProps, "scale" | "horizontal">, domain?: DomainPropType): {
|
|
7
|
+
x: number[];
|
|
8
|
+
y: number[];
|
|
9
|
+
};
|
|
7
10
|
export declare function getDataCoordinates(props: any, scale: ScaleXYPropType, x: number, y: number): SVGCoordinateType;
|
|
8
11
|
export declare function getBounds(props: ComputedCommonProps): SVGCoordinateBounds;
|
|
9
12
|
export declare type SVGCoordinateType = {
|
|
@@ -20,6 +23,7 @@ declare type ComputedCommonProps = {
|
|
|
20
23
|
x2: number;
|
|
21
24
|
y1: number;
|
|
22
25
|
y2: number;
|
|
26
|
+
horizontal?: boolean;
|
|
23
27
|
};
|
|
24
28
|
export {};
|
|
25
29
|
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -42,9 +42,9 @@ function getParentSVG(evt) {
|
|
|
42
42
|
var getParent = function (target) {
|
|
43
43
|
if (target.nodeName === "svg") {
|
|
44
44
|
return target;
|
|
45
|
-
} else {
|
|
46
|
-
return target.parentNode ? getParent(target.parentNode) : target;
|
|
47
45
|
}
|
|
46
|
+
|
|
47
|
+
return target.parentNode ? getParent(target.parentNode) : target;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
return getParent(evt.target);
|
|
@@ -93,20 +93,20 @@ function getDataCoordinates(props, scale, x, y) {
|
|
|
93
93
|
x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
|
|
94
94
|
y: horizontal ? scale.y.invert(x) : scale.y.invert(y)
|
|
95
95
|
};
|
|
96
|
-
} else {
|
|
97
|
-
var origin = props.origin || {
|
|
98
|
-
x: 0,
|
|
99
|
-
y: 0
|
|
100
|
-
};
|
|
101
|
-
var baseX = x - origin.x;
|
|
102
|
-
var baseY = y - origin.y;
|
|
103
|
-
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
104
|
-
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
105
|
-
return {
|
|
106
|
-
x: scale.x.invert(angle),
|
|
107
|
-
y: scale.y.invert(radius)
|
|
108
|
-
};
|
|
109
96
|
}
|
|
97
|
+
|
|
98
|
+
var origin = props.origin || {
|
|
99
|
+
x: 0,
|
|
100
|
+
y: 0
|
|
101
|
+
};
|
|
102
|
+
var baseX = x - origin.x;
|
|
103
|
+
var baseY = y - origin.y;
|
|
104
|
+
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
105
|
+
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
106
|
+
return {
|
|
107
|
+
x: scale.x.invert(angle),
|
|
108
|
+
y: scale.y.invert(radius)
|
|
109
|
+
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function getBounds(props) {
|
|
@@ -24,22 +24,22 @@ var toTransformString = function (obj) {
|
|
|
24
24
|
return more.reduce(function (memo, currentObj) {
|
|
25
25
|
return [memo, toTransformString(currentObj)].join(" ");
|
|
26
26
|
}, toTransformString(obj)).trim();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (obj === undefined || obj === null || typeof obj === "string") {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
var transforms = [];
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
for (var key in obj) {
|
|
36
|
+
if (obj.hasOwnProperty(key)) {
|
|
37
|
+
var value = obj[key];
|
|
38
|
+
transforms.push("".concat(key, "(").concat(value, ")"));
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
return transforms.join(" ").trim();
|
|
42
40
|
}
|
|
41
|
+
|
|
42
|
+
return transforms.join(" ").trim();
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* Given the name of a color scale, getColorScale will return an array
|
|
@@ -25,7 +25,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
25
25
|
|
|
26
26
|
// Based on measuring specific character widths
|
|
27
27
|
// as in the following example https://bl.ocks.org/tophtucker/62f93a4658387bb61e4510c37e2e97cf
|
|
28
|
-
//prettier-ignore
|
|
28
|
+
// prettier-ignore
|
|
29
29
|
var fonts = {
|
|
30
30
|
"American Typewriter": {
|
|
31
31
|
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.4203125, 0.3296875, 0.6, 0.6375, 0.8015625, 0.8203125, 0.1875, 0.45625, 0.45625, 0.6375, 0.5, 0.2734375, 0.309375, 0.2734375, 0.4390625, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.6375, 0.2734375, 0.2734375, 0.5, 0.5, 0.5, 0.6, 0.6921875, 0.7640625, 0.6921875, 0.6375, 0.728125, 0.6734375, 0.6203125, 0.7109375, 0.784375, 0.3828125, 0.6421875, 0.7859375, 0.6375, 0.9484375, 0.7640625, 0.65625, 0.6375, 0.65625, 0.7296875, 0.6203125, 0.6375, 0.7109375, 0.740625, 0.940625, 0.784375, 0.7578125, 0.6203125, 0.4375, 0.5, 0.4375, 0.5, 0.5, 0.4921875, 0.5734375, 0.5890625, 0.5109375, 0.6, 0.528125, 0.43125, 0.5578125, 0.6375, 0.3109375, 0.40625, 0.6234375, 0.309375, 0.928125, 0.6375, 0.546875, 0.6, 0.58125, 0.4921875, 0.4921875, 0.4, 0.6203125, 0.625, 0.825, 0.6375, 0.640625, 0.528125, 0.5, 0.5, 0.5, 0.6671875],
|
|
@@ -131,7 +131,7 @@ var fonts = {
|
|
|
131
131
|
widths: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.35, 0.39375, 0.459375, 0.81875, 0.6359375, 1.0765625, 0.759375, 0.26875, 0.4546875, 0.4546875, 0.6359375, 0.81875, 0.3640625, 0.4546875, 0.3640625, 0.4703125, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.6359375, 0.4546875, 0.4546875, 0.81875, 0.81875, 0.81875, 0.546875, 1, 0.684375, 0.6859375, 0.6984375, 0.771875, 0.6328125, 0.575, 0.7765625, 0.7515625, 0.421875, 0.4546875, 0.69375, 0.5578125, 0.84375, 0.7484375, 0.7875, 0.603125, 0.7875, 0.7, 0.684375, 0.6171875, 0.7328125, 0.684375, 0.9890625, 0.6859375, 0.615625, 0.6859375, 0.4546875, 0.46875, 0.4546875, 0.81875, 0.6421875, 0.6359375, 0.6015625, 0.6234375, 0.521875, 0.6234375, 0.596875, 0.384375, 0.6234375, 0.6328125, 0.275, 0.3765625, 0.5921875, 0.275, 0.9734375, 0.6328125, 0.6078125, 0.6234375, 0.6234375, 0.43125, 0.521875, 0.3953125, 0.6328125, 0.5921875, 0.81875, 0.5921875, 0.5921875, 0.5265625, 0.6359375, 0.4546875, 0.6359375, 0.81875],
|
|
132
132
|
avg: 0.6171875000000003
|
|
133
133
|
}
|
|
134
|
-
}; //https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
134
|
+
}; // https://developer.mozilla.org/en/docs/Web/CSS/length
|
|
135
135
|
// Absolute sizes in pixels for obsolete measurement units.
|
|
136
136
|
|
|
137
137
|
var absoluteMeasurementUnitsToPixels = {
|
|
@@ -357,9 +357,9 @@ function getTransitionPropsFactory(props, state, setState) {
|
|
|
357
357
|
if (defaultTransitions) {
|
|
358
358
|
var animationDuration = animate[type] && animate[type].duration;
|
|
359
359
|
return animationDuration !== undefined ? animationDuration : defaultTransitions[type] && defaultTransitions[type].duration;
|
|
360
|
-
} else {
|
|
361
|
-
return {};
|
|
362
360
|
}
|
|
361
|
+
|
|
362
|
+
return {};
|
|
363
363
|
}; // eslint-disable-next-line max-statements, complexity, max-len
|
|
364
364
|
|
|
365
365
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { VictoryProviderProps } from "victory-
|
|
2
|
+
import { VictoryProviderProps } from "../victory-state";
|
|
3
3
|
import { VictoryCommonProps } from "./common-props";
|
|
4
4
|
export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: (props: Props) => React.ReactElement, initialProviderProps?: Partial<VictoryProviderProps>): (props: Props) => JSX.Element;
|
|
5
5
|
//# sourceMappingURL=with-container.d.ts.map
|
|
@@ -7,7 +7,9 @@ exports.withContainer = withContainer;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _victoryState = require("../victory-state");
|
|
11
|
+
|
|
12
|
+
var _victoryContainer = require("../victory-container/victory-container");
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
@@ -32,10 +34,10 @@ function withContainer(WrappedComponent) {
|
|
|
32
34
|
var _props$standalone = props.standalone,
|
|
33
35
|
standalone = _props$standalone === void 0 ? true : _props$standalone,
|
|
34
36
|
_props$containerCompo = props.containerComponent,
|
|
35
|
-
containerComponent = _props$containerCompo === void 0 ? /*#__PURE__*/_react.default.createElement(
|
|
37
|
+
containerComponent = _props$containerCompo === void 0 ? /*#__PURE__*/_react.default.createElement(_victoryContainer.VictoryContainer, null) : _props$containerCompo;
|
|
36
38
|
|
|
37
39
|
if (standalone) {
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_victoryState.VictoryProvider, providerProps, /*#__PURE__*/_react.default.cloneElement(containerComponent, providerProps, /*#__PURE__*/_react.default.createElement(WrappedComponent, props)));
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
return /*#__PURE__*/_react.default.createElement(WrappedComponent, props);
|
|
@@ -292,9 +292,9 @@ function getDomainFromChildren(props, axis, childComponents) {
|
|
|
292
292
|
return null;
|
|
293
293
|
} else if (child.type && (0, _isFunction2.default)(child.type.getDomain)) {
|
|
294
294
|
return child.props && child.type.getDomain(sharedProps, axis);
|
|
295
|
-
} else {
|
|
296
|
-
return Domain.getDomain(sharedProps, axis);
|
|
297
295
|
}
|
|
296
|
+
|
|
297
|
+
return Domain.getDomain(sharedProps, axis);
|
|
298
298
|
};
|
|
299
299
|
|
|
300
300
|
var childDomains = Helpers.reduceChildren(children, iteratee, props);
|
|
@@ -419,13 +419,13 @@ function getStringsFromCategories(childComponents, axis) {
|
|
|
419
419
|
|
|
420
420
|
if (!Domain.isDomainComponent(child) || !childProps.categories) {
|
|
421
421
|
return null;
|
|
422
|
-
} else {
|
|
423
|
-
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
424
|
-
var categoryStrings = categories && categories.filter(function (val) {
|
|
425
|
-
return typeof val === "string";
|
|
426
|
-
});
|
|
427
|
-
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
428
422
|
}
|
|
423
|
+
|
|
424
|
+
var categories = childProps.categories && !Array.isArray(childProps.categories) ? childProps.categories[axis] : childProps.props.categories;
|
|
425
|
+
var categoryStrings = categories && categories.filter(function (val) {
|
|
426
|
+
return typeof val === "string";
|
|
427
|
+
});
|
|
428
|
+
return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
|
|
429
429
|
};
|
|
430
430
|
|
|
431
431
|
return Helpers.reduceChildren(childComponents.slice(0), iteratee);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.6.0",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/formidablelabs/victory.git"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://formidable.com/open-source/victory",
|
|
16
|
+
"sideEffects": false,
|
|
16
17
|
"main": "lib/index.js",
|
|
17
18
|
"module": "es/index.js",
|
|
18
19
|
"jsnext:main": "es/index.js",
|
|
@@ -22,14 +23,258 @@
|
|
|
22
23
|
"lodash": "^4.17.21",
|
|
23
24
|
"prop-types": "^15.8.1",
|
|
24
25
|
"react-fast-compare": "^3.2.0",
|
|
25
|
-
"victory-vendor": "^36.
|
|
26
|
+
"victory-vendor": "^36.6.0"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"react": ">=16.6.0"
|
|
29
30
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"victory-axis": "*",
|
|
33
|
+
"victory-bar": "*",
|
|
34
|
+
"victory-core": "*",
|
|
35
|
+
"victory-line": "*"
|
|
32
36
|
},
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
}
|
|
37
|
+
"wireit": {
|
|
38
|
+
"### THESE WIREIT CONFIGS ARE GENERATED ####": {},
|
|
39
|
+
"### DO NOT MODIFY THESE MANUALLY ####": {},
|
|
40
|
+
"build": {
|
|
41
|
+
"dependencies": [
|
|
42
|
+
"build:lib",
|
|
43
|
+
"build:dist",
|
|
44
|
+
"types:create"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"build:lib": {
|
|
48
|
+
"dependencies": [
|
|
49
|
+
"build:lib:esm",
|
|
50
|
+
"build:lib:cjs"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"build:lib:esm": {
|
|
54
|
+
"command": "nps build:lib:esm",
|
|
55
|
+
"files": [
|
|
56
|
+
"src/**",
|
|
57
|
+
"!src/**/*.test.*",
|
|
58
|
+
"../../.babelrc.build.js"
|
|
59
|
+
],
|
|
60
|
+
"output": [
|
|
61
|
+
"es/**/*.js",
|
|
62
|
+
"es/**/*.js.map"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": [
|
|
65
|
+
"../victory-vendor:build:lib:esm"
|
|
66
|
+
],
|
|
67
|
+
"packageLocks": [
|
|
68
|
+
"pnpm-lock.yaml"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"build:lib:cjs": {
|
|
72
|
+
"command": "nps build:lib:cjs",
|
|
73
|
+
"files": [
|
|
74
|
+
"src/**",
|
|
75
|
+
"!src/**/*.test.*",
|
|
76
|
+
"../../.babelrc.build.js"
|
|
77
|
+
],
|
|
78
|
+
"output": [
|
|
79
|
+
"lib/**/*.js",
|
|
80
|
+
"lib/**/*.js.map"
|
|
81
|
+
],
|
|
82
|
+
"dependencies": [
|
|
83
|
+
"../victory-vendor:build:lib:cjs"
|
|
84
|
+
],
|
|
85
|
+
"packageLocks": [
|
|
86
|
+
"pnpm-lock.yaml"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"build:dist": {
|
|
90
|
+
"dependencies": [
|
|
91
|
+
"build:dist:dev",
|
|
92
|
+
"build:dist:min"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"build:dist:dev": {
|
|
96
|
+
"command": "nps build:dist:dev",
|
|
97
|
+
"files": [
|
|
98
|
+
"src/**",
|
|
99
|
+
"!src/**/*.test.*",
|
|
100
|
+
"../../.babelrc.build.js",
|
|
101
|
+
"../../config/webpack.config.js",
|
|
102
|
+
"../../config/webpack.config.dev.js"
|
|
103
|
+
],
|
|
104
|
+
"output": [
|
|
105
|
+
"dist/victory*.js",
|
|
106
|
+
"!dist/victory*.min.js*"
|
|
107
|
+
],
|
|
108
|
+
"dependencies": [
|
|
109
|
+
"../victory-vendor:build:lib:esm"
|
|
110
|
+
],
|
|
111
|
+
"packageLocks": [
|
|
112
|
+
"pnpm-lock.yaml"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"build:dist:min": {
|
|
116
|
+
"command": "nps build:dist:min",
|
|
117
|
+
"files": [
|
|
118
|
+
"src/**",
|
|
119
|
+
"!src/**/*.test.*",
|
|
120
|
+
"../../.babelrc.build.js",
|
|
121
|
+
"../../config/webpack.config.js"
|
|
122
|
+
],
|
|
123
|
+
"output": [
|
|
124
|
+
"dist/victory*.min.js*"
|
|
125
|
+
],
|
|
126
|
+
"dependencies": [
|
|
127
|
+
"../victory-vendor:build:lib:esm"
|
|
128
|
+
],
|
|
129
|
+
"packageLocks": [
|
|
130
|
+
"pnpm-lock.yaml"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"types:check": {
|
|
134
|
+
"command": "nps types:pkg:check",
|
|
135
|
+
"files": [
|
|
136
|
+
"src/**/*.{ts,tsx}",
|
|
137
|
+
"../../tsconfig.base.json",
|
|
138
|
+
"tsconfig.json"
|
|
139
|
+
],
|
|
140
|
+
"dependencies": [
|
|
141
|
+
"types:create",
|
|
142
|
+
"../victory-vendor:types:create",
|
|
143
|
+
"../victory-axis:types:create",
|
|
144
|
+
"../victory-bar:types:create",
|
|
145
|
+
"../victory-line:types:create",
|
|
146
|
+
"../victory-voronoi:types:create"
|
|
147
|
+
],
|
|
148
|
+
"output": [],
|
|
149
|
+
"packageLocks": [
|
|
150
|
+
"pnpm-lock.yaml"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
"types:create": {
|
|
154
|
+
"command": "nps types:pkg:create",
|
|
155
|
+
"files": [
|
|
156
|
+
"src/**",
|
|
157
|
+
"!src/**/*.test.*",
|
|
158
|
+
"../../tsconfig.base.json",
|
|
159
|
+
"tsconfig.build.json"
|
|
160
|
+
],
|
|
161
|
+
"output": [
|
|
162
|
+
"es/**/*.d.ts",
|
|
163
|
+
"es/**/*.d.ts.map",
|
|
164
|
+
"lib/**/*.d.ts",
|
|
165
|
+
"lib/**/*.d.ts.map"
|
|
166
|
+
],
|
|
167
|
+
"dependencies": [
|
|
168
|
+
"../victory-vendor:types:create"
|
|
169
|
+
],
|
|
170
|
+
"packageLocks": [
|
|
171
|
+
"pnpm-lock.yaml"
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
"format": {
|
|
175
|
+
"command": "nps format:pkg",
|
|
176
|
+
"files": [
|
|
177
|
+
"src/**",
|
|
178
|
+
"*.json",
|
|
179
|
+
"../../.prettierignore",
|
|
180
|
+
"../../.prettierrc.json"
|
|
181
|
+
],
|
|
182
|
+
"output": [],
|
|
183
|
+
"packageLocks": [
|
|
184
|
+
"pnpm-lock.yaml"
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"lint": {
|
|
188
|
+
"command": "nps lint:pkg",
|
|
189
|
+
"files": [
|
|
190
|
+
"src/**",
|
|
191
|
+
"../../.eslintignore",
|
|
192
|
+
"../../.eslintrc.js"
|
|
193
|
+
],
|
|
194
|
+
"output": [],
|
|
195
|
+
"dependencies": [
|
|
196
|
+
"../victory-vendor:build",
|
|
197
|
+
"../victory-vendor:types:create",
|
|
198
|
+
"../victory-axis:types:create",
|
|
199
|
+
"../victory-bar:types:create",
|
|
200
|
+
"../victory-line:types:create",
|
|
201
|
+
"../victory-voronoi:types:create"
|
|
202
|
+
],
|
|
203
|
+
"packageLocks": [
|
|
204
|
+
"pnpm-lock.yaml"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"format:fix": {
|
|
208
|
+
"command": "pnpm run format || nps format:pkg:fix",
|
|
209
|
+
"files": [
|
|
210
|
+
"src/**",
|
|
211
|
+
"*.json",
|
|
212
|
+
"../../.prettierignore",
|
|
213
|
+
"../../.prettierrc.json"
|
|
214
|
+
],
|
|
215
|
+
"output": [],
|
|
216
|
+
"packageLocks": [
|
|
217
|
+
"pnpm-lock.yaml"
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"lint:fix": {
|
|
221
|
+
"command": "pnpm run lint || nps lint:pkg:fix",
|
|
222
|
+
"files": [
|
|
223
|
+
"src/**",
|
|
224
|
+
"../../.eslintignore",
|
|
225
|
+
"../../.eslintrc.js"
|
|
226
|
+
],
|
|
227
|
+
"output": [],
|
|
228
|
+
"dependencies": [
|
|
229
|
+
"../victory-vendor:build",
|
|
230
|
+
"../victory-vendor:types:create",
|
|
231
|
+
"../victory-axis:types:create",
|
|
232
|
+
"../victory-bar:types:create",
|
|
233
|
+
"../victory-line:types:create",
|
|
234
|
+
"../victory-voronoi:types:create"
|
|
235
|
+
],
|
|
236
|
+
"packageLocks": [
|
|
237
|
+
"pnpm-lock.yaml"
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
"jest": {
|
|
241
|
+
"command": "nps jest:pkg",
|
|
242
|
+
"files": [
|
|
243
|
+
"src/**/*.test.*",
|
|
244
|
+
"../../.babelrc.js",
|
|
245
|
+
"../../test/jest-config.js",
|
|
246
|
+
"../../test/jest-setup.ts"
|
|
247
|
+
],
|
|
248
|
+
"output": [],
|
|
249
|
+
"dependencies": [
|
|
250
|
+
"build:lib:cjs",
|
|
251
|
+
"../victory-axis:build:lib:cjs",
|
|
252
|
+
"../victory-bar:build:lib:cjs",
|
|
253
|
+
"../victory-line:build:lib:cjs",
|
|
254
|
+
"../victory-vendor:build:lib:cjs",
|
|
255
|
+
"../victory-voronoi:build:lib:cjs"
|
|
256
|
+
],
|
|
257
|
+
"packageLocks": [
|
|
258
|
+
"pnpm-lock.yaml"
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"scripts": {
|
|
263
|
+
"### THESE SCRIPTS ARE GENERATED ###": "true",
|
|
264
|
+
"### DO NOT MODIFY THESE MANUALLY ###": "true",
|
|
265
|
+
"build": "wireit",
|
|
266
|
+
"build:lib": "wireit",
|
|
267
|
+
"build:lib:esm": "wireit",
|
|
268
|
+
"build:lib:cjs": "wireit",
|
|
269
|
+
"build:dist": "wireit",
|
|
270
|
+
"build:dist:dev": "wireit",
|
|
271
|
+
"build:dist:min": "wireit",
|
|
272
|
+
"types:check": "wireit",
|
|
273
|
+
"types:create": "wireit",
|
|
274
|
+
"format": "wireit",
|
|
275
|
+
"format:fix": "wireit",
|
|
276
|
+
"lint": "wireit",
|
|
277
|
+
"lint:fix": "wireit",
|
|
278
|
+
"jest": "wireit"
|
|
279
|
+
}
|
|
280
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,5 +13,6 @@ export * from "./victory-portal/portal-context";
|
|
|
13
13
|
export * from "./victory-portal/victory-portal";
|
|
14
14
|
export * from "./victory-primitives";
|
|
15
15
|
export { Border as Box } from "./victory-primitives";
|
|
16
|
+
export type { BorderProps as BoxProps } from "./victory-primitives";
|
|
16
17
|
export * from "./victory-util";
|
|
17
18
|
export * from "./victory-state";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
|
|
1
|
+
/* eslint no-magic-numbers: ["error", { "ignore": [-0.5, 0.5, 0, 1, 2] }]*/
|
|
2
2
|
import { assign, defaults, isEmpty } from "lodash";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import React from "react";
|
|
@@ -89,13 +89,12 @@ const getFontSize = (style) => {
|
|
|
89
89
|
} else if (baseSize === undefined || baseSize === null) {
|
|
90
90
|
return defaultStyles.fontSize;
|
|
91
91
|
} else if (typeof baseSize === "string") {
|
|
92
|
-
const fontSize =
|
|
92
|
+
const fontSize = Number(baseSize.replace("px", ""));
|
|
93
93
|
if (!isNaN(fontSize)) {
|
|
94
94
|
return fontSize;
|
|
95
|
-
} else {
|
|
96
|
-
Log.warn("fontSize should be expressed as a number of pixels");
|
|
97
|
-
return defaultStyles.fontSize;
|
|
98
95
|
}
|
|
96
|
+
Log.warn("fontSize should be expressed as a number of pixels");
|
|
97
|
+
return defaultStyles.fontSize;
|
|
99
98
|
}
|
|
100
99
|
return defaultStyles.fontSize;
|
|
101
100
|
};
|
|
@@ -146,19 +145,17 @@ const getBackgroundPadding = (props) => {
|
|
|
146
145
|
const padding = Helpers.evaluateProp(backgroundPadding, props);
|
|
147
146
|
return Helpers.getPadding({ padding });
|
|
148
147
|
});
|
|
149
|
-
} else {
|
|
150
|
-
const padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
151
|
-
return Helpers.getPadding({ padding });
|
|
152
148
|
}
|
|
149
|
+
const padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
150
|
+
return Helpers.getPadding({ padding });
|
|
153
151
|
};
|
|
154
152
|
|
|
155
153
|
const getLineHeight = (props) => {
|
|
156
154
|
const lineHeight = Helpers.evaluateProp(props.lineHeight, props);
|
|
157
155
|
if (Array.isArray(lineHeight)) {
|
|
158
156
|
return isEmpty(lineHeight) ? [1] : lineHeight;
|
|
159
|
-
} else {
|
|
160
|
-
return lineHeight;
|
|
161
157
|
}
|
|
158
|
+
return lineHeight;
|
|
162
159
|
};
|
|
163
160
|
|
|
164
161
|
const getContent = (text, props) => {
|
|
@@ -200,20 +197,19 @@ const getDy = (props, verticalAnchor, lineHeight) => {
|
|
|
200
197
|
? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0]
|
|
201
198
|
: dy +
|
|
202
199
|
(capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
|
|
203
|
-
} else {
|
|
204
|
-
const allHeights = [...Array(length).keys()].reduce((memo, i) => {
|
|
205
|
-
return (
|
|
206
|
-
memo +
|
|
207
|
-
((capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i]) /
|
|
208
|
-
length
|
|
209
|
-
);
|
|
210
|
-
}, 0);
|
|
211
|
-
return anchor === "end"
|
|
212
|
-
? dy + allHeights
|
|
213
|
-
: dy +
|
|
214
|
-
allHeights / 2 +
|
|
215
|
-
(capHeight / 2) * lineHeights[length - 1] * fontSizes[length - 1];
|
|
216
200
|
}
|
|
201
|
+
const allHeights = [...Array(length).keys()].reduce((memo, i) => {
|
|
202
|
+
return (
|
|
203
|
+
memo +
|
|
204
|
+
((capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i]) /
|
|
205
|
+
length
|
|
206
|
+
);
|
|
207
|
+
}, 0);
|
|
208
|
+
return anchor === "end"
|
|
209
|
+
? dy + allHeights
|
|
210
|
+
: dy +
|
|
211
|
+
allHeights / 2 +
|
|
212
|
+
(capHeight / 2) * lineHeights[length - 1] * fontSizes[length - 1];
|
|
217
213
|
};
|
|
218
214
|
|
|
219
215
|
const getTransform = (props, x, y) => {
|
|
@@ -455,9 +451,8 @@ const getTSpanDy = (tspanValues, calculatedProps, i) => {
|
|
|
455
451
|
return calculateSpanDy(tspanValues, i, calculatedProps);
|
|
456
452
|
} else if (inline) {
|
|
457
453
|
return i === 0 ? current.backgroundPadding.top : undefined;
|
|
458
|
-
} else {
|
|
459
|
-
return current.backgroundPadding.top;
|
|
460
454
|
}
|
|
455
|
+
return current.backgroundPadding.top;
|
|
461
456
|
};
|
|
462
457
|
|
|
463
458
|
const evaluateProps = (props) => {
|