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
package/es/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ 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";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -30,7 +30,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
30
30
|
|
|
31
31
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
32
32
|
|
|
33
|
-
/*global setTimeout:false */
|
|
33
|
+
/* global setTimeout:false */
|
|
34
34
|
import React from "react";
|
|
35
35
|
import PropTypes from "prop-types";
|
|
36
36
|
import * as d3Ease from "victory-vendor/d3-ease";
|
|
@@ -57,14 +57,14 @@ var getFontSize = function (style) {
|
|
|
57
57
|
} else if (baseSize === undefined || baseSize === null) {
|
|
58
58
|
return defaultStyles.fontSize;
|
|
59
59
|
} else if (typeof baseSize === "string") {
|
|
60
|
-
var fontSize =
|
|
60
|
+
var fontSize = Number(baseSize.replace("px", ""));
|
|
61
61
|
|
|
62
62
|
if (!isNaN(fontSize)) {
|
|
63
63
|
return fontSize;
|
|
64
|
-
} else {
|
|
65
|
-
Log.warn("fontSize should be expressed as a number of pixels");
|
|
66
|
-
return defaultStyles.fontSize;
|
|
67
64
|
}
|
|
65
|
+
|
|
66
|
+
Log.warn("fontSize should be expressed as a number of pixels");
|
|
67
|
+
return defaultStyles.fontSize;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return defaultStyles.fontSize;
|
|
@@ -121,12 +121,12 @@ var getBackgroundPadding = function (props) {
|
|
|
121
121
|
padding: padding
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
-
} else {
|
|
125
|
-
var padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
126
|
-
return Helpers.getPadding({
|
|
127
|
-
padding: padding
|
|
128
|
-
});
|
|
129
124
|
}
|
|
125
|
+
|
|
126
|
+
var padding = Helpers.evaluateProp(props.backgroundPadding, props);
|
|
127
|
+
return Helpers.getPadding({
|
|
128
|
+
padding: padding
|
|
129
|
+
});
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
var getLineHeight = function (props) {
|
|
@@ -134,9 +134,9 @@ var getLineHeight = function (props) {
|
|
|
134
134
|
|
|
135
135
|
if (Array.isArray(lineHeight)) {
|
|
136
136
|
return _isEmpty(lineHeight) ? [1] : lineHeight;
|
|
137
|
-
} else {
|
|
138
|
-
return lineHeight;
|
|
139
137
|
}
|
|
138
|
+
|
|
139
|
+
return lineHeight;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
var getContent = function (text, props) {
|
|
@@ -179,13 +179,13 @@ var getDy = function (props, verticalAnchor, lineHeight) {
|
|
|
179
179
|
return anchor === "end" ? dy + (capHeight / 2 - lineHeights[0] / 2) * fontSizes[0] : dy + capHeight / 2 * fontSizes[0];
|
|
180
180
|
} else if (length === 1) {
|
|
181
181
|
return anchor === "end" ? dy + (capHeight / 2 + (0.5 - length) * lineHeights[0]) * fontSizes[0] : dy + (capHeight / 2 + (0.5 - length / 2) * lineHeights[0]) * fontSizes[0];
|
|
182
|
-
} else {
|
|
183
|
-
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
|
|
184
|
-
return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
|
|
185
|
-
}, 0);
|
|
186
|
-
|
|
187
|
-
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
|
|
188
182
|
}
|
|
183
|
+
|
|
184
|
+
var allHeights = _toConsumableArray(Array(length).keys()).reduce(function (memo, i) {
|
|
185
|
+
return memo + (capHeight / 2 + (0.5 - length) * lineHeights[i]) * fontSizes[i] / length;
|
|
186
|
+
}, 0);
|
|
187
|
+
|
|
188
|
+
return anchor === "end" ? dy + allHeights : dy + allHeights / 2 + capHeight / 2 * lineHeights[length - 1] * fontSizes[length - 1];
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
var getTransform = function (props, x, y) {
|
|
@@ -389,9 +389,9 @@ var getTSpanDy = function (tspanValues, calculatedProps, i) {
|
|
|
389
389
|
return calculateSpanDy(tspanValues, i, calculatedProps);
|
|
390
390
|
} else if (inline) {
|
|
391
391
|
return i === 0 ? current.backgroundPadding.top : undefined;
|
|
392
|
-
} else {
|
|
393
|
-
return current.backgroundPadding.top;
|
|
394
392
|
}
|
|
393
|
+
|
|
394
|
+
return current.backgroundPadding.top;
|
|
395
395
|
};
|
|
396
396
|
|
|
397
397
|
var evaluateProps = function (props) {
|
|
@@ -23,8 +23,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
23
23
|
import React from "react";
|
|
24
24
|
import PropTypes from "prop-types";
|
|
25
25
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
26
|
-
export var Portal = /*#__PURE__*/function (
|
|
27
|
-
_inherits(Portal,
|
|
26
|
+
export var Portal = /*#__PURE__*/function (_ref) {
|
|
27
|
+
_inherits(Portal, _ref);
|
|
28
28
|
|
|
29
29
|
var _super = _createSuper(Portal);
|
|
30
30
|
|
|
@@ -6,7 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
|
|
9
|
-
/*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
|
|
9
|
+
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 180] }]*/
|
|
10
10
|
import React from "react";
|
|
11
11
|
import PropTypes from "prop-types";
|
|
12
12
|
import * as Helpers from "../victory-util/helpers";
|
|
@@ -23,12 +23,12 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
23
23
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
24
24
|
|
|
25
25
|
import * as React from "react";
|
|
26
|
-
import { createContext,
|
|
26
|
+
import { createContext, useContext } from "react";
|
|
27
27
|
import { getData } from "./helpers/get-data";
|
|
28
28
|
import { getDomain } from "./helpers/get-domain";
|
|
29
29
|
import { getRange } from "./helpers/get-range";
|
|
30
30
|
import { getScale } from "./helpers/get-scale";
|
|
31
|
-
var VictoryContext = createContext(null);
|
|
31
|
+
var VictoryContext = /*#__PURE__*/createContext(null);
|
|
32
32
|
export function VictoryProvider(_ref) {
|
|
33
33
|
var children = _ref.children,
|
|
34
34
|
initialProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -82,13 +82,13 @@ export function VictoryProvider(_ref) {
|
|
|
82
82
|
}, children);
|
|
83
83
|
}
|
|
84
84
|
export function useVictoryContext(selector) {
|
|
85
|
-
|
|
86
|
-
if (!context) {
|
|
87
|
-
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
88
|
-
}
|
|
85
|
+
var context = useContext(VictoryContext);
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
if (!context) {
|
|
88
|
+
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return selector(context);
|
|
92
92
|
}
|
|
93
93
|
export function useScale() {
|
|
94
94
|
return useVictoryContext(function (value) {
|
|
@@ -62,7 +62,7 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
62
62
|
value: function componentDidMount() {
|
|
63
63
|
this.setState({
|
|
64
64
|
nodesShouldLoad: true
|
|
65
|
-
}); //eslint-disable-line react/no-did-mount-set-state
|
|
65
|
+
}); // eslint-disable-line react/no-did-mount-set-state
|
|
66
66
|
}
|
|
67
67
|
}, {
|
|
68
68
|
key: "shouldComponentUpdate",
|
|
@@ -97,25 +97,25 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
97
97
|
oldProps: oldProps,
|
|
98
98
|
nextProps: nextProps
|
|
99
99
|
};
|
|
100
|
-
} else {
|
|
101
|
-
var oldChildren = React.Children.toArray(props.children);
|
|
102
|
-
var nextChildren = React.Children.toArray(nextProps.children);
|
|
103
|
-
|
|
104
|
-
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
|
|
105
|
-
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
106
|
-
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
107
|
-
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
108
|
-
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
nodesWillExit: nodesWillExit,
|
|
112
|
-
nodesWillEnter: nodesWillEnter,
|
|
113
|
-
childrenTransitions: childrenTransitions,
|
|
114
|
-
nodesShouldEnter: nodesShouldEnter,
|
|
115
|
-
oldProps: nodesWillExit ? props : null,
|
|
116
|
-
nextProps: nextProps
|
|
117
|
-
};
|
|
118
100
|
}
|
|
101
|
+
|
|
102
|
+
var oldChildren = React.Children.toArray(props.children);
|
|
103
|
+
var nextChildren = React.Children.toArray(nextProps.children);
|
|
104
|
+
|
|
105
|
+
var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
|
|
106
|
+
nodesWillExit = _Transitions$getIniti.nodesWillExit,
|
|
107
|
+
nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
|
|
108
|
+
childrenTransitions = _Transitions$getIniti.childrenTransitions,
|
|
109
|
+
nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
nodesWillExit: nodesWillExit,
|
|
113
|
+
nodesWillEnter: nodesWillEnter,
|
|
114
|
+
childrenTransitions: childrenTransitions,
|
|
115
|
+
nodesShouldEnter: nodesShouldEnter,
|
|
116
|
+
oldProps: nodesWillExit ? props : null,
|
|
117
|
+
nextProps: nextProps
|
|
118
|
+
};
|
|
119
119
|
}
|
|
120
120
|
}, {
|
|
121
121
|
key: "getDomainFromChildren",
|
|
@@ -139,10 +139,10 @@ export var VictoryTransition = /*#__PURE__*/function (_React$Component) {
|
|
|
139
139
|
|
|
140
140
|
if (!childProps.children && domain) {
|
|
141
141
|
return domain;
|
|
142
|
-
} else {
|
|
143
|
-
var childDomains = getChildDomains([child]);
|
|
144
|
-
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
145
142
|
}
|
|
143
|
+
|
|
144
|
+
var childDomains = getChildDomains([child]);
|
|
145
|
+
return childDomains.length === 0 ? [0, 1] : [Collection.getMinValue(childDomains), Collection.getMaxValue(childDomains)];
|
|
146
146
|
}
|
|
147
147
|
}, {
|
|
148
148
|
key: "pickProps",
|
|
@@ -6,7 +6,7 @@ import { VictoryLabelableProps } from "../types/prop-types";
|
|
|
6
6
|
export declare type MixinOptions = {
|
|
7
7
|
components?: Array<{
|
|
8
8
|
name: string;
|
|
9
|
-
index?: string;
|
|
9
|
+
index?: string | number;
|
|
10
10
|
}>;
|
|
11
11
|
};
|
|
12
12
|
export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatableProps, VictoryLabelableProps {
|
|
@@ -21,11 +21,14 @@ export interface EventMixinCommonProps extends VictoryCommonProps, VictoryDatabl
|
|
|
21
21
|
* class MyComponent extends React.Component<MyProps> { ... }
|
|
22
22
|
*/
|
|
23
23
|
export interface EventsMixinClass<TProps> {
|
|
24
|
-
renderContainer(component: React.ReactElement, children: React.ReactElement[]): React.ReactElement;
|
|
24
|
+
renderContainer(component: React.ReactElement, children: React.ReactElement | React.ReactElement[]): React.ReactElement;
|
|
25
25
|
cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
|
|
26
26
|
getEventState: typeof Events.getEventState;
|
|
27
|
+
renderData(props: TProps): any;
|
|
27
28
|
renderContinuousData(props: TProps): any;
|
|
28
29
|
animateComponent(props: TProps, defaultAnimationWhitelist: any): any;
|
|
30
|
+
getComponentProps(component: React.ReactElement, type: string, index: number): TProps;
|
|
31
|
+
dataKeys: string[];
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* These fields are calculated by the Mixin
|
|
@@ -40,7 +40,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
40
40
|
|
|
41
41
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
42
42
|
|
|
43
|
-
/*global window:false */
|
|
44
43
|
import React from "react";
|
|
45
44
|
import * as Events from "./events";
|
|
46
45
|
import isEqual from "react-fast-compare";
|
|
@@ -210,11 +209,11 @@ export function addEvents(WrappedComponent) {
|
|
|
210
209
|
if (!props.standalone && component.name === "parent") {
|
|
211
210
|
// don't check for changes on parent props for non-standalone components
|
|
212
211
|
return undefined;
|
|
213
|
-
} else {
|
|
214
|
-
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
215
|
-
return getState(key, component.name);
|
|
216
|
-
}).filter(Boolean);
|
|
217
212
|
}
|
|
213
|
+
|
|
214
|
+
return component.index !== undefined ? getState(component.index, component.name) : _this6.dataKeys.map(function (key) {
|
|
215
|
+
return getState(key, component.name);
|
|
216
|
+
}).filter(Boolean);
|
|
218
217
|
}).filter(Boolean);
|
|
219
218
|
return stateChanges;
|
|
220
219
|
}
|
package/es/victory-util/axis.js
CHANGED
|
@@ -160,22 +160,22 @@ function getDefaultTickFormat(props) {
|
|
|
160
160
|
return stringTicks(props) ? function (x, index) {
|
|
161
161
|
return tickValues[index];
|
|
162
162
|
} : fallbackFormat;
|
|
163
|
-
}
|
|
164
|
-
var invertedStringMap = stringMap && _invert(stringMap);
|
|
163
|
+
}
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
return n;
|
|
168
|
-
});
|
|
165
|
+
var invertedStringMap = stringMap && _invert(stringMap);
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
var tickValueArray = _orderBy(_values(stringMap), function (n) {
|
|
168
|
+
return n;
|
|
169
|
+
});
|
|
173
170
|
|
|
174
|
-
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
var dataNames = tickValueArray.map(function (tick) {
|
|
172
|
+
return invertedStringMap[tick];
|
|
173
|
+
}); // string ticks should have one tick of padding at the beginning
|
|
174
|
+
|
|
175
|
+
var dataTicks = [""].concat(_toConsumableArray(dataNames), [""]);
|
|
176
|
+
return function (x) {
|
|
177
|
+
return dataTicks[x];
|
|
178
|
+
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
function getStringTicks(props) {
|
|
@@ -242,7 +242,9 @@ function getTickArray(props) {
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
return newTickArray;
|
|
245
|
-
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return undefined;
|
|
246
248
|
};
|
|
247
249
|
|
|
248
250
|
return Array.isArray(tickArray) && tickArray.length ? buildTickArray(tickArray) : undefined;
|
|
@@ -284,11 +286,11 @@ export function getTickFormat(props, scale) {
|
|
|
284
286
|
};
|
|
285
287
|
|
|
286
288
|
return stringMap ? applyStringTicks : tickFormat;
|
|
287
|
-
} else {
|
|
288
|
-
return function (x) {
|
|
289
|
-
return x;
|
|
290
|
-
};
|
|
291
289
|
}
|
|
290
|
+
|
|
291
|
+
return function (x) {
|
|
292
|
+
return x;
|
|
293
|
+
};
|
|
292
294
|
}
|
|
293
295
|
|
|
294
296
|
function downsampleTicks(ticks, tickCount) {
|
|
@@ -335,7 +337,7 @@ export function getTicks(props, scale) {
|
|
|
335
337
|
* @param {String} axis: either x or y
|
|
336
338
|
* @returns {Array} returns a domain from tickValues
|
|
337
339
|
*/
|
|
338
|
-
//eslint-disable-next-line max-statements
|
|
340
|
+
// eslint-disable-next-line max-statements
|
|
339
341
|
|
|
340
342
|
function getDomainFromData(props, axis) {
|
|
341
343
|
var polar = props.polar,
|
|
@@ -356,7 +358,7 @@ function getDomainFromData(props, axis) {
|
|
|
356
358
|
var maxDomain = Domain.getMaxFromProps(props, axis);
|
|
357
359
|
var tickStrings = stringTicks(props);
|
|
358
360
|
var ticks = tickValues.map(function (value) {
|
|
359
|
-
return
|
|
361
|
+
return Number(value);
|
|
360
362
|
});
|
|
361
363
|
var defaultMin = tickStrings ? 1 : Collection.getMinValue(ticks);
|
|
362
364
|
var defaultMax = tickStrings ? tickValues.length : Collection.getMaxValue(ticks);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare function containsStrings<T>(collection: Array<T>): boolean;
|
|
2
2
|
export declare function containsDates(collection: Array<number | Date>): boolean;
|
|
3
3
|
export declare function containsNumbers(collection: any): boolean;
|
|
4
|
-
export declare function containsOnlyStrings(collection:
|
|
5
|
-
export declare function isArrayOfArrays(collection:
|
|
4
|
+
export declare function containsOnlyStrings(collection: Array<string> | unknown): collection is Array<string>;
|
|
5
|
+
export declare function isArrayOfArrays<T>(collection: Array<T> | Array<Array<T>> | unknown): collection is Array<Array<T>>;
|
|
6
6
|
export declare function removeUndefined(arr: any): any;
|
|
7
7
|
export declare function getMaxValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
|
|
8
8
|
export declare function getMinValue(arr: Array<number | Date>, ...values: Array<number | Date>): number | Date;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline
|
|
1
|
+
export declare function formatDataFromDomain(dataset: any, domain: any, defaultBaseline?: any): any;
|
|
2
2
|
/**
|
|
3
3
|
* Returns an object mapping string data to numeric data
|
|
4
4
|
* @param {Object} props: the props object
|
package/es/victory-util/data.js
CHANGED
|
@@ -141,9 +141,9 @@ function addEventKeys(props, data) {
|
|
|
141
141
|
return eventKey !== undefined ? _assign({
|
|
142
142
|
eventKey: eventKey
|
|
143
143
|
}, datum) : datum;
|
|
144
|
-
} else {
|
|
145
|
-
return datum;
|
|
146
144
|
}
|
|
145
|
+
|
|
146
|
+
return datum;
|
|
147
147
|
});
|
|
148
148
|
} // Exported Functions
|
|
149
149
|
// This method will remove data points that fall outside of the desired domain (non-continuous charts only)
|
|
@@ -81,7 +81,7 @@ function getExtremeFromData(dataset, axis) {
|
|
|
81
81
|
}, initialValue);
|
|
82
82
|
|
|
83
83
|
return containsDate ? new Date(result) : result;
|
|
84
|
-
} //eslint-disable-next-line max-statements
|
|
84
|
+
} // eslint-disable-next-line max-statements
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
function padDomain(domain, props, axis) {
|
|
@@ -274,12 +274,12 @@ export function getDomainFromMinMax(min, max) {
|
|
|
274
274
|
var verySmallNumber = // eslint-disable-next-line no-magic-numbers
|
|
275
275
|
val === 0 ? 2 * Math.pow(10, -10) : Math.pow(10, -10);
|
|
276
276
|
var verySmallDate = 1;
|
|
277
|
-
var minVal = val instanceof Date ? new Date(
|
|
278
|
-
var maxVal = val instanceof Date ? new Date(
|
|
277
|
+
var minVal = val instanceof Date ? new Date(Number(val) - verySmallDate) : Number(val) - verySmallNumber;
|
|
278
|
+
var maxVal = val instanceof Date ? new Date(Number(val) + verySmallDate) : Number(val) + verySmallNumber;
|
|
279
279
|
return val === 0 ? [0, maxVal] : [minVal, maxVal];
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
-
return
|
|
282
|
+
return Number(min) === Number(max) ? getSinglePointDomain(max) : [min, max];
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* Returns a the domain for a given axis if domain is given in props
|
|
@@ -386,9 +386,9 @@ export function getExternalMutation(mutations, baseProps, baseState, identifier)
|
|
|
386
386
|
return "".concat(m);
|
|
387
387
|
});
|
|
388
388
|
return _includes(stringArray, identifier[type]);
|
|
389
|
-
} else {
|
|
390
|
-
return false;
|
|
391
389
|
}
|
|
390
|
+
|
|
391
|
+
return false;
|
|
392
392
|
};
|
|
393
393
|
|
|
394
394
|
mutations = Array.isArray(mutations) ? mutations : [mutations];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare type AnyObject = Record<string, any>;
|
|
2
|
+
export declare type AnimationState = {
|
|
3
|
+
nodesShouldLoad?: boolean;
|
|
4
|
+
nodesDoneLoad?: boolean;
|
|
5
|
+
animating?: boolean;
|
|
6
|
+
childrenTransitions?: any[];
|
|
7
|
+
nodesWillExit?: boolean;
|
|
8
|
+
nodesWillEnter?: boolean;
|
|
9
|
+
nodesShouldEnter?: boolean;
|
|
10
|
+
oldProps?: AnyObject;
|
|
11
|
+
nextProps?: AnyObject;
|
|
12
|
+
continuous?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const useAnimationState: (initialState?: AnimationState) => {
|
|
15
|
+
state: AnimationState;
|
|
16
|
+
setState: (newState: AnimationState) => void;
|
|
17
|
+
getAnimationProps: (props: AnyObject | undefined, child: any, index: any) => any;
|
|
18
|
+
setAnimationState: (props: AnyObject | undefined, nextProps: any) => void;
|
|
19
|
+
getProps: (initialProps: AnyObject) => AnyObject;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=use-animation-state.d.ts.map
|
|
@@ -43,7 +43,7 @@ export var useAnimationState = function () {
|
|
|
43
43
|
}, [_setState]); // This is a copy of Wrapper.getAnimationProps
|
|
44
44
|
|
|
45
45
|
var getAnimationProps = React.useCallback(function (props, child, index) {
|
|
46
|
-
if (!props.animate) {
|
|
46
|
+
if (!(props !== null && props !== void 0 && props.animate)) {
|
|
47
47
|
return child.props.animate;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -76,7 +76,7 @@ export var useAnimationState = function () {
|
|
|
76
76
|
}, [state, setState]); // This is a copy of Wrapper.setAnimationState
|
|
77
77
|
|
|
78
78
|
var setAnimationState = React.useCallback(function (props, nextProps) {
|
|
79
|
-
if (!props.animate) {
|
|
79
|
+
if (!(props !== null && props !== void 0 && props.animate)) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -117,7 +117,7 @@ export var useAnimationState = function () {
|
|
|
117
117
|
nodesWillEnter: nodesWillEnter,
|
|
118
118
|
nodesShouldEnter: nodesShouldEnter,
|
|
119
119
|
childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
|
|
120
|
-
oldProps: _nodesWillExit ? props :
|
|
120
|
+
oldProps: _nodesWillExit ? props : undefined,
|
|
121
121
|
nextProps: nextProps,
|
|
122
122
|
continuous: continuous
|
|
123
123
|
});
|
|
@@ -13,9 +13,9 @@ function getVerticalAnchor(props, datum) {
|
|
|
13
13
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
14
14
|
} else if (!props.horizontal) {
|
|
15
15
|
return sign >= 0 ? "end" : "start";
|
|
16
|
-
} else {
|
|
17
|
-
return "middle";
|
|
18
16
|
}
|
|
17
|
+
|
|
18
|
+
return "middle";
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function getTextAnchor(props, datum) {
|
|
@@ -29,9 +29,9 @@ function getTextAnchor(props, datum) {
|
|
|
29
29
|
return datum.verticalAnchor || labelStyle.verticalAnchor;
|
|
30
30
|
} else if (!horizontal) {
|
|
31
31
|
return "middle";
|
|
32
|
-
} else {
|
|
33
|
-
return sign >= 0 ? "start" : "end";
|
|
34
32
|
}
|
|
33
|
+
|
|
34
|
+
return sign >= 0 ? "start" : "end";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function getAngle(props, datum) {
|
|
@@ -77,13 +77,13 @@ function getPosition(props, datum) {
|
|
|
77
77
|
x: x,
|
|
78
78
|
y: y
|
|
79
79
|
};
|
|
80
|
-
} else {
|
|
81
|
-
var polarPadding = getPolarPadding(props, datum);
|
|
82
|
-
return {
|
|
83
|
-
x: x + polarPadding.x,
|
|
84
|
-
y: y + polarPadding.y
|
|
85
|
-
};
|
|
86
80
|
}
|
|
81
|
+
|
|
82
|
+
var polarPadding = getPolarPadding(props, datum);
|
|
83
|
+
return {
|
|
84
|
+
x: x + polarPadding.x,
|
|
85
|
+
y: y + polarPadding.y
|
|
86
|
+
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function getPolarPadding(props, datum) {
|
|
@@ -114,9 +114,9 @@ function getPolarOrientation(degrees) {
|
|
|
114
114
|
return "top"; // eslint-disable-next-line no-magic-numbers
|
|
115
115
|
} else if (degrees > 135 && degrees < 225) {
|
|
116
116
|
return "left";
|
|
117
|
-
} else {
|
|
118
|
-
return "bottom";
|
|
119
117
|
}
|
|
118
|
+
|
|
119
|
+
return "bottom";
|
|
120
120
|
} // Exported Functions
|
|
121
121
|
|
|
122
122
|
|
|
@@ -61,9 +61,9 @@ var getConstructor = function (value) {
|
|
|
61
61
|
return undefinedConstructor;
|
|
62
62
|
} else if (value === null) {
|
|
63
63
|
return nullConstructor;
|
|
64
|
-
} else {
|
|
65
|
-
return value.constructor;
|
|
66
64
|
}
|
|
65
|
+
|
|
66
|
+
return value.constructor;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* Get the name of the constructor used to create `value`, using
|
package/es/victory-util/scale.js
CHANGED
|
@@ -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
|
|
@@ -31,9 +31,9 @@ export function getParentSVG(evt) {
|
|
|
31
31
|
var getParent = function (target) {
|
|
32
32
|
if (target.nodeName === "svg") {
|
|
33
33
|
return target;
|
|
34
|
-
} else {
|
|
35
|
-
return target.parentNode ? getParent(target.parentNode) : target;
|
|
36
34
|
}
|
|
35
|
+
|
|
36
|
+
return target.parentNode ? getParent(target.parentNode) : target;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
return getParent(evt.target);
|
|
@@ -79,20 +79,20 @@ export function getDataCoordinates(props, scale, x, y) {
|
|
|
79
79
|
x: horizontal ? scale.x.invert(y) : scale.x.invert(x),
|
|
80
80
|
y: horizontal ? scale.y.invert(x) : scale.y.invert(y)
|
|
81
81
|
};
|
|
82
|
-
} else {
|
|
83
|
-
var origin = props.origin || {
|
|
84
|
-
x: 0,
|
|
85
|
-
y: 0
|
|
86
|
-
};
|
|
87
|
-
var baseX = x - origin.x;
|
|
88
|
-
var baseY = y - origin.y;
|
|
89
|
-
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
90
|
-
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
91
|
-
return {
|
|
92
|
-
x: scale.x.invert(angle),
|
|
93
|
-
y: scale.y.invert(radius)
|
|
94
|
-
};
|
|
95
82
|
}
|
|
83
|
+
|
|
84
|
+
var origin = props.origin || {
|
|
85
|
+
x: 0,
|
|
86
|
+
y: 0
|
|
87
|
+
};
|
|
88
|
+
var baseX = x - origin.x;
|
|
89
|
+
var baseY = y - origin.y;
|
|
90
|
+
var radius = Math.abs(baseX * Math.sqrt(1 + Math.pow(-baseY / baseX, 2)));
|
|
91
|
+
var angle = (-Math.atan2(baseY, baseX) + Math.PI * 2) % (Math.PI * 2);
|
|
92
|
+
return {
|
|
93
|
+
x: scale.x.invert(angle),
|
|
94
|
+
y: scale.y.invert(radius)
|
|
95
|
+
};
|
|
96
96
|
}
|
|
97
97
|
export function getBounds(props) {
|
|
98
98
|
var x1 = props.x1,
|