victory-bar 36.7.0 → 36.8.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/victory-bar.js +278 -415
  3. package/dist/victory-bar.min.js +1 -1
  4. package/es/bar-helper-methods.d.ts +7 -0
  5. package/es/bar-helper-methods.js +7 -3
  6. package/es/bar.d.ts +20 -0
  7. package/es/bar.js +15 -34
  8. package/es/geometry-helper-methods.d.ts +91 -0
  9. package/es/geometry-helper-methods.js +4 -13
  10. package/es/helper-methods.d.ts +8 -0
  11. package/es/index.d.ts +6 -73
  12. package/es/index.js +2 -2
  13. package/es/path-helper-methods.d.ts +7 -0
  14. package/es/path-helper-methods.js +2 -2
  15. package/es/victory-bar.d.ts +129 -0
  16. package/es/victory-bar.js +24 -42
  17. package/lib/bar-helper-methods.d.ts +7 -0
  18. package/lib/bar-helper-methods.js +8 -3
  19. package/lib/bar.d.ts +20 -0
  20. package/lib/bar.js +14 -34
  21. package/lib/geometry-helper-methods.d.ts +91 -0
  22. package/lib/geometry-helper-methods.js +3 -10
  23. package/lib/helper-methods.d.ts +8 -0
  24. package/lib/index.d.ts +6 -73
  25. package/lib/index.js +39 -17
  26. package/lib/path-helper-methods.d.ts +7 -0
  27. package/lib/path-helper-methods.js +2 -2
  28. package/lib/victory-bar.d.ts +129 -0
  29. package/lib/victory-bar.js +26 -47
  30. package/package.json +3 -3
  31. package/src/{bar-helper-methods.js → bar-helper-methods.ts} +36 -11
  32. package/src/{bar.js → bar.tsx} +44 -41
  33. package/src/geometry-helper-methods.ts +103 -0
  34. package/src/{helper-methods.js → helper-methods.ts} +2 -2
  35. package/src/{index.js → index.ts} +2 -2
  36. package/src/{path-helper-methods.js → path-helper-methods.ts} +11 -8
  37. package/src/{victory-bar.js → victory-bar.tsx} +57 -32
  38. package/es/v37/victory-bar-v1.d.ts +0 -24
  39. package/es/v37/victory-bar-v1.js +0 -102
  40. package/es/v37/victory-bar-v2.d.ts +0 -24
  41. package/es/v37/victory-bar-v2.js +0 -97
  42. package/es/v37/victory-bar.stories.d.ts +0 -19
  43. package/es/v37/victory-bar.stories.js +0 -22
  44. package/lib/v37/victory-bar-v1.d.ts +0 -24
  45. package/lib/v37/victory-bar-v1.js +0 -123
  46. package/lib/v37/victory-bar-v2.d.ts +0 -24
  47. package/lib/v37/victory-bar-v2.js +0 -114
  48. package/lib/v37/victory-bar.stories.d.ts +0 -19
  49. package/lib/v37/victory-bar.stories.js +0 -45
  50. package/src/geometry-helper-methods.js +0 -113
  51. package/src/index.d.ts +0 -73
  52. package/src/v37/victory-bar-v1.tsx +0 -129
  53. package/src/v37/victory-bar-v2.tsx +0 -96
  54. package/src/v37/victory-bar.stories.tsx +0 -28
@@ -0,0 +1,7 @@
1
+ import { VictoryStyleObject } from "victory-core";
2
+ import { BarProps } from "./bar";
3
+ import { VictoryBarCornerRadiusKey } from "./victory-bar";
4
+ export declare const getBarWidth: (barWidth: BarProps["barWidth"], props: BarProps) => any;
5
+ export declare const getCornerRadius: (cornerRadius: BarProps["cornerRadius"], props: BarProps) => Partial<Record<VictoryBarCornerRadiusKey, import("victory-core").NumberOrCallback>>;
6
+ export declare const getStyle: (style: VictoryStyleObject | undefined, props: BarProps) => any;
7
+ //# sourceMappingURL=bar-helper-methods.d.ts.map
@@ -2,10 +2,10 @@ import _isPlainObject from "lodash/isPlainObject";
2
2
  import _isNil from "lodash/isNil";
