victory-chart 31.1.0 → 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.
@@ -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 { Log, Helpers, Scale, Axis, Wrapper } from "victory-core";
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[currentAxis],
27
+ stringMap: stringMap,
28
+ horizontal: horizontal,
28
29
  categories: categories[currentAxis],
29
30
  startAngle: props.startAngle,
30
31
  endAngle: props.endAngle,
@@ -175,22 +176,7 @@ var getChildComponents = function (props, defaultAxes) {
175
176
  return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
176
177
  }
177
178
 
178
- var axisCount = 0;
179
- return childComponents.filter(function (child) {
180
- var role = child.type && child.type.role;
181
- var childProps = child.props || {};
182
-
183
- if (role !== "axis" || childProps.dependentAxis) {
184
- return true;
185
- } else if (axisCount < 1) {
186
- axisCount++;
187
- return true;
188
- } else {
189
- 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";
190
- Log.warn(msg);
191
- return false;
192
- }
193
- });
179
+ return childComponents;
194
180
  };
195
181
 
196
182
  var getDefaultDomainPadding = function (childComponents, horizontal) {
@@ -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: "componentWillMount",
61
- value: function componentWillMount() {
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
- this.setAnimationState(this.props, nextProps);
64
+ if (!isEqual(this.props, nextProps)) {
65
+ this.setAnimationState(this.props, nextProps);
66
+ return false;
67
+ }
69
68
  }
70
69
 
71
- this.events = Wrapper.getAllEvents(nextProps);
72
- } // the old ones were bad
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 (this.events) {
140
+ if (!_isEmpty(events)) {
142
141
  return React.createElement(VictorySharedEvents, {
143
142
  container: container,
144
143
  eventKey: eventKey,
145
- events: this.events,
144
+ events: events,
146
145
  externalEventMutations: externalEventMutations
147
146
  }, newChildren);
148
147
  }
@@ -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[currentAxis],
44
+ stringMap: stringMap,
45
+ horizontal: horizontal,
45
46
  categories: categories[currentAxis],
46
47
  startAngle: props.startAngle,
47
48
  endAngle: props.endAngle,
@@ -195,24 +196,7 @@ var getChildComponents = function (props, defaultAxes) {
195
196
  return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
196
197
  }
197
198
 
198
- var axisCount = 0;
199
- return childComponents.filter(function (child) {
200
- var role = child.type && child.type.role;
201
- var childProps = child.props || {};
202
-
203
- if (role !== "axis" || childProps.dependentAxis) {
204
- return true;
205
- } else if (axisCount < 1) {
206
- axisCount++;
207
- return true;
208
- } else {
209
- 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";
210
-
211
- _victoryCore.Log.warn(msg);
212
-
213
- return false;
214
- }
215
- });
199
+ return childComponents;
216
200
  };
217
201
 
218
202
  exports.getChildComponents = getChildComponents;
@@ -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: "componentWillMount",
78
- value: function componentWillMount() {
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
- this.setAnimationState(this.props, nextProps);
83
+ if (!(0, _reactFastCompare.default)(this.props, nextProps)) {
84
+ this.setAnimationState(this.props, nextProps);
85
+ return false;
86
+ }
86
87
  }
87
88
 
88
- this.events = _victoryCore.Wrapper.getAllEvents(nextProps);
89
- } // the old ones were bad
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
- if (this.events) {
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: this.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": "31.1.0",
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": "^31.1.0",
26
- "victory-core": "^31.1.0",
27
- "victory-polar-axis": "^31.1.0",
28
- "victory-shared-events": "^31.1.0"
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"
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable no-use-before-define */
3
3
 
4
4
  import React from "react";
5
- import { Log, Helpers, Scale, Axis, Wrapper } from "victory-core";
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: stringMap[currentAxis],
20
+ stringMap,
21
+ horizontal,
21
22
  categories: categories[currentAxis],
22
23
  startAngle: props.startAngle,
23
24
  endAngle: props.endAngle,
@@ -162,25 +163,7 @@ const getChildComponents = (props, defaultAxes) => {
162
163
  if (axisComponents.dependent.length === 0 && axisComponents.independent.length === 0) {
163
164
  return childComponents.concat([defaultAxes.independent, defaultAxes.dependent]);
164
165
  }
165
-
166
- let axisCount = 0;
167
- return childComponents.filter((child) => {
168
- const role = child.type && child.type.role;
169
- const childProps = child.props || {};
170
- if (role !== "axis" || childProps.dependentAxis) {
171
- return true;
172
- } else if (axisCount < 1) {
173
- axisCount++;
174
- return true;
175
- } else {
176
- const msg =
177
- "Only one independent VictoryAxis component is allowed when " +
178
- "using the VictoryChart wrapper. Only the first axis will be used. Please compose " +
179
- "multi-axis charts manually";
180
- Log.warn(msg);
181
- return false;
182
- }
183
- });
166
+ return childComponents;
184
167
  };
185
168
 
186
169
  const getDefaultDomainPadding = (childComponents, horizontal) => {
@@ -1,4 +1,4 @@
1
- import { defaults, assign } from "lodash";
1
+ import { defaults, assign, isEmpty } from "lodash";
2
2
  import PropTypes from "prop-types";
3
3
  import React from "react";
4
4
  import {
@@ -13,6 +13,7 @@ import { VictorySharedEvents } from "victory-shared-events";
13
13
  import { VictoryAxis } from "victory-axis";
14
14
  import { VictoryPolarAxis } from "victory-polar-axis";
15
15
  import { getChildComponents, getCalculatedProps, getChildren } from "./helper-methods";
16
+ import isEqual from "react-fast-compare";
16
17
 
17
18
  const fallbackProps = {
18
19
  width: 450,
@@ -65,23 +66,20 @@ export default class VictoryChart extends React.Component {
65
66
  nodesDoneLoad: false,
66
67
  animating: true
67
68
  };
69
+ this.setAnimationState = Wrapper.setAnimationState.bind(this);
68
70
  }
69
- this.setAnimationState = Wrapper.setAnimationState.bind(this);
70
- this.events = Wrapper.getAllEvents(props);
71
71
  }
72
72
 
73
- componentWillMount() {
74
- this.events = Wrapper.getAllEvents(this.props);
75
- }
76
-
77
- componentWillReceiveProps(nextProps) {
73
+ shouldComponentUpdate(nextProps) {
78
74
  if (this.props.animate) {
79
- this.setAnimationState(this.props, nextProps);
75
+ if (!isEqual(this.props, nextProps)) {
76
+ this.setAnimationState(this.props, nextProps);
77
+ return false;
78
+ }
80
79
  }
81
- this.events = Wrapper.getAllEvents(nextProps);
80
+ return true;
82
81
  }
83
82
 
84
- // the old ones were bad
85
83
  getNewChildren(props, childComponents, calculatedProps) {
86
84
  const children = getChildren(props, childComponents, calculatedProps);
87
85
  const getAnimationProps = Wrapper.getAnimationProps.bind(this);
@@ -134,12 +132,13 @@ export default class VictoryChart extends React.Component {
134
132
  const container = standalone
135
133
  ? this.renderContainer(containerComponent, containerProps)
136
134
  : groupComponent;
137
- if (this.events) {
135
+ const events = Wrapper.getAllEvents(props);
136
+ if (!isEmpty(events)) {
138
137
  return (
139
138
  <VictorySharedEvents
140
139
  container={container}
141
140
  eventKey={eventKey}
142
- events={this.events}
141
+ events={events}
143
142
  externalEventMutations={externalEventMutations}
144
143
  >
145
144
  {newChildren}