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.
@@ -4,176 +4,150 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getVerticalPolarBarPath = exports.getVerticalBarPath = exports.getPolarBarPath = exports.getHorizontalBarPath = exports.getCustomBarPath = exports.getBarPath = void 0;
7
-
8
7
  var d3Shape = _interopRequireWildcard(require("victory-vendor/d3-shape"));
9
-
10
8
  var _geometryHelperMethods = require("./geometry-helper-methods");
11
-
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
- 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; }
17
-
18
- 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; }
19
-
20
- 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; }
21
-
22
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
-
24
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
-
26
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
-
28
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
29
-
30
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
31
-
32
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
33
-
34
- var getPosition = function (props, width) {
35
- var x = props.x,
36
- x0 = props.x0,
37
- y = props.y,
38
- y0 = props.y0,
39
- horizontal = props.horizontal;
40
- var alignment = props.alignment || "middle";
41
- var size = alignment === "middle" ? width / 2 : width;
42
- var sign = horizontal ? -1 : 1;
43
-
9
+ 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); }
10
+ 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; }
11
+ const getPosition = (props, width) => {
12
+ const {
13
+ x,
14
+ x0,
15
+ y,
16
+ y0,
17
+ horizontal
18
+ } = props;
19
+ const alignment = props.alignment || "middle";
20
+ const size = alignment === "middle" ? width / 2 : width;
21
+ const sign = horizontal ? -1 : 1;
44
22
  if (horizontal) {
45
23
  return {
46
- x0: x0,
24
+ x0,
47
25
  x1: x,
48
26
  y0: alignment === "start" ? y : y - sign * size,
49
27
  y1: alignment === "end" ? y : y + sign * size
50
28
  };
51
29
  }
52
-
53
30
  return {
54
31
  x0: alignment === "start" ? x : x - sign * size,
55
32
  x1: alignment === "end" ? x : x + sign * size,
56
- y0: y0,
33
+ y0,
57
34
  y1: y
58
35
  };
59
36
  };