3
3
  import _assign from "lodash/assign";
4
4
  import { Helpers } from "victory-core";
5
+ var DEFAULT_BAR_WIDTH = 8;
5
6
  export var getBarWidth = function (barWidth, props) {
6
7
  var scale = props.scale,
7
8
  data = props.data,
8
- defaultBarWidth = props.defaultBarWidth,
9
9
  style = props.style;
10
10
 
11
11
  if (barWidth) {
@@ -18,7 +18,7 @@ export var getBarWidth = function (barWidth, props) {
18
18
  var extent = Math.abs(range[1] - range[0]);
19
19
  var bars = data.length + 2;
20
20
  var barRatio = props.barRatio || 0.5;
21
- var defaultWidth = barRatio * (data.length < 2 ? defaultBarWidth : extent / bars);
21
+ var defaultWidth = barRatio * (data.length < 2 ? DEFAULT_BAR_WIDTH : extent / bars);
22
22
  return Math.max(1, defaultWidth);
23
23
  };
24
24
 
@@ -45,6 +45,10 @@ var getCornerRadiusFromObject = function (cornerRadius, props) {
45
45
  return realCornerRadius;
46
46
  };
47
47
 
48
+ function isCornerRadiusObject(cornerRadius) {
49
+ return _isPlainObject(cornerRadius);
50
+ }
51
+
48
52
  export var getCornerRadius = function (cornerRadius, props) {
49
53
  var realCornerRadius = {
50
54
  topLeft: 0,
@@ -57,7 +61,7 @@ export var getCornerRadius = function (cornerRadius, props) {
57
61
  return realCornerRadius;
58
62
  }
59
63
 
60
- if (_isPlainObject(cornerRadius)) {
64
+ if (isCornerRadiusObject(cornerRadius)) {
61
65
  return getCornerRadiusFromObject(cornerRadius, props);
62
66
  }
63
67
 
package/es/bar.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { NumberOrCallback, VictoryCommonPrimitiveProps } from "victory-core";
3
+ import { VictoryBarAlignmentType, VictoryBarCornerRadiusObject } from "./victory-bar";
4
+ export interface BarProps extends VictoryCommonPrimitiveProps {
5
+ alignment?: VictoryBarAlignmentType;
6
+ barOffset?: number[];
7
+ barRatio?: number;
8
+ barWidth?: NumberOrCallback;
9
+ cornerRadius?: NumberOrCallback | VictoryBarCornerRadiusObject;
10
+ datum?: any;
11
+ getPath?: (x: number, y: number, props: any) => string;
12
+ horizontal?: boolean;
13
+ pathComponent?: React.ReactElement;
14
+ width?: number;
15
+ x?: number;
16
+ y?: number;
17
+ y0?: number;
18
+ }
19
+ export declare const Bar: React.ForwardRefExoticComponent<BarProps & React.RefAttributes<SVGPathElement>>;
20
+ //# sourceMappingURL=bar.d.ts.map
package/es/bar.js CHANGED
@@ -6,9 +6,8 @@ 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
- import PropTypes from "prop-types";
10
9
  import React, { forwardRef } from "react";
11
- import { CommonProps, Helpers, Path } from "victory-core";
10
+ import { Helpers, Path } from "victory-core";
12
11
  import { getStyle, getBarWidth, getCornerRadius } from "./bar-helper-methods";
13
12
  import { getPolarBarPath, getBarPath } from "./path-helper-methods";
14
13
 
@@ -46,11 +45,16 @@ var evaluateProps = function (props) {
46
45
  id: id,
47
46
  tabIndex: tabIndex
48
47
  });
49
- }; // eslint-disable-next-line prefer-arrow-callback
48
+ };
50
49
 
50
+ var defaultProps = {
51
+ pathComponent: /*#__PURE__*/React.createElement(Path, null),
52
+ role: "presentation",
53
+ shapeRendering: "auto"
54
+ }; // eslint-disable-next-line prefer-arrow-callback
51
55
 
52
- var Bar = /*#__PURE__*/forwardRef(function Bar(props, ref) {
53
- props = evaluateProps(props);
56
+ export var Bar = /*#__PURE__*/forwardRef(function Bar(props, ref) {
57
+ props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), props));
54
58
  var _props = props,
55
59
  polar = _props.polar,
56
60
  origin = _props.origin,
@@ -59,6 +63,11 @@ var Bar = /*#__PURE__*/forwardRef(function Bar(props, ref) {
59
63
  cornerRadius = _props.cornerRadius;
60
64
  var path = polar ? getPolarBarPath(props, cornerRadius) : getBarPath(props, barWidth, cornerRadius);
61
65
  var defaultTransform = polar && origin ? "translate(".concat(origin.x, ", ").concat(origin.y, ")") : undefined;
66
+
67
+ if (!props.pathComponent) {
68
+ return null;
69
+ }
70
+
62
71
  return /*#__PURE__*/React.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, {
63
72
  "aria-label": props.ariaLabel,
64
73
  style: style,
@@ -73,32 +82,4 @@ var Bar = /*#__PURE__*/forwardRef(function Bar(props, ref) {
73
82
  tabIndex: props.tabIndex,
74
83
  ref: ref
75
84
  }));
76
- });
77
- Bar.propTypes = _objectSpread(_objectSpread({}, CommonProps.primitiveProps), {}, {
78
- alignment: PropTypes.oneOf(["start", "middle", "end"]),
79
- barRatio: PropTypes.number,
80
- barWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
81
- cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.func, PropTypes.shape({
82
- top: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
83
- topLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
84
- topRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
85
- bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
86
- bottomLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
87
- bottomRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
88
- })]),
89
- datum: PropTypes.object,
90
- getPath: PropTypes.func,
91
- horizontal: PropTypes.bool,
92
- pathComponent: PropTypes.element,
93
- width: PropTypes.number,
94
- x: PropTypes.number,
95
- y: PropTypes.number,
96
- y0: PropTypes.number
97
- });
98
- Bar.defaultProps = {
99
- defaultBarWidth: 8,
100
- pathComponent: /*#__PURE__*/React.createElement(Path, null),
101
- role: "presentation",
102
- shapeRendering: "auto"
103
- };
104
- export default Bar;
85
+ });
@@ -0,0 +1,91 @@
1
+ /**
2
+ * A point in the 2d plane
3
+ */
4
+ export declare const point: (x: number, y: number) => {
5
+ x: number;
6
+ y: number;
7
+ distance(p1: {
8
+ x: number;
9
+ y: number;
10
+ }): number;
11
+ add(p1: {
12
+ x: number;
13
+ y: number;
14
+ }): any;
15
+ subtract(p1: {
16
+ x: number;
17
+ y: number;
18
+ }): any;
19
+ scalarMult(n: number): any;
20
+ scalarDivide(n: number): any;
21
+ equals(p1: {
22
+ x: number;
23
+ y: number;
24
+ }): boolean;
25
+ };
26
+ declare type Center = ReturnType<typeof point>;
27
+ /**
28
+ * A circle in the 2d plane
29
+ */
30
+ export declare const circle: (center: Center, radius: number) => {
31
+ center: {
32
+ x: number;
33
+ y: number;
34
+ distance(p1: {
35
+ x: number;
36
+ y: number;
37
+ }): number;
38
+ add(p1: {
39
+ x: number;
40
+ y: number;
41
+ }): any;
42
+ subtract(p1: {
43
+ x: number;
44
+ y: number;
45
+ }): any;
46
+ scalarMult(n: number): any;
47
+ scalarDivide(n: number): any;
48
+ equals(p1: {
49
+ x: number;
50
+ y: number;
51
+ }): boolean;
52
+ };
53
+ radius: number;
54
+ hasIntersection(circle1: {
55
+ center: Center;
56
+ radius: number;
57
+ }): boolean;
58
+ equals(circle1: {
59
+ center: Center;
60
+ radius: number;
61
+ }): boolean;
62
+ intersection(circle1: {
63
+ center: Center;
64
+ radius: number;
65
+ }): {
66
+ x: number;
67
+ y: number;
68
+ distance(p1: {
69
+ x: number;
70
+ y: number;
71
+ }): number;
72
+ add(p1: {
73
+ x: number;
74
+ y: number;
75
+ }): any;
76
+ subtract(p1: {
77
+ x: number;
78
+ y: number;
79
+ }): any;
80
+ scalarMult(n: number): any;
81
+ scalarDivide(n: number): any;
82
+ equals(p1: {
83
+ x: number;
84
+ y: number;
85
+ }): boolean;
86
+ }[];
87
+ solveX(y: number): number[];
88
+ solveY(x: number): number[];
89
+ };
90
+ export {};
91
+ //# sourceMappingURL=geometry-helper-methods.d.ts.map
@@ -1,10 +1,7 @@
1
1
  /**
2
2
  * A point in the 2d plane
3
- * @param {number} x - x coordinate
4
- * @param {number} y - y coordinate
5
- * @returns {object} - point object
6
3
  */
