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