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/src/victory-chart.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
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 {
|
|
5
|
-
Helpers,
|
|
5
|
+
Helpers,
|
|
6
|
+
VictoryContainer,
|
|
7
|
+
VictoryTheme,
|
|
8
|
+
CommonProps,
|
|
9
|
+
PropTypes as CustomPropTypes,
|
|
10
|
+
Wrapper
|
|
6
11
|
} from "victory-core";
|
|
7
12
|
import { VictorySharedEvents } from "victory-shared-events";
|
|
8
13
|
import { VictoryAxis } from "victory-axis";
|
|
9
14
|
import { VictoryPolarAxis } from "victory-polar-axis";
|
|
10
15
|
import { getChildComponents, getCalculatedProps, getChildren } from "./helper-methods";
|
|
16
|
+
import isEqual from "react-fast-compare";
|
|
11
17
|
|
|
12
18
|
const fallbackProps = {
|
|
13
19
|
width: 450,
|
|
@@ -20,10 +26,7 @@ export default class VictoryChart extends React.Component {
|
|
|
20
26
|
|
|
21
27
|
static propTypes = {
|
|
22
28
|
...CommonProps.baseProps,
|
|
23
|
-
children: PropTypes.oneOfType([
|
|
24
|
-
PropTypes.arrayOf(PropTypes.node),
|
|
25
|
-
PropTypes.node
|
|
26
|
-
]),
|
|
29
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
27
30
|
defaultAxes: PropTypes.shape({
|
|
28
31
|
independent: PropTypes.element,
|
|
29
32
|
dependent: PropTypes.element
|
|
@@ -38,23 +41,21 @@ export default class VictoryChart extends React.Component {
|
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
static defaultProps = {
|
|
41
|
-
containerComponent: <VictoryContainer/>,
|
|
44
|
+
containerComponent: <VictoryContainer />,
|
|
42
45
|
defaultAxes: {
|
|
43
|
-
independent: <VictoryAxis/>,
|
|
44
|
-
dependent: <VictoryAxis dependentAxis/>
|
|
46
|
+
independent: <VictoryAxis />,
|
|
47
|
+
dependent: <VictoryAxis dependentAxis />
|
|
45
48
|
},
|
|
46
49
|
defaultPolarAxes: {
|
|
47
|
-
independent: <VictoryPolarAxis/>,
|
|
48
|
-
dependent: <VictoryPolarAxis dependentAxis/>
|
|
50
|
+
independent: <VictoryPolarAxis />,
|
|
51
|
+
dependent: <VictoryPolarAxis dependentAxis />
|
|
49
52
|
},
|
|
50
|
-
groupComponent: <g/>,
|
|
53
|
+
groupComponent: <g />,
|
|
51
54
|
standalone: true,
|
|
52
55
|
theme: VictoryTheme.grayscale
|
|
53
56
|
};
|
|
54
57
|
|
|
55
|
-
static expectedComponents = [
|
|
56
|
-
"groupComponent", "containerComponent"
|
|
57
|
-
];
|
|
58
|
+
static expectedComponents = ["groupComponent", "containerComponent"];
|
|
58
59
|
|
|
59
60
|
constructor(props) {
|
|
60
61
|
super(props);
|
|
@@ -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
|
-
|
|
74
|
-
this.events = Wrapper.getAllEvents(this.props);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
componentWillReceiveProps(nextProps) {
|
|
73
|
+
shouldComponentUpdate(nextProps) {
|
|
78
74
|
if (this.props.animate) {
|
|
79
|
-
|
|
75
|
+
if (!isEqual(this.props, nextProps)) {
|
|
76
|
+
this.setAnimationState(this.props, nextProps);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
80
79
|
}
|
|
81
|
-
|
|
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);
|
|
@@ -100,31 +98,47 @@ export default class VictoryChart extends React.Component {
|
|
|
100
98
|
const { width, height, standalone, theme, polar, name } = props;
|
|
101
99
|
const { domain, scale, style, origin, radius, horizontal } = calculatedProps;
|
|
102
100
|
return {
|
|
103
|
-
domain,
|
|
104
|
-
|
|
101
|
+
domain,
|
|
102
|
+
scale,
|
|
103
|
+
width,
|
|
104
|
+
height,
|
|
105
|
+
standalone,
|
|
106
|
+
theme,
|
|
107
|
+
style: style.parent,
|
|
108
|
+
horizontal,
|
|
109
|
+
name,
|
|
110
|
+
polar,
|
|
111
|
+
radius,
|
|
112
|
+
origin: polar ? origin : undefined
|
|
105
113
|
};
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
render() {
|
|
109
|
-
const props =
|
|
110
|
-
this.state.oldProps || this.props : this.props;
|
|
117
|
+
const props =
|
|
118
|
+
this.state && this.state.nodesWillExit ? this.state.oldProps || this.props : this.props;
|
|
111
119
|
const modifiedProps = Helpers.modifyProps(props, fallbackProps, "chart");
|
|
112
120
|
const {
|
|
113
|
-
eventKey,
|
|
121
|
+
eventKey,
|
|
122
|
+
containerComponent,
|
|
123
|
+
groupComponent,
|
|
124
|
+
standalone,
|
|
125
|
+
externalEventMutations
|
|
114
126
|
} = modifiedProps;
|
|
115
127
|
const axes = props.polar ? modifiedProps.defaultPolarAxes : modifiedProps.defaultAxes;
|
|
116
128
|
const childComponents = getChildComponents(modifiedProps, axes);
|
|
117
129
|
const calculatedProps = getCalculatedProps(modifiedProps, childComponents);
|
|
118
130
|
const newChildren = this.getNewChildren(modifiedProps, childComponents, calculatedProps);
|
|
119
131
|
const containerProps = standalone ? this.getContainerProps(modifiedProps, calculatedProps) : {};
|
|
120
|
-
const container = standalone
|
|
121
|
-
this.renderContainer(containerComponent, containerProps)
|
|
122
|
-
|
|
132
|
+
const container = standalone
|
|
133
|
+
? this.renderContainer(containerComponent, containerProps)
|
|
134
|
+
: groupComponent;
|
|
135
|
+
const events = Wrapper.getAllEvents(props);
|
|
136
|
+
if (!isEmpty(events)) {
|
|
123
137
|
return (
|
|
124
138
|
<VictorySharedEvents
|
|
125
139
|
container={container}
|
|
126
140
|
eventKey={eventKey}
|
|
127
|
-
events={
|
|
141
|
+
events={events}
|
|
128
142
|
externalEventMutations={externalEventMutations}
|
|
129
143
|
>
|
|
130
144
|
{newChildren}
|