victory-bar 37.3.1 → 37.3.2
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 +2 -0
- package/dist/victory-bar.js +15 -48
- package/dist/victory-bar.min.js +1 -1
- package/es/bar.js +2 -2
- package/es/geometry-helper-methods.js +0 -1
- package/es/path-helper-methods.js +0 -12
- package/es/victory-bar.d.ts +1 -1
- package/es/victory-bar.js +1 -1
- package/lib/bar.js +2 -2
- package/lib/geometry-helper-methods.js +0 -1
- package/lib/path-helper-methods.js +0 -12
- package/lib/victory-bar.d.ts +1 -1
- package/lib/victory-bar.js +1 -1
- package/package.json +7 -11
- package/src/bar.tsx +30 -31
- package/src/geometry-helper-methods.ts +0 -1
- package/src/path-helper-methods.ts +0 -6
- package/src/victory-bar.tsx +1 -1
package/es/bar.js
CHANGED
|
@@ -43,9 +43,9 @@ 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
|
-
|
|
48
|
+
function Bar(initialProps, ref) {
|
|
49
49
|
const props = evaluateProps(_defaults({}, initialProps, defaultProps));
|
|
50
50
|
const {
|
|
51
51
|
polar,
|
|
@@ -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;
|
|
@@ -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
|
@@ -112,7 +112,7 @@ export declare const VictoryBar: {
|
|
|
112
112
|
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
113
113
|
componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
114
114
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
115
|
-
componentEvents: import("victory-core/lib/victory-util/events").ComponentEvent[];
|
|
115
|
+
componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent[];
|
|
116
116
|
getSharedEventState: (key: string, value: string) => unknown;
|
|
117
117
|
baseProps: Record<string, object>;
|
|
118
118
|
dataKeys: string[];
|
package/es/victory-bar.js
CHANGED
|
@@ -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
|
package/lib/bar.js
CHANGED
|
@@ -52,9 +52,9 @@ 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
|
-
|
|
57
|
+
function Bar(initialProps, ref) {
|
|
58
58
|
const props = evaluateProps((0, _defaults2.default)({}, initialProps, defaultProps));
|
|
59
59
|
const {
|
|
60
60
|
polar,
|
|
@@ -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;
|
|
@@ -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,
|
package/lib/victory-bar.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export declare const VictoryBar: {
|
|
|
112
112
|
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
|
|
113
113
|
componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
114
114
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
|
|
115
|
-
componentEvents: import("victory-core/lib/victory-util/events").ComponentEvent[];
|
|
115
|
+
componentEvents: import("@/victory-core/lib/victory-util/events").ComponentEvent[];
|
|
116
116
|
getSharedEventState: (key: string, value: string) => unknown;
|
|
117
117
|
baseProps: Record<string, object>;
|
|
118
118
|
dataKeys: string[];
|
package/lib/victory-bar.js
CHANGED
|
@@ -28,7 +28,7 @@ const defaultData = [{
|
|
|
28
28
|
y: 4
|
|
29
29
|
}];
|
|
30
30
|
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-bar",
|
|
3
|
-
"version": "37.3.
|
|
3
|
+
"version": "37.3.2",
|
|
4
4
|
"description": "Bar Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"lodash": "^4.17.19",
|
|
24
|
-
"victory-core": "37.3.
|
|
25
|
-
"victory-vendor": "37.3.
|
|
24
|
+
"victory-core": "37.3.2",
|
|
25
|
+
"victory-vendor": "37.3.2"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=16.6.0"
|
|
@@ -217,11 +217,9 @@
|
|
|
217
217
|
]
|
|
218
218
|
},
|
|
219
219
|
"lint": {
|
|
220
|
-
"command": "
|
|
220
|
+
"command": "eslint src",
|
|
221
221
|
"files": [
|
|
222
|
-
"src/**"
|
|
223
|
-
"../../.eslintignore",
|
|
224
|
-
"../../.eslintrc.js"
|
|
222
|
+
"src/**"
|
|
225
223
|
],
|
|
226
224
|
"output": [],
|
|
227
225
|
"dependencies": [
|
|
@@ -236,11 +234,9 @@
|
|
|
236
234
|
]
|
|
237
235
|
},
|
|
238
236
|
"lint:fix": {
|
|
239
|
-
"command": "
|
|
237
|
+
"command": "eslint --fix src",
|
|
240
238
|
"files": [
|
|
241
|
-
"src/**"
|
|
242
|
-
"../../.eslintignore",
|
|
243
|
-
"../../.eslintrc.js"
|
|
239
|
+
"src/**"
|
|
244
240
|
],
|
|
245
241
|
"output": [],
|
|
246
242
|
"dependencies": [
|
package/src/bar.tsx
CHANGED
|
@@ -74,37 +74,36 @@ const defaultProps: Partial<BarProps> = {
|
|
|
74
74
|
shapeRendering: "auto",
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
initialProps,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
83
|
-
const { polar, origin, style, barWidth, cornerRadius } = props;
|
|
77
|
+
export const Bar = forwardRef<SVGPathElement, BarProps>(
|
|
78
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
79
|
+
function Bar(initialProps, ref) {
|
|
80
|
+
const props = evaluateProps(defaults({}, initialProps, defaultProps));
|
|
81
|
+
const { polar, origin, style, barWidth, cornerRadius } = props;
|
|
84
82
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
const path = polar
|
|
84
|
+
? getPolarBarPath(props, cornerRadius)
|
|
85
|
+
: getBarPath(props, barWidth, cornerRadius);
|
|
86
|
+
const defaultTransform =
|
|
87
|
+
polar && origin ? `translate(${origin.x}, ${origin.y})` : undefined;
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
if (!props.pathComponent) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
93
|
+
return React.cloneElement(props.pathComponent, {
|
|
94
|
+
...props.events,
|
|
95
|
+
"aria-label": props.ariaLabel,
|
|
96
|
+
style,
|
|
97
|
+
d: path,
|
|
98
|
+
className: props.className,
|
|
99
|
+
clipPath: props.clipPath,
|
|
100
|
+
desc: props.desc,
|
|
101
|
+
index: props.index,
|
|
102
|
+
role: props.role,
|
|
103
|
+
shapeRendering: props.shapeRendering,
|
|
104
|
+
transform: props.transform || defaultTransform,
|
|
105
|
+
tabIndex: props.tabIndex,
|
|
106
|
+
ref,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
);
|
|
@@ -66,7 +66,6 @@ export const circle = (center: Center, radius: number) => ({
|
|
|
66
66
|
// Left-most point is returned as 0th element of array
|
|
67
67
|
// Right-most point is returned as 1st elemennt of array
|
|
68
68
|
intersection(circle1: { center: Center; radius: number }) {
|
|
69
|
-
// eslint-disable-line max-statements
|
|
70
69
|
const P0 = this.center;
|
|
71
70
|
const P1 = circle1.center;
|
|
72
71
|
const r0 = this.radius;
|
|
@@ -119,7 +119,6 @@ const mapPointsToPath = (coords, cornerRadius, direction) => {
|
|
|
119
119
|
const getVerticalBarPoints = (position, sign, cr) => {
|
|
120
120
|
const { x0, x1, y0, y1 } = position;
|
|
121
121
|
|
|
122
|
-
// eslint-disable-next-line max-statements, max-len
|
|
123
122
|
const getHalfPoints = (side) => {
|
|
124
123
|
const isLeft = side === "Left";
|
|
125
124
|
const signL = isLeft ? 1 : -1;
|
|
@@ -177,7 +176,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
177
176
|
const x0 = position.x0 < position.x1 ? position.x0 : position.x1;
|
|
178
177
|
const x1 = position.x0 < position.x1 ? position.x1 : position.x0;
|
|
179
178
|
|
|
180
|
-
// eslint-disable-next-line max-statements, max-len
|
|
181
179
|
const getHalfPoints = (side) => {
|
|
182
180
|
const isTop = side === "top";
|
|
183
181
|
const signL = isTop ? -1 : 1;
|
|
@@ -234,7 +232,6 @@ const getHorizontalBarPoints = (position, sign, cr) => {
|
|
|
234
232
|
];
|
|
235
233
|
};
|
|
236
234
|
|
|
237
|
-
// eslint-disable-next-line max-params
|
|
238
235
|
export const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
239
236
|
const position = getPosition(props, width);
|
|
240
237
|
|
|
@@ -244,7 +241,6 @@ export const getVerticalBarPath = (props, width, cornerRadius) => {
|
|
|
244
241
|
return mapPointsToPath(points, cornerRadius, direction);
|
|
245
242
|
};
|
|
246
243
|
|
|
247
|
-
// eslint-disable-next-line max-params
|
|
248
244
|
export const getHorizontalBarPath = (props, width, cornerRadius) => {
|
|
249
245
|
const position = getPosition(props, width);
|
|
250
246
|
|
|
@@ -310,7 +306,6 @@ export const getVerticalPolarBarPath = (props: BarProps, cornerRadius) => {
|
|
|
310
306
|
};
|
|
311
307
|
};
|
|
312
308
|
|
|
313
|
-
// eslint-disable-next-line max-statements
|
|
314
309
|
const getTopPath = () => {
|
|
315
310
|
const { topRight, topLeft } = cornerRadius;
|
|
316
311
|
const arcLength = r2 * Math.abs(end - start);
|
|
@@ -360,7 +355,6 @@ export const getVerticalPolarBarPath = (props: BarProps, cornerRadius) => {
|
|
|
360
355
|
}));
|
|
361
356
|
};
|
|
362
357
|
|
|
363
|
-
// eslint-disable-next-line max-statements
|
|
364
358
|
const getBottomPath = () => {
|
|
365
359
|
const { bottomRight, bottomLeft } = cornerRadius;
|
|
366
360
|
const arcLength = r1 * Math.abs(end - start);
|
package/src/victory-bar.tsx
CHANGED
|
@@ -66,7 +66,7 @@ const defaultData = [
|
|
|
66
66
|
{ x: 4, y: 4 },
|
|
67
67
|
];
|
|
68
68
|
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
70
70
|
interface VictoryBarBase extends EventsMixinClass<VictoryBarProps> {}
|
|
71
71
|
|
|
72
72
|
/**
|