victory-bar 36.9.2 → 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,84 +1,75 @@
1
1
  import _isPlainObject from "lodash/isPlainObject";
2
2
  import { Helpers } from "victory-core";
3
- var DEFAULT_BAR_WIDTH = 8;
4
- export var getBarWidth = function (barWidth, props) {
5
- var scale = props.scale,
6
- data = props.data,
7
- style = props.style;
8
-
3
+ const DEFAULT_BAR_WIDTH = 8;
4
+ export const getBarWidth = (barWidth, props) => {
5
+ const {
6
+ scale,
7
+ data,
8
+ style
9
+ } = props;
9
10
  if (barWidth) {
10
11
  return Helpers.evaluateProp(barWidth, props);
11
12
  } else if (style.width) {
12
13
  return style.width;
13
14
  }
14
-
15
- var range = scale.x.range();
16
- var extent = Math.abs(range[1] - range[0]);
17
- var bars = data.length + 2;
18
- var barRatio = props.barRatio || 0.5;
19
- var defaultWidth = barRatio * (data.length < 2 ? DEFAULT_BAR_WIDTH : extent / bars);
15
+ const range = scale.x.range();
16
+ const extent = Math.abs(range[1] - range[0]);
17
+ const bars = data.length + 2;
18
+ const barRatio = props.barRatio || 0.5;
19
+ const defaultWidth = barRatio * (data.length < 2 ? DEFAULT_BAR_WIDTH : extent / bars);
20
20
  return Math.max(1, defaultWidth);
21
21
  };
22
-
23
- var getCornerRadiusFromObject = function (cornerRadius, props) {
24
- var realCornerRadius = {
22
+ const getCornerRadiusFromObject = (cornerRadius, props) => {
23
+ const realCornerRadius = {
25
24
  topLeft: 0,
26
25
  topRight: 0,
27
26
  bottomLeft: 0,
28
27
  bottomRight: 0
29
28
  };
30
-
31
- var updateCornerRadius = function (corner, fallback) {
29
+ const updateCornerRadius = (corner, fallback) => {
32
30
  if (!Helpers.isNil(cornerRadius[corner])) {
33
31
  realCornerRadius[corner] = Helpers.evaluateProp(cornerRadius[corner], props);
34
32
  } else if (!Helpers.isNil(cornerRadius[fallback])) {
35
33
  realCornerRadius[corner] = Helpers.evaluateProp(cornerRadius[fallback], props);
36
34
  }
37
35
  };
38
-
39
36
  updateCornerRadius("topLeft", "top");
40
37
  updateCornerRadius("topRight", "top");
41
38
  updateCornerRadius("bottomLeft", "bottom");
42
39
  updateCornerRadius("bottomRight", "bottom");
43
40
  return realCornerRadius;
44
41
  };
45
-
46
42
  function isCornerRadiusObject(cornerRadius) {
47
43
  return _isPlainObject(cornerRadius);
48
44
  }
49
-
50
- export var getCornerRadius = function (cornerRadius, props) {
51
- var realCornerRadius = {
45
+ export const getCornerRadius = (cornerRadius, props) => {
46
+ const realCornerRadius = {
52
47
  topLeft: 0,
53
48
  topRight: 0,
54
49
  bottomLeft: 0,
55
50
  bottomRight: 0
56
51
  };
57
-
58
52
  if (!cornerRadius) {
59
53
  return realCornerRadius;
60
54
  }
61
-
62
55
  if (isCornerRadiusObject(cornerRadius)) {
63
56
  return getCornerRadiusFromObject(cornerRadius, props);
64
57
  }
65
-
66
58
  realCornerRadius.topLeft = Helpers.evaluateProp(cornerRadius, props);
67
59
  realCornerRadius.topRight = Helpers.evaluateProp(cornerRadius, props);
68
60
  return realCornerRadius;
69
61
  };
70
- export var getStyle = function () {
71
- var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
- var props = arguments.length > 1 ? arguments[1] : undefined;
73
-
62
+ export const getStyle = function (style, props) {
63
+ if (style === void 0) {
64
+ style = {};
65
+ }
74
66
  if (props.disableInlineStyles) {
75
67
  return {};
76
68
  }
77
-
78
- var stroke = style.fill || "black";
79
- var baseStyle = {
69
+ const stroke = style.fill || "black";
70
+ const baseStyle = {
80
71
  fill: "black",
81
- stroke: stroke
72
+ stroke
82
73
  };
83
74
  return Helpers.evaluateStyle(Object.assign(baseStyle, style), props);
84
75
  };
package/es/bar.js CHANGED
@@ -1,15 +1,8 @@
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
  import React, { forwardRef } from "react";
8
2
  import { Helpers, Path } from "victory-core";
9
3
  import { getStyle, getBarWidth, getCornerRadius } from "./bar-helper-methods";
10
4
  import { getPolarBarPath, getBarPath } from "./path-helper-methods";
11
-
12
- var evaluateProps = function (props) {
5
+ const evaluateProps = props => {
13
6
  /**
14
7
  * Potential evaluated props of following must be evaluated in this order:
15
8
  * 1) `style`
@@ -22,52 +15,56 @@ var evaluateProps = function (props) {
22
15
  * `id`
23
16
  * `tabIndex`
24
17
  */
25
- var style = getStyle(props.style, props);
26
- var barWidth = getBarWidth(props.barWidth, Object.assign({}, props, {
27
- style: style
18
+ const style = getStyle(props.style, props);
19
+ const barWidth = getBarWidth(props.barWidth, Object.assign({}, props, {
20
+ style
28
21
  }));
29
- var cornerRadius = getCornerRadius(props.cornerRadius, Object.assign({}, props, {
30
- style: style,
31
- barWidth: barWidth
22
+ const cornerRadius = getCornerRadius(props.cornerRadius, Object.assign({}, props, {
23
+ style,
24
+ barWidth
32
25
  }));
33
- var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
34
- var desc = Helpers.evaluateProp(props.desc, props);
35
- var id = Helpers.evaluateProp(props.id, props);
36
- var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
26
+ const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
27
+ const desc = Helpers.evaluateProp(props.desc, props);
28
+ const id = Helpers.evaluateProp(props.id, props);
29
+ const tabIndex = Helpers.evaluateProp(props.tabIndex, props);
37
30
  return Object.assign({}, props, {
38
- ariaLabel: ariaLabel,
39
- style: style,
40
- barWidth: barWidth,
41
- cornerRadius: cornerRadius,
42
- desc: desc,
43
- id: id,
44
- tabIndex: tabIndex
31
+ ariaLabel,
32
+ style,
33
+ barWidth,
34
+ cornerRadius,
35
+ desc,
36
+ id,
37
+ tabIndex
45
38
  });
46
39
  };
47
-
48
- var defaultProps = {
40
+ const defaultProps = {
49
41
  pathComponent: /*#__PURE__*/React.createElement(Path, null),
50
42
  role: "presentation",
51
43
  shapeRendering: "auto"
52
- }; // eslint-disable-next-line prefer-arrow-callback
53
-
54
- export var Bar = /*#__PURE__*/forwardRef(function Bar(initialProps, ref) {
55
- var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
56
- var polar = props.polar,
57
- origin = props.origin,
58
- style = props.style,
59
- barWidth = props.barWidth,
60
- cornerRadius = props.cornerRadius;
61
- var path = polar ? getPolarBarPath(props, cornerRadius) : getBarPath(props, barWidth, cornerRadius);
62
- var defaultTransform = polar && origin ? "translate(".concat(origin.x, ", ").concat(origin.y, ")") : undefined;
44
+ };
63
45
 
46
+ // eslint-disable-next-line prefer-arrow-callback
47
+ export const Bar = /*#__PURE__*/forwardRef(function Bar(initialProps, ref) {
48
+ const props = evaluateProps({
49
+ ...defaultProps,
50
+ ...initialProps
51
+ });
52
+ const {
53
+ polar,
54
+ origin,
55
+ style,
56
+ barWidth,
57
+ cornerRadius
58
+ } = props;
59
+ const path = polar ? getPolarBarPath(props, cornerRadius) : getBarPath(props, barWidth, cornerRadius);
60
+ const defaultTransform = polar && origin ? `translate(${origin.x}, ${origin.y})` : undefined;
64
61
  if (!props.pathComponent) {
65
62
  return null;
66
63
  }
67
-
68
- return /*#__PURE__*/React.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, {
64
+ return /*#__PURE__*/React.cloneElement(props.pathComponent, {
65
+ ...props.events,
69
66
  "aria-label": props.ariaLabel,
70
- style: style,
67
+ style,
71
68
  d: path,
72
69
  className: props.className,
73
70
  clipPath: props.clipPath,
@@ -77,6 +74,6 @@ export var Bar = /*#__PURE__*/forwardRef(function Bar(initialProps, ref) {
77
74
  shapeRendering: props.shapeRendering,
78
75
  transform: props.transform || defaultTransform,
79
76
  tabIndex: props.tabIndex,
80
- ref: ref
81
- }));
77
+ ref
78
+ });
82
79
  });
@@ -1,108 +1,101 @@
1
1
  /**
2
2
  * A point in the 2d plane
3
3
  */
4
- export var point = function (x, y) {
5
- return {
6
- x: x,
7
- y: y,
8
- distance: function (p1) {
9
- return Math.sqrt(Math.pow(this.x - p1.x, 2) + Math.pow(this.y - p1.y, 2));
10
- },
11
- // vector addition in 2d plane
12
- add: function (p1) {
13
- return point(this.x + p1.x, this.y + p1.y);
14
- },
15
- // vector subtraction in 2d
16
- // returns p0 - p1
17
- subtract: function (p1) {
18
- return point(this.x - p1.x, this.y - p1.y);
19
- },
20
- // multiply a 2d point by a scalar
21
- scalarMult: function (n) {
22
- return point(this.x * n, this.y * n);
23
- },
24
- scalarDivide: function (n) {
25
- if (n === 0) {
26
- throw new Error("Division by 0 error");
27
- }
28
-
29
- return point(this.x / n, this.y / n);
30
- },
31
- equals: function (p1) {
32
- return this.x === p1.x && this.y === p1.y;
4
+ export const point = (x, y) => ({
5
+ x,
6
+ y,
7
+ distance(p1) {
8
+ return Math.sqrt(Math.pow(this.x - p1.x, 2) + Math.pow(this.y - p1.y, 2));
9
+ },
10
+ // vector addition in 2d plane
11
+ add(p1) {
12
+ return point(this.x + p1.x, this.y + p1.y);
13
+ },
14
+ // vector subtraction in 2d
15
+ // returns p0 - p1
16
+ subtract(p1) {
17
+ return point(this.x - p1.x, this.y - p1.y);
18
+ },
19
+ // multiply a 2d point by a scalar
20
+ scalarMult(n) {
21
+ return point(this.x * n, this.y * n);
22
+ },
23
+ scalarDivide(n) {
24
+ if (n === 0) {
25
+ throw new Error("Division by 0 error");
33
26
  }
34
- };
35
- };
36
-
27
+ return point(this.x / n, this.y / n);
28
+ },
29
+ equals(p1) {
30
+ return this.x === p1.x && this.y === p1.y;
31
+ }
32
+ });
37
33
  /**
38
34
  * A circle in the 2d plane
39
35
  */
40
- export var circle = function (center, radius) {
41
- return {
42
- center: center,
43
- radius: radius,
44
- hasIntersection: function (circle1) {
45
- var P0 = this.center;
46
- var P1 = circle1.center;
47
- var r0 = this.radius;
48
- var r1 = circle1.radius;
49
- var d = P0.distance(P1);
50
-
51
- if (d > r0 + r1) {
52
- return false; // separate circles
53
- }
54
-
55
- if (d < Math.abs(r0 - r1)) {
56
- return false; // one circle contains another
57
- }
58
-
59
- return true;
60
- },
61
- equals: function (circle1) {
62
- var P0 = this.center;
63
- var P1 = circle1.center;
64
- var r0 = this.radius;
65
- var r1 = circle1.radius;
66
- return r0 === r1 && P0.equals(P1);
67
- },
68
- // Source: http://paulbourke.net/geometry/circlesphere/
69
- // "Intersection of two circles" by Paul Bourke
70
- // Left-most point is returned as 0th element of array
71
- // Right-most point is returned as 1st elemennt of array
72
- intersection: function (circle1) {
73
- // eslint-disable-line max-statements
74
- var P0 = this.center;
75
- var P1 = circle1.center;
76
- var r0 = this.radius;
77
- var r1 = circle1.radius;
78
- var d = P0.distance(P1);
79
-
80
- if (!this.hasIntersection(circle1) || this.equals(circle1)) {
81
- return [];
82
- }
83
-
84
- var a = (Math.pow(r0, 2) - Math.pow(r1, 2) + Math.pow(d, 2)) / (2 * d);
85
- var h = Math.sqrt(Math.pow(r0, 2) - Math.pow(a, 2));
86
- var P2 = P0.add(P1.subtract(P0).scalarMult(a).scalarDivide(d));
87
- var x0 = P0.x,
88
- y0 = P0.y;
89
- var x1 = P1.x,
90
- y1 = P1.y;
91
- var x2 = P2.x,
92
- y2 = P2.y;
93
- var P3s = [point(x2 - h * (y1 - y0) / d, y2 + h * (x1 - x0) / d), point(x2 + h * (y1 - y0) / d, y2 - h * (x1 - x0) / d)];
94
- P3s.sort(function (Point1, Point2) {
95
- return Point1.x - Point2.x;
96
- });
97
- return P3s;
98
- },
99
- solveX: function (y) {
100
- var sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(y - this.center.y, 2));
101
- return [this.center.x - sqrt, this.center.x + sqrt];
102
- },
103
- solveY: function (x) {
104
- var sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(x - this.center.x, 2));
105
- return [this.center.y - sqrt, this.center.y + sqrt];
36
+ export const circle = (center, radius) => ({
37
+ center,
38
+ radius,
39
+ hasIntersection(circle1) {
40
+ const P0 = this.center;
41
+ const P1 = circle1.center;
42
+ const r0 = this.radius;
43
+ const r1 = circle1.radius;
44
+ const d = P0.distance(P1);
45
+ if (d > r0 + r1) {
46
+ return false; // separate circles
106
47
  }
107
- };
108
- };
48
+ if (d < Math.abs(r0 - r1)) {
49
+ return false; // one circle contains another
50
+ }
51
+ return true;
52
+ },
53
+ equals(circle1) {
54
+ const P0 = this.center;
55
+ const P1 = circle1.center;
56
+ const r0 = this.radius;
57
+ const r1 = circle1.radius;
58
+ return r0 === r1 && P0.equals(P1);
59
+ },
60
+ // Source: http://paulbourke.net/geometry/circlesphere/
61
+ // "Intersection of two circles" by Paul Bourke
62
+ // Left-most point is returned as 0th element of array
63
+ // Right-most point is returned as 1st elemennt of array
64
+ intersection(circle1) {
65
+ // eslint-disable-line max-statements
66
+ const P0 = this.center;
67
+ const P1 = circle1.center;
68
+ const r0 = this.radius;
69
+ const r1 = circle1.radius;
70
+ const d = P0.distance(P1);
71
+ if (!this.hasIntersection(circle1) || this.equals(circle1)) {
72
+ return [];
73
+ }
74
+ const a = (Math.pow(r0, 2) - Math.pow(r1, 2) + Math.pow(d, 2)) / (2 * d);
75
+ const h = Math.sqrt(Math.pow(r0, 2) - Math.pow(a, 2));
76
+ const P2 = P0.add(P1.subtract(P0).scalarMult(a).scalarDivide(d));
77
+ const {
78
+ x: x0,
79
+ y: y0
80
+ } = P0;
81
+ const {
82
+ x: x1,
83
+ y: y1
84
+ } = P1;
85
+ const {
86
+ x: x2,
87
+ y: y2
88
+ } = P2;
89
+ const P3s = [point(x2 - h * (y1 - y0) / d, y2 + h * (x1 - x0) / d), point(x2 + h * (y1 - y0) / d, y2 - h * (x1 - x0) / d)];
90
+ P3s.sort((Point1, Point2) => Point1.x - Point2.x);
91
+ return P3s;
92
+ },
93
+ solveX(y) {
94
+ const sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(y - this.center.y, 2));
95
+ return [this.center.x - sqrt, this.center.x + sqrt];
96
+ },
97
+ solveY(x) {
98
+ const sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(x - this.center.x, 2));
99
+ return [this.center.y - sqrt, this.center.y + sqrt];
100
+ }
101
+ });
@@ -1,140 +1,134 @@
1
1
  import { Collection, Data, Domain, Helpers, LabelHelpers, Scale } from "victory-core";
2
- export var getBarPosition = function (props, datum) {
3
- var getDefaultMin = function (axis) {
4
- var defaultZero = Scale.getType(props.scale[axis]) === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
5
- var defaultMin = defaultZero;
6
- var minY = Collection.getMinValue(props.domain[axis]);
7
- var maxY = Collection.getMaxValue(props.domain[axis]);
8
-
2
+ export const getBarPosition = (props, datum) => {
3
+ const getDefaultMin = axis => {
4
+ const defaultZero = Scale.getType(props.scale[axis]) === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
5
+ let defaultMin = defaultZero;
6
+ const minY = Collection.getMinValue(props.domain[axis]);
7
+ const maxY = Collection.getMaxValue(props.domain[axis]);
9
8
  if (minY < 0 && maxY <= 0) {
10
9
  defaultMin = maxY;
11
10
  } else if (minY >= 0 && maxY > 0) {
12
11
  defaultMin = minY;
13
12
  }
14
-
15
- return datum["_".concat(axis)] instanceof Date ? new Date(defaultMin) : defaultMin;
13
+ return datum[`_${axis}`] instanceof Date ? new Date(defaultMin) : defaultMin;
16
14
  };
17
-
18
- var _y0 = datum._y0 !== undefined ? datum._y0 : getDefaultMin("y");
19
-
20
- var _x0 = datum._x0 !== undefined ? datum._x0 : getDefaultMin("x");
21
-
15
+ const _y0 = datum._y0 !== undefined ? datum._y0 : getDefaultMin("y");
16
+ const _x0 = datum._x0 !== undefined ? datum._x0 : getDefaultMin("x");
22
17
  return Helpers.scalePoint(props, Object.assign({}, datum, {
23
- _y0: _y0,
24
- _x0: _x0
18
+ _y0,
19
+ _x0
25
20
  }));
26
21
  };
27
-
28
- var getCalculatedValues = function (props) {
29
- var polar = props.polar;
30
- var defaultStyles = Helpers.getDefaultStyles(props, "bar");
31
- var style = !props.disableInlineStyles ? Helpers.getStyles(props.style, defaultStyles) : {};
32
- var range = props.range || {
22
+ const getCalculatedValues = props => {
23
+ const {
24
+ polar
25
+ } = props;
26
+ const defaultStyles = Helpers.getDefaultStyles(props, "bar");
27
+ const style = !props.disableInlineStyles ? Helpers.getStyles(props.style, defaultStyles) : {};
28
+ const range = props.range || {
33
29
  x: Helpers.getRange(props, "x"),
34
30
  y: Helpers.getRange(props, "y")
35
31
  };
36
- var domain = {
32
+ const domain = {
37
33
  x: Domain.getDomainWithZero(props, "x"),
38
34
  y: Domain.getDomainWithZero(props, "y")
39
35
  };
40
- var scale = {
36
+ const scale = {
41
37
  x: Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
42
38
  y: Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
43
39
  };
44
- var origin = polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
45
- var data = Data.getData(props);
40
+ const origin = polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
41
+ let data = Data.getData(props);
46
42
  data = Data.formatDataFromDomain(data, domain, 0);
47
43
  return {
48
- style: style,
49
- data: data,
50
- scale: scale,
51
- domain: domain,
52
- origin: origin
44
+ style,
45
+ data,
46
+ scale,
47
+ domain,
48
+ origin
53
49
  };
54
50
  };
55
-
56
- export var getBaseProps = function (initialProps, fallbackProps) {
57
- var modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "bar");
58
- var props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
59
- var alignment = props.alignment,
60
- barRatio = props.barRatio,
61
- cornerRadius = props.cornerRadius,
62
- data = props.data,
63
- disableInlineStyles = props.disableInlineStyles,
64
- domain = props.domain,
65
- events = props.events,
66
- height = props.height,
67
- horizontal = props.horizontal,
68
- origin = props.origin,
69
- padding = props.padding,
70
- polar = props.polar,
71
- scale = props.scale,
72
- sharedEvents = props.sharedEvents,
73
- standalone = props.standalone,
74
- style = props.style,
75
- theme = props.theme,
76
- width = props.width,
77
- labels = props.labels,
78
- name = props.name,
79
- barWidth = props.barWidth,
80
- getPath = props.getPath;
81
- var initialChildProps = {
51
+ export const getBaseProps = (initialProps, fallbackProps) => {
52
+ const modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "bar");
53
+ const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
54
+ const {
55
+ alignment,
56
+ barRatio,
57
+ cornerRadius,
58
+ data,
59
+ disableInlineStyles,
60
+ domain,
61
+ events,
62
+ height,
63
+ horizontal,
64
+ origin,
65
+ padding,
66
+ polar,
67
+ scale,
68
+ sharedEvents,
69
+ standalone,
70
+ style,
71
+ theme,
72
+ width,
73
+ labels,
74
+ name,
75
+ barWidth,
76
+ getPath
77
+ } = props;
78
+ const initialChildProps = {
82
79
  parent: {
83
- horizontal: horizontal,
84
- domain: domain,
85
- scale: scale,
86
- width: width,
87
- height: height,
88
- data: data,
89
- standalone: standalone,
90
- name: name,
91
- theme: theme,
92
- polar: polar,
93
- origin: origin,
94
- padding: padding,
80
+ horizontal,
81
+ domain,
82
+ scale,
83
+ width,
84
+ height,
85
+ data,
86
+ standalone,
87
+ name,
88
+ theme,
89
+ polar,
90
+ origin,
91
+ padding,
95
92
  style: style.parent
96
93
  }
97
94
  };
98
- return data.reduce(function (childProps, datum, index) {
99
- var eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
100
-
101
- var _getBarPosition = getBarPosition(props, datum),
102
- x = _getBarPosition.x,
103
- y = _getBarPosition.y,
104
- y0 = _getBarPosition.y0,
105
- x0 = _getBarPosition.x0;
106
-
107
- var dataProps = {
108
- alignment: alignment,
109
- barRatio: barRatio,
110
- barWidth: barWidth,
111
- cornerRadius: cornerRadius,
112
- data: data,
113
- datum: datum,
114
- disableInlineStyles: disableInlineStyles,
115
- getPath: getPath,
116
- horizontal: horizontal,
117
- index: index,
118
- polar: polar,
119
- origin: origin,
120
- scale: scale,
95
+ return data.reduce((childProps, datum, index) => {
96
+ const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
97
+ const {
98
+ x,
99
+ y,
100
+ y0,
101
+ x0
102
+ } = getBarPosition(props, datum);
103
+ const dataProps = {
104
+ alignment,
105
+ barRatio,
106
+ barWidth,
107
+ cornerRadius,
108
+ data,
109
+ datum,
110
+ disableInlineStyles,
111
+ getPath,
112
+ horizontal,
113
+ index,
114
+ polar,
115
+ origin,
116
+ scale,
121
117
  style: style.data,
122
- width: width,
123
- height: height,
124
- x: x,
125
- y: y,
126
- y0: y0,
127
- x0: x0
118
+ width,
119
+ height,
120
+ x,
121
+ y,
122
+ y0,
123
+ x0
128
124
  };
129
125
  childProps[eventKey] = {
130
126
  data: dataProps
131
127
  };
132
- var text = LabelHelpers.getText(props, datum, index);
133
-
128
+ const text = LabelHelpers.getText(props, datum, index);
134
129
  if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
135
130
  childProps[eventKey].labels = LabelHelpers.getProps(props, index);
136
131
  }
137
-
138
132
  return childProps;
139
133
  }, initialChildProps);
140
134
  };