60
-
61
- var getAngle = function (props, index) {
62
- var data = props.data,
63
- scale = props.scale;
64
- var x = data[index]._x1 === undefined ? "_x" : "_x1";
37
+ const getAngle = (props, index) => {
38
+ const {
39
+ data,
40
+ scale
41
+ } = props;
42
+ const x = data[index]._x1 === undefined ? "_x" : "_x1";
65
43
  return scale.x(data[index][x]);
66
44
  };
67
-
68
- var getAngularWidth = function (props, width) {
69
- var scale = props.scale;
70
- var range = scale.y.range();
71
- var r = Math.max.apply(Math, _toConsumableArray(range));
72
- var angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
45
+ const getAngularWidth = (props, width) => {
46
+ const {
47
+ scale
48
+ } = props;
49
+ const range = scale.y.range();
50
+ const r = Math.max(...range);
51
+ const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
73
52
  return width / (2 * Math.PI * r) * angularRange;
74
53
  };
75
-
76
- var transformAngle = function (angle) {
54
+ const transformAngle = angle => {
77
55
  return -1 * angle + Math.PI / 2;
78
56
  };
79
-
80
- var getCustomBarPath = function (props, width) {
81
- var getPath = props.getPath;
82
-
57
+ const getCustomBarPath = (props, width) => {
58
+ const {
59
+ getPath
60
+ } = props;
83
61
  if (typeof getPath === "function") {
84
- var propsWithCalculatedValues = _objectSpread(_objectSpread({}, props), getPosition(props, width));
85
-
62
+ const propsWithCalculatedValues = {
63
+ ...props,
64
+ ...getPosition(props, width)
65
+ };
86
66
  return getPath(propsWithCalculatedValues);
87
67
  }
88
68
  };
89
-
90
69
  exports.getCustomBarPath = getCustomBarPath;
91
-
92
- var getStartAngle = function (props, index) {
93
- var data = props.data,
94
- scale = props.scale,
95
- alignment = props.alignment;
96
- var currentAngle = getAngle(props, index);
97
- var angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
98
- var previousAngle = index === 0 ? getAngle(props, data.length - 1) - Math.PI * 2 : getAngle(props, index - 1);
99
-
70
+ const getStartAngle = (props, index) => {
71
+ const {
72
+ data,
73
+ scale,
74
+ alignment
75
+ } = props;
76
+ const currentAngle = getAngle(props, index);
77
+ const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
78
+ const previousAngle = index === 0 ? getAngle(props, data.length - 1) - Math.PI * 2 : getAngle(props, index - 1);
100
79
  if (index === 0 && angularRange < 2 * Math.PI) {
101
80
  return scale.x.range()[0];
102
81
  } else if (alignment === "start" || alignment === "end") {
103
82
  return alignment === "start" ? previousAngle : currentAngle;
104
83
  }
105
-
106
84
  return (currentAngle + previousAngle) / 2;
107
85
  };
108
-
109
- var getEndAngle = function (props, index) {
110
- var data = props.data,
111
- scale = props.scale,
112
- alignment = props.alignment;
113
- var currentAngle = getAngle(props, index);
114
- var angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
115
- var lastAngle = scale.x.range()[1] === 2 * Math.PI ? getAngle(props, 0) + Math.PI * 2 : scale.x.range()[1];
116
- var nextAngle = index === data.length - 1 ? getAngle(props, 0) + Math.PI * 2 : getAngle(props, index + 1);
117
-
86
+ const getEndAngle = (props, index) => {
87
+ const {
88
+ data,
89
+ scale,
90
+ alignment
91
+ } = props;
92
+ const currentAngle = getAngle(props, index);
93
+ const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
94
+ const lastAngle = scale.x.range()[1] === 2 * Math.PI ? getAngle(props, 0) + Math.PI * 2 : scale.x.range()[1];
95
+ const nextAngle = index === data.length - 1 ? getAngle(props, 0) + Math.PI * 2 : getAngle(props, index + 1);
118
96
  if (index === data.length - 1 && angularRange < 2 * Math.PI) {
119
97
  return lastAngle;
120
98
  } else if (alignment === "start" || alignment === "end") {
121
99
  return alignment === "start" ? currentAngle : nextAngle;
122
100
  }
123
-
124
101
  return (currentAngle + nextAngle) / 2;
125
102
  };
126
-
127
- var mapPointsToPath = function (coords, cornerRadius, direction) {
128
- var topLeftPath = "".concat(cornerRadius.topLeft, " ").concat(cornerRadius.topLeft, " ").concat(direction);
129
- var topRightPath = "".concat(cornerRadius.topRight, " ").concat(cornerRadius.topRight, " ").concat(direction);
130
- var bottomLeftPath = "".concat(cornerRadius.bottomLeft, " ").concat(cornerRadius.bottomLeft, " ").concat(direction);
131
- var bottomRightPath = "".concat(cornerRadius.bottomRight, " ").concat(cornerRadius.bottomRight, " ").concat(direction);
132
- var commands = ["M", "A ".concat(bottomLeftPath, ","), "L", "A ".concat(topLeftPath, ","), "L", "A ".concat(topRightPath, ","), "L", "A ".concat(bottomRightPath, ",")];
133
- var path = commands.reduce(function (acc, command, i) {
134
- return "".concat(acc).concat(command, " ").concat(coords[i].x, ", ").concat(coords[i].y, " \n");
135
- }, "");
136
- return "".concat(path, " z");
103
+ const mapPointsToPath = (coords, cornerRadius, direction) => {
104
+ const topLeftPath = `${cornerRadius.topLeft} ${cornerRadius.topLeft} ${direction}`;
105
+ const topRightPath = `${cornerRadius.topRight} ${cornerRadius.topRight} ${direction}`;
106
+ const bottomLeftPath = `${cornerRadius.bottomLeft} ${cornerRadius.bottomLeft} ${direction}`;
107
+ const bottomRightPath = `${cornerRadius.bottomRight} ${cornerRadius.bottomRight} ${direction}`;
108
+ const commands = ["M", `A ${bottomLeftPath},`, "L", `A ${topLeftPath},`, "L", `A ${topRightPath},`, "L", `A ${bottomRightPath},`];
109
+ const path = commands.reduce((acc, command, i) => `${acc}${command} ${coords[i].x}, ${coords[i].y} \n`, "");
110
+ return `${path} z`;
137
111
  };
138
-
139
- var getVerticalBarPoints = function (position, sign, cr) {
140
- var x0 = position.x0,
141
- x1 = position.x1,
142
- y0 = position.y0,
143
- y1 = position.y1; // eslint-disable-next-line max-statements, max-len
144
-
145
- var getHalfPoints = function (side) {
146
- var isLeft = side === "Left";
147
- var signL = isLeft ? 1 : -1;
148
- var x = isLeft ? x0 : x1;
149
- var bottomPoint = {
150
- x: x + signL * cr["bottom".concat(side)],
112
+ const getVerticalBarPoints = (position, sign, cr) => {
113
+ const {
114
+ x0,
115
+ x1,
116
+ y0,
117
+ y1
118
+ } = position;
119
+
120
+ // eslint-disable-next-line max-statements, max-len
121
+ const getHalfPoints = side => {
122
+ const isLeft = side === "Left";
123
+ const signL = isLeft ? 1 : -1;
124
+ const x = isLeft ? x0 : x1;
125
+ let bottomPoint = {
126
+ x: x + signL * cr[`bottom${side}`],
151
127
  y: y0
152
128
  };
153
- var bottomMiddlePoint = {
154
- x: x,
155
- y: y0 - sign * cr["bottom".concat(side)]
129
+ let bottomMiddlePoint = {
130
+ x,
131
+ y: y0 - sign * cr[`bottom${side}`]
156
132
  };
157
- var topMiddlePoint = {
158
- x: x,
159
- y: y1 + sign * cr["top".concat(side)]
133
+ let topMiddlePoint = {
134
+ x,
135
+ y: y1 + sign * cr[`top${side}`]
160
136
  };
161
- var topPoint = {
162
- x: x + signL * cr["top".concat(side)],
137
+ let topPoint = {
138
+ x: x + signL * cr[`top${side}`],
163
139
  y: y1
164
140
  };
165
- var hasIntersection = sign === 1 ? y0 - cr["bottom".concat(side)] < y1 + cr["top".concat(side)] : y0 + cr["bottom".concat(side)] > y1 - cr["top".concat(side)];
166
-
141
+ const hasIntersection = sign === 1 ? y0 - cr[`bottom${side}`] < y1 + cr[`top${side}`] : y0 + cr[`bottom${side}`] > y1 - cr[`top${side}`];
167
142
  if (hasIntersection) {
168
- var topCenter = (0, _geometryHelperMethods.point)(x + signL * cr["top".concat(side)], y1 + sign * cr["top".concat(side)]);
169
- var topCircle = (0, _geometryHelperMethods.circle)(topCenter, cr["top".concat(side)]);
170
- var bottomCenter = (0, _geometryHelperMethods.point)(x + signL * cr["bottom".concat(side)], y0 - sign * cr["bottom".concat(side)]);
171
- var bottomCircle = (0, _geometryHelperMethods.circle)(bottomCenter, cr["bottom".concat(side)]);
172
- var circleIntersection = topCircle.intersection(bottomCircle);
173
- var hasArcIntersection = circleIntersection.length > 0;
174
-
143
+ const topCenter = (0, _geometryHelperMethods.point)(x + signL * cr[`top${side}`], y1 + sign * cr[`top${side}`]);
144
+ const topCircle = (0, _geometryHelperMethods.circle)(topCenter, cr[`top${side}`]);
145
+ const bottomCenter = (0, _geometryHelperMethods.point)(x + signL * cr[`bottom${side}`], y0 - sign * cr[`bottom${side}`]);
146
+ const bottomCircle = (0, _geometryHelperMethods.circle)(bottomCenter, cr[`bottom${side}`]);
147
+ const circleIntersection = topCircle.intersection(bottomCircle);
148
+ const hasArcIntersection = circleIntersection.length > 0;
175
149
  if (hasArcIntersection) {
176
- var arcIntersection = circleIntersection[isLeft ? 0 : 1];
150
+ const arcIntersection = circleIntersection[isLeft ? 0 : 1];
177
151
  bottomMiddlePoint = {
178
152
  x: arcIntersection.x,
179
153
  y: arcIntersection.y
@@ -183,10 +157,9 @@ var getVerticalBarPoints = function (position, sign, cr) {
183
157
  y: arcIntersection.y
184
158
  };
185
159
  } else {
186
- var hasBottomLineTopArcIntersection = cr["top".concat(side)] > cr["bottom".concat(side)];
187
-
160
+ const hasBottomLineTopArcIntersection = cr[`top${side}`] > cr[`bottom${side}`];
188
161
  if (hasBottomLineTopArcIntersection) {
189
- var newX = topCircle.solveX(y0)[isLeft ? 0 : 1];
162
+ const newX = topCircle.solveX(y0)[isLeft ? 0 : 1];
190
163
  bottomPoint = {
191
164
  x: newX,
192
165
  y: y0
@@ -200,68 +173,66 @@ var getVerticalBarPoints = function (position, sign, cr) {
200
173
  y: y0
201
174
  };
202
175
  } else {
203
- var _newX = bottomCircle.solveX(y1)[isLeft ? 0 : 1];
176
+ const newX = bottomCircle.solveX(y1)[isLeft ? 0 : 1];
204
177
  bottomMiddlePoint = {
205
- x: _newX,
178
+ x: newX,
206
179
  y: y1
207
180
  };
208
181
  topMiddlePoint = {
209
- x: _newX,
182
+ x: newX,
210
183
  y: y1
211
184
  };
212
185
  topPoint = {
213
- x: _newX,
186
+ x: newX,
214
187
  y: y1
215
188
  };
216
189
  }
217
190
  }
218
191
  }
219
-
220
- var points = [bottomPoint, bottomMiddlePoint, topMiddlePoint, topPoint];
192
+ const points = [bottomPoint, bottomMiddlePoint, topMiddlePoint, topPoint];
221
193
  return isLeft ? points : points.reverse();
222
194
  };
223
-
224
195
  return getHalfPoints("Left").concat(getHalfPoints("Right"));
225
196
  };
226
-
227
- var getHorizontalBarPoints = function (position, sign, cr) {
228
- var y0 = position.y0,
229
- y1 = position.y1;
230
- var x0 = position.x0 < position.x1 ? position.x0 : position.x1;
231
- var x1 = position.x0 < position.x1 ? position.x1 : position.x0; // eslint-disable-next-line max-statements, max-len
232
-
233
- var getHalfPoints = function (side) {
234
- var isTop = side === "top";
235
- var signL = isTop ? -1 : 1;
236
- var y = isTop ? y1 : y0;
237
- var leftPoint = {
197
+ const getHorizontalBarPoints = (position, sign, cr) => {
198
+ const {
199
+ y0,
200
+ y1
201
+ } = position;
202
+ const x0 = position.x0 < position.x1 ? position.x0 : position.x1;
203
+ const x1 = position.x0 < position.x1 ? position.x1 : position.x0;
204
+
205
+ // eslint-disable-next-line max-statements, max-len
206
+ const getHalfPoints = side => {
207
+ const isTop = side === "top";
208
+ const signL = isTop ? -1 : 1;
209
+ const y = isTop ? y1 : y0;
210
+ let leftPoint = {
238
211
  x: x0,
239
- y: y - signL * cr["".concat(side, "Left")]
212
+ y: y - signL * cr[`${side}Left`]
240
213
  };
241
- var leftMiddlePoint = {
242
- x: x0 + cr["".concat(side, "Left")],
243
- y: y
214
+ let leftMiddlePoint = {
215
+ x: x0 + cr[`${side}Left`],
216
+ y
244
217
  };
245
- var rightMiddlePoint = {
246
- x: x1 - cr["".concat(side, "Right")],
247
- y: y
218
+ let rightMiddlePoint = {
219
+ x: x1 - cr[`${side}Right`],
220
+ y
248
221
  };
249
- var rightPoint = {
222
+ let rightPoint = {
250
223
  x: x1,
251
- y: y - signL * cr["".concat(side, "Right")]
224
+ y: y - signL * cr[`${side}Right`]
252
225
  };
253
- var hasIntersection = leftMiddlePoint.x > rightMiddlePoint.x;
254
-
226
+ const hasIntersection = leftMiddlePoint.x > rightMiddlePoint.x;
255
227
  if (hasIntersection) {
256
- var leftCenter = (0, _geometryHelperMethods.point)(x0 + cr["".concat(side, "Left")], y - signL * cr["".concat(side, "Left")]);
257
- var leftCircle = (0, _geometryHelperMethods.circle)(leftCenter, cr["".concat(side, "Left")]);
258
- var rightCenter = (0, _geometryHelperMethods.point)(x1 - cr["".concat(side, "Right")], y - signL * cr["".concat(side, "Right")]);
259
- var rightCircle = (0, _geometryHelperMethods.circle)(rightCenter, cr["".concat(side, "Right")]);
260
- var circleIntersection = leftCircle.intersection(rightCircle);
261
- var hasArcIntersection = circleIntersection.length > 0;
262
-
228
+ const leftCenter = (0, _geometryHelperMethods.point)(x0 + cr[`${side}Left`], y - signL * cr[`${side}Left`]);
229
+ const leftCircle = (0, _geometryHelperMethods.circle)(leftCenter, cr[`${side}Left`]);
230
+ const rightCenter = (0, _geometryHelperMethods.point)(x1 - cr[`${side}Right`], y - signL * cr[`${side}Right`]);
231
+ const rightCircle = (0, _geometryHelperMethods.circle)(rightCenter, cr[`${side}Right`]);
232
+ const circleIntersection = leftCircle.intersection(rightCircle);
233
+ const hasArcIntersection = circleIntersection.length > 0;
263
234
  if (hasArcIntersection) {
264
- var arcIntersection = circleIntersection[sign > 0 ? 1 : 0];
235
+ const arcIntersection = circleIntersection[sign > 0 ? 1 : 0];
265
236
  leftMiddlePoint = {
266
237
  x: arcIntersection.x,
267
238
  y: arcIntersection.y
@@ -271,10 +242,9 @@ var getHorizontalBarPoints = function (position, sign, cr) {
271
242
  y: arcIntersection.y
272
243
  };
273
244
  } else {
274
- var hasLeftLineRightArcIntersection = cr["".concat(side, "Right")] > cr["".concat(side, "Left")];
275
-
245
+ const hasLeftLineRightArcIntersection = cr[`${side}Right`] > cr[`${side}Left`];
276
246
  if (hasLeftLineRightArcIntersection) {
277
- var newY = rightCircle.solveY(x0)[isTop ? 0 : 1];
247
+ const newY = rightCircle.solveY(x0)[isTop ? 0 : 1];
278
248
  leftPoint = {
279
249
  x: x0,
280
250
  y: newY
@@ -288,227 +258,198 @@ var getHorizontalBarPoints = function (position, sign, cr) {
288
258
  y: newY
289
259
  };
290
260
  } else {
291
- var _newY = leftCircle.solveY(x1)[isTop ? 0 : 1];
261
+ const newY = leftCircle.solveY(x1)[isTop ? 0 : 1];
292
262
  rightPoint = {
293
263
  x: x1,
294
- y: _newY
264
+ y: newY
295
265
  };
296
266
  rightMiddlePoint = {
297
267
  x: x1,
298
- y: _newY
268
+ y: newY
299
269
  };
300
270
  leftMiddlePoint = {
301
271
  x: x1,
302
- y: _newY
272
+ y: newY
303
273
  };
304
274
  }
305
275
  }
306
276
  }
307
-
308
277
  return [leftPoint, leftMiddlePoint, rightMiddlePoint, rightPoint];
309
278
  };
279
+ const topPoints = getHalfPoints("top");
280
+ const bottomPoints = getHalfPoints("bottom");
281
+ return [bottomPoints[1], bottomPoints[0], ...topPoints,
282
+ // eslint-disable-next-line no-magic-numbers
283
+ bottomPoints[3], bottomPoints[2]];
284
+ };
310
285
 
311
- var topPoints = getHalfPoints("top");
312
- var bottomPoints = getHalfPoints("bottom");
313
- return [bottomPoints[1], bottomPoints[0]].concat(_toConsumableArray(topPoints), [// eslint-disable-next-line no-magic-numbers
314
- bottomPoints[3], bottomPoints[2]]);
315
- }; // eslint-disable-next-line max-params
316
-
317
-
318
- var getVerticalBarPath = function (props, width, cornerRadius) {
319
- var position = getPosition(props, width);
320
- var sign = position.y0 > position.y1 ? 1 : -1;
321
- var direction = sign > 0 ? "0 0 1" : "0 0 0";
322
- var points = getVerticalBarPoints(position, sign, cornerRadius);
286
+ // eslint-disable-next-line max-params
287
+ const getVerticalBarPath = (props, width, cornerRadius) => {
288
+ const position = getPosition(props, width);
289
+ const sign = position.y0 > position.y1 ? 1 : -1;
290
+ const direction = sign > 0 ? "0 0 1" : "0 0 0";
291
+ const points = getVerticalBarPoints(position, sign, cornerRadius);
323
292
  return mapPointsToPath(points, cornerRadius, direction);
324
- }; // eslint-disable-next-line max-params
325
-
293
+ };
326
294
 
295
+ // eslint-disable-next-line max-params
327
296
  exports.getVerticalBarPath = getVerticalBarPath;
328
-
329
- var getHorizontalBarPath = function (props, width, cornerRadius) {
330
- var position = getPosition(props, width);
331
- var sign = position.x0 < position.x1 ? 1 : -1;
332
- var direction = "0 0 1";
333
- var cr = {
297
+ const getHorizontalBarPath = (props, width, cornerRadius) => {
298
+ const position = getPosition(props, width);
299
+ const sign = position.x0 < position.x1 ? 1 : -1;
300
+ const direction = "0 0 1";
301
+ const cr = {
334
302
  topRight: sign > 0 ? cornerRadius.topLeft : cornerRadius.bottomLeft,
335
303
  bottomRight: sign > 0 ? cornerRadius.topRight : cornerRadius.bottomRight,
336
304
  bottomLeft: sign > 0 ? cornerRadius.bottomRight : cornerRadius.topRight,
337
305
  topLeft: sign > 0 ? cornerRadius.bottomLeft : cornerRadius.topLeft
338
306
  };
339
- var points = getHorizontalBarPoints(position, sign, cr);
307
+ const points = getHorizontalBarPoints(position, sign, cr);
340
308
  return mapPointsToPath(points, cr, direction);
341
309
  };
342
-
343
310
  exports.getHorizontalBarPath = getHorizontalBarPath;
344
-
345
- var getVerticalPolarBarPath = function (props, cornerRadius) {
346
- var datum = props.datum,
347
- scale = props.scale,
348
- index = props.index,
349
- alignment = props.alignment,
350
- style = props.style;
351
- var r1 = scale.y(datum._y0 || 0);
352
- var r2 = scale.y(datum._y1 !== undefined ? datum._y1 : datum._y);
353
- var currentAngle = scale.x(datum._x1 !== undefined ? datum._x1 : datum._x);
354
- var start;
355
- var end;
356
-
311
+ const getVerticalPolarBarPath = (props, cornerRadius) => {
312
+ const {
313
+ datum,
314
+ scale,
315
+ index,
316
+ alignment,
317
+ style
318
+ } = props;
319
+ const r1 = scale.y(datum._y0 || 0);
320
+ const r2 = scale.y(datum._y1 !== undefined ? datum._y1 : datum._y);
321
+ const currentAngle = scale.x(datum._x1 !== undefined ? datum._x1 : datum._x);
322
+ let start;
323
+ let end;
357
324
  if (style.width) {
358
- var width = getAngularWidth(props, style.width);
359
- var size = alignment === "middle" ? width / 2 : width;
325
+ const width = getAngularWidth(props, style.width);
326
+ const size = alignment === "middle" ? width / 2 : width;
360
327
  start = alignment === "start" ? currentAngle : currentAngle - size;
361
328
  end = alignment === "end" ? currentAngle : currentAngle + size;
362
329
  } else {
363
330
  start = getStartAngle(props, Number(index));
364
331
  end = getEndAngle(props, Number(index));
365
332
  }
366
-
367
- var getPath = function (edge) {
368
- var pathFunction = d3Shape.arc().innerRadius(r1).outerRadius(r2).startAngle(transformAngle(start)).endAngle(transformAngle(end)).cornerRadius(cornerRadius[edge]);
333
+ const getPath = edge => {
334
+ const pathFunction = d3Shape.arc().innerRadius(r1).outerRadius(r2).startAngle(transformAngle(start)).endAngle(transformAngle(end)).cornerRadius(cornerRadius[edge]);
369
335
  return pathFunction();
370
336
  };
371
-
372
- var getPathData = function (edge) {
373
- var rightPath = getPath("".concat(edge, "Right"));
374
- var rightMoves = rightPath.match(/[A-Z]/g) || [];
375
- var rightCoords = rightPath.split(/[A-Z]/).slice(1);
376
- var rightMiddle = rightMoves.indexOf("L");
377
- var leftPath = getPath("".concat(edge, "Left"));
378
- var leftMoves = leftPath.match(/[A-Z]/g) || [];
379
- var leftCoords = leftPath.split(/[A-Z]/).slice(1);
380
- var leftMiddle = leftMoves.indexOf("L");
337
+ const getPathData = edge => {
338
+ const rightPath = getPath(`${edge}Right`);
339
+ const rightMoves = rightPath.match(/[A-Z]/g) || [];
340
+ const rightCoords = rightPath.split(/[A-Z]/).slice(1);
341
+ const rightMiddle = rightMoves.indexOf("L");
342
+ const leftPath = getPath(`${edge}Left`);
343
+ const leftMoves = leftPath.match(/[A-Z]/g) || [];
344
+ const leftCoords = leftPath.split(/[A-Z]/).slice(1);
345
+ const leftMiddle = leftMoves.indexOf("L");
381
346
  return {
382
- rightMoves: rightMoves,
383
- rightCoords: rightCoords,
384
- rightMiddle: rightMiddle,
385
- leftMoves: leftMoves,
386
- leftCoords: leftCoords,
387
- leftMiddle: leftMiddle
347
+ rightMoves,
348
+ rightCoords,
349
+ rightMiddle,
350
+ leftMoves,
351
+ leftCoords,
352
+ leftMiddle
388
353
  };
389
- }; // eslint-disable-next-line max-statements
390
-
391
-
392
- var getTopPath = function () {
393
- var topRight = cornerRadius.topRight,
394
- topLeft = cornerRadius.topLeft;
395
- var arcLength = r2 * Math.abs(end - start);
396
-
397
- var _getPathData = getPathData("top"),
398
- rightMoves = _getPathData.rightMoves,
399
- rightCoords = _getPathData.rightCoords,
400
- rightMiddle = _getPathData.rightMiddle,
401
- leftMoves = _getPathData.leftMoves,
402
- leftCoords = _getPathData.leftCoords,
403
- leftMiddle = _getPathData.leftMiddle;
404
-
405
- var moves;
406
- var coords;
354
+ };
407
355
 
356
+ // eslint-disable-next-line max-statements
357
+ const getTopPath = () => {
358
+ const {
359
+ topRight,
360
+ topLeft
361
+ } = cornerRadius;
362
+ const arcLength = r2 * Math.abs(end - start);
363
+ const {
364
+ rightMoves,
365
+ rightCoords,
366
+ rightMiddle,
367
+ leftMoves,
368
+ leftCoords,
369
+ leftMiddle
370
+ } = getPathData("top");
371
+ let moves;
372
+ let coords;
408
373
  if (topRight === topLeft || arcLength < 2 * topRight + 2 * topLeft) {
409
374
  moves = topRight > topLeft ? rightMoves : leftMoves;
410
375
  coords = topRight > topLeft ? rightCoords : leftCoords;
411
376
  } else {
412
377
  // eslint-disable-next-line no-magic-numbers
413
- var isShort = function (middle) {
414
- return middle < 3;
415
- };
416
-
417
- var rightOffset = topLeft > topRight && isShort(rightMiddle) ? 1 : 2;
418
- var leftOffset;
419
-
378
+ const isShort = middle => middle < 3;
379
+ const rightOffset = topLeft > topRight && isShort(rightMiddle) ? 1 : 2;
380
+ let leftOffset;
420
381
  if (topRight > topLeft) {
421
- var defaultOffset = isShort(rightMiddle) ? leftMiddle : leftMiddle - 2;
382
+ const defaultOffset = isShort(rightMiddle) ? leftMiddle : leftMiddle - 2;
422
383
  leftOffset = isShort(leftMiddle) ? leftMiddle - 1 : defaultOffset;
423
384
  } else {
424
- var _defaultOffset = isShort(leftMiddle) ? 1 : 2;
425
-
426
- leftOffset = isShort(rightMiddle) ? _defaultOffset : leftMiddle - 2;
385
+ const defaultOffset = isShort(leftMiddle) ? 1 : 2;
386
+ leftOffset = isShort(rightMiddle) ? defaultOffset : leftMiddle - 2;
427
387
  }
428
-
429
- moves = [].concat(_toConsumableArray(rightMoves.slice(0, rightOffset)), _toConsumableArray(leftMoves.slice(leftOffset)));
430
- coords = [].concat(_toConsumableArray(rightCoords.slice(0, rightOffset)), _toConsumableArray(leftCoords.slice(leftOffset)));
388
+ moves = [...rightMoves.slice(0, rightOffset), ...leftMoves.slice(leftOffset)];
389
+ coords = [...rightCoords.slice(0, rightOffset), ...leftCoords.slice(leftOffset)];
431
390
  }
391
+ const middle = moves.indexOf("L");
392
+ const subMoves = moves.slice(0, middle);
393
+ const subCoords = coords.slice(0, middle);
394
+ return subMoves.map((m, i) => ({
395
+ command: m,
396
+ coords: subCoords[i].split(",")
397
+ }));
398
+ };
432
399
 
433
- var middle = moves.indexOf("L");
434
- var subMoves = moves.slice(0, middle);
435
- var subCoords = coords.slice(0, middle);
436
- return subMoves.map(function (m, i) {
437
- return {
438
- command: m,
439
- coords: subCoords[i].split(",")
440
- };
441
- });
442
- }; // eslint-disable-next-line max-statements
443
-
444
-
445
- var getBottomPath = function () {
446
- var bottomRight = cornerRadius.bottomRight,
447
- bottomLeft = cornerRadius.bottomLeft;
448
- var arcLength = r1 * Math.abs(end - start);
449
-
450
- var _getPathData2 = getPathData("bottom"),
451
- rightMoves = _getPathData2.rightMoves,
452
- rightCoords = _getPathData2.rightCoords,
453
- rightMiddle = _getPathData2.rightMiddle,
454
- leftMoves = _getPathData2.leftMoves,
455
- leftCoords = _getPathData2.leftCoords,
456
- leftMiddle = _getPathData2.leftMiddle;
457
-
458
- var moves;
459
- var coords;
460
-
400
+ // eslint-disable-next-line max-statements
401
+ const getBottomPath = () => {
402
+ const {
403
+ bottomRight,
404
+ bottomLeft
405
+ } = cornerRadius;
406
+ const arcLength = r1 * Math.abs(end - start);
407
+ const {
408
+ rightMoves,
409
+ rightCoords,
410
+ rightMiddle,
411
+ leftMoves,
412
+ leftCoords,
413
+ leftMiddle
414
+ } = getPathData("bottom");
415
+ let moves;
416
+ let coords;
461
417
  if (bottomRight === bottomLeft || arcLength < 2 * bottomRight + 2 * bottomLeft) {
462
418
  moves = bottomRight > bottomLeft ? rightMoves : leftMoves;
463
419
  coords = bottomRight > bottomLeft ? rightCoords : leftCoords;
464
420
  } else {
465
421
  // eslint-disable-next-line no-magic-numbers
466
- var isShort = function (m, middle) {
467
- return m.length - middle < 4;
468
- };
469
-
470
- var shortPath = bottomRight > bottomLeft ? isShort(rightMoves, rightMiddle) : isShort(leftMoves, leftMiddle); // eslint-disable-next-line no-magic-numbers
471
-
472
- var rightOffset = shortPath ? -1 : -3;
473
- moves = [].concat(_toConsumableArray(leftMoves.slice(0, leftMiddle + 2)), _toConsumableArray(rightMoves.slice(rightOffset)));
474
- coords = [].concat(_toConsumableArray(leftCoords.slice(0, leftMiddle + 2)), _toConsumableArray(rightCoords.slice(rightOffset)));
422
+ const isShort = (m, middle) => m.length - middle < 4;
423
+ const shortPath = bottomRight > bottomLeft ? isShort(rightMoves, rightMiddle) : isShort(leftMoves, leftMiddle);
424
+ // eslint-disable-next-line no-magic-numbers
425
+ const rightOffset = shortPath ? -1 : -3;
426
+ moves = [...leftMoves.slice(0, leftMiddle + 2), ...rightMoves.slice(rightOffset)];
427
+ coords = [...leftCoords.slice(0, leftMiddle + 2), ...rightCoords.slice(rightOffset)];
475
428
  }
476
-
477
- var middle = moves.indexOf("L");
478
- var subMoves = moves.slice(middle, -1);
479
- var subCoords = coords.slice(middle, -1);
480
- return subMoves.map(function (m, i) {
481
- return {
482
- command: m,
483
- coords: subCoords[i].split(",")
484
- };
485
- });
429
+ const middle = moves.indexOf("L");
430
+ const subMoves = moves.slice(middle, -1);
431
+ const subCoords = coords.slice(middle, -1);
432
+ return subMoves.map((m, i) => ({
433
+ command: m,
434
+ coords: subCoords[i].split(",")
435
+ }));
486
436
  };
487
-
488
- var topPath = getTopPath();
489
- var bottomPath = getBottomPath();
490
- var moves = [].concat(_toConsumableArray(topPath), _toConsumableArray(bottomPath));
491
- var path = moves.reduce(function (memo, move) {
492
- return "".concat(memo).concat(move.command, " ").concat(move.coords.join());
493
- }, "");
494
- return "".concat(path, " z");
437
+ const topPath = getTopPath();
438
+ const bottomPath = getBottomPath();
439
+ const moves = [...topPath, ...bottomPath];
440
+ const path = moves.reduce((memo, move) => `${memo}${move.command} ${move.coords.join()}`, "");
441
+ return `${path} z`;
495
442
  };
496
-
497
443
  exports.getVerticalPolarBarPath = getVerticalPolarBarPath;
498
-
499
- var getBarPath = function (props, width, cornerRadius) {
444
+ const getBarPath = (props, width, cornerRadius) => {
500
445
  if (props.getPath) {
501
446
  return getCustomBarPath(props, width);
502
447
  }
503
-
504
448
  return props.horizontal ? getHorizontalBarPath(props, width, cornerRadius) : getVerticalBarPath(props, width, cornerRadius);
505
449
  };
506
-
507
450
  exports.getBarPath = getBarPath;
508
-
509
- var getPolarBarPath = function (props, cornerRadius) {
451
+ const getPolarBarPath = (props, cornerRadius) => {
510
452
  // TODO Radial bars
511
453
  return getVerticalPolarBarPath(props, cornerRadius);
512
454
  };
513
-
514
455
  exports.getPolarBarPath = getPolarBarPath;