victory-chart 36.9.2-next.3 → 37.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,41 @@
1
- import React from "react";
2
- export declare function getBackgroundWithProps(props: any, calculatedProps: any): React.DetailedReactHTMLElement<any, HTMLElement>;
3
- export declare function getCalculatedProps(initialProps: any, childComponents: any): {
4
- categories: {
5
- x: any;
6
- y: any;
7
- };
8
- domain: {
9
- x: any;
10
- y: any;
11
- };
12
- range: {
13
- x: any;
14
- y: any;
15
- };
16
- horizontal: any;
17
- scale: {
18
- x: import("victory-core").D3Scale<any>;
19
- y: import("victory-core").D3Scale<any>;
20
- };
21
- stringMap: {
22
- x: any;
23
- y: any;
24
- };
25
- style: {
26
- parent: any;
27
- };
28
- origin: {
29
- x: number | Date;
30
- y: number | Date;
31
- };
32
- padding: {
33
- top: any;
34
- bottom: any;
35
- left: any;
36
- right: any;
37
- };
38
- };
39
- export declare function getChildren(props: any, childComponents: any, calculatedProps: any): any;
40
- export declare const getChildComponents: (props: any, defaultAxes?: any) => (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | React.ReactPortal)[];
1
+ import React from "react";
2
+ export declare function getBackgroundWithProps(props: any, calculatedProps: any): React.DetailedReactHTMLElement<any, HTMLElement>;
3
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
4
+ categories: {
5
+ x: any;
6
+ y: any;
7
+ };
8
+ domain: {
9
+ x: any;
10
+ y: any;
11
+ };
12
+ range: {
13
+ x: any;
14
+ y: any;
15
+ };
16
+ horizontal: any;
17
+ scale: {
18
+ x: import("victory-core").D3Scale<any>;
19
+ y: import("victory-core").D3Scale<any>;
20
+ };
21
+ stringMap: {
22
+ x: any;
23
+ y: any;
24
+ };
25
+ style: {
26
+ parent: any;
27
+ };
28
+ origin: {
29
+ x: number | Date;
30
+ y: number | Date;
31
+ };
32
+ padding: {
33
+ top: any;
34
+ bottom: any;
35
+ left: any;
36
+ right: any;
37
+ };
38
+ };
39
+ export declare function getChildren(props: any, childComponents: any, calculatedProps: any): any;
40
+ export declare const getChildComponents: (props: any, defaultAxes?: any) => (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | React.ReactPortal)[];
41
41
  //# sourceMappingURL=helper-methods.d.ts.map
@@ -7,87 +7,81 @@ exports.getBackgroundWithProps = getBackgroundWithProps;
7
7
  exports.getCalculatedProps = getCalculatedProps;
8
8
  exports.getChildComponents = void 0;
9
9
  exports.getChildren = getChildren;
10
-
11
10
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
12
-
13
11
  var _react = _interopRequireDefault(require("react"));
14
-
15
12
  var _victoryCore = require("victory-core");
16
-
17
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
14
  /* eslint-disable no-use-before-define */
