victory-box-plot 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.
- package/CHANGELOG.md +6 -0
- package/dist/victory-box-plot.js +3764 -4910
- package/dist/victory-box-plot.min.js +1 -1
- package/es/helper-methods.js +268 -320
- package/es/victory-box-plot.js +87 -151
- package/lib/helper-methods.js +268 -334
- package/lib/index.js +0 -2
- package/lib/victory-box-plot.js +87 -158
- package/package.json +3 -3
package/es/victory-box-plot.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
|
-
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."); }
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
-
|
|
15
|
-
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); } }
|
|
16
|
-
|
|
17
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
-
|
|
19
|
-
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); }
|
|
20
|
-
|
|
21
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
-
|
|
23
|
-
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); }; }
|
|
24
|
-
|
|
25
|
-
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); }
|
|
26
|
-
|
|
27
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
|
-
|
|
29
|
-
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; } }
|
|
30
|
-
|
|
31
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
32
|
-
|
|
33
1
|
import React from "react";
|
|
34
2
|
import { Helpers, VictoryLabel, addEvents, LineSegment, VictoryContainer, VictoryTheme, Box, Whisker, DefaultTransitions, UserProps } from "victory-core";
|
|
35
3
|
import { getDomain, getData, getBaseProps } from "./helper-methods";
|
|
36
|
-
|
|
4
|
+
const fallbackProps = {
|
|
37
5
|
width: 450,
|
|
38
6
|
height: 300,
|
|
39
7
|
padding: {
|
|
@@ -43,7 +11,7 @@ var fallbackProps = {
|
|
|
43
11
|
left: 20
|
|
44
12
|
}
|
|
45
13
|
};
|
|
46
|
-
|
|
14
|
+
const defaultData = [{
|
|
47
15
|
x: 1,
|
|
48
16
|
min: 5,
|
|
49
17
|
q1: 7,
|
|
@@ -58,7 +26,7 @@ var defaultData = [{
|
|
|
58
26
|
q3: 12,
|
|
59
27
|
max: 15
|
|
60
28
|
}];
|
|
61
|
-
|
|
29
|
+
const options = {
|
|
62
30
|
components: [{
|
|
63
31
|
name: "min"
|
|
64
32
|
}, {
|
|
@@ -85,122 +53,90 @@ var options = {
|
|
|
85
53
|
}]
|
|
86
54
|
};
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
57
|
+
|
|
58
|
+
class VictoryBoxPlotBase extends React.Component {
|
|
59
|
+
static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
|
|
60
|
+
static displayName = "VictoryBoxPlot";
|
|
61
|
+
static role = "boxplot";
|
|
62
|
+
static defaultTransitions = DefaultTransitions.discreteTransitions();
|
|
63
|
+
static defaultProps = {
|
|
64
|
+
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
65
|
+
data: defaultData,
|
|
66
|
+
dataComponent: /*#__PURE__*/React.createElement(Box, null),
|
|
67
|
+
groupComponent: /*#__PURE__*/React.createElement("g", {
|
|
68
|
+
role: "presentation"
|
|
69
|
+
}),
|
|
70
|
+
maxComponent: /*#__PURE__*/React.createElement(Whisker, null),
|
|
71
|
+
maxLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
72
|
+
medianComponent: /*#__PURE__*/React.createElement(LineSegment, null),
|
|
73
|
+
medianLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
74
|
+
minComponent: /*#__PURE__*/React.createElement(Whisker, null),
|
|
75
|
+
minLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
76
|
+
q1Component: /*#__PURE__*/React.createElement(Box, null),
|
|
77
|
+
q1LabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
78
|
+
q3Component: /*#__PURE__*/React.createElement(Box, null),
|
|
79
|
+
q3LabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
80
|
+
samples: 50,
|
|
81
|
+
sortKey: "x",
|
|
82
|
+
sortOrder: "ascending",
|
|
83
|
+
standalone: true,
|
|
84
|
+
theme: VictoryTheme.grayscale
|
|
85
|
+
};
|
|
86
|
+
static getDomain = getDomain;
|
|
87
|
+
static getData = getData;
|
|
88
|
+
static getBaseProps = props => getBaseProps(props, fallbackProps);
|
|
89
|
+
static expectedComponents = ["maxComponent", "maxLabelComponent", "medianComponent", "medianLabelComponent", "minComponent", "minLabelComponent", "q1Component", "q1LabelComponent", "q3Component", "q3LabelComponent", "groupComponent", "containerComponent"];
|
|
90
|
+
renderBoxPlot(props) {
|
|
91
|
+
const types = ["q1", "q3", "max", "min", "median"];
|
|
92
|
+
const dataComponents = types.map(type => {
|
|
93
|
+
return this.dataKeys.reduce((validDataComponents, _key, index) => {
|
|
94
|
+
const baseComponent = props[`${type}Component`];
|
|
95
|
+
const componentProps = this.getComponentProps(baseComponent, type, index);
|
|
96
|
+
if (this.shouldRenderDatum(componentProps.datum)) {
|
|
97
|
+
validDataComponents.push( /*#__PURE__*/React.cloneElement(baseComponent, componentProps));
|
|
98
|
+
}
|
|
99
|
+
return validDataComponents;
|
|
100
|
+
}, []);
|
|
101
|
+
}).flat();
|
|
102
|
+
const labelComponents = types.map(type => {
|
|
103
|
+
const components = this.dataKeys.reduce((validComponents, _key, index) => {
|
|
104
|
+
const name = `${type}Labels`;
|
|
105
|
+
const baseComponent = props[`${type}LabelComponent`];
|
|
106
|
+
const labelProps = this.getComponentProps(baseComponent, name, index);
|
|
107
|
+
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
108
|
+
validComponents.push( /*#__PURE__*/React.cloneElement(baseComponent, labelProps));
|
|
109
|
+
}
|
|
110
|
+
return validComponents;
|
|
111
|
+
}, []);
|
|
112
|
+
return components.filter(Boolean);
|
|
113
|
+
}).flat();
|
|
114
|
+
const children = [...dataComponents, ...labelComponents];
|
|
115
|
+
return this.renderContainer(props.groupComponent, children);
|
|
97
116
|
}
|
|
98
117
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}).flat();
|
|
118
|
-
var labelComponents = types.map(function (type) {
|
|
119
|
-
var components = _this.dataKeys.reduce(function (validComponents, _key, index) {
|
|
120
|
-
var name = "".concat(type, "Labels");
|
|
121
|
-
var baseComponent = props["".concat(type, "LabelComponent")];
|
|
122
|
-
|
|
123
|
-
var labelProps = _this.getComponentProps(baseComponent, name, index);
|
|
124
|
-
|
|
125
|
-
if (labelProps.text !== undefined && labelProps.text !== null) {
|
|
126
|
-
validComponents.push( /*#__PURE__*/React.cloneElement(baseComponent, labelProps));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return validComponents;
|
|
130
|
-
}, []);
|
|
131
|
-
|
|
132
|
-
return components.filter(Boolean);
|
|
133
|
-
}).flat();
|
|
134
|
-
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
|
|
135
|
-
return this.renderContainer(props.groupComponent, children);
|
|
136
|
-
} // Overridden in native versions
|
|
137
|
-
|
|
138
|
-
}, {
|
|
139
|
-
key: "shouldAnimate",
|
|
140
|
-
value: function shouldAnimate() {
|
|
141
|
-
return !!this.props.animate;
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: "shouldRenderDatum",
|
|
145
|
-
value: function shouldRenderDatum(datum) {
|
|
146
|
-
var hasX = !Helpers.isNil(datum._x);
|
|
147
|
-
var hasY = !Helpers.isNil(datum._y);
|
|
148
|
-
var hasSummaryStatistics = !Helpers.isNil(datum._min) && !Helpers.isNil(datum._max) && !Helpers.isNil(datum._median) && !Helpers.isNil(datum._q1) && !Helpers.isNil(datum._q3);
|
|
149
|
-
return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "render",
|
|
153
|
-
value: function render() {
|
|
154
|
-
var animationWhitelist = VictoryBoxPlot.animationWhitelist,
|
|
155
|
-
role = VictoryBoxPlot.role;
|
|
156
|
-
var props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
157
|
-
|
|
158
|
-
if (this.shouldAnimate()) {
|
|
159
|
-
return this.animateComponent(props, animationWhitelist);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
var children = this.renderBoxPlot(props);
|
|
163
|
-
var component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
164
|
-
return UserProps.withSafeUserProps(component, props);
|
|
118
|
+
// Overridden in native versions
|
|
119
|
+
shouldAnimate() {
|
|
120
|
+
return !!this.props.animate;
|
|
121
|
+
}
|
|
122
|
+
shouldRenderDatum(datum) {
|
|
123
|
+
const hasX = !Helpers.isNil(datum._x);
|
|
124
|
+
const hasY = !Helpers.isNil(datum._y);
|
|
125
|
+
const hasSummaryStatistics = !Helpers.isNil(datum._min) && !Helpers.isNil(datum._max) && !Helpers.isNil(datum._median) && !Helpers.isNil(datum._q1) && !Helpers.isNil(datum._q3);
|
|
126
|
+
return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
|
|
127
|
+
}
|
|
128
|
+
render() {
|
|
129
|
+
const {
|
|
130
|
+
animationWhitelist,
|
|
131
|
+
role
|
|
132
|
+
} = VictoryBoxPlot;
|
|
133
|
+
const props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
134
|
+
if (this.shouldAnimate()) {
|
|
135
|
+
return this.animateComponent(props, animationWhitelist);
|
|
165
136
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
VictoryBoxPlotBase.displayName = "VictoryBoxPlot";
|
|
173
|
-
VictoryBoxPlotBase.role = "boxplot";
|
|
174
|
-
VictoryBoxPlotBase.defaultTransitions = DefaultTransitions.discreteTransitions();
|
|
175
|
-
VictoryBoxPlotBase.defaultProps = {
|
|
176
|
-
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
177
|
-
data: defaultData,
|
|
178
|
-
dataComponent: /*#__PURE__*/React.createElement(Box, null),
|
|
179
|
-
groupComponent: /*#__PURE__*/React.createElement("g", {
|
|
180
|
-
role: "presentation"
|
|
181
|
-
}),
|
|
182
|
-
maxComponent: /*#__PURE__*/React.createElement(Whisker, null),
|
|
183
|
-
maxLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
184
|
-
medianComponent: /*#__PURE__*/React.createElement(LineSegment, null),
|
|
185
|
-
medianLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
186
|
-
minComponent: /*#__PURE__*/React.createElement(Whisker, null),
|
|
187
|
-
minLabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
188
|
-
q1Component: /*#__PURE__*/React.createElement(Box, null),
|
|
189
|
-
q1LabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
190
|
-
q3Component: /*#__PURE__*/React.createElement(Box, null),
|
|
191
|
-
q3LabelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
|
|
192
|
-
samples: 50,
|
|
193
|
-
sortKey: "x",
|
|
194
|
-
sortOrder: "ascending",
|
|
195
|
-
standalone: true,
|
|
196
|
-
theme: VictoryTheme.grayscale
|
|
197
|
-
};
|
|
198
|
-
VictoryBoxPlotBase.getDomain = getDomain;
|
|
199
|
-
VictoryBoxPlotBase.getData = getData;
|
|
200
|
-
|
|
201
|
-
VictoryBoxPlotBase.getBaseProps = function (props) {
|
|
202
|
-
return getBaseProps(props, fallbackProps);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
VictoryBoxPlotBase.expectedComponents = ["maxComponent", "maxLabelComponent", "medianComponent", "medianLabelComponent", "minComponent", "minLabelComponent", "q1Component", "q1LabelComponent", "q3Component", "q3LabelComponent", "groupComponent", "containerComponent"];
|
|
206
|
-
export var VictoryBoxPlot = addEvents(VictoryBoxPlotBase, options);
|
|
137
|
+
const children = this.renderBoxPlot(props);
|
|
138
|
+
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
|
|
139
|
+
return UserProps.withSafeUserProps(component, props);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export const VictoryBoxPlot = addEvents(VictoryBoxPlotBase, options);
|