7
- var point = function (x, y) {
4
+ export var point = function (x, y) {
8
5
  return {
9
6
  x: x,
10
7
  y: y,
@@ -36,15 +33,11 @@ var point = function (x, y) {
36
33
  }
37
34
  };
38
35
  };
36
+
39
37
  /**
40
38
  * A circle in the 2d plane
41
- * @param {point} center - center of circle
42
- * @param {number} radius - radius of circle
43
- * @returns {object} - point object
44
39
  */
45
-
46
-
47
- var circle = function (center, radius) {
40
+ export var circle = function (center, radius) {
48
41
  return {
49
42
  center: center,
50
43
  radius: radius,
@@ -112,6 +105,4 @@ var circle = function (center, radius) {
112
105
  return [this.center.y - sqrt, this.center.y + sqrt];
113
106
  }
114
107
  };
115
- };
116
-
117
- export { circle, point };
108
+ };
@@ -0,0 +1,8 @@
1
+ export declare const getBarPosition: (props: any, datum: any) => {
2
+ x: any;
3
+ x0: any;
4
+ y: any;
5
+ y0: any;
6
+ };
7
+ export declare const getBaseProps: (props: any, fallbackProps: any) => any;
8
+ //# sourceMappingURL=helper-methods.d.ts.map
package/es/index.d.ts CHANGED
@@ -1,73 +1,6 @@
1
- import * as React from "react";
2
- import {
3
- EventPropTypeInterface,
4
- NumberOrCallback,
5
- StringOrNumberOrCallback,
6
- VictoryCommonProps,
7
- VictoryCommonPrimitiveProps,
8
- VictoryDatableProps,
9
- VictoryMultiLabelableProps,
10
- VictoryStyleInterface,
11
- } from "victory-core";
12
-
13
- export type VictoryBarTTargetType = "data" | "labels" | "parent";
14
- export type VictoryBarAlignmentType = "start" | "middle" | "end";
15
-
16
- export interface VictoryBarProps
17
- extends VictoryCommonProps,
18
- VictoryDatableProps,
19
- VictoryMultiLabelableProps {
20
- alignment?: VictoryBarAlignmentType;
21
- barRatio?: number;
22
- barWidth?: NumberOrCallback;
23
- cornerRadius?:
24
- | NumberOrCallback
25
- | {
26
- top?: NumberOrCallback;
27
- topLeft?: NumberOrCallback;
28
- topRight?: NumberOrCallback;
29
- bottom?: NumberOrCallback;
30
- bottomLeft?: NumberOrCallback;
31
- bottomRight?: NumberOrCallback;
32
- };
33
- events?: EventPropTypeInterface<
34
- VictoryBarTTargetType,
35
- number | string | number[] | string[]
36
- >[];
37
- eventKey?: StringOrNumberOrCallback;
38
- horizontal?: boolean;
39
- style?: VictoryStyleInterface;
40
- }
41
-
42
- /**
43
- * Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
44
- * Check out VictoryChart for complete bar charts and more.
45
- */
46
- export class VictoryBar extends React.Component<VictoryBarProps, any> {}
47
-
48
- export interface BarProps extends VictoryCommonPrimitiveProps {
49
- alignment?: VictoryBarAlignmentType;
50
- barOffset?: number[];
51
- barRatio?: number;
52
- barWidth?: NumberOrCallback;
53
- cornerRadius?:
54
- | NumberOrCallback
55
- | {
56
- top?: NumberOrCallback;
57
- topLeft?: NumberOrCallback;
58
- topRight?: NumberOrCallback;
59
- bottom?: NumberOrCallback;
60
- bottomLeft?: NumberOrCallback;
61
- bottomRight?: NumberOrCallback;
62
- };
63
- datum?: any;
64
- getPath?: Function;
65
- horizontal?: boolean;
66
- pathComponent?: React.ReactElement;
67
- width?: number;
68
- x?: number;
69
- y?: number;
70
- y0?: number;
71
- }
72
-
73
- export class Bar extends React.Component<BarProps, any> {}
1
+ export * from "./victory-bar";
2
+ export * from "./bar";
3
+ export { getBarPosition } from "./helper-methods";
4
+ export { getVerticalBarPath, getHorizontalBarPath, getVerticalPolarBarPath, getCustomBarPath, getPolarBarPath, getBarPath, } from "./path-helper-methods";
5
+ export { getBarWidth, getStyle, getCornerRadius } from "./bar-helper-methods";
6
+ //# sourceMappingURL=index.d.ts.map
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { default as VictoryBar } from "./victory-bar";
2
- export { default as Bar } from "./bar";
1
+ export * from "./victory-bar";
2
+ export * from "./bar";
3
3
  export { getBarPosition } from "./helper-methods";
4
4
  export { getVerticalBarPath, getHorizontalBarPath, getVerticalPolarBarPath, getCustomBarPath, getPolarBarPath, getBarPath } from "./path-helper-methods";
5
5
  export { getBarWidth, getStyle, getCornerRadius } from "./bar-helper-methods";
@@ -0,0 +1,7 @@
1
+ export declare const getCustomBarPath: (props: any, width: any) => any;
2
+ export declare const getVerticalBarPath: (props: any, width: any, cornerRadius: any) => string;
3
+ export declare const getHorizontalBarPath: (props: any, width: any, cornerRadius: any) => string;
4
+ export declare const getVerticalPolarBarPath: (props: any, cornerRadius: any) => string;
5
+ export declare const getBarPath: (props: any, width: any, cornerRadius: any) => any;
6
+ export declare const getPolarBarPath: (props: any, cornerRadius: any) => string;
7
+ //# sourceMappingURL=path-helper-methods.d.ts.map
@@ -350,11 +350,11 @@ export var getVerticalPolarBarPath = function (props, cornerRadius) {
350
350
 
351
351
  var getPathData = function (edge) {
352
352
  var rightPath = getPath("".concat(edge, "Right"));
353
- var rightMoves = rightPath.match(/[A-Z]/g);
353
+ var rightMoves = rightPath.match(/[A-Z]/g) || [];
354
354
  var rightCoords = rightPath.split(/[A-Z]/).slice(1);
355
355
  var rightMiddle = rightMoves.indexOf("L");
356
356
  var leftPath = getPath("".concat(edge, "Left"));
357
- var leftMoves = leftPath.match(/[A-Z]/g);
357
+ var leftMoves = leftPath.match(/[A-Z]/g) || [];
358
358
  var leftCoords = leftPath.split(/[A-Z]/).slice(1);
359
359
  var leftMiddle = leftMoves.indexOf("L");
360
360
  return {
@@ -0,0 +1,129 @@
1
+ import React from "react";
2
+ import { Data, Domain, EventPropTypeInterface, NumberOrCallback, StringOrNumberOrCallback, VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps, VictoryStyleInterface, EventsMixinClass } from "victory-core";
3
+ export declare type VictoryBarCornerRadiusKey = "top" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
4
+ export declare type VictoryBarCornerRadiusObject = Partial<Record<VictoryBarCornerRadiusKey, NumberOrCallback>>;
5
+ export declare type VictoryBarTTargetType = "data" | "labels" | "parent";
6
+ export declare type VictoryBarAlignmentType = "start" | "middle" | "end";
7
+ export interface VictoryBarProps extends VictoryCommonProps, VictoryDatableProps, VictoryMultiLabelableProps {
8
+ alignment?: VictoryBarAlignmentType;
9
+ barRatio?: number;
10
+ barWidth?: NumberOrCallback;
11
+ cornerRadius?: NumberOrCallback | VictoryBarCornerRadiusObject;
12
+ events?: EventPropTypeInterface<VictoryBarTTargetType, number | string | number[] | string[]>[];
13
+ eventKey?: StringOrNumberOrCallback;
14
+ horizontal?: boolean;
15
+ style?: VictoryStyleInterface;
16
+ }
17
+ interface VictoryBarBase extends EventsMixinClass<VictoryBarProps> {
18
+ }
19
+ /**
20
+ * Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
21
+ * Check out VictoryChart for complete bar charts and more.
22
+ */
23
+ declare class VictoryBarBase extends React.Component<VictoryBarProps> {
24
+ static animationWhitelist: (keyof VictoryBarProps)[];
25
+ static displayName: string;
26
+ static role: string;
27
+ static defaultTransitions: {
28
+ onLoad: {
29
+ duration: number;
30
+ before: () => {
31
+ _y: number;
32
+ _y1: number;
33
+ _y0: number;
34
+ };
35
+ after: (datum: any) => {
36
+ _y: any;
37
+ _y1: any;
38
+ _y0: any;
39
+ };
40
+ };
41
+ onExit: {
42
+ duration: number;
43
+ before: () => {
44
+ _y: number;
45
+ yOffset: number;
46
+ };
47
+ };
48
+ onEnter: {
49
+ duration: number;
50
+ before: () => {
51
+ _y: number;
52
+ _y1: number;
53
+ _y0: number;
54
+ };
55
+ after: (datum: any) => {
56
+ _y: any;
57
+ _y1: any;
58
+ _y0: any;
59
+ };
60
+ };
61
+ };
62
+ static defaultProps: VictoryBarProps;
63
+ static getDomain: typeof Domain.getDomainWithZero;
64
+ static getData: typeof Data.getData;
65
+ static getBaseProps: (props: VictoryBarProps) => any;
66
+ static expectedComponents: (keyof VictoryBarProps)[];
67
+ shouldAnimate(): boolean;
68
+ render(): React.ReactElement;
69
+ }
70
+ export declare const VictoryBar: {
71
+ new (props: import("victory-core").EventMixinCommonProps): {
72
+ state: {};
73
+ getEventState: (eventKey: string | number, namespace: string, childType?: string | undefined) => any;
74
+ getScopedEvents: (events: any, namespace: any, childType: any, baseProps: any) => {};
75
+ getEvents: (p: any, target: any, eventKey: any) => any;
76
+ externalMutations: {} | undefined;
77
+ calculatedState: {};
78
+ globalEvents: {};
79
+ prevGlobalEventKeys: string[];
80
+ boundGlobalEvents: {};
81
+ shouldComponentUpdate(nextProps: import("victory-core").EventMixinCommonProps): boolean;
82
+ componentDidMount(): void;
83
+ componentDidUpdate(prevProps: any): void;
84
+ componentWillUnmount(): void;
85
+ addGlobalListener(key: any): void;
86
+ removeGlobalListener(key: any): void;
87
+ getStateChanges(props: any): {};
88
+ applyExternalMutations(props: any, externalMutations: any): void;
89
+ getCalculatedValues(props: any): import("victory-core").EventMixinCalculatedValues;
90
+ getExternalMutations(props: import("victory-core").EventMixinCommonProps): {} | undefined;
91
+ cacheValues(obj: any): void;
92
+ getBaseProps(props: any, getSharedEventState: any): Record<string, object>;
93
+ getAllEvents(props: any): any;
94
+ getComponentProps(component: React.ReactNode, type: string, index: string | number): any;
95
+ renderContainer(component: any, children: any): React.DetailedReactHTMLElement<any, HTMLElement>;
96
+ animateComponent(props: import("victory-core").EventMixinCommonProps, defaultAnimationWhitelist: string[]): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
97
+ renderContinuousData(props: import("victory-core").EventMixinCommonProps): React.DetailedReactHTMLElement<any, HTMLElement>;
98
+ renderData(props: any, shouldRenderDatum?: ((datum: any) => boolean) | undefined): React.DetailedReactHTMLElement<any, HTMLElement>;
99
+ context: unknown;
100
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<import("victory-core").EventMixinCommonProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
101
+ forceUpdate(callback?: (() => void) | undefined): void;
102
+ render(): React.ReactNode;
103
+ readonly props: Readonly<import("victory-core").EventMixinCommonProps>;
104
+ refs: {
105
+ [key: string]: React.ReactInstance;
106
+ };
107
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
108
+ getSnapshotBeforeUpdate?(prevProps: Readonly<import("victory-core").EventMixinCommonProps>, prevState: Readonly<{}>): any;
109
+ componentWillMount?(): void;
110
+ UNSAFE_componentWillMount?(): void;
111
+ componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
112
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextContext: any): void;
113
+ componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
114
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<import("victory-core").EventMixinCommonProps>, nextState: Readonly<{}>, nextContext: any): void;
115
+ componentEvents: import("victory-core/lib/victory-util/events").ComponentEvent[];
116
+ getSharedEventState: (key: string, value: string) => unknown;
117
+ baseProps: Record<string, object>;
118
+ dataKeys: string[];
119
+ hasEvents: unknown;
120
+ events: unknown;
121
+ };
122
+ getBaseProps?(props: import("victory-core").EventMixinCommonProps): Record<string, object>;
123
+ role?: string | undefined;
124
+ expectedComponents?: string[] | undefined;
125
+ getChildren?: ((props: import("victory-core").EventMixinCommonProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: import("victory-core").EventMixinCommonProps | undefined) => void) | undefined;
126
+ animationWhitelist?: string[] | undefined;
127
+ } & typeof VictoryBarBase;
128
+ export {};
129
+ //# sourceMappingURL=victory-bar.d.ts.map
package/es/victory-bar.js CHANGED
@@ -1,9 +1,3 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- 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; }
6
-
7
1
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
2
 
9
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -24,11 +18,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
24
18
 
25
19
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
20
 
27
- import PropTypes from "prop-types";
28
21
  import React from "react";
29
22
  import { getBaseProps } from "./helper-methods";
30
- import Bar from "./bar";
31
- import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme, CommonProps, addEvents, Data, Domain, UserProps } from "victory-core";
23
+ import { Bar } from "./bar";
24
+ import { Helpers, VictoryLabel, VictoryContainer, VictoryTheme, addEvents, Data, Domain, UserProps } from "victory-core";
32
25
  var fallbackProps = {
33
26
  width: 450,
34
27
  height: 300,
@@ -46,20 +39,24 @@ var defaultData = [{
46
39
  }, {
47
40
  x: 4,
48
41
  y: 4
49
- }];
42
+ }]; // eslint-disable-next-line @typescript-eslint/no-empty-interface
50
43
 
