victory-chart 35.11.3 → 36.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/dist/victory-chart.js +1126 -1905
- package/dist/victory-chart.min.js +1 -1
- package/es/victory-chart.js +121 -176
- package/lib/victory-chart.js +131 -177
- package/package.json +6 -6
- package/src/victory-chart.js +157 -140
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-chart",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "36.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.19",
|
|
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": "^36.2.0",
|
|
26
|
+
"victory-core": "^36.2.0",
|
|
27
|
+
"victory-polar-axis": "^36.2.0",
|
|
28
|
+
"victory-shared-events": "^36.2.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^16.6.0 || ^17.0.0"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"version": "yarn run nps build-libs && nps build-dists"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false,
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "00c362fcd3e8f3880e14d3ba42873c34dd69c577"
|
|
38
38
|
}
|
package/src/victory-chart.js
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
VictoryTheme,
|
|
9
9
|
CommonProps,
|
|
10
10
|
PropTypes as CustomPropTypes,
|
|
11
|
-
Wrapper
|
|
11
|
+
Wrapper,
|
|
12
|
+
Hooks
|
|
12
13
|
} from "victory-core";
|
|
13
14
|
import { VictorySharedEvents } from "victory-shared-events";
|
|
14
15
|
import { VictoryAxis } from "victory-axis";
|
|
@@ -27,78 +28,47 @@ const fallbackProps = {
|
|
|
27
28
|
padding: 50
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
standalone: true,
|
|
67
|
-
theme: VictoryTheme.grayscale
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
static expectedComponents = ["groupComponent", "containerComponent"];
|
|
71
|
-
|
|
72
|
-
constructor(props) {
|
|
73
|
-
super(props);
|
|
74
|
-
this.state = {};
|
|
75
|
-
if (props.animate) {
|
|
76
|
-
this.state = {
|
|
77
|
-
nodesShouldLoad: false,
|
|
78
|
-
nodesDoneLoad: false,
|
|
79
|
-
animating: true
|
|
80
|
-
};
|
|
81
|
-
this.setAnimationState = Wrapper.setAnimationState.bind(this);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
shouldComponentUpdate(nextProps) {
|
|
86
|
-
if (this.props.animate) {
|
|
87
|
-
if (!isEqual(this.props, nextProps)) {
|
|
88
|
-
this.setAnimationState(this.props, nextProps);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
getNewChildren(props, childComponents, calculatedProps) {
|
|
31
|
+
const VictoryChart = (initialProps) => {
|
|
32
|
+
const role = "chart";
|
|
33
|
+
const { getAnimationProps, setAnimationState, getProps } =
|
|
34
|
+
Hooks.useAnimationState();
|
|
35
|
+
const props = getProps(initialProps);
|
|
36
|
+
|
|
37
|
+
const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
|
|
38
|
+
const {
|
|
39
|
+
eventKey,
|
|
40
|
+
containerComponent,
|
|
41
|
+
standalone,
|
|
42
|
+
groupComponent,
|
|
43
|
+
externalEventMutations,
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
theme,
|
|
47
|
+
polar,
|
|
48
|
+
name
|
|
49
|
+
} = modifiedProps;
|
|
50
|
+
|
|
51
|
+
const axes = props.polar
|
|
52
|
+
? modifiedProps.defaultPolarAxes
|
|
53
|
+
: modifiedProps.defaultAxes;
|
|
54
|
+
|
|
55
|
+
const childComponents = React.useMemo(
|
|
56
|
+
() => getChildComponents(modifiedProps, axes),
|
|
57
|
+
[modifiedProps, axes]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const calculatedProps = React.useMemo(
|
|
61
|
+
() => getCalculatedProps(modifiedProps, childComponents),
|
|
62
|
+
[modifiedProps, childComponents]
|
|
63
|
+
);
|
|
64
|
+
const { domain, scale, style, origin, radius, horizontal } = calculatedProps;
|
|
65
|
+
|
|
66
|
+
const newChildren = React.useMemo(() => {
|
|
96
67
|
const children = getChildren(props, childComponents, calculatedProps);
|
|
97
|
-
const getAnimationProps = Wrapper.getAnimationProps.bind(this);
|
|
98
68
|
|
|
99
|
-
const
|
|
69
|
+
const mappedChildren = children.map((child, index) => {
|
|
100
70
|
const childProps = assign(
|
|
101
|
-
{ animate: getAnimationProps(props, child, index) },
|
|
71
|
+
{ animate: getAnimationProps(props, child, index, "victory chart") },
|
|
102
72
|
child.props
|
|
103
73
|
);
|
|
104
74
|
return React.cloneElement(child, childProps);
|
|
@@ -110,80 +80,127 @@ export default class VictoryChart extends React.Component {
|
|
|
110
80
|
calculatedProps
|
|
111
81
|
);
|
|
112
82
|
|
|
113
|
-
|
|
83
|
+
mappedChildren.unshift(backgroundComponent);
|
|
114
84
|
}
|
|
115
85
|
|
|
116
|
-
return
|
|
117
|
-
}
|
|
86
|
+
return mappedChildren;
|
|
87
|
+
}, [getAnimationProps, childComponents, props, calculatedProps]);
|
|
88
|
+
|
|
89
|
+
const containerProps = React.useMemo(() => {
|
|
90
|
+
if (standalone) {
|
|
91
|
+
return {
|
|
92
|
+
domain,
|
|
93
|
+
scale,
|
|
94
|
+
width,
|
|
95
|
+
height,
|
|
96
|
+
standalone,
|
|
97
|
+
theme,
|
|
98
|
+
style: style.parent,
|
|
99
|
+
horizontal,
|
|
100
|
+
name,
|
|
101
|
+
polar,
|
|
102
|
+
radius,
|
|
103
|
+
origin: polar ? origin : undefined
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {};
|
|
107
|
+
}, [
|
|
108
|
+
domain,
|
|
109
|
+
scale,
|
|
110
|
+
width,
|
|
111
|
+
height,
|
|
112
|
+
standalone,
|
|
113
|
+
theme,
|
|
114
|
+
style,
|
|
115
|
+
horizontal,
|
|
116
|
+
name,
|
|
117
|
+
polar,
|
|
118
|
+
radius,
|
|
119
|
+
origin
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
const container = React.useMemo(() => {
|
|
123
|
+
if (standalone) {
|
|
124
|
+
const defaultContainerProps = defaults(
|
|
125
|
+
{},
|
|
126
|
+
containerComponent.props,
|
|
127
|
+
containerProps
|
|
128
|
+
);
|
|
129
|
+
return React.cloneElement(containerComponent, defaultContainerProps);
|
|
130
|
+
}
|
|
131
|
+
return groupComponent;
|
|
132
|
+
}, [groupComponent, standalone, containerComponent, containerProps]);
|
|
118
133
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
134
|
+
const events = React.useMemo(() => {
|
|
135
|
+
return Wrapper.getAllEvents(props);
|
|
136
|
+
}, [props]);
|
|
123
137
|
|
|
124
|
-
|
|
125
|
-
const { width, height, standalone, theme, polar, name } = props;
|
|
126
|
-
const { domain, scale, style, origin, radius, horizontal } =
|
|
127
|
-
calculatedProps;
|
|
128
|
-
return {
|
|
129
|
-
domain,
|
|
130
|
-
scale,
|
|
131
|
-
width,
|
|
132
|
-
height,
|
|
133
|
-
standalone,
|
|
134
|
-
theme,
|
|
135
|
-
style: style.parent,
|
|
136
|
-
horizontal,
|
|
137
|
-
name,
|
|
138
|
-
polar,
|
|
139
|
-
radius,
|
|
140
|
-
origin: polar ? origin : undefined
|
|
141
|
-
};
|
|
142
|
-
}
|
|
138
|
+
const previousProps = Hooks.usePreviousProps(initialProps);
|
|
143
139
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
modifiedProps,
|
|
164
|
-
childComponents,
|
|
165
|
-
calculatedProps
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
// This is called before dismount to keep state in sync
|
|
142
|
+
return () => {
|
|
143
|
+
if (initialProps.animate) {
|
|
144
|
+
setAnimationState(previousProps, initialProps);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}, [setAnimationState, previousProps, initialProps]);
|
|
148
|
+
|
|
149
|
+
if (!isEmpty(events)) {
|
|
150
|
+
return (
|
|
151
|
+
<VictorySharedEvents
|
|
152
|
+
container={container}
|
|
153
|
+
eventKey={eventKey}
|
|
154
|
+
events={events}
|
|
155
|
+
externalEventMutations={externalEventMutations}
|
|
156
|
+
>
|
|
157
|
+
{newChildren}
|
|
158
|
+
</VictorySharedEvents>
|
|
166
159
|
);
|
|
167
|
-
const containerProps = standalone
|
|
168
|
-
? this.getContainerProps(modifiedProps, calculatedProps)
|
|
169
|
-
: {};
|
|
170
|
-
const container = standalone
|
|
171
|
-
? this.renderContainer(containerComponent, containerProps)
|
|
172
|
-
: groupComponent;
|
|
173
|
-
const events = Wrapper.getAllEvents(props);
|
|
174
|
-
|
|
175
|
-
if (!isEmpty(events)) {
|
|
176
|
-
return (
|
|
177
|
-
<VictorySharedEvents
|
|
178
|
-
container={container}
|
|
179
|
-
eventKey={eventKey}
|
|
180
|
-
events={events}
|
|
181
|
-
externalEventMutations={externalEventMutations}
|
|
182
|
-
>
|
|
183
|
-
{newChildren}
|
|
184
|
-
</VictorySharedEvents>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
return React.cloneElement(container, container.props, newChildren);
|
|
188
160
|
}
|
|
189
|
-
|
|
161
|
+
return React.cloneElement(container, container.props, newChildren);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
VictoryChart.propTypes = {
|
|
165
|
+
...CommonProps.baseProps,
|
|
166
|
+
backgroundComponent: PropTypes.element,
|
|
167
|
+
children: PropTypes.oneOfType([
|
|
168
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
169
|
+
PropTypes.node
|
|
170
|
+
]),
|
|
171
|
+
defaultAxes: PropTypes.shape({
|
|
172
|
+
independent: PropTypes.element,
|
|
173
|
+
dependent: PropTypes.element
|
|
174
|
+
}),
|
|
175
|
+
defaultPolarAxes: PropTypes.shape({
|
|
176
|
+
independent: PropTypes.element,
|
|
177
|
+
dependent: PropTypes.element
|
|
178
|
+
}),
|
|
179
|
+
endAngle: PropTypes.number,
|
|
180
|
+
innerRadius: CustomPropTypes.nonNegative,
|
|
181
|
+
prependDefaultAxes: PropTypes.bool,
|
|
182
|
+
startAngle: PropTypes.number
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
VictoryChart.defaultProps = {
|
|
186
|
+
backgroundComponent: <Background />,
|
|
187
|
+
containerComponent: <VictoryContainer />,
|
|
188
|
+
defaultAxes: {
|
|
189
|
+
independent: <VictoryAxis />,
|
|
190
|
+
dependent: <VictoryAxis dependentAxis />
|
|
191
|
+
},
|
|
192
|
+
defaultPolarAxes: {
|
|
193
|
+
independent: <VictoryPolarAxis />,
|
|
194
|
+
dependent: <VictoryPolarAxis dependentAxis />
|
|
195
|
+
},
|
|
196
|
+
groupComponent: <g />,
|
|
197
|
+
standalone: true,
|
|
198
|
+
theme: VictoryTheme.grayscale
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const VictoryChartMemo = React.memo(VictoryChart, isEqual);
|
|
202
|
+
|
|
203
|
+
VictoryChartMemo.displayName = "VictoryChart";
|
|
204
|
+
VictoryChartMemo.expectedComponents = ["groupComponent", "containerComponent"];
|
|
205
|
+
|
|
206
|
+
export default VictoryChartMemo;
|