20
- var fallbackProps = {
15
+
16
+ const fallbackProps = {
21
17
  width: 450,
22
18
  height: 300,
23
19
  padding: 50
24
20
  };
25
-
26
21
  function getAxisProps(child, props, calculatedProps) {
27
- var domain = calculatedProps.domain,
28
- scale = calculatedProps.scale,
29
- stringMap = calculatedProps.stringMap,
30
- categories = calculatedProps.categories,
31
- horizontal = calculatedProps.horizontal;
22
+ const {
23
+ domain,
24
+ scale,
25
+ stringMap,
26
+ categories,
27
+ horizontal
28
+ } = calculatedProps;
32
29
  return {
33
- stringMap: stringMap,
34
- horizontal: horizontal,
35
- categories: categories,
30
+ stringMap,
31
+ horizontal,
32
+ categories,
36
33
  startAngle: props.startAngle,
37
34
  endAngle: props.endAngle,
38
35
  innerRadius: props.innerRadius,
39
- domain: domain,
40
- scale: scale
36
+ domain,
37
+ scale
41
38
  };
42
39
  }
43
-
44
40
  function getBackgroundWithProps(props, calculatedProps) {
45
- var backgroundElement = props.backgroundComponent;
46
- var height = props.polar ? calculatedProps.range.y[1] : calculatedProps.range.y[0] - calculatedProps.range.y[1];
47
- var width = calculatedProps.range.x[1] - calculatedProps.range.x[0];
48
- var xScale = props.horizontal ? calculatedProps.scale.y.range()[0] : calculatedProps.scale.x.range()[0];
49
- var yScale = props.horizontal ? calculatedProps.scale.x.range()[1] : calculatedProps.scale.y.range()[1];
50
- var xCoordinate = props.polar ? calculatedProps.origin.x : xScale;
51
- var yCoordinate = props.polar ? calculatedProps.origin.y : yScale;
52
- var parentName = props.name || "chart";
53
- var backgroundProps = {
54
- height: height,
41
+ const backgroundElement = props.backgroundComponent;
42
+ const height = props.polar ? calculatedProps.range.y[1] : calculatedProps.range.y[0] - calculatedProps.range.y[1];
43
+ const width = calculatedProps.range.x[1] - calculatedProps.range.x[0];
44
+ const xScale = props.horizontal ? calculatedProps.scale.y.range()[0] : calculatedProps.scale.x.range()[0];
45
+ const yScale = props.horizontal ? calculatedProps.scale.x.range()[1] : calculatedProps.scale.y.range()[1];
46
+ const xCoordinate = props.polar ? calculatedProps.origin.x : xScale;
47
+ const yCoordinate = props.polar ? calculatedProps.origin.y : yScale;
48
+ const parentName = props.name || "chart";
49
+ const backgroundProps = {
50
+ height,
55
51
  polar: props.polar,
56
52
  scale: calculatedProps.scale,
57
53
  style: props.style.background,
58
54
  x: xCoordinate,
59
55
  y: yCoordinate,
60
- key: "".concat(parentName, "-background"),
61
- width: width
56
+ key: `${parentName}-background`,
57
+ width
62
58
  };
63
59
  return /*#__PURE__*/_react.default.cloneElement(backgroundElement, (0, _defaults2.default)({}, backgroundElement.props, backgroundProps));
64
60
  }
65
-
66
61
  function getChildProps(child, props, calculatedProps) {
67
- var axisChild = _victoryCore.Axis.findAxisComponents([child]);
68
-
62
+ const axisChild = _victoryCore.Axis.findAxisComponents([child]);
69
63
  if (axisChild.length > 0) {
70
64
  return getAxisProps(axisChild[0], props, calculatedProps);
71
65
  }
72
-
73
- var categories = calculatedProps.categories,
74
- domain = calculatedProps.domain,
75
- range = calculatedProps.range,
76
- scale = calculatedProps.scale,
77
- stringMap = calculatedProps.stringMap,
78
- horizontal = calculatedProps.horizontal;
66
+ const {
67
+ categories,
68
+ domain,
69
+ range,
70
+ scale,
71
+ stringMap,
72
+ horizontal
73
+ } = calculatedProps;
79
74
  return {
80
- categories: categories,
81
- domain: domain,
82
- range: range,
83
- scale: scale,
84
- stringMap: stringMap,
85
- horizontal: horizontal
75
+ categories,
76
+ domain,
77
+ range,
78
+ scale,
79
+ stringMap,
80
+ horizontal
86
81
  };
87
82
  }
88
-
89
83
  function getStyles(props) {
90
- var styleProps = props.style && props.style.parent;
84
+ const styleProps = props.style && props.style.parent;
91
85
  return {
92
86
  parent: (0, _defaults2.default)({}, styleProps, {
93
87
  height: "100%",
@@ -96,135 +90,122 @@ function getStyles(props) {
96
90
  })
97
91
  };
98
92
  }
99
-
100
93
  function getCalculatedProps(initialProps, childComponents) {
101
- var style = getStyles(initialProps);
102
-
103
- var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "chart");
104
-
105
- var horizontal = props.horizontal,
106
- polar = props.polar;
107
-
108
- var allStrings = _victoryCore.Wrapper.getStringsFromChildren(props, childComponents);
109
-
110
- var categories = _victoryCore.Wrapper.getCategories(props, childComponents, allStrings);
111
-
112
- var stringMap = createStringMap(props, childComponents, allStrings);
113
- var domain = {
94
+ const style = getStyles(initialProps);
95
+ const props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "chart");
96
+ const {
97
+ horizontal,
98
+ polar
99
+ } = props;
100
+ const allStrings = _victoryCore.Wrapper.getStringsFromChildren(props, childComponents);
101
+ const categories = _victoryCore.Wrapper.getCategories(props, childComponents, allStrings);
102
+ const stringMap = createStringMap(props, childComponents, allStrings);
103
+ const domain = {
114
104
  x: getDomain(Object.assign({}, props, {
115
- categories: categories
105
+ categories
116
106
  }), "x", childComponents),
117
107
  y: getDomain(Object.assign({}, props, {
118
- categories: categories
108
+ categories
119
109
  }), "y", childComponents)
120
110
  };
121
- var range = {
111
+ const range = {
122
112
  x: _victoryCore.Helpers.getRange(props, "x"),
123
113
  y: _victoryCore.Helpers.getRange(props, "y")
124
114
  };
125
- var baseScale = {
115
+ const baseScale = {
126
116
  x: _victoryCore.Scale.getScaleFromProps(props, "x") || _victoryCore.Wrapper.getScale(props, "x"),
127
117
  y: _victoryCore.Scale.getScaleFromProps(props, "y") || _victoryCore.Wrapper.getScale(props, "y")
128
118
  };
129
- var scale = {
119
+ const scale = {
130
120
  x: baseScale.x.domain(domain.x).range(horizontal ? range.y : range.x),
131
121
  y: baseScale.y.domain(domain.y).range(horizontal ? range.x : range.y)
132
122
  };
133
- var origin = polar ? _victoryCore.Helpers.getPolarOrigin(props) : _victoryCore.Axis.getOrigin(domain);
134
-
135
- var padding = _victoryCore.Helpers.getPadding(props);
136
-
123
+ const origin = polar ? _victoryCore.Helpers.getPolarOrigin(props) : _victoryCore.Axis.getOrigin(domain);
124
+ const padding = _victoryCore.Helpers.getPadding(props);
137
125
  return {
138
- categories: categories,
139
- domain: domain,
140
- range: range,
141
- horizontal: horizontal,
142
- scale: scale,
143
- stringMap: stringMap,
144
- style: style,
145
- origin: origin,
146
- padding: padding
126
+ categories,
127
+ domain,
128
+ range,
129
+ horizontal,
130
+ scale,
131
+ stringMap,
132
+ style,
133
+ origin,
134
+ padding
147
135
  };
148
136
  }
149
-
150
137
  function getChildren(props, childComponents, calculatedProps) {
151
- var children = childComponents || getChildComponents(props);
152
- var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
153
- var baseStyle = newCalculatedProps.style.parent;
154
- var height = props.height,
155
- polar = props.polar,
156
- theme = props.theme,
157
- width = props.width;
158
- var origin = newCalculatedProps.origin,
159
- horizontal = newCalculatedProps.horizontal;
160
- var parentName = props.name || "chart";
161
- return children.filter(_react.default.isValidElement).map(function (child, index) {
162
- var role = child.type && child.type.role;
163
- var style = Array.isArray(child.props.style) ? child.props.style : (0, _defaults2.default)({}, child.props.style, {
138
+ const children = childComponents || getChildComponents(props);
139
+ const newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
140
+ const baseStyle = newCalculatedProps.style.parent;
141
+ const {
142
+ height,
143
+ polar,
144
+ theme,
145
+ width
146
+ } = props;
147
+ const {
148
+ origin,
149
+ horizontal
150
+ } = newCalculatedProps;
151
+ const parentName = props.name || "chart";
152
+ return children.filter(_react.default.isValidElement).map((child, index) => {
153
+ const role = child.type && child.type.role;
154
+ const style = Array.isArray(child.props.style) ? child.props.style : (0, _defaults2.default)({}, child.props.style, {
164
155
  parent: baseStyle
165
156
  });
166
- var childProps = getChildProps(child, props, newCalculatedProps);
167
- var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
168
- var newProps = (0, _defaults2.default)({
169
- horizontal: horizontal,
170
- height: height,
171
- polar: polar,
172
- theme: theme,
173
- width: width,
174
- style: style,
175
- name: name,
157
+ const childProps = getChildProps(child, props, newCalculatedProps);
158
+ const name = child.props.name || `${parentName}-${role}-${index}`;
159
+ const newProps = (0, _defaults2.default)({
160
+ horizontal,
161
+ height,
162
+ polar,
163
+ theme,
164
+ width,
165
+ style,
166
+ name,
176
167
  origin: polar ? origin : undefined,
177
168
  padding: newCalculatedProps.padding,
178
- key: "".concat(name, "-key-").concat(index),
169
+ key: `${name}-key-${index}`,
179
170
  standalone: false
180
171
  }, childProps);
181
172
  return /*#__PURE__*/_react.default.cloneElement(child, newProps);
182
173
  });
183
174
  }
184
-
185
- var getChildComponents = function (props, defaultAxes) {
186
- var childComponents = _react.default.Children.toArray(props.children);
187
-
175
+ const getChildComponents = (props, defaultAxes) => {
176
+ let childComponents = _react.default.Children.toArray(props.children);
188
177
  if (childComponents.length === 0) {
189
178
  childComponents.push(defaultAxes.independent, defaultAxes.dependent);
190
179
  } else {
191
- var axisComponents = {
180
+ const axisComponents = {
192
181
  dependent: _victoryCore.Axis.getAxisComponentsWithParent(childComponents, "dependent"),
193
182
  independent: _victoryCore.Axis.getAxisComponentsWithParent(childComponents, "independent")
194
183
  };
195
-
196
184
  if (axisComponents.dependent.length === 0 && axisComponents.independent.length === 0) {
197
185
  childComponents = props.prependDefaultAxes ? [defaultAxes.independent, defaultAxes.dependent].concat(childComponents) : childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
198
186
  }
199
187
  }
200
-
201
188
  return childComponents;
202
189
  };
203
-
204
190
  exports.getChildComponents = getChildComponents;
205
-
206
- var getDomain = function (props, axis, childComponents) {
207
- var children = childComponents || _react.default.Children.toArray(props.children);
208
-
209
- var domain = _victoryCore.Wrapper.getDomain(props, axis, children);
210
-
211
- var axisComponent = _victoryCore.Axis.getAxisComponent(children, axis);
212
-
213
- var invertDomain = axisComponent && axisComponent.props && axisComponent.props.invertAxis;
191
+ const getDomain = (props, axis, childComponents) => {
192
+ const children = childComponents || _react.default.Children.toArray(props.children);
193
+ const domain = _victoryCore.Wrapper.getDomain(props, axis, children);
194
+ const axisComponent = _victoryCore.Axis.getAxisComponent(children, axis);
195
+ const invertDomain = axisComponent && axisComponent.props && axisComponent.props.invertAxis;
214
196
  return invertDomain ? domain.concat().reverse() : domain;
215
197
  };
216
-
217
- var createStringMap = function (props, childComponents, allStrings) {
218
- var x = !allStrings.x || allStrings.x.length === 0 ? null : allStrings.x.reduce(function (memo, string, index) {
198
+ const createStringMap = (props, childComponents, allStrings) => {
199
+ const x = !allStrings.x || allStrings.x.length === 0 ? null : allStrings.x.reduce((memo, string, index) => {
219
200
  memo[string] = index + 1;
220
201
  return memo;
221
202
  }, {});
222
- var y = !allStrings.y || allStrings.y.length === 0 ? null : allStrings.y.reduce(function (memo, string, index) {
203
+ const y = !allStrings.y || allStrings.y.length === 0 ? null : allStrings.y.reduce((memo, string, index) => {
223
204
  memo[string] = index + 1;
224
205
  return memo;
225
206
  }, {});
226
207
  return {
227
- x: x,
228
- y: y
208
+ x,
209
+ y
229
210
  };
230
211
  };
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./victory-chart";
1
+ export * from "./victory-chart";
2
2
  //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _victoryChart = require("./victory-chart");
8
-
9
7
  Object.keys(_victoryChart).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _victoryChart[key]) return;
@@ -1,27 +1,27 @@
1
- import React from "react";
2
- import { CategoryPropType, DomainPropType, EventPropTypeInterface, StringOrNumberOrCallback, VictoryCommonProps, VictoryStyleInterface, VictoryStyleObject } from "victory-core";
3
- export declare const VictoryChart: React.NamedExoticComponent<VictoryChartProps>;
4
- export declare type AxesType = {
5
- dependent?: React.ReactElement | null;
6
- independent?: React.ReactElement | null;
7
- };
8
- export interface VictoryChartProps extends VictoryCommonProps {
9
- backgroundComponent?: React.ReactElement;
10
- categories?: CategoryPropType;
11
- children?: React.ReactNode | React.ReactNode[];
12
- desc?: string;
13
- defaultAxes?: AxesType;
14
- defaultPolarAxes?: AxesType;
15
- domain?: DomainPropType;
16
- endAngle?: number;
17
- eventKey?: StringOrNumberOrCallback;
18
- events?: EventPropTypeInterface<string, string[] | number[] | string | number>[];
19
- innerRadius?: number;
20
- prependDefaultAxes?: boolean;
21
- startAngle?: number;
22
- style?: Pick<VictoryStyleInterface, "parent"> & {
23
- background?: VictoryStyleObject;
24
- };
25
- title?: string;
26
- }
1
+ import React from "react";
2
+ import { CategoryPropType, DomainPropType, EventPropTypeInterface, StringOrNumberOrCallback, VictoryCommonProps, VictoryStyleInterface, VictoryStyleObject } from "victory-core";
3
+ export declare const VictoryChart: React.NamedExoticComponent<VictoryChartProps>;
4
+ export declare type AxesType = {
5
+ dependent?: React.ReactElement | null;
6
+ independent?: React.ReactElement | null;
7
+ };
8
+ export interface VictoryChartProps extends VictoryCommonProps {
9
+ backgroundComponent?: React.ReactElement;
10
+ categories?: CategoryPropType;
11
+ children?: React.ReactNode | React.ReactNode[];
12
+ desc?: string;
13
+ defaultAxes?: AxesType;
14
+ defaultPolarAxes?: AxesType;
15
+ domain?: DomainPropType;
16
+ endAngle?: number;
17
+ eventKey?: StringOrNumberOrCallback;
18
+ events?: EventPropTypeInterface<string, string[] | number[] | string | number>[];
19
+ innerRadius?: number;
20
+ prependDefaultAxes?: boolean;
21
+ startAngle?: number;
22
+ style?: Pick<VictoryStyleInterface, "parent"> & {
23
+ background?: VictoryStyleObject;
24
+ };
25
+ title?: string;
26
+ }
27
27
  //# sourceMappingURL=victory-chart.d.ts.map