51
- var VictoryBar = /*#__PURE__*/function (_React$Component) {
52
- _inherits(VictoryBar, _React$Component);
44
+ /**
45
+ * Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
46
+ * Check out VictoryChart for complete bar charts and more.
47
+ */
48
+ var VictoryBarBase = /*#__PURE__*/function (_React$Component) {
49
+ _inherits(VictoryBarBase, _React$Component);
53
50
 
54
- var _super = _createSuper(VictoryBar);
51
+ var _super = _createSuper(VictoryBarBase);
55
52
 
56
- function VictoryBar() {
57
- _classCallCheck(this, VictoryBar);
53
+ function VictoryBarBase() {
54
+ _classCallCheck(this, VictoryBarBase);
58
55
 
59
56
  return _super.apply(this, arguments);
60
57
  }
61
58
 
62
- _createClass(VictoryBar, [{
59
+ _createClass(VictoryBarBase, [{
63
60
  key: "shouldAnimate",
64
61
  value: // Overridden in native versions
65
62
  function shouldAnimate() {
@@ -82,13 +79,13 @@ var VictoryBar = /*#__PURE__*/function (_React$Component) {
82
79
  }
83
80
  }]);
84
81
 
85
- return VictoryBar;
82
+ return VictoryBarBase;
86
83
  }(React.Component);
87
84
 
88
- VictoryBar.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
89
- VictoryBar.displayName = "VictoryBar";
90
- VictoryBar.role = "bar";
91
- VictoryBar.defaultTransitions = {
85
+ VictoryBarBase.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
86
+ VictoryBarBase.displayName = "VictoryBar";
87
+ VictoryBarBase.role = "bar";
88
+ VictoryBarBase.defaultTransitions = {
92
89
  onLoad: {
93
90
  duration: 2000,
94
91
  before: function () {
@@ -133,22 +130,7 @@ VictoryBar.defaultTransitions = {
133
130
  }
134
131
  }
135
132
  };
136
- VictoryBar.propTypes = _objectSpread(_objectSpread(_objectSpread({}, CommonProps.baseProps), CommonProps.dataProps), {}, {
137
- alignment: PropTypes.oneOf(["start", "middle", "end"]),
138
- barRatio: PropTypes.number,
139
- barWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
140
- cornerRadius: PropTypes.oneOfType([PropTypes.number, PropTypes.func, PropTypes.shape({
141
- top: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
142
- topLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
143
- topRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
144
- bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
145
- bottomLeft: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
146
- bottomRight: PropTypes.oneOfType([PropTypes.number, PropTypes.func])
147
- })]),
148
- getPath: PropTypes.func,
149
- horizontal: PropTypes.bool
150
- });
151
- VictoryBar.defaultProps = {
133
+ VictoryBarBase.defaultProps = {
152
134
  containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
153
135
  data: defaultData,
154
136
  dataComponent: /*#__PURE__*/React.createElement(Bar, null),
@@ -161,12 +143,12 @@ VictoryBar.defaultProps = {
161
143
  standalone: true,
162
144
  theme: VictoryTheme.grayscale
163
145
  };
164
- VictoryBar.getDomain = Domain.getDomainWithZero;
165
- VictoryBar.getData = Data.getData;
146
+ VictoryBarBase.getDomain = Domain.getDomainWithZero;
147
+ VictoryBarBase.getData = Data.getData;
166
148
 
167
- VictoryBar.getBaseProps = function (props) {
149
+ VictoryBarBase.getBaseProps = function (props) {
168
150
  return getBaseProps(props, fallbackProps);
169
151
  };
170
152
 
171
- VictoryBar.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
172
- export default addEvents(VictoryBar);
153
+ VictoryBarBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
154
+ export var VictoryBar = addEvents(VictoryBarBase);
@@ -0,0 +1,7 @@
1
+ import { VictoryStyleObject } from "victory-core";
2
+ import { BarProps } from "./bar";
3
+ import { VictoryBarCornerRadiusKey } from "./victory-bar";
4
+ export declare const getBarWidth: (barWidth: BarProps["barWidth"], props: BarProps) => any;
5
+ export declare const getCornerRadius: (cornerRadius: BarProps["cornerRadius"], props: BarProps) => Partial<Record<VictoryBarCornerRadiusKey, import("victory-core").NumberOrCallback>>;
6
+ export declare const getStyle: (style: VictoryStyleObject | undefined, props: BarProps) => any;
7
+ //# sourceMappingURL=bar-helper-methods.d.ts.map