victory-bar 37.3.1 → 37.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/victory-bar.js +601 -302
- package/dist/victory-bar.min.js +1 -1
- package/es/bar-helper-methods.js +2 -2
- package/es/bar.js +4 -4
- package/es/geometry-helper-methods.d.ts +97 -13
- package/es/geometry-helper-methods.js +0 -1
- package/es/helper-methods.d.ts +4 -4
- package/es/helper-methods.js +11 -1
- package/es/path-helper-methods.js +0 -12
- package/es/victory-bar.d.ts +11 -10
- package/es/victory-bar.js +14 -4
- package/lib/bar-helper-methods.js +2 -2
- package/lib/bar.js +5 -5
- package/lib/geometry-helper-methods.d.ts +97 -13
- package/lib/geometry-helper-methods.js +0 -1
- package/lib/helper-methods.d.ts +4 -4
- package/lib/helper-methods.js +10 -0
- package/lib/path-helper-methods.js +0 -12
- package/lib/victory-bar.d.ts +11 -10
- package/lib/victory-bar.js +13 -3
- package/package.json +7 -39
- package/src/bar-helper-methods.ts +1 -1
- package/src/bar.tsx +31 -32
- package/src/geometry-helper-methods.ts +0 -1
- package/src/helper-methods.ts +7 -0
- package/src/path-helper-methods.ts +0 -6
- package/src/victory-bar.tsx +14 -3
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";
|
|
@@ -43,10 +43,10 @@ const defaultProps = {
|
|
|
43
43
|
role: "presentation",
|
|
44
44
|
shapeRendering: "auto"
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
export const Bar = /*#__PURE__*/forwardRef(
|
|
47
47
|
// eslint-disable-next-line prefer-arrow-callback
|
|
48
|
-
|
|
49
|
-
const props = evaluateProps(
|
|
48
|
+
function Bar(initialProps, ref) {
|
|
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;
|
|
@@ -62,7 +62,6 @@ export const circle = (center, radius) => ({
|
|
|
62
62
|
// Left-most point is returned as 0th element of array
|
|
63
63
|
// Right-most point is returned as 1st elemennt of array
|
|
64
64
|
intersection(circle1) {
|
|
65
|
-
// eslint-disable-line max-statements
|
|
66
65
|
const P0 = this.center;
|
|
67
66
|
const P1 = circle1.center;
|
|
68
67
|
const r0 = this.radius;
|
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,
|
|
@@ -107,8 +107,6 @@ const getVerticalBarPoints = (position, sign, cr) => {
|
|
|
107
107
|
y0,
|
|
108
108
|
y1
|
|
109
109
|
} = position;
|
|
110
|
-
|
|
111
|
-
// eslint-disable-next-line max-statements, max-len
|
|
112
110
|
const getHalfPoints = side => {
|
|
113
111
|
const isLeft = side === "Left";
|
|
114
112
|
const signL = isLeft ? 1 : -1;
|
|
@@ -192,8 +190,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
192
190
|
} = position;
|
|
193
191
|
const x0 = position.x0 < position.x1 ? position.x0 : position.x1;
|
|
194
192
|
const x1 = position.x0 < position.x1 ? position.x1 : position.x0;
|
|
195
|
-
|
|
196
|
-
// eslint-disable-next-line max-statements, max-len
|
|
197
193
|
const getHalfPoints = side => {
|
|
198
194
|
const isTop = side === "top";
|
|
199
195
|
const signL = isTop ? -1 : 1;
|
|
@@ -273,8 +269,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
273
269
|
// eslint-disable-next-line no-magic-numbers
|
|
274
270
|
bottomPoints[3], bottomPoints[2]];
|
|
275
271
|
};
|
|
276
|
-
|
|
277
|
-
// eslint-disable-next-line max-params
|
|
278
272
|
export const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
279
273
|
const position = getPosition(props, width);
|
|
280
274
|
const sign = position.y0 > position.y1 ? 1 : -1;
|
|
@@ -282,8 +276,6 @@ export const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
|
282
276
|
const points = getVerticalBarPoints(position, sign, cornerRadius);
|
|
283
277
|
return mapPointsToPath(points, cornerRadius, direction);
|
|
284
278
|
};
|
|
285
|
-
|
|
286
|
-
// eslint-disable-next-line max-params
|
|
287
279
|
export const getHorizontalBarPath = (props, width, cornerRadius) => {
|
|
288
280
|
const position = getPosition(props, width);
|
|
289
281
|
const sign = position.x0 < position.x1 ? 1 : -1;
|
|
@@ -341,8 +333,6 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
341
333
|
leftMiddle
|
|
342
334
|
};
|
|
343
335
|
};
|
|
344
|
-
|
|
345
|
-
// eslint-disable-next-line max-statements
|
|
346
336
|
const getTopPath = () => {
|
|
347
337
|
const {
|
|
348
338
|
topRight,
|
|
@@ -385,8 +375,6 @@ export const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
385
375
|
coords: subCoords[i].split(",")
|
|
386
376
|
}));
|
|
387
377
|
};
|
|
388
|
-
|
|
389
|
-
// eslint-disable-next-line max-statements
|
|
390
378
|
const getBottomPath = () => {
|
|
391
379
|
const {
|
|
392
380
|
bottomRight,
|
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,
|
|
@@ -21,7 +21,7 @@ const defaultData = [{
|
|
|
21
21
|
y: 4
|
|
22
22
|
}];
|
|
23
23
|
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
|
|
@@ -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:
|
|
@@ -52,10 +52,10 @@ const defaultProps = {
|
|
|
52
52
|
role: "presentation",
|
|
53
53
|
shapeRendering: "auto"
|
|
54
54
|
};
|
|
55
|
-
|
|
55
|
+
const Bar = exports.Bar = /*#__PURE__*/(0, _react.forwardRef)(
|
|
56
56
|
// eslint-disable-next-line prefer-arrow-callback
|
|
57
|
-
|
|
58
|
-
const props = evaluateProps((0,
|
|
57
|
+
function Bar(initialProps, ref) {
|
|
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;
|
|
@@ -69,7 +69,6 @@ const circle = (center, radius) => ({
|
|
|
69
69
|
// Left-most point is returned as 0th element of array
|
|
70
70
|
// Right-most point is returned as 1st elemennt of array
|
|
71
71
|
intersection(circle1) {
|
|
72
|
-
// eslint-disable-line max-statements
|
|
73
72
|
const P0 = this.center;
|
|
74
73
|
const P1 = circle1.center;
|
|
75
74
|
const r0 = this.radius;
|
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,
|
|
@@ -116,8 +116,6 @@ const getVerticalBarPoints = (position, sign, cr) => {
|
|
|
116
116
|
y0,
|
|
117
117
|
y1
|
|
118
118
|
} = position;
|
|
119
|
-
|
|
120
|
-
// eslint-disable-next-line max-statements, max-len
|
|
121
119
|
const getHalfPoints = side => {
|
|
122
120
|
const isLeft = side === "Left";
|
|
123
121
|
const signL = isLeft ? 1 : -1;
|
|
@@ -201,8 +199,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
201
199
|
} = position;
|
|
202
200
|
const x0 = position.x0 < position.x1 ? position.x0 : position.x1;
|
|
203
201
|
const x1 = position.x0 < position.x1 ? position.x1 : position.x0;
|
|
204
|
-
|
|
205
|
-
// eslint-disable-next-line max-statements, max-len
|
|
206
202
|
const getHalfPoints = side => {
|
|
207
203
|
const isTop = side === "top";
|
|
208
204
|
const signL = isTop ? -1 : 1;
|
|
@@ -282,8 +278,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
282
278
|
// eslint-disable-next-line no-magic-numbers
|
|
283
279
|
bottomPoints[3], bottomPoints[2]];
|
|
284
280
|
};
|
|
285
|
-
|
|
286
|
-
// eslint-disable-next-line max-params
|
|
287
281
|
const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
288
282
|
const position = getPosition(props, width);
|
|
289
283
|
const sign = position.y0 > position.y1 ? 1 : -1;
|
|
@@ -291,8 +285,6 @@ const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
|
291
285
|
const points = getVerticalBarPoints(position, sign, cornerRadius);
|
|
292
286
|
return mapPointsToPath(points, cornerRadius, direction);
|
|
293
287
|
};
|
|
294
|
-
|
|
295
|
-
// eslint-disable-next-line max-params
|
|
296
288
|
exports.getVerticalBarPath = getVerticalBarPath;
|
|
297
289
|
const getHorizontalBarPath = (props, width, cornerRadius) => {
|
|
298
290
|
const position = getPosition(props, width);
|
|
@@ -352,8 +344,6 @@ const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
352
344
|
leftMiddle
|
|
353
345
|
};
|
|
354
346
|
};
|
|
355
|
-
|
|
356
|
-
// eslint-disable-next-line max-statements
|
|
357
347
|
const getTopPath = () => {
|
|
358
348
|
const {
|
|
359
349
|
topRight,
|
|
@@ -396,8 +386,6 @@ const getVerticalPolarBarPath = (props, cornerRadius) => {
|
|
|
396
386
|
coords: subCoords[i].split(",")
|
|
397
387
|
}));
|
|
398
388
|
};
|
|
399
|
-
|
|
400
|
-
// eslint-disable-next-line max-statements
|
|
401
389
|
const getBottomPath = () => {
|
|
402
390
|
const {
|
|
403
391
|
bottomRight,
|