victory-bar 37.3.2 → 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 +8 -0
- package/dist/victory-bar.js +587 -255
- package/dist/victory-bar.min.js +1 -1
- package/es/bar-helper-methods.js +2 -2
- package/es/bar.js +2 -2
- package/es/geometry-helper-methods.d.ts +97 -13
- package/es/helper-methods.d.ts +4 -4
- package/es/helper-methods.js +11 -1
- package/es/victory-bar.d.ts +11 -10
- package/es/victory-bar.js +13 -3
- package/lib/bar-helper-methods.js +2 -2
- package/lib/bar.js +3 -3
- package/lib/geometry-helper-methods.d.ts +97 -13
- package/lib/helper-methods.d.ts +4 -4
- package/lib/helper-methods.js +10 -0
- package/lib/victory-bar.d.ts +11 -10
- package/lib/victory-bar.js +12 -2
- package/package.json +3 -31
- package/src/bar-helper-methods.ts +1 -1
- package/src/bar.tsx +1 -1
- package/src/helper-methods.ts +7 -0
- package/src/victory-bar.tsx +13 -2
package/es/bar-helper-methods.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isPlainObject from "lodash/isPlainObject";
|
|
2
2
|
import { Helpers } from "victory-core";
|
|
3
3
|
const DEFAULT_BAR_WIDTH = 8;
|
|
4
4
|
export const getBarWidth = (barWidth, props) => {
|
|
@@ -40,7 +40,7 @@ const getCornerRadiusFromObject = (cornerRadius, props) => {
|
|
|
40
40
|
return realCornerRadius;
|
|
41
41
|
};
|
|
42
42
|
function isCornerRadiusObject(cornerRadius) {
|
|
43
|
-
return
|
|
43
|
+
return isPlainObject(cornerRadius);
|
|
44
44
|
}
|
|
45
45
|
export const getCornerRadius = (cornerRadius, props) => {
|
|
46
46
|
const realCornerRadius = {
|
package/es/bar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defaults from "lodash/defaults";
|
|
2
1
|
import React, { forwardRef } from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
3
|
import { Helpers, Path } from "victory-core";
|
|
4
4
|
import { getStyle, getBarWidth, getCornerRadius } from "./bar-helper-methods";
|
|
5
5
|
import { getPolarBarPath, getBarPath } from "./path-helper-methods";
|
|
@@ -46,7 +46,7 @@ const defaultProps = {
|
|
|
46
46
|
export const Bar = /*#__PURE__*/forwardRef(
|
|
47
47
|
// eslint-disable-next-line prefer-arrow-callback
|
|
48
48
|
function Bar(initialProps, ref) {
|
|
49
|
-
const props = evaluateProps(
|
|
49
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
50
50
|
const {
|
|
51
51
|
polar,
|
|
52
52
|
origin,
|
|
@@ -11,19 +11,103 @@ export declare const point: (x: number, y: number) => {
|
|
|
11
11
|
add(p1: {
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
|
-
}):
|
|
14
|
+
}): {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
distance(p1: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}): number;
|
|
21
|
+
add(p1: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}): /*elided*/ any;
|
|
25
|
+
subtract(p1: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}): /*elided*/ any;
|
|
29
|
+
scalarMult(n: number): /*elided*/ any;
|
|
30
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
31
|
+
equals(p1: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}): boolean;
|
|
35
|
+
};
|
|
15
36
|
subtract(p1: {
|
|
16
37
|
x: number;
|
|
17
38
|
y: number;
|
|
18
|
-
}):
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
}): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
distance(p1: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}): number;
|
|
46
|
+
add(p1: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}): /*elided*/ any;
|
|
50
|
+
subtract(p1: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
}): /*elided*/ any;
|
|
54
|
+
scalarMult(n: number): /*elided*/ any;
|
|
55
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
56
|
+
equals(p1: {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
}): boolean;
|
|
60
|
+
};
|
|
61
|
+
scalarMult(n: number): {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
distance(p1: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
}): number;
|
|
68
|
+
add(p1: {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
}): /*elided*/ any;
|
|
72
|
+
subtract(p1: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}): /*elided*/ any;
|
|
76
|
+
scalarMult(n: number): /*elided*/ any;
|
|
77
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
78
|
+
equals(p1: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
}): boolean;
|
|
82
|
+
};
|
|
83
|
+
scalarDivide(n: number): {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
distance(p1: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
}): number;
|
|
90
|
+
add(p1: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
}): /*elided*/ any;
|
|
94
|
+
subtract(p1: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
}): /*elided*/ any;
|
|
98
|
+
scalarMult(n: number): /*elided*/ any;
|
|
99
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
100
|
+
equals(p1: {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
}): boolean;
|
|
104
|
+
};
|
|
21
105
|
equals(p1: {
|
|
22
106
|
x: number;
|
|
23
107
|
y: number;
|
|
24
108
|
}): boolean;
|
|
25
109
|
};
|
|
26
|
-
|
|
110
|
+
type Center = ReturnType<typeof point>;
|
|
27
111
|
/**
|
|
28
112
|
* A circle in the 2d plane
|
|
29
113
|
*/
|
|
@@ -38,13 +122,13 @@ export declare const circle: (center: Center, radius: number) => {
|
|
|
38
122
|
add(p1: {
|
|
39
123
|
x: number;
|
|
40
124
|
y: number;
|
|
41
|
-
}): any;
|
|
125
|
+
}): /*elided*/ any;
|
|
42
126
|
subtract(p1: {
|
|
43
127
|
x: number;
|
|
44
128
|
y: number;
|
|
45
|
-
}): any;
|
|
46
|
-
scalarMult(n: number): any;
|
|
47
|
-
scalarDivide(n: number): any;
|
|
129
|
+
}): /*elided*/ any;
|
|
130
|
+
scalarMult(n: number): /*elided*/ any;
|
|
131
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
48
132
|
equals(p1: {
|
|
49
133
|
x: number;
|
|
50
134
|
y: number;
|
|
@@ -72,13 +156,13 @@ export declare const circle: (center: Center, radius: number) => {
|
|
|
72
156
|
add(p1: {
|
|
73
157
|
x: number;
|
|
74
158
|
y: number;
|
|
75
|
-
}): any;
|
|
159
|
+
}): /*elided*/ any;
|
|
76
160
|
subtract(p1: {
|
|
77
161
|
x: number;
|
|
78
162
|
y: number;
|
|
79
|
-
}): any;
|
|
80
|
-
scalarMult(n: number): any;
|
|
81
|
-
scalarDivide(n: number): any;
|
|
163
|
+
}): /*elided*/ any;
|
|
164
|
+
scalarMult(n: number): /*elided*/ any;
|
|
165
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
82
166
|
equals(p1: {
|
|
83
167
|
x: number;
|
|
84
168
|
y: number;
|
package/es/helper-methods.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const getBarPosition: (props: any, datum: any) => {
|
|
2
|
-
x:
|
|
3
|
-
x0:
|
|
4
|
-
y:
|
|
5
|
-
y0:
|
|
2
|
+
x: number;
|
|
3
|
+
x0: number;
|
|
4
|
+
y: number;
|
|
5
|
+
y0: number;
|
|
6
6
|
};
|
|
7
7
|
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
8
8
|
//# sourceMappingURL=helper-methods.d.ts.map
|
package/es/helper-methods.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Collection, Data, Domain, Helpers, LabelHelpers, Scale } from "victory-core";
|
|
1
|
+
import { Collection, Data, Domain, Helpers, LabelHelpers, Scale, VictoryClipContainer } from "victory-core";
|
|
2
2
|
export const getBarPosition = (props, datum) => {
|
|
3
3
|
const getDefaultMin = axis => {
|
|
4
4
|
const defaultZero = Scale.getType(props.scale[axis]) === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
|
|
@@ -40,6 +40,16 @@ const getCalculatedValues = props => {
|
|
|
40
40
|
const origin = polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
|
|
41
41
|
let data = Data.getData(props);
|
|
42
42
|
data = Data.formatDataFromDomain(data, domain, 0);
|
|
43
|
+
|
|
44
|
+
// when inside a zoom container, reset the _x and _y properties of each datum to the original
|
|
45
|
+
// x and y property values so they will not be clipped. See https://github.com/FormidableLabs/victory/pull/2970
|
|
46
|
+
if (props.groupComponent.type === VictoryClipContainer) {
|
|
47
|
+
data = data.map(datum => ({
|
|
48
|
+
...datum,
|
|
49
|
+
_x: datum.x,
|
|
50
|
+
_y: datum.y
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
43
53
|
return {
|
|
44
54
|
style,
|
|
45
55
|
data,
|
package/es/victory-bar.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Data, Domain, EventPropTypeInterface, NumberOrCallback, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps, VictoryStyleInterface, EventsMixinClass } from "victory-core";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type VictoryBarCornerRadiusKey = "top" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
4
|
+
export type VictoryBarCornerRadiusObject = Partial<Record<VictoryBarCornerRadiusKey, NumberOrCallback>>;
|
|
5
|
+
export type VictoryBarTTargetType = "data" | "labels" | "parent";
|
|
6
|
+
export type VictoryBarAlignmentType = "start" | "middle" | "end";
|
|
7
7
|
export interface VictoryBarProps extends VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps {
|
|
8
8
|
alignment?: VictoryBarAlignmentType;
|
|
9
9
|
barRatio?: number;
|
|
@@ -64,6 +64,7 @@ declare class VictoryBarBase extends React.Component<VictoryBarProps> {
|
|
|
64
64
|
static getData: typeof Data.getData;
|
|
65
65
|
static getBaseProps(props: VictoryBarProps): any;
|
|
66
66
|
static expectedComponents: (keyof VictoryBarProps)[];
|
|
67
|
+
static shouldRenderDatum: () => boolean;
|
|
67
68
|
shouldAnimate(): boolean;
|
|
68
69
|
render(): React.ReactElement;
|
|
69
70
|
}
|
|
@@ -93,9 +94,9 @@ export declare const VictoryBar: {
|
|
|
93
94
|
getAllEvents(props: any): any;
|
|
94
95
|
getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
|
|
95
96
|
renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
96
|
-
animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement
|
|
97
|
+
animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement;
|
|
97
98
|
renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
98
|
-
renderData(props: any, shouldRenderDatum?: (
|
|
99
|
+
renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
99
100
|
context: unknown;
|
|
100
101
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
101
102
|
forceUpdate(callback?: (() => void) | undefined): void;
|
|
@@ -112,17 +113,17 @@ export declare const VictoryBar: {
|
|
|
112
113
|
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
113
114
|
componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
114
115
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
115
|
-
componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent
|
|
116
|
+
componentEvents: Array<import("@/victory-core/lib/victory-util/events").ComponentEvent>;
|
|
116
117
|
getSharedEventState: (key: string, value: string) => unknown;
|
|
117
118
|
baseProps: Record<string, object>;
|
|
118
119
|
dataKeys: string[];
|
|
119
120
|
hasEvents: unknown;
|
|
120
121
|
events: unknown;
|
|
121
122
|
};
|
|
122
|
-
getBaseProps?(props: import("victory-core").EventMixinCommonProps):
|
|
123
|
-
role?:
|
|
123
|
+
getBaseProps?(props: import("victory-core").EventMixinCommonProps): import("victory-core").EventMixinCalculatedValues["baseProps"];
|
|
124
|
+
role?: import("victory-core").VictoryComponentRole;
|
|
124
125
|
expectedComponents?: string[] | undefined;
|
|
125
|
-
getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode
|
|
126
|
+
getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: Array<React.ReactNode>, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
|
|
126
127
|
animationWhitelist?: string[] | undefined;
|
|
127
128
|
} & typeof VictoryBarBase;
|
|
128
129
|
export {};
|
package/es/victory-bar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { getBaseProps } from "./helper-methods";
|
|
3
3
|
import { Bar } from "./bar";
|
|
4
|
-
import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme, addEvents, Data, Domain, UserProps } from "victory-core";
|
|
4
|
+
import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme, addEvents, Data, Domain, UserProps, VictoryClipContainer } from "victory-core";
|
|
5
5
|
const fallbackProps = {
|
|
6
6
|
width: 450,
|
|
7
7
|
height: 300,
|
|
@@ -85,7 +85,9 @@ class VictoryBarBase extends React.Component {
|
|
|
85
85
|
return getBaseProps(props, fallbackProps);
|
|
86
86
|
}
|
|
87
87
|
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
88
|
-
|
|
88
|
+
// passed to addEvents.renderData to prevent data props with undefined _x or _y from excluding data from render.
|
|
89
|
+
// used when inside of VictoryZoomContainer
|
|
90
|
+
static shouldRenderDatum = () => true;
|
|
89
91
|
// Overridden in native versions
|
|
90
92
|
shouldAnimate() {
|
|
91
93
|
return !!this.props.animate;
|
|
@@ -99,7 +101,15 @@ class VictoryBarBase extends React.Component {
|
|
|
99
101
|
if (this.shouldAnimate()) {
|
|
100
102
|
return this.animateComponent(props, animationWhitelist);
|
|
101
103
|
}
|
|
102
|
-
|
|
104
|
+
let children;
|
|
105
|
+
// when inside a zoom container (the only place VictoryClipContainer is used), all data
|
|
106
|
+
// should be renderable so bars won't dissappear before they've fully exited the container's bounds
|
|
107
|
+
// see https://github.com/FormidableLabs/victory/pull/2970
|
|
108
|
+
if (props.groupComponent.type === VictoryClipContainer) {
|
|
109
|
+
children = this.renderData(props, VictoryBarBase.shouldRenderDatum);
|
|
110
|
+
} else {
|
|
111
|
+
children = this.renderData(props);
|
|
112
|
+
}
|
|
103
113
|
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
104
114
|
return UserProps.withSafeUserProps(component, props);
|
|
105
115
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getStyle = exports.getCornerRadius = exports.getBarWidth = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
8
8
|
var _victoryCore = require("victory-core");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
const DEFAULT_BAR_WIDTH = 8;
|
|
@@ -48,7 +48,7 @@ const getCornerRadiusFromObject = (cornerRadius, props) => {
|
|
|
48
48
|
return realCornerRadius;
|
|
49
49
|
};
|
|
50
50
|
function isCornerRadiusObject(cornerRadius) {
|
|
51
|
-
return (0,
|
|
51
|
+
return (0, _isPlainObject.default)(cornerRadius);
|
|
52
52
|
}
|
|
53
53
|
const getCornerRadius = (cornerRadius, props) => {
|
|
54
54
|
const realCornerRadius = {
|
package/lib/bar.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Bar = void 0;
|
|
7
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
9
9
|
var _victoryCore = require("victory-core");
|
|
10
10
|
var _barHelperMethods = require("./bar-helper-methods");
|
|
11
11
|
var _pathHelperMethods = require("./path-helper-methods");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
const evaluateProps = props => {
|
|
16
16
|
/**
|
|
17
17
|
* Potential evaluated props of following must be evaluated in this order:
|
|
@@ -55,7 +55,7 @@ const defaultProps = {
|
|
|
55
55
|
const Bar = exports.Bar = /*#__PURE__*/(0, _react.forwardRef)(
|
|
56
56
|
// eslint-disable-next-line prefer-arrow-callback
|
|
57
57
|
function Bar(initialProps, ref) {
|
|
58
|
-
const props = evaluateProps((0,
|
|
58
|
+
const props = evaluateProps((0, _defaults.default)({}, initialProps, defaultProps));
|
|
59
59
|
const {
|
|
60
60
|
polar,
|
|
61
61
|
origin,
|
|
@@ -11,19 +11,103 @@ export declare const point: (x: number, y: number) => {
|
|
|
11
11
|
add(p1: {
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
|
-
}):
|
|
14
|
+
}): {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
distance(p1: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}): number;
|
|
21
|
+
add(p1: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}): /*elided*/ any;
|
|
25
|
+
subtract(p1: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}): /*elided*/ any;
|
|
29
|
+
scalarMult(n: number): /*elided*/ any;
|
|
30
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
31
|
+
equals(p1: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}): boolean;
|
|
35
|
+
};
|
|
15
36
|
subtract(p1: {
|
|
16
37
|
x: number;
|
|
17
38
|
y: number;
|
|
18
|
-
}):
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
}): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
distance(p1: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}): number;
|
|
46
|
+
add(p1: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}): /*elided*/ any;
|
|
50
|
+
subtract(p1: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
}): /*elided*/ any;
|
|
54
|
+
scalarMult(n: number): /*elided*/ any;
|
|
55
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
56
|
+
equals(p1: {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
}): boolean;
|
|
60
|
+
};
|
|
61
|
+
scalarMult(n: number): {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
distance(p1: {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
}): number;
|
|
68
|
+
add(p1: {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
}): /*elided*/ any;
|
|
72
|
+
subtract(p1: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
}): /*elided*/ any;
|
|
76
|
+
scalarMult(n: number): /*elided*/ any;
|
|
77
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
78
|
+
equals(p1: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
}): boolean;
|
|
82
|
+
};
|
|
83
|
+
scalarDivide(n: number): {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
distance(p1: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
}): number;
|
|
90
|
+
add(p1: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
}): /*elided*/ any;
|
|
94
|
+
subtract(p1: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
}): /*elided*/ any;
|
|
98
|
+
scalarMult(n: number): /*elided*/ any;
|
|
99
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
100
|
+
equals(p1: {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
}): boolean;
|
|
104
|
+
};
|
|
21
105
|
equals(p1: {
|
|
22
106
|
x: number;
|
|
23
107
|
y: number;
|
|
24
108
|
}): boolean;
|
|
25
109
|
};
|
|
26
|
-
|
|
110
|
+
type Center = ReturnType<typeof point>;
|
|
27
111
|
/**
|
|
28
112
|
* A circle in the 2d plane
|
|
29
113
|
*/
|
|
@@ -38,13 +122,13 @@ export declare const circle: (center: Center, radius: number) => {
|
|
|
38
122
|
add(p1: {
|
|
39
123
|
x: number;
|
|
40
124
|
y: number;
|
|
41
|
-
}): any;
|
|
125
|
+
}): /*elided*/ any;
|
|
42
126
|
subtract(p1: {
|
|
43
127
|
x: number;
|
|
44
128
|
y: number;
|
|
45
|
-
}): any;
|
|
46
|
-
scalarMult(n: number): any;
|
|
47
|
-
scalarDivide(n: number): any;
|
|
129
|
+
}): /*elided*/ any;
|
|
130
|
+
scalarMult(n: number): /*elided*/ any;
|
|
131
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
48
132
|
equals(p1: {
|
|
49
133
|
x: number;
|
|
50
134
|
y: number;
|
|
@@ -72,13 +156,13 @@ export declare const circle: (center: Center, radius: number) => {
|
|
|
72
156
|
add(p1: {
|
|
73
157
|
x: number;
|
|
74
158
|
y: number;
|
|
75
|
-
}): any;
|
|
159
|
+
}): /*elided*/ any;
|
|
76
160
|
subtract(p1: {
|
|
77
161
|
x: number;
|
|
78
162
|
y: number;
|
|
79
|
-
}): any;
|
|
80
|
-
scalarMult(n: number): any;
|
|
81
|
-
scalarDivide(n: number): any;
|
|
163
|
+
}): /*elided*/ any;
|
|
164
|
+
scalarMult(n: number): /*elided*/ any;
|
|
165
|
+
scalarDivide(n: number): /*elided*/ any;
|
|
82
166
|
equals(p1: {
|
|
83
167
|
x: number;
|
|
84
168
|
y: number;
|
package/lib/helper-methods.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const getBarPosition: (props: any, datum: any) => {
|
|
2
|
-
x:
|
|
3
|
-
x0:
|
|
4
|
-
y:
|
|
5
|
-
y0:
|
|
2
|
+
x: number;
|
|
3
|
+
x0: number;
|
|
4
|
+
y: number;
|
|
5
|
+
y0: number;
|
|
6
6
|
};
|
|
7
7
|
export declare const getBaseProps: (initialProps: any, fallbackProps: any) => any;
|
|
8
8
|
//# sourceMappingURL=helper-methods.d.ts.map
|
package/lib/helper-methods.js
CHANGED
|
@@ -47,6 +47,16 @@ const getCalculatedValues = props => {
|
|
|
47
47
|
const origin = polar ? props.origin || _victoryCore.Helpers.getPolarOrigin(props) : undefined;
|
|
48
48
|
let data = _victoryCore.Data.getData(props);
|
|
49
49
|
data = _victoryCore.Data.formatDataFromDomain(data, domain, 0);
|
|
50
|
+
|
|
51
|
+
// when inside a zoom container, reset the _x and _y properties of each datum to the original
|
|
52
|
+
// x and y property values so they will not be clipped. See https://github.com/FormidableLabs/victory/pull/2970
|
|
53
|
+
if (props.groupComponent.type === _victoryCore.VictoryClipContainer) {
|
|
54
|
+
data = data.map(datum => ({
|
|
55
|
+
...datum,
|
|
56
|
+
_x: datum.x,
|
|
57
|
+
_y: datum.y
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
50
60
|
return {
|
|
51
61
|
style,
|
|
52
62
|
data,
|
package/lib/victory-bar.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Data, Domain, EventPropTypeInterface, NumberOrCallback, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps, VictoryStyleInterface, EventsMixinClass } from "victory-core";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
3
|
+
export type VictoryBarCornerRadiusKey = "top" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
4
|
+
export type VictoryBarCornerRadiusObject = Partial<Record<VictoryBarCornerRadiusKey, NumberOrCallback>>;
|
|
5
|
+
export type VictoryBarTTargetType = "data" | "labels" | "parent";
|
|
6
|
+
export type VictoryBarAlignmentType = "start" | "middle" | "end";
|
|
7
7
|
export interface VictoryBarProps extends VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps {
|
|
8
8
|
alignment?: VictoryBarAlignmentType;
|
|
9
9
|
barRatio?: number;
|
|
@@ -64,6 +64,7 @@ declare class VictoryBarBase extends React.Component<VictoryBarProps> {
|
|
|
64
64
|
static getData: typeof Data.getData;
|
|
65
65
|
static getBaseProps(props: VictoryBarProps): any;
|
|
66
66
|
static expectedComponents: (keyof VictoryBarProps)[];
|
|
67
|
+
static shouldRenderDatum: () => boolean;
|
|
67
68
|
shouldAnimate(): boolean;
|
|
68
69
|
render(): React.ReactElement;
|
|
69
70
|
}
|
|
@@ -93,9 +94,9 @@ export declare const VictoryBar: {
|
|
|
93
94
|
getAllEvents(props: any): any;
|
|
94
95
|
getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
|
|
95
96
|
renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
96
|
-
animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement
|
|
97
|
+
animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement;
|
|
97
98
|
renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
98
|
-
renderData(props: any, shouldRenderDatum?: (
|
|
99
|
+
renderData(props: any, shouldRenderDatum?: (datum: any) => boolean): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
99
100
|
context: unknown;
|
|
100
101
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
101
102
|
forceUpdate(callback?: (() => void) | undefined): void;
|
|
@@ -112,17 +113,17 @@ export declare const VictoryBar: {
|
|
|
112
113
|
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
113
114
|
componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
114
115
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
115
|
-
componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent
|
|
116
|
+
componentEvents: Array<import("@/victory-core/lib/victory-util/events").ComponentEvent>;
|
|
116
117
|
getSharedEventState: (key: string, value: string) => unknown;
|
|
117
118
|
baseProps: Record<string, object>;
|
|
118
119
|
dataKeys: string[];
|
|
119
120
|
hasEvents: unknown;
|
|
120
121
|
events: unknown;
|
|
121
122
|
};
|
|
122
|
-
getBaseProps?(props: import("victory-core").EventMixinCommonProps):
|
|
123
|
-
role?:
|
|
123
|
+
getBaseProps?(props: import("victory-core").EventMixinCommonProps): import("victory-core").EventMixinCalculatedValues["baseProps"];
|
|
124
|
+
role?: import("victory-core").VictoryComponentRole;
|
|
124
125
|
expectedComponents?: string[] | undefined;
|
|
125
|
-
getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode
|
|
126
|
+
getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: Array<React.ReactNode>, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
|
|
126
127
|
animationWhitelist?: string[] | undefined;
|
|
127
128
|
} & typeof VictoryBarBase;
|
|
128
129
|
export {};
|
package/lib/victory-bar.js
CHANGED
|
@@ -92,7 +92,9 @@ class VictoryBarBase extends _react.default.Component {
|
|
|
92
92
|
return (0, _helperMethods.getBaseProps)(props, fallbackProps);
|
|
93
93
|
}
|
|
94
94
|
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
|
|
95
|
-
|
|
95
|
+
// passed to addEvents.renderData to prevent data props with undefined _x or _y from excluding data from render.
|
|
96
|
+
// used when inside of VictoryZoomContainer
|
|
97
|
+
static shouldRenderDatum = () => true;
|
|
96
98
|
// Overridden in native versions
|
|
97
99
|
shouldAnimate() {
|
|
98
100
|
return !!this.props.animate;
|
|
@@ -106,7 +108,15 @@ class VictoryBarBase extends _react.default.Component {
|
|
|
106
108
|
if (this.shouldAnimate()) {
|
|
107
109
|
return this.animateComponent(props, animationWhitelist);
|
|
108
110
|
}
|
|
109
|
-
|
|
111
|
+
let children;
|
|
112
|
+
// when inside a zoom container (the only place VictoryClipContainer is used), all data
|
|
113
|
+
// should be renderable so bars won't dissappear before they've fully exited the container's bounds
|
|
114
|
+
// see https://github.com/FormidableLabs/victory/pull/2970
|
|
115
|
+
if (props.groupComponent.type === _victoryCore.VictoryClipContainer) {
|
|
116
|
+
children = this.renderData(props, VictoryBarBase.shouldRenderDatum);
|
|
117
|
+
} else {
|
|
118
|
+
children = this.renderData(props);
|
|
119
|
+
}
|
|
110
120
|
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
111
121
|
return _victoryCore.UserProps.withSafeUserProps(component, props);
|
|
112
122
|
}
|