victory-box-plot 36.9.1-next.0 → 36.9.2-next.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.
package/lib/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _victoryBoxPlot = require("./victory-box-plot");
8
-
9
7
  Object.keys(_victoryBoxPlot).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _victoryBoxPlot[key]) return;
@@ -4,52 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VictoryBoxPlot = void 0;
7
-
8
- var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
9
-
10
7
  var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
11
-
12
8
  var _react = _interopRequireDefault(require("react"));
13
-
14
9
  var _victoryCore = require("victory-core");
15
-
16
10
  var _helperMethods = require("./helper-methods");
17
-
18
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
-
22
- 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."); }
23
-
24
- 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); }
25
-
26
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
27
-
28
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
-
30
- 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; }
31
-
32
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
-
34
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
-
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
-
38
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
-
40
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
-
42
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
43
-
44
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
45
-
46
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
-
48
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
49
-
50
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
51
-
52
- var fallbackProps = {
12
+ const fallbackProps = {
53
13
  width: 450,
54
14
  height: 300,
55
15
  padding: {
@@ -59,7 +19,7 @@ var fallbackProps = {
59
19
  left: 20
60
20
  }
61
21
  };
62
- var defaultData = [{
22
+ const defaultData = [{
63
23
  x: 1,
64
24
  min: 5,
65
25
  q1: 7,
@@ -74,7 +34,7 @@ var defaultData = [{
74
34
  q3: 12,
75
35
  max: 15
76
36
  }];
77
- var options = {
37
+ const options = {
78
38
  components: [{
79
39
  name: "min"
80
40
  }, {
@@ -101,124 +61,90 @@ var options = {
101
61
  }]
102
62
  };
103
63
 
104
- var VictoryBoxPlotBase = /*#__PURE__*/function (_React$Component) {
105
- _inherits(VictoryBoxPlotBase, _React$Component);
106
-
107
- var _super = _createSuper(VictoryBoxPlotBase);
108
-
109
- function VictoryBoxPlotBase() {
110
- _classCallCheck(this, VictoryBoxPlotBase);
111
-
112
- return _super.apply(this, arguments);
64
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
65
+
66
+ class VictoryBoxPlotBase extends _react.default.Component {
67
+ static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
68
+ static displayName = "VictoryBoxPlot";
69
+ static role = "boxplot";
70
+ static defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
71
+ static defaultProps = {
72
+ containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
73
+ data: defaultData,
74
+ dataComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
75
+ groupComponent: /*#__PURE__*/_react.default.createElement("g", {
76
+ role: "presentation"
77
+ }),
78
+ maxComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Whisker, null),
79
+ maxLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
80
+ medianComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.LineSegment, null),
81
+ medianLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
82
+ minComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Whisker, null),
83
+ minLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
84
+ q1Component: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
85
+ q1LabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
86
+ q3Component: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
87
+ q3LabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
88
+ samples: 50,
89
+ sortKey: "x",
90
+ sortOrder: "ascending",
91
+ standalone: true,
92
+ theme: _victoryCore.VictoryTheme.grayscale
93
+ };
94
+ static getDomain = _helperMethods.getDomain;
95
+ static getData = _helperMethods.getData;
96
+ static getBaseProps = props => (0, _helperMethods.getBaseProps)(props, fallbackProps);
97
+ static expectedComponents = ["maxComponent", "maxLabelComponent", "medianComponent", "medianLabelComponent", "minComponent", "minLabelComponent", "q1Component", "q1LabelComponent", "q3Component", "q3LabelComponent", "groupComponent", "containerComponent"];
98
+ renderBoxPlot(props) {
99
+ const types = ["q1", "q3", "max", "min", "median"];
100
+ const dataComponents = (0, _flatten2.default)(types.map(type => {
101
+ return this.dataKeys.reduce((validDataComponents, _key, index) => {
102
+ const baseComponent = props[`${type}Component`];
103
+ const componentProps = this.getComponentProps(baseComponent, type, index);
104
+ if (this.shouldRenderDatum(componentProps.datum)) {
105
+ validDataComponents.push( /*#__PURE__*/_react.default.cloneElement(baseComponent, componentProps));
106
+ }
107
+ return validDataComponents;
108
+ }, []);
109
+ }));
110
+ const labelComponents = (0, _flatten2.default)(types.map(type => {
111
+ const components = this.dataKeys.reduce((validComponents, _key, index) => {
112
+ const name = `${type}Labels`;
113
+ const baseComponent = props[`${type}LabelComponent`];
114
+ const labelProps = this.getComponentProps(baseComponent, name, index);
115
+ if (labelProps.text !== undefined && labelProps.text !== null) {
116
+ validComponents.push( /*#__PURE__*/_react.default.cloneElement(baseComponent, labelProps));
117
+ }
118
+ return validComponents;
119
+ }, []);
120
+ return components.filter(Boolean);
121
+ }));
122
+ const children = [...dataComponents, ...labelComponents];
123
+ return this.renderContainer(props.groupComponent, children);
113
124
  }
114
125
 
115
- _createClass(VictoryBoxPlotBase, [{
116
- key: "renderBoxPlot",
117
- value: function renderBoxPlot(props) {
118
- var _this = this;
119
-
120
- var types = ["q1", "q3", "max", "min", "median"];
121
- var dataComponents = (0, _flatten2.default)(types.map(function (type) {
122
- return _this.dataKeys.reduce(function (validDataComponents, _key, index) {
123
- var baseComponent = props["".concat(type, "Component")];
124
-
125
- var componentProps = _this.getComponentProps(baseComponent, type, index);
126
-
127
- if (_this.shouldRenderDatum(componentProps.datum)) {
128
- validDataComponents.push( /*#__PURE__*/_react.default.cloneElement(baseComponent, componentProps));
129
- }
130
-
131
- return validDataComponents;
132
- }, []);
133
- }));
134
- var labelComponents = (0, _flatten2.default)(types.map(function (type) {
135
- var components = _this.dataKeys.reduce(function (validComponents, _key, index) {
136
- var name = "".concat(type, "Labels");
137
- var baseComponent = props["".concat(type, "LabelComponent")];
138
-
139
- var labelProps = _this.getComponentProps(baseComponent, name, index);
140
-
141
- if (labelProps.text !== undefined && labelProps.text !== null) {
142
- validComponents.push( /*#__PURE__*/_react.default.cloneElement(baseComponent, labelProps));
143
- }
144
-
145
- return validComponents;
146
- }, []);
147
-
148
- return components.filter(Boolean);
149
- }));
150
- var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
151
- return this.renderContainer(props.groupComponent, children);
152
- } // Overridden in native versions
153
-
154
- }, {
155
- key: "shouldAnimate",
156
- value: function shouldAnimate() {
157
- return !!this.props.animate;
158
- }
159
- }, {
160
- key: "shouldRenderDatum",
161
- value: function shouldRenderDatum(datum) {
162
- var hasX = !(0, _isNil2.default)(datum._x);
163
- var hasY = !(0, _isNil2.default)(datum._y);
164
- var hasSummaryStatistics = !(0, _isNil2.default)(datum._min) && !(0, _isNil2.default)(datum._max) && !(0, _isNil2.default)(datum._median) && !(0, _isNil2.default)(datum._q1) && !(0, _isNil2.default)(datum._q3);
165
- return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
166
- }
167
- }, {
168
- key: "render",
169
- value: function render() {
170
- var animationWhitelist = VictoryBoxPlot.animationWhitelist,
171
- role = VictoryBoxPlot.role;
172
-
173
- var props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
174
-
175
- if (this.shouldAnimate()) {
176
- return this.animateComponent(props, animationWhitelist);
177
- }
178
-
179
- var children = this.renderBoxPlot(props);
180
- var component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
181
- return _victoryCore.UserProps.withSafeUserProps(component, props);
126
+ // Overridden in native versions
127
+ shouldAnimate() {
128
+ return !!this.props.animate;
129
+ }
130
+ shouldRenderDatum(datum) {
131
+ const hasX = !_victoryCore.Helpers.isNil(datum._x);
132
+ const hasY = !_victoryCore.Helpers.isNil(datum._y);
133
+ const hasSummaryStatistics = !_victoryCore.Helpers.isNil(datum._min) && !_victoryCore.Helpers.isNil(datum._max) && !_victoryCore.Helpers.isNil(datum._median) && !_victoryCore.Helpers.isNil(datum._q1) && !_victoryCore.Helpers.isNil(datum._q3);
134
+ return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
135
+ }
136
+ render() {
137
+ const {
138
+ animationWhitelist,
139
+ role
140
+ } = VictoryBoxPlot;
141
+ const props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
142
+ if (this.shouldAnimate()) {
143
+ return this.animateComponent(props, animationWhitelist);
182
144
  }
183
- }]);
184
-
185
- return VictoryBoxPlotBase;
186
- }(_react.default.Component);
187
-
188
- VictoryBoxPlotBase.animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
189
- VictoryBoxPlotBase.displayName = "VictoryBoxPlot";
190
- VictoryBoxPlotBase.role = "boxplot";
191
- VictoryBoxPlotBase.defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
192
- VictoryBoxPlotBase.defaultProps = {
193
- containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
194
- data: defaultData,
195
- dataComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
196
- groupComponent: /*#__PURE__*/_react.default.createElement("g", {
197
- role: "presentation"
198
- }),
199
- maxComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Whisker, null),
200
- maxLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
201
- medianComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.LineSegment, null),
202
- medianLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
203
- minComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Whisker, null),
204
- minLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
205
- q1Component: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
206
- q1LabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
207
- q3Component: /*#__PURE__*/_react.default.createElement(_victoryCore.Box, null),
208
- q3LabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
209
- samples: 50,
210
- sortKey: "x",
211
- sortOrder: "ascending",
212
- standalone: true,
213
- theme: _victoryCore.VictoryTheme.grayscale
214
- };
215
- VictoryBoxPlotBase.getDomain = _helperMethods.getDomain;
216
- VictoryBoxPlotBase.getData = _helperMethods.getData;
217
-
218
- VictoryBoxPlotBase.getBaseProps = function (props) {
219
- return (0, _helperMethods.getBaseProps)(props, fallbackProps);
220
- };
221
-
222
- VictoryBoxPlotBase.expectedComponents = ["maxComponent", "maxLabelComponent", "medianComponent", "medianLabelComponent", "minComponent", "minLabelComponent", "q1Component", "q1LabelComponent", "q3Component", "q3LabelComponent", "groupComponent", "containerComponent"];
223
- var VictoryBoxPlot = (0, _victoryCore.addEvents)(VictoryBoxPlotBase, options);
224
- exports.VictoryBoxPlot = VictoryBoxPlot;
145
+ const children = this.renderBoxPlot(props);
146
+ const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
147
+ return _victoryCore.UserProps.withSafeUserProps(component, props);
148
+ }
149
+ }
150
+ const VictoryBoxPlot = exports.VictoryBoxPlot = (0, _victoryCore.addEvents)(VictoryBoxPlotBase, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-box-plot",
3
- "version": "36.9.1-next.0",
3
+ "version": "36.9.2-next.0",
4
4
  "description": "Box Plot Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -21,15 +21,14 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
- "victory-core": "^36.9.1-next.0",
25
- "victory-vendor": "^36.9.1-next.0"
24
+ "victory-core": "^36.9.2-next.0",
25
+ "victory-vendor": "^36.9.2-next.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=16.6.0"
29
29
  },
30
30
  "devDependencies": {
31
- "victory-box-plot": "36.9.1-next.0",
32
- "victory-chart": "^36.9.1-next.0"
31
+ "victory-chart": "36.9.2-next.0"
33
32
  },
34
33
  "wireit": {
35
34
  "### THESE WIREIT CONFIGS ARE GENERATED ####": {},
@@ -253,7 +252,7 @@
253
252
  ]
254
253
  },
255
254
  "jest": {
256
- "command": "nps jest:pkg",
255
+ "command": "jest --passWithNoTests",
257
256
  "files": [
258
257
  "src/**/*.test.*",
259
258
  "../../.babelrc.js",
@@ -262,10 +261,10 @@
262
261
  ],
263
262
  "output": [],
264
263
  "dependencies": [
265
- "build:lib:cjs",
266
- "../victory-chart:build:lib:cjs",
267
- "../victory-vendor:build:lib:cjs",
268
- "../victory-voronoi:build:lib:cjs"
264
+ "../victory-core:build",
265
+ "../victory-vendor:build",
266
+ "../victory-chart:build",
267
+ "../victory-voronoi:build"
269
268
  ],
270
269
  "packageLocks": [
271
270
  "pnpm-lock.yaml"
@@ -1,4 +1,4 @@
1
- import { orderBy, defaults, uniq, groupBy, keys, isNaN, isNil } from "lodash";
1
+ import { orderBy, defaults, uniq, groupBy, keys } from "lodash";
2
2
  import { Helpers, Scale, Domain, Data, Collection } from "victory-core";
3
3
  import {
4
4
  min as d3Min,
@@ -30,7 +30,7 @@ const checkProcessedData = (data) => {
30
30
  return false;
31
31
  };
32
32
 
33
- const nanToNull = (val) => (isNaN(val) ? null : val);
33
+ const nanToNull = (val) => (Number.isNaN(val) ? null : val);
34
34
 
35
35
  const getSummaryStatistics = (data) => {
36
36
  const dependentVars = data.map((datum) => datum._y);
@@ -493,7 +493,7 @@ export const getBaseProps = (initialProps, fallbackProps) => {
493
493
  };
494
494
  const boxScale = scale.y;
495
495
  return data.reduce((acc, datum, index) => {
496
- const eventKey = !isNil(datum.eventKey) ? datum.eventKey : index;
496
+ const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
497
497
 
498
498
  if (isDatumOutOfBounds(datum, domain)) return acc;
499
499
 
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { flatten, isNil } from "lodash";
2
+ import { flatten } from "lodash";
3
3
  import {
4
4
  Helpers,
5
5
  VictoryLabel,
@@ -234,14 +234,14 @@ class VictoryBoxPlotBase extends React.Component<VictoryBoxPlotProps> {
234
234
  }
235
235
 
236
236
  shouldRenderDatum(datum) {
237
- const hasX = !isNil(datum._x);
238
- const hasY = !isNil(datum._y);
237
+ const hasX = !Helpers.isNil(datum._x);
238
+ const hasY = !Helpers.isNil(datum._y);
239
239
  const hasSummaryStatistics =
240
- !isNil(datum._min) &&
241
- !isNil(datum._max) &&
242
- !isNil(datum._median) &&
243
- !isNil(datum._q1) &&
244
- !isNil(datum._q3);
240
+ !Helpers.isNil(datum._min) &&
241
+ !Helpers.isNil(datum._max) &&
242
+ !Helpers.isNil(datum._median) &&
243
+ !Helpers.isNil(datum._q1) &&
244
+ !Helpers.isNil(datum._q3);
245
245
 
246
246
  return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
247
247
  }