victory-box-plot 36.9.2-next.0 → 36.9.2-next.3

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,38 +4,59 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getDomain = exports.getData = exports.getBaseProps = void 0;
7
- var _keys2 = _interopRequireDefault(require("lodash/keys"));
7
+
8
8
  var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
9
+
9
10
  var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
11
+
10
12
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
13
+
11
14
  var _orderBy2 = _interopRequireDefault(require("lodash/orderBy"));
15
+
12
16
  var _victoryCore = require("victory-core");
17
+
13
18
  var _d3Array = require("victory-vendor/d3-array");
19
+
14
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- const TYPES = ["max", "min", "median", "q1", "q3"];
16
- const checkProcessedData = data => {
21
+
22
+ 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; }
23
+
24
+ var TYPES = ["max", "min", "median", "q1", "q3"];
25
+
26
+ var checkProcessedData = function (data) {
17
27
  /* check if the data is pre-processed. start by checking that it has
18
28
  all required quartile attributes. */
19
- const hasQuartileAttributes = data.every(datum => {
20
- return TYPES.every(val => typeof datum[`_${val}`] !== "undefined");
29
+ var hasQuartileAttributes = data.every(function (datum) {
30
+ return TYPES.every(function (val) {
31
+ return typeof datum["_".concat(val)] !== "undefined";
32
+ });
21
33
  });
34
+
22
35
  if (hasQuartileAttributes) {
23
36
  // check that the independent variable is distinct
24
- const values = data.map(d => d._x);
37
+ var values = data.map(function (d) {
38
+ return d._x;
39
+ });
40
+
25
41
  if (!(0, _uniq2.default)(values).length === values.length) {
26
- throw new Error(`
27
- data prop may only take an array of objects with a unique
28
- independent variable. Make sure your x values are distinct.
29
- `);
42
+ throw new Error("\n data prop may only take an array of objects with a unique\n independent variable. Make sure your x values are distinct.\n ");
30
43
  }
44
+
31
45
  return true;
32
46
  }
47
+
33
48
  return false;
34
49
  };
35
- const nanToNull = val => Number.isNaN(val) ? null : val;
36
- const getSummaryStatistics = data => {
37
- const dependentVars = data.map(datum => datum._y);
38
- const quartiles = {
50
+
51
+ var nanToNull = function (val) {
52
+ return Number.isNaN(val) ? null : val;
53
+ };
54
+
55
+ var getSummaryStatistics = function (data) {
56
+ var dependentVars = data.map(function (datum) {
57
+ return datum._y;
58
+ });
59
+ var quartiles = {
39
60
  _q1: nanToNull((0, _d3Array.quantile)(dependentVars, 0.25)),
40
61
  // eslint-disable-line no-magic-numbers
41
62
  _q3: nanToNull((0, _d3Array.quantile)(dependentVars, 0.75)),
@@ -48,36 +69,41 @@ const getSummaryStatistics = data => {
48
69
  _y: data[0]._y
49
70
  });
50
71
  };
51
- const processData = data => {
72
+
73
+ var processData = function (data) {
52
74
  /* check if the data is coming in a pre-processed form,
53
75
  i.e. { x || y, min, max, q1, q3, median }. if not, process it. */
54
- const isProcessed = checkProcessedData(data);
76
+ var isProcessed = checkProcessedData(data);
77
+
55
78
  if (!isProcessed) {
56
79
  // check if the data is coming with x or y values as an array
57
- const arrayX = data.every(datum => Array.isArray(datum._x));
58
- const arrayY = data.every(datum => Array.isArray(datum._y));
59
- const sortKey = "_y";
60
- const groupKey = "_x";
80
+ var arrayX = data.every(function (datum) {
81
+ return Array.isArray(datum._x);
82
+ });
83
+ var arrayY = data.every(function (datum) {
84
+ return Array.isArray(datum._y);
85
+ });
86
+ var sortKey = "_y";
87
+ var groupKey = "_x";
88
+
61
89
  if (arrayX) {
62
- throw new Error(`
63
- data should not be given as in array for x
64
- `);
90
+ throw new Error("\n data should not be given as in array for x\n ");
65
91
  } else if (arrayY) {
66
92
  /* generate summary statistics for each datum. to do this, flatten
67
93
  the depedentVarArray and process each datum separately */
68
- return data.map(datum => {
69
- const dataArray = datum[sortKey].map(d => Object.assign({}, datum, {
70
- [sortKey]: d
71
- }));
72
- const sortedData = (0, _orderBy2.default)(dataArray, sortKey);
94
+ return data.map(function (datum) {
95
+ var dataArray = datum[sortKey].map(function (d) {
96
+ return Object.assign({}, datum, _defineProperty({}, sortKey, d));
97
+ });
98
+ var sortedData = (0, _orderBy2.default)(dataArray, sortKey);
73
99
  return getSummaryStatistics(sortedData);
74
100
  });
75
101
  } else {
76
102
  /* Group data by independent variable and generate summary statistics for each group */
77
- const groupedData = (0, _groupBy2.default)(data, groupKey);
78
- return (0, _keys2.default)(groupedData).map(key => {
79
- const datum = groupedData[key];
80
- const sortedData = (0, _orderBy2.default)(datum, sortKey);
103
+ var groupedData = (0, _groupBy2.default)(data, groupKey);
104
+ return Object.keys(groupedData).map(function (key) {
105
+ var datum = groupedData[key];
106
+ var sortedData = (0, _orderBy2.default)(datum, sortKey);
81
107
  return getSummaryStatistics(sortedData);
82
108
  });
83
109
  }
@@ -85,71 +111,92 @@ const processData = data => {
85
111
  return data;
86
112
  }
87
113
  };
88
- const getData = props => {
89
- const accessorTypes = TYPES.concat("x", "y");
90
- const formattedData = _victoryCore.Data.formatData(props.data, props, accessorTypes);
114
+
115
+ var getData = function (props) {
116
+ var accessorTypes = TYPES.concat("x", "y");
117
+
118
+ var formattedData = _victoryCore.Data.formatData(props.data, props, accessorTypes);
119
+
91
120
  return formattedData.length ? processData(formattedData) : [];
92
121
  };
122
+
93
123
  exports.getData = getData;
94
- const reduceDataset = (dataset, props, axis) => {
95
- const minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
96
- const maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
97
- const minData = minDomain !== undefined ? minDomain : dataset.reduce((memo, datum) => {
98
- return memo < datum[`_${axis}`] ? memo : datum[`_${axis}`];
124
+
125
+ var reduceDataset = function (dataset, props, axis) {
126
+ var minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
127
+
128
+ var maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
129
+
130
+ var minData = minDomain !== undefined ? minDomain : dataset.reduce(function (memo, datum) {
131
+ return memo < datum["_".concat(axis)] ? memo : datum["_".concat(axis)];
99
132
  }, Infinity);
100
- const maxData = maxDomain !== undefined ? maxDomain : dataset.reduce((memo, datum) => {
101
- return memo > datum[`_${axis}`] ? memo : datum[`_${axis}`];
133
+ var maxData = maxDomain !== undefined ? maxDomain : dataset.reduce(function (memo, datum) {
134
+ return memo > datum["_".concat(axis)] ? memo : datum["_".concat(axis)];
102
135
  }, -Infinity);
103
136
  return _victoryCore.Domain.getDomainFromMinMax(minData, maxData);
104
137
  };
105
- const getDomainFromMinMaxValues = (dataset, props, axis) => {
106
- const minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
107
- const maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
108
- const minData = minDomain !== undefined ? minDomain : dataset.reduce((memo, datum) => {
138
+
139
+ var getDomainFromMinMaxValues = function (dataset, props, axis) {
140
+ var minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
141
+
142
+ var maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
143
+
144
+ var minData = minDomain !== undefined ? minDomain : dataset.reduce(function (memo, datum) {
109
145
  return memo < datum._min ? memo : datum._min;
110
146
  }, Infinity);
111
- const maxData = maxDomain !== undefined ? maxDomain : dataset.reduce((memo, datum) => {
147
+ var maxData = maxDomain !== undefined ? maxDomain : dataset.reduce(function (memo, datum) {
112
148
  return memo > datum._max ? memo : datum._max;
113
149
  }, -Infinity);
114
150
  return _victoryCore.Domain.getDomainFromMinMax(minData, maxData);
115
151
  };
116
- const getDomainFromData = (props, axis) => {
117
- const minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
118
- const maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
119
- const dataset = getData(props);
152
+
153
+ var getDomainFromData = function (props, axis) {
154
+ var minDomain = _victoryCore.Domain.getMinFromProps(props, axis);
155
+
156
+ var maxDomain = _victoryCore.Domain.getMaxFromProps(props, axis);
157
+
158
+ var dataset = getData(props);
159
+
120
160
  if (dataset.length < 1) {
121
161
  return minDomain !== undefined && maxDomain !== undefined ? _victoryCore.Domain.getDomainFromMinMax(minDomain, maxDomain) : undefined;
122
162
  }
163
+
123
164
  return axis === "y" ? getDomainFromMinMaxValues(dataset, props, axis) : reduceDataset(dataset, props, axis);
124
165
  };
125
- const getDomain = (props, axis) => {
166
+
167
+ var getDomain = function (props, axis) {
126
168
  return _victoryCore.Domain.createDomainFunction(getDomainFromData)(props, axis);
127
169
  };
170
+
128
171
  exports.getDomain = getDomain;
129
- const getLabelStyle = (props, styleObject, namespace) => {
130
- const component = props[`${namespace}LabelComponent`] || props.labelComponent;
131
- const baseStyle = styleObject[`${namespace}Labels`] || styleObject.labels;
172
+
173
+ var getLabelStyle = function (props, styleObject, namespace) {
174
+ var component = props["".concat(namespace, "LabelComponent")] || props.labelComponent;
175
+ var baseStyle = styleObject["".concat(namespace, "Labels")] || styleObject.labels;
176
+
132
177
  if (!_victoryCore.Helpers.isTooltip(component)) {
133
178
  return baseStyle;
134
179
  }
135
- const tooltipTheme = props.theme && props.theme.tooltip || {};
180
+
181
+ var tooltipTheme = props.theme && props.theme.tooltip || {};
136
182
  return (0, _defaults2.default)({}, tooltipTheme.style, baseStyle);
137
183
  };
138
- const getStyles = function (props, styleObject) {
139
- if (styleObject === void 0) {
140
- styleObject = {};
141
- }
184
+
185
+ var getStyles = function (props) {
186
+ var styleObject = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
187
+
142
188
  if (props.disableInlineStyles) {
143
189
  return {};
144
190
  }
145
- const style = props.style || {};
146
- const parentStyles = {
191
+
192
+ var style = props.style || {};
193
+ var parentStyles = {
147
194
  height: "100%",
148
195
  width: "100%"
149
196
  };
150
- const labelStyles = (0, _defaults2.default)({}, style.labels, getLabelStyle(props, styleObject));
151
- const boxStyles = (0, _defaults2.default)({}, style.boxes, styleObject.boxes);
152
- const whiskerStyles = (0, _defaults2.default)({}, style.whiskers, styleObject.whiskers);
197
+ var labelStyles = (0, _defaults2.default)({}, style.labels, getLabelStyle(props, styleObject));
198
+ var boxStyles = (0, _defaults2.default)({}, style.boxes, styleObject.boxes);
199
+ var whiskerStyles = (0, _defaults2.default)({}, style.whiskers, styleObject.whiskers);
153
200
  return {
154
201
  boxes: boxStyles,
155
202
  labels: labelStyles,
@@ -167,67 +214,63 @@ const getStyles = function (props, styleObject) {
167
214
  whiskers: whiskerStyles
168
215
  };
169
216
  };
170
- const getCalculatedValues = props => {
171
- const {
172
- theme,
173
- horizontal
174
- } = props;
175
- const data = getData(props);
176
- const range = {
217
+
218
+ var getCalculatedValues = function (props) {
219
+ var theme = props.theme,
220
+ horizontal = props.horizontal;
221
+ var data = getData(props);
222
+ var range = {
177
223
  x: _victoryCore.Helpers.getRange(props, "x"),
178
224
  y: _victoryCore.Helpers.getRange(props, "y")
179
225
  };
180
- const domain = {
226
+ var domain = {
181
227
  x: getDomain(props, "x"),
182
228
  y: getDomain(props, "y")
183
229
  };
184
- const scale = {
230
+ var scale = {
185
231
  x: _victoryCore.Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
186
232
  y: _victoryCore.Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
187
233
  };
188
- const defaultStyles = theme && theme.boxplot && theme.boxplot.style ? theme.boxplot.style : {};
189
- const style = getStyles(props, defaultStyles);
190
- const defaultOrientation = props.horizontal ? "top" : "right";
191
- const labelOrientation = props.labelOrientation || defaultOrientation;
192
- const boxWidth = props.boxWidth || 1;
234
+ var defaultStyles = theme && theme.boxplot && theme.boxplot.style ? theme.boxplot.style : {};
235
+ var style = getStyles(props, defaultStyles);
236
+ var defaultOrientation = props.horizontal ? "top" : "right";
237
+ var labelOrientation = props.labelOrientation || defaultOrientation;
238
+ var boxWidth = props.boxWidth || 1;
193
239
  return {
194
- data,
195
- horizontal,
196
- domain,
197
- scale,
198
- style,
199
- labelOrientation,
200
- boxWidth
240
+ data: data,
241
+ horizontal: horizontal,
242
+ domain: domain,
243
+ scale: scale,
244
+ style: style,
245
+ labelOrientation: labelOrientation,
246
+ boxWidth: boxWidth
201
247
  };
202
- };
248
+ }; // eslint-disable-next-line complexity
249
+
203
250
 
204
- // eslint-disable-next-line complexity
205
- const getWhiskerProps = (props, type) => {
206
- const {
207
- horizontal,
208
- style,
209
- boxWidth,
210
- whiskerWidth,
211
- datum,
212
- scale,
213
- index,
214
- disableInlineStyles
215
- } = props;
216
- const {
217
- min,
218
- max,
219
- q1,
220
- q3,
221
- x,
222
- y
223
- } = props.positions;
224
- const boxValue = type === "min" ? q1 : q3;
225
- const whiskerValue = type === "min" ? min : max;
226
- const width = typeof whiskerWidth === "number" ? whiskerWidth : boxWidth;
251
+ var getWhiskerProps = function (props, type) {
252
+ var horizontal = props.horizontal,
253
+ style = props.style,
254
+ boxWidth = props.boxWidth,
255
+ whiskerWidth = props.whiskerWidth,
256
+ datum = props.datum,
257
+ scale = props.scale,
258
+ index = props.index,
259
+ disableInlineStyles = props.disableInlineStyles;
260
+ var _props$positions = props.positions,
261
+ min = _props$positions.min,
262
+ max = _props$positions.max,
263
+ q1 = _props$positions.q1,
264
+ q3 = _props$positions.q3,
265
+ x = _props$positions.x,
266
+ y = _props$positions.y;
267
+ var boxValue = type === "min" ? q1 : q3;
268
+ var whiskerValue = type === "min" ? min : max;
269
+ var width = typeof whiskerWidth === "number" ? whiskerWidth : boxWidth;
227
270
  return {
228
- datum,
229
- index,
230
- scale,
271
+ datum: datum,
272
+ index: index,
273
+ scale: scale,
231
274
  majorWhisker: {
232
275
  x1: horizontal ? boxValue : x,
233
276
  y1: horizontal ? y : boxValue,
@@ -241,127 +284,128 @@ const getWhiskerProps = (props, type) => {
241
284
  y2: horizontal ? y + width / 2 : whiskerValue
242
285
  },
243
286
  style: disableInlineStyles ? {} : style[type] || style.whisker,
244
- disableInlineStyles
287
+ disableInlineStyles: disableInlineStyles
245
288
  };
246
289
  };
247
- const getBoxProps = (props, type) => {
248
- const {
249
- horizontal,
250
- boxWidth,
251
- style,
252
- scale,
253
- datum,
254
- index,
255
- disableInlineStyles
256
- } = props;
257
- const {
258
- median,
259
- q1,
260
- q3,
261
- x,
262
- y
263
- } = props.positions;
264
- const defaultX = type === "q1" ? q1 : median;
265
- const defaultY = type === "q1" ? median : q3;
266
- const defaultWidth = type === "q1" ? median - q1 : q3 - median;
267
- const defaultHeight = type === "q1" ? q1 - median : median - q3;
290
+
291
+ var getBoxProps = function (props, type) {
292
+ var horizontal = props.horizontal,
293
+ boxWidth = props.boxWidth,
294
+ style = props.style,
295
+ scale = props.scale,
296
+ datum = props.datum,
297
+ index = props.index,
298
+ disableInlineStyles = props.disableInlineStyles;
299
+ var _props$positions2 = props.positions,
300
+ median = _props$positions2.median,
301
+ q1 = _props$positions2.q1,
302
+ q3 = _props$positions2.q3,
303
+ x = _props$positions2.x,
304
+ y = _props$positions2.y;
305
+ var defaultX = type === "q1" ? q1 : median;
306
+ var defaultY = type === "q1" ? median : q3;
307
+ var defaultWidth = type === "q1" ? median - q1 : q3 - median;
308
+ var defaultHeight = type === "q1" ? q1 - median : median - q3;
268
309
  return {
269
- datum,
270
- scale,
271
- index,
310
+ datum: datum,
311
+ scale: scale,
312
+ index: index,
272
313
  x: horizontal ? defaultX : x - boxWidth / 2,
273
314
  y: horizontal ? y - boxWidth / 2 : defaultY,
274
315
  width: horizontal ? defaultWidth : boxWidth,
275
316
  height: horizontal ? boxWidth : defaultHeight,
276
317
  style: disableInlineStyles ? {} : style[type] || style.boxes,
277
- disableInlineStyles
318
+ disableInlineStyles: disableInlineStyles
278
319
  };
279
320
  };
280
- const getMedianProps = props => {
281
- const {
282
- boxWidth,
283
- horizontal,
284
- style,
285
- datum,
286
- scale,
287
- index,
288
- disableInlineStyles
289
- } = props;
290
- const {
291
- median,
292
- x,
293
- y
294
- } = props.positions;
321
+
322
+ var getMedianProps = function (props) {
323
+ var boxWidth = props.boxWidth,
324
+ horizontal = props.horizontal,
325
+ style = props.style,
326
+ datum = props.datum,
327
+ scale = props.scale,
328
+ index = props.index,
329
+ disableInlineStyles = props.disableInlineStyles;
330
+ var _props$positions3 = props.positions,
331
+ median = _props$positions3.median,
332
+ x = _props$positions3.x,
333
+ y = _props$positions3.y;
295
334
  return {
296
- datum,
297
- scale,
298
- index,
335
+ datum: datum,
336
+ scale: scale,
337
+ index: index,
299
338
  x1: horizontal ? median : x - boxWidth / 2,
300
339
  y1: horizontal ? y - boxWidth / 2 : median,
301
340
  x2: horizontal ? median : x + boxWidth / 2,
302
341
  y2: horizontal ? y + boxWidth / 2 : median,
303
342
  style: disableInlineStyles ? {} : style.median,
304
- disableInlineStyles
343
+ disableInlineStyles: disableInlineStyles
305
344
  };
306
345
  };
307
- const getText = (props, type) => {
308
- const {
309
- datum,
310
- index,
311
- labels
312
- } = props;
313
- const propName = `${type}Labels`;
314
- const labelProp = props[propName];
346
+
347
+ var getText = function (props, type) {
348
+ var datum = props.datum,
349
+ index = props.index,
350
+ labels = props.labels;
351
+ var propName = "".concat(type, "Labels");
352
+ var labelProp = props[propName];
353
+
315
354
  if (!labelProp && !labels) {
316
355
  return null;
317
356
  } else if (labelProp === true || labels === true) {
318
- const dataName = `_${type}`;
319
- return `${datum[dataName]}`;
357
+ var dataName = "_".concat(type);
358
+ return "".concat(datum[dataName]);
320
359
  }
360
+
321
361
  return Array.isArray(labelProp) ? labelProp[index] : labelProp;
322
362
  };
323
- const getOrientation = (labelOrientation, type) => typeof labelOrientation === "object" && labelOrientation[type] || labelOrientation;
324
- const getLabelProps = (props, text, type) => {
325
- const {
326
- datum,
327
- positions,
328
- index,
329
- boxWidth,
330
- horizontal,
331
- labelOrientation,
332
- style,
333
- theme,
334
- disableInlineStyles
335
- } = props;
336
- const orientation = getOrientation(labelOrientation, type);
337
- const namespace = `${type}Labels`;
338
- const labelStyle = style[namespace] || style.labels;
339
- const defaultVerticalAnchors = {
363
+
364
+ var getOrientation = function (labelOrientation, type) {
365
+ return typeof labelOrientation === "object" && labelOrientation[type] || labelOrientation;
366
+ };
367
+
368
+ var getLabelProps = function (props, text, type) {
369
+ var datum = props.datum,
370
+ positions = props.positions,
371
+ index = props.index,
372
+ boxWidth = props.boxWidth,
373
+ horizontal = props.horizontal,
374
+ labelOrientation = props.labelOrientation,
375
+ style = props.style,
376
+ theme = props.theme,
377
+ disableInlineStyles = props.disableInlineStyles;
378
+ var orientation = getOrientation(labelOrientation, type);
379
+ var namespace = "".concat(type, "Labels");
380
+ var labelStyle = style[namespace] || style.labels;
381
+ var defaultVerticalAnchors = {
340
382
  top: "end",
341
383
  bottom: "start",
342
384
  left: "middle",
343
385
  right: "middle"
344
386
  };
345
- const defaultTextAnchors = {
387
+ var defaultTextAnchors = {
346
388
  left: "end",
347
389
  right: "start",
348
390
  top: "middle",
349
391
  bottom: "middle"
350
392
  };
351
- const whiskerWidth = typeof props.whiskerWidth === "number" ? props.whiskerWidth : boxWidth;
352
- const width = type === "min" || type === "max" ? whiskerWidth : boxWidth;
353
- const getOffset = coord => {
354
- const sign = {
393
+ var whiskerWidth = typeof props.whiskerWidth === "number" ? props.whiskerWidth : boxWidth;
394
+ var width = type === "min" || type === "max" ? whiskerWidth : boxWidth;
395
+
396
+ var getOffset = function (coord) {
397
+ var sign = {
355
398
  x: orientation === "left" ? -1 : 1,
356
399
  y: orientation === "top" ? -1 : 1
357
400
  };
358
401
  return sign[coord] * width / 2 + sign[coord] * (labelStyle.padding || 0);
359
402
  };
360
- const labelProps = {
361
- text,
362
- datum,
363
- index,
364
- orientation,
403
+
404
+ var labelProps = {
405
+ text: text,
406
+ datum: datum,
407
+ index: index,
408
+ orientation: orientation,
365
409
  style: disableInlineStyles ? {} : labelStyle,
366
410
  y: horizontal ? positions.y : positions[type],
367
411
  x: horizontal ? positions[type] : positions.x,
@@ -370,92 +414,111 @@ const getLabelProps = (props, text, type) => {
370
414
  textAnchor: labelStyle.textAnchor || defaultTextAnchors[orientation],
371
415
  verticalAnchor: labelStyle.verticalAnchor || defaultVerticalAnchors[orientation],
372
416
  angle: labelStyle.angle,
373
- horizontal,
374
- disableInlineStyles
417
+ horizontal: horizontal,
418
+ disableInlineStyles: disableInlineStyles
375
419
  };
376
- const component = props[`${type}LabelComponent`];
420
+ var component = props["".concat(type, "LabelComponent")];
421
+
377
422
  if (!_victoryCore.Helpers.isTooltip(component)) {
378
423
  return labelProps;
379
424
  }
380
- const tooltipTheme = theme && theme.tooltip || {};
425
+
426
+ var tooltipTheme = theme && theme.tooltip || {};
381
427
  return (0, _defaults2.default)({}, labelProps, _victoryCore.Helpers.omit(tooltipTheme, ["style"]));
382
428
  };
383
- const getDataProps = (props, type) => {
429
+
430
+ var getDataProps = function (props, type) {
384
431
  if (type === "median") {
385
432
  return getMedianProps(props);
386
433
  } else if (type === "min" || type === "max") {
387
434
  return getWhiskerProps(props, type);
388
435
  }
436
+
389
437
  return getBoxProps(props, type);
390
- };
438
+ }; // if all data points on an axis are out of bound of the domain, filter out this datum
439
+
440
+
441
+ var isDatumOutOfBounds = function (datum, domain) {
442
+ var exists = function (val) {
443
+ return val !== undefined;
444
+ };
445
+
446
+ var _x = datum._x,
447
+ _min = datum._min,
448
+ _max = datum._max;
449
+
450
+ var minDomainX = _victoryCore.Collection.getMinValue(domain.x);
451
+
452
+ var maxDomainX = _victoryCore.Collection.getMaxValue(domain.x);
453
+
454
+ var minDomainY = _victoryCore.Collection.getMinValue(domain.y);
455
+
456
+ var maxDomainY = _victoryCore.Collection.getMaxValue(domain.y);
457
+
458
+ var underMin = function (min) {
459
+ return function (val) {
460
+ return exists(val) && val < min;
461
+ };
462
+ };
463
+
464
+ var overMax = function (max) {
465
+ return function (val) {
466
+ return exists(val) && val > max;
467
+ };
468
+ };
469
+
470
+ var isUnderMinX = underMin(minDomainX);
471
+ var isUnderMinY = underMin(minDomainY);
472
+ var isOverMaxX = overMax(maxDomainX);
473
+ var isOverMaxY = overMax(maxDomainY);
474
+ var yOutOfBounds;
475
+ var xOutOfBounds; // if x is out of the bounds of the domain
476
+
477
+ if (isUnderMinX(_x) || isOverMaxX(_x)) xOutOfBounds = true; // if min/max are out of the bounds of the domain
391
478
 
392
- // if all data points on an axis are out of bound of the domain, filter out this datum
393
- const isDatumOutOfBounds = (datum, domain) => {
394
- const exists = val => val !== undefined;
395
- const {
396
- _x,
397
- _min,
398
- _max
399
- } = datum;
400
- const minDomainX = _victoryCore.Collection.getMinValue(domain.x);
401
- const maxDomainX = _victoryCore.Collection.getMaxValue(domain.x);
402
- const minDomainY = _victoryCore.Collection.getMinValue(domain.y);
403
- const maxDomainY = _victoryCore.Collection.getMaxValue(domain.y);
404
- const underMin = min => val => exists(val) && val < min;
405
- const overMax = max => val => exists(val) && val > max;
406
- const isUnderMinX = underMin(minDomainX);
407
- const isUnderMinY = underMin(minDomainY);
408
- const isOverMaxX = overMax(maxDomainX);
409
- const isOverMaxY = overMax(maxDomainY);
410
- let yOutOfBounds;
411
- let xOutOfBounds;
412
-
413
- // if x is out of the bounds of the domain
414
- if (isUnderMinX(_x) || isOverMaxX(_x)) xOutOfBounds = true;
415
- // if min/max are out of the bounds of the domain
416
479
  if (isUnderMinY(_min) && isUnderMinY(_max) || isOverMaxY(_min) && isOverMaxY(_max)) yOutOfBounds = true;
417
480
  return yOutOfBounds || xOutOfBounds;
418
481
  };
419
- const getBaseProps = (initialProps, fallbackProps) => {
420
- const modifiedProps = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "boxplot");
421
- const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
422
- const {
423
- groupComponent,
424
- width,
425
- height,
426
- padding,
427
- standalone,
428
- theme,
429
- events,
430
- sharedEvents,
431
- scale,
432
- horizontal,
433
- data,
434
- style,
435
- domain,
436
- name
437
- } = props;
438
- const initialChildProps = {
482
+
483
+ var getBaseProps = function (initialProps, fallbackProps) {
484
+ var modifiedProps = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "boxplot");
485
+
486
+ var props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
487
+ var groupComponent = props.groupComponent,
488
+ width = props.width,
489
+ height = props.height,
490
+ padding = props.padding,
491
+ standalone = props.standalone,
492
+ theme = props.theme,
493
+ events = props.events,
494
+ sharedEvents = props.sharedEvents,
495
+ scale = props.scale,
496
+ horizontal = props.horizontal,
497
+ data = props.data,
498
+ style = props.style,
499
+ domain = props.domain,
500
+ name = props.name;
501
+ var initialChildProps = {
439
502
  parent: {
440
- domain,
441
- scale,
442
- width,
443
- height,
444
- data,
445
- standalone,
446
- name,
447
- theme,
503
+ domain: domain,
504
+ scale: scale,
505
+ width: width,
506
+ height: height,
507
+ data: data,
508
+ standalone: standalone,
509
+ name: name,
510
+ theme: theme,
448
511
  style: style.parent || {},
449
- padding,
450
- groupComponent,
451
- horizontal
512
+ padding: padding,
513
+ groupComponent: groupComponent,
514
+ horizontal: horizontal
452
515
  }
453
516
  };
454
- const boxScale = scale.y;
455
- return data.reduce((acc, datum, index) => {
456
- const eventKey = !_victoryCore.Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
517
+ var boxScale = scale.y;
518
+ return data.reduce(function (acc, datum, index) {
519
+ var eventKey = !_victoryCore.Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
457
520
  if (isDatumOutOfBounds(datum, domain)) return acc;
458
- const positions = {
521
+ var positions = {
459
522
  x: horizontal ? scale.y(datum._y) : scale.x(datum._x),
460
523
  y: horizontal ? scale.x(datum._x) : scale.y(datum._y),
461
524
  min: boxScale(datum._min),
@@ -464,25 +527,27 @@ const getBaseProps = (initialProps, fallbackProps) => {
464
527
  q1: boxScale(datum._q1),
465
528
  q3: boxScale(datum._q3)
466
529
  };
467
- const dataProps = Object.assign({
468
- index,
469
- datum,
470
- positions
530
+ var dataProps = Object.assign({
531
+ index: index,
532
+ datum: datum,
533
+ positions: positions
471
534
  }, props);
472
- const dataObj = TYPES.reduce((memo, type) => {
535
+ var dataObj = TYPES.reduce(function (memo, type) {
473
536
  memo[type] = getDataProps(dataProps, type);
474
537
  return memo;
475
538
  }, {});
476
539
  acc[eventKey] = dataObj;
477
- TYPES.forEach(type => {
478
- const labelText = getText(dataProps, type);
479
- const labelProp = props.labels || props[`${type}Labels`];
540
+ TYPES.forEach(function (type) {
541
+ var labelText = getText(dataProps, type);
542
+ var labelProp = props.labels || props["".concat(type, "Labels")];
543
+
480
544
  if (labelText !== null && labelText !== undefined || labelProp && (events || sharedEvents)) {
481
- const target = `${type}Labels`;
545
+ var target = "".concat(type, "Labels");
482
546
  acc[eventKey][target] = getLabelProps(Object.assign({}, props, dataProps), labelText, type);
483
547
  }
484
548
  });
485
549
  return acc;
486
550
  }, initialChildProps);
487
551
  };
552
+
488
553
  exports.getBaseProps = getBaseProps;