victory-chart 30.6.1 → 31.2.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/README.md +29 -31
- package/dist/victory-chart.js +1899 -1643
- package/dist/victory-chart.min.js +1 -1
- package/es/helper-methods.js +17 -29
- package/es/victory-chart.js +14 -15
- package/lib/helper-methods.js +17 -30
- package/lib/victory-chart.js +17 -15
- package/package.json +5 -5
- package/src/helper-methods.js +81 -73
- package/src/victory-chart.js +48 -34
package/es/helper-methods.js
CHANGED
|
@@ -5,7 +5,7 @@ import _defaults from "lodash/defaults";
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable no-use-before-define */
|
|
7
7
|
import React from "react";
|
|
8
|
-
import {
|
|
8
|
+
import { Helpers, Scale, Axis, Wrapper } from "victory-core";
|
|
9
9
|
|
|
10
10
|
function getAxisProps(child, props, calculatedProps) {
|
|
11
11
|
var domain = calculatedProps.domain,
|
|
@@ -24,7 +24,8 @@ function getAxisProps(child, props, calculatedProps) {
|
|
|
24
24
|
var crossAxis = childProps.crossAxis === false ? false : true;
|
|
25
25
|
var orientation = Axis.getOrientation(child, axis, originSign[otherAxis]);
|
|
26
26
|
return {
|
|
27
|
-
stringMap: stringMap
|
|
27
|
+
stringMap: stringMap,
|
|
28
|
+
horizontal: horizontal,
|
|
28
29
|
categories: categories[currentAxis],
|
|
29
30
|
startAngle: props.startAngle,
|
|
30
31
|
endAngle: props.endAngle,
|
|
@@ -72,14 +73,8 @@ function getCalculatedProps(props, childComponents) {
|
|
|
72
73
|
var style = getStyles(props);
|
|
73
74
|
var horizontal = Helpers.isHorizontal(props); // TODO: check
|
|
74
75
|
|
|
75
|
-
var categories =
|
|
76
|
-
|
|
77
|
-
y: Wrapper.getCategories(props, "y", childComponents)
|
|
78
|
-
};
|
|
79
|
-
var stringMap = {
|
|
80
|
-
x: createStringMap(props, "x", childComponents),
|
|
81
|
-
y: createStringMap(props, "y", childComponents)
|
|
82
|
-
};
|
|
76
|
+
var categories = Wrapper.getCategories(props, childComponents);
|
|
77
|
+
var stringMap = createStringMap(props, childComponents);
|
|
83
78
|
var axisComponents = {
|
|
84
79
|
x: Axis.getAxisComponent(childComponents, "x"),
|
|
85
80
|
y: Axis.getAxisComponent(childComponents, "y")
|
|
@@ -181,22 +176,7 @@ var getChildComponents = function (props, defaultAxes) {
|
|
|
181
176
|
return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
|
|
182
177
|
}
|
|
183
178
|
|
|
184
|
-
|
|
185
|
-
return childComponents.filter(function (child) {
|
|
186
|
-
var role = child.type && child.type.role;
|
|
187
|
-
var childProps = child.props || {};
|
|
188
|
-
|
|
189
|
-
if (role !== "axis" || childProps.dependentAxis) {
|
|
190
|
-
return true;
|
|
191
|
-
} else if (axisCount < 1) {
|
|
192
|
-
axisCount++;
|
|
193
|
-
return true;
|
|
194
|
-
} else {
|
|
195
|
-
var msg = "Only one independent VictoryAxis component is allowed when " + "using the VictoryChart wrapper. Only the first axis will be used. Please compose " + "multi-axis charts manually";
|
|
196
|
-
Log.warn(msg);
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
179
|
+
return childComponents;
|
|
200
180
|
};
|
|
201
181
|
|
|
202
182
|
var getDefaultDomainPadding = function (childComponents, horizontal) {
|
|
@@ -265,12 +245,20 @@ var getAxisOffset = function (props, calculatedProps) {
|
|
|
265
245
|
};
|
|
266
246
|
};
|
|
267
247
|
|
|
268
|
-
var createStringMap = function (props,
|
|
269
|
-
var allStrings = Wrapper.getStringsFromChildren(props,
|
|
270
|
-
|
|
248
|
+
var createStringMap = function (props, childComponents) {
|
|
249
|
+
var allStrings = Wrapper.getStringsFromChildren(props, childComponents);
|
|
250
|
+
var x = !allStrings.x || allStrings.x.length === 0 ? null : allStrings.x.reduce(function (memo, string, index) {
|
|
251
|
+
memo[string] = index + 1;
|
|
252
|
+
return memo;
|
|
253
|
+
}, {});
|
|
254
|
+
var y = !allStrings.y || allStrings.y.length === 0 ? null : allStrings.y.reduce(function (memo, string, index) {
|
|
271
255
|
memo[string] = index + 1;
|
|
272
256
|
return memo;
|
|
273
257
|
}, {});
|
|
258
|
+
return {
|
|
259
|
+
x: x,
|
|
260
|
+
y: y
|
|
261
|
+
};
|
|
274
262
|
};
|
|
275
263
|
|
|
276
264
|
export { getChildren, getCalculatedProps, getChildComponents };
|
package/es/victory-chart.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isEmpty from "lodash/isEmpty";
|
|
1
2
|
import _assign from "lodash/assign";
|
|
2
3
|
import _defaults from "lodash/defaults";
|
|
3
4
|
|
|
@@ -24,6 +25,7 @@ import { VictorySharedEvents } from "victory-shared-events";
|
|
|
24
25
|
import { VictoryAxis } from "victory-axis";
|
|
25
26
|
import { VictoryPolarAxis } from "victory-polar-axis";
|
|
26
27
|
import { getChildComponents, getCalculatedProps, getChildren } from "./helper-methods";
|
|
28
|
+
import isEqual from "react-fast-compare";
|
|
27
29
|
var fallbackProps = {
|
|
28
30
|
width: 450,
|
|
29
31
|
height: 300,
|
|
@@ -49,28 +51,24 @@ function (_React$Component) {
|
|
|
49
51
|
nodesDoneLoad: false,
|
|
50
52
|
animating: true
|
|
51
53
|
};
|
|
54
|
+
_this.setAnimationState = Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
_this.setAnimationState = Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
|
|
55
|
-
_this.events = Wrapper.getAllEvents(props);
|
|
56
57
|
return _this;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
_createClass(VictoryChart, [{
|
|
60
|
-
key: "
|
|
61
|
-
value: function
|
|
62
|
-
this.events = Wrapper.getAllEvents(this.props);
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "componentWillReceiveProps",
|
|
66
|
-
value: function componentWillReceiveProps(nextProps) {
|
|
61
|
+
key: "shouldComponentUpdate",
|
|
62
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
67
63
|
if (this.props.animate) {
|
|
68
|
-
|
|
64
|
+
if (!isEqual(this.props, nextProps)) {
|
|
65
|
+
this.setAnimationState(this.props, nextProps);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
74
72
|
}, {
|
|
75
73
|
key: "getNewChildren",
|
|
76
74
|
value: function getNewChildren(props, childComponents, calculatedProps) {
|
|
@@ -137,12 +135,13 @@ function (_React$Component) {
|
|
|
137
135
|
var newChildren = this.getNewChildren(modifiedProps, childComponents, calculatedProps);
|
|
138
136
|
var containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
|
|
139
137
|
var container = standalone ? this.renderContainer(containerComponent, containerProps) : groupComponent;
|
|
138
|
+
var events = Wrapper.getAllEvents(props);
|
|
140
139
|
|
|
141
|
-
if (
|
|
140
|
+
if (!_isEmpty(events)) {
|
|
142
141
|
return React.createElement(VictorySharedEvents, {
|
|
143
142
|
container: container,
|
|
144
143
|
eventKey: eventKey,
|
|
145
|
-
events:
|
|
144
|
+
events: events,
|
|
146
145
|
externalEventMutations: externalEventMutations
|
|
147
146
|
}, newChildren);
|
|
148
147
|
}
|
package/lib/helper-methods.js
CHANGED
|
@@ -41,7 +41,8 @@ function getAxisProps(child, props, calculatedProps) {
|
|
|
41
41
|
var orientation = _victoryCore.Axis.getOrientation(child, axis, originSign[otherAxis]);
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
|
-
stringMap: stringMap
|
|
44
|
+
stringMap: stringMap,
|
|
45
|
+
horizontal: horizontal,
|
|
45
46
|
categories: categories[currentAxis],
|
|
46
47
|
startAngle: props.startAngle,
|
|
47
48
|
endAngle: props.endAngle,
|
|
@@ -91,14 +92,9 @@ function getCalculatedProps(props, childComponents) {
|
|
|
91
92
|
var horizontal = _victoryCore.Helpers.isHorizontal(props); // TODO: check
|
|
92
93
|
|
|
93
94
|
|
|
94
|
-
var categories =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
var stringMap = {
|
|
99
|
-
x: createStringMap(props, "x", childComponents),
|
|
100
|
-
y: createStringMap(props, "y", childComponents)
|
|
101
|
-
};
|
|
95
|
+
var categories = _victoryCore.Wrapper.getCategories(props, childComponents);
|
|
96
|
+
|
|
97
|
+
var stringMap = createStringMap(props, childComponents);
|
|
102
98
|
var axisComponents = {
|
|
103
99
|
x: _victoryCore.Axis.getAxisComponent(childComponents, "x"),
|
|
104
100
|
y: _victoryCore.Axis.getAxisComponent(childComponents, "y")
|
|
@@ -200,24 +196,7 @@ var getChildComponents = function (props, defaultAxes) {
|
|
|
200
196
|
return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
|
|
201
197
|
}
|
|
202
198
|
|
|
203
|
-
|
|
204
|
-
return childComponents.filter(function (child) {
|
|
205
|
-
var role = child.type && child.type.role;
|
|
206
|
-
var childProps = child.props || {};
|
|
207
|
-
|
|
208
|
-
if (role !== "axis" || childProps.dependentAxis) {
|
|
209
|
-
return true;
|
|
210
|
-
} else if (axisCount < 1) {
|
|
211
|
-
axisCount++;
|
|
212
|
-
return true;
|
|
213
|
-
} else {
|
|
214
|
-
var msg = "Only one independent VictoryAxis component is allowed when " + "using the VictoryChart wrapper. Only the first axis will be used. Please compose " + "multi-axis charts manually";
|
|
215
|
-
|
|
216
|
-
_victoryCore.Log.warn(msg);
|
|
217
|
-
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
});
|
|
199
|
+
return childComponents;
|
|
221
200
|
};
|
|
222
201
|
|
|
223
202
|
exports.getChildComponents = getChildComponents;
|
|
@@ -291,11 +270,19 @@ var getAxisOffset = function (props, calculatedProps) {
|
|
|
291
270
|
};
|
|
292
271
|
};
|
|
293
272
|
|
|
294
|
-
var createStringMap = function (props,
|
|
295
|
-
var allStrings = _victoryCore.Wrapper.getStringsFromChildren(props,
|
|
273
|
+
var createStringMap = function (props, childComponents) {
|
|
274
|
+
var allStrings = _victoryCore.Wrapper.getStringsFromChildren(props, childComponents);
|
|
296
275
|
|
|
297
|
-
|
|
276
|
+
var x = !allStrings.x || allStrings.x.length === 0 ? null : allStrings.x.reduce(function (memo, string, index) {
|
|
298
277
|
memo[string] = index + 1;
|
|
299
278
|
return memo;
|
|
300
279
|
}, {});
|
|
280
|
+
var y = !allStrings.y || allStrings.y.length === 0 ? null : allStrings.y.reduce(function (memo, string, index) {
|
|
281
|
+
memo[string] = index + 1;
|
|
282
|
+
return memo;
|
|
283
|
+
}, {});
|
|
284
|
+
return {
|
|
285
|
+
x: x,
|
|
286
|
+
y: y
|
|
287
|
+
};
|
|
301
288
|
};
|
package/lib/victory-chart.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
|
+
|
|
8
10
|
var _assign2 = _interopRequireDefault(require("lodash/assign"));
|
|
9
11
|
|
|
10
12
|
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
@@ -23,6 +25,8 @@ var _victoryPolarAxis = require("victory-polar-axis");
|
|
|
23
25
|
|
|
24
26
|
var _helperMethods = require("./helper-methods");
|
|
25
27
|
|
|
28
|
+
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
29
|
+
|
|
26
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
31
|
|
|
28
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
@@ -66,28 +70,24 @@ function (_React$Component) {
|
|
|
66
70
|
nodesDoneLoad: false,
|
|
67
71
|
animating: true
|
|
68
72
|
};
|
|
73
|
+
_this.setAnimationState = _victoryCore.Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
_this.setAnimationState = _victoryCore.Wrapper.setAnimationState.bind(_assertThisInitialized(_this));
|
|
72
|
-
_this.events = _victoryCore.Wrapper.getAllEvents(props);
|
|
73
76
|
return _this;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
_createClass(VictoryChart, [{
|
|
77
|
-
key: "
|
|
78
|
-
value: function
|
|
79
|
-
this.events = _victoryCore.Wrapper.getAllEvents(this.props);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "componentWillReceiveProps",
|
|
83
|
-
value: function componentWillReceiveProps(nextProps) {
|
|
80
|
+
key: "shouldComponentUpdate",
|
|
81
|
+
value: function shouldComponentUpdate(nextProps) {
|
|
84
82
|
if (this.props.animate) {
|
|
85
|
-
|
|
83
|
+
if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
|
|
84
|
+
this.setAnimationState(this.props, nextProps);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
91
|
}, {
|
|
92
92
|
key: "getNewChildren",
|
|
93
93
|
value: function getNewChildren(props, childComponents, calculatedProps) {
|
|
@@ -157,11 +157,13 @@ function (_React$Component) {
|
|
|
157
157
|
var containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
|
|
158
158
|
var container = standalone ? this.renderContainer(containerComponent, containerProps) : groupComponent;
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
var events = _victoryCore.Wrapper.getAllEvents(props);
|
|
161
|
+
|
|
162
|
+
if (!(0, _isEmpty2.default)(events)) {
|
|
161
163
|
return _react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
|
|
162
164
|
container: container,
|
|
163
165
|
eventKey: eventKey,
|
|
164
|
-
events:
|
|
166
|
+
events: events,
|
|
165
167
|
externalEventMutations: externalEventMutations
|
|
166
168
|
}, newChildren);
|
|
167
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-chart",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.2.0",
|
|
4
4
|
"description": "Chart Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"lodash": "^4.17.5",
|
|
23
23
|
"prop-types": "^15.5.8",
|
|
24
24
|
"react-fast-compare": "^2.0.0",
|
|
25
|
-
"victory-axis": "^
|
|
26
|
-
"victory-core": "^
|
|
27
|
-
"victory-polar-axis": "^
|
|
28
|
-
"victory-shared-events": "^
|
|
25
|
+
"victory-axis": "^31.2.0",
|
|
26
|
+
"victory-core": "^31.2.0",
|
|
27
|
+
"victory-polar-axis": "^31.2.0",
|
|
28
|
+
"victory-shared-events": "^31.2.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"version": "nps build-libs && nps build-dists"
|
package/src/helper-methods.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable no-use-before-define */
|
|
3
3
|
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { Helpers, Scale, Axis, Wrapper } from "victory-core";
|
|
6
6
|
import { defaults, assign } from "lodash";
|
|
7
7
|
|
|
8
8
|
function getAxisProps(child, props, calculatedProps) {
|
|
@@ -17,7 +17,8 @@ function getAxisProps(child, props, calculatedProps) {
|
|
|
17
17
|
const crossAxis = childProps.crossAxis === false ? false : true;
|
|
18
18
|
const orientation = Axis.getOrientation(child, axis, originSign[otherAxis]);
|
|
19
19
|
return {
|
|
20
|
-
stringMap
|
|
20
|
+
stringMap,
|
|
21
|
+
horizontal,
|
|
21
22
|
categories: categories[currentAxis],
|
|
22
23
|
startAngle: props.startAngle,
|
|
23
24
|
endAngle: props.endAngle,
|
|
@@ -43,29 +44,22 @@ function getChildProps(child, props, calculatedProps) {
|
|
|
43
44
|
function getStyles(props) {
|
|
44
45
|
const styleProps = props.style && props.style.parent;
|
|
45
46
|
return {
|
|
46
|
-
parent: defaults(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
userSelect: "none"
|
|
53
|
-
}
|
|
54
|
-
) };
|
|
47
|
+
parent: defaults({}, styleProps, {
|
|
48
|
+
height: "100%",
|
|
49
|
+
width: "100%",
|
|
50
|
+
userSelect: "none"
|
|
51
|
+
})
|
|
52
|
+
};
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
function getCalculatedProps(props, childComponents) {
|
|
58
56
|
const style = getStyles(props);
|
|
59
57
|
const horizontal = Helpers.isHorizontal(props);
|
|
60
58
|
// TODO: check
|
|
61
|
-
const categories =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const stringMap = {
|
|
66
|
-
x: createStringMap(props, "x", childComponents),
|
|
67
|
-
y: createStringMap(props, "y", childComponents)
|
|
68
|
-
};
|
|
59
|
+
const categories = Wrapper.getCategories(props, childComponents);
|
|
60
|
+
|
|
61
|
+
const stringMap = createStringMap(props, childComponents);
|
|
62
|
+
|
|
69
63
|
const axisComponents = {
|
|
70
64
|
x: Axis.getAxisComponent(childComponents, "x"),
|
|
71
65
|
y: Axis.getAxisComponent(childComponents, "y")
|
|
@@ -79,11 +73,13 @@ function getCalculatedProps(props, childComponents) {
|
|
|
79
73
|
y: Helpers.getRange(props, "y")
|
|
80
74
|
};
|
|
81
75
|
const baseScale = {
|
|
82
|
-
x:
|
|
83
|
-
|
|
76
|
+
x:
|
|
77
|
+
Scale.getScaleFromProps(props, "x") ||
|
|
78
|
+
(axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props)) ||
|
|
84
79
|
Scale.getDefaultScale(),
|
|
85
|
-
y:
|
|
86
|
-
|
|
80
|
+
y:
|
|
81
|
+
Scale.getScaleFromProps(props, "y") ||
|
|
82
|
+
(axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props)) ||
|
|
87
83
|
Scale.getDefaultScale()
|
|
88
84
|
};
|
|
89
85
|
const scale = {
|
|
@@ -103,8 +99,18 @@ function getCalculatedProps(props, childComponents) {
|
|
|
103
99
|
const padding = Helpers.getPadding(props);
|
|
104
100
|
|
|
105
101
|
return {
|
|
106
|
-
axisComponents,
|
|
107
|
-
|
|
102
|
+
axisComponents,
|
|
103
|
+
categories,
|
|
104
|
+
domain,
|
|
105
|
+
range,
|
|
106
|
+
horizontal,
|
|
107
|
+
scale,
|
|
108
|
+
stringMap,
|
|
109
|
+
style,
|
|
110
|
+
origin,
|
|
111
|
+
originSign,
|
|
112
|
+
defaultDomainPadding,
|
|
113
|
+
padding
|
|
108
114
|
};
|
|
109
115
|
}
|
|
110
116
|
|
|
@@ -117,19 +123,27 @@ function getChildren(props, childComponents, calculatedProps) {
|
|
|
117
123
|
const parentName = props.name || "chart";
|
|
118
124
|
return childComponents.map((child, index) => {
|
|
119
125
|
const role = child.type && child.type.role;
|
|
120
|
-
const style = Array.isArray(child.props.style)
|
|
121
|
-
child.props.style
|
|
122
|
-
defaults({}, child.props.style, { parent: baseStyle });
|
|
126
|
+
const style = Array.isArray(child.props.style)
|
|
127
|
+
? child.props.style
|
|
128
|
+
: defaults({}, child.props.style, { parent: baseStyle });
|
|
123
129
|
const childProps = getChildProps(child, props, calculatedProps);
|
|
124
130
|
const name = child.props.name || `${parentName}-${role}-${index}`;
|
|
125
|
-
const newProps = defaults(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const newProps = defaults(
|
|
132
|
+
{
|
|
133
|
+
horizontal,
|
|
134
|
+
height,
|
|
135
|
+
polar,
|
|
136
|
+
theme,
|
|
137
|
+
width,
|
|
138
|
+
style,
|
|
139
|
+
name,
|
|
140
|
+
origin: polar ? origin : undefined,
|
|
141
|
+
padding: calculatedProps.padding,
|
|
142
|
+
key: `${name}-key-${index}`,
|
|
143
|
+
standalone: false
|
|
144
|
+
},
|
|
145
|
+
childProps
|
|
146
|
+
);
|
|
133
147
|
|
|
134
148
|
return React.cloneElement(child, newProps);
|
|
135
149
|
});
|
|
@@ -149,24 +163,7 @@ const getChildComponents = (props, defaultAxes) => {
|
|
|
149
163
|
if (axisComponents.dependent.length === 0 && axisComponents.independent.length === 0) {
|
|
150
164
|
return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
|
|
151
165
|
}
|
|
152
|
-
|
|
153
|
-
let axisCount = 0;
|
|
154
|
-
return childComponents.filter((child) => {
|
|
155
|
-
const role = child.type && child.type.role;
|
|
156
|
-
const childProps = child.props || {};
|
|
157
|
-
if (role !== "axis" || childProps.dependentAxis) {
|
|
158
|
-
return true;
|
|
159
|
-
} else if (axisCount < 1) {
|
|
160
|
-
axisCount++;
|
|
161
|
-
return true;
|
|
162
|
-
} else {
|
|
163
|
-
const msg = "Only one independent VictoryAxis component is allowed when " +
|
|
164
|
-
"using the VictoryChart wrapper. Only the first axis will be used. Please compose " +
|
|
165
|
-
"multi-axis charts manually";
|
|
166
|
-
Log.warn(msg);
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
});
|
|
166
|
+
return childComponents;
|
|
170
167
|
};
|
|
171
168
|
|
|
172
169
|
const getDefaultDomainPadding = (childComponents, horizontal) => {
|
|
@@ -179,9 +176,7 @@ const getDefaultDomainPadding = (childComponents, horizontal) => {
|
|
|
179
176
|
}
|
|
180
177
|
|
|
181
178
|
const { offset, children } = groupComponent[0].props;
|
|
182
|
-
return horizontal ?
|
|
183
|
-
{ y: (offset * children.length) / 2 } :
|
|
184
|
-
{ x: (offset * children.length) / 2 };
|
|
179
|
+
return horizontal ? { y: (offset * children.length) / 2 } : { x: (offset * children.length) / 2 };
|
|
185
180
|
};
|
|
186
181
|
|
|
187
182
|
const getDomain = (props, axis, childComponents) => {
|
|
@@ -219,24 +214,37 @@ const getAxisOffset = (props, calculatedProps) => {
|
|
|
219
214
|
};
|
|
220
215
|
|
|
221
216
|
return {
|
|
222
|
-
x:
|
|
223
|
-
axisComponents.x.offsetX
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
x:
|
|
218
|
+
axisComponents.x && axisComponents.x.offsetX !== undefined
|
|
219
|
+
? axisComponents.x.offsetX
|
|
220
|
+
: calculatedOffset.x,
|
|
221
|
+
y:
|
|
222
|
+
axisComponents.y && axisComponents.y.offsetY !== undefined
|
|
223
|
+
? axisComponents.y.offsetY
|
|
224
|
+
: calculatedOffset.y
|
|
226
225
|
};
|
|
227
226
|
};
|
|
228
227
|
|
|
229
|
-
const createStringMap = (props,
|
|
230
|
-
const allStrings = Wrapper.getStringsFromChildren(props,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
const createStringMap = (props, childComponents) => {
|
|
229
|
+
const allStrings = Wrapper.getStringsFromChildren(props, childComponents);
|
|
230
|
+
|
|
231
|
+
const x =
|
|
232
|
+
!allStrings.x || allStrings.x.length === 0
|
|
233
|
+
? null
|
|
234
|
+
: allStrings.x.reduce((memo, string, index) => {
|
|
235
|
+
memo[string] = index + 1;
|
|
236
|
+
return memo;
|
|
237
|
+
}, {});
|
|
238
|
+
|
|
239
|
+
const y =
|
|
240
|
+
!allStrings.y || allStrings.y.length === 0
|
|
241
|
+
? null
|
|
242
|
+
: allStrings.y.reduce((memo, string, index) => {
|
|
243
|
+
memo[string] = index + 1;
|
|
244
|
+
return memo;
|
|
245
|
+
}, {});
|
|
246
|
+
|
|
247
|
+
return { x, y };
|
|
236
248
|
};
|
|
237
249
|
|
|
238
|
-
export {
|
|
239
|
-
getChildren,
|
|
240
|
-
getCalculatedProps,
|
|
241
|
-
getChildComponents
|
|
242
|
-
};
|
|
250
|
+
export { getChildren, getCalculatedProps, getChildComponents };
|