victory-pie 36.8.2 → 36.8.3
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-pie.js +487 -224
- package/dist/victory-pie.min.js +1 -1
- package/es/helper-methods.d.ts +14 -0
- package/es/helper-methods.js +72 -9
- package/es/index.d.ts +3 -83
- package/es/index.js +2 -2
- package/es/slice.d.ts +62 -0
- package/es/slice.js +3 -6
- package/es/victory-pie.d.ts +117 -0
- package/es/victory-pie.js +106 -83
- package/lib/helper-methods.d.ts +14 -0
- package/lib/helper-methods.js +92 -10
- package/lib/index.d.ts +3 -83
- package/lib/index.js +23 -15
- package/lib/slice.d.ts +62 -0
- package/lib/slice.js +5 -6
- package/lib/victory-pie.d.ts +117 -0
- package/lib/victory-pie.js +109 -88
- package/package.json +3 -3
- package/src/{helper-methods.js → helper-methods.ts} +80 -8
- package/src/index.ts +2 -0
- package/src/{slice.js → slice.tsx} +46 -6
- package/src/victory-pie.tsx +269 -0
- package/src/index.d.ts +0 -83
- package/src/index.js +0 -2
- package/src/victory-pie.js +0 -268
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
addEvents,
|
|
4
|
+
Helpers,
|
|
5
|
+
Data,
|
|
6
|
+
LineSegment,
|
|
7
|
+
VictoryContainer,
|
|
8
|
+
VictoryLabel,
|
|
9
|
+
VictoryTheme,
|
|
10
|
+
UserProps,
|
|
11
|
+
ColorScalePropType,
|
|
12
|
+
EventPropTypeInterface,
|
|
13
|
+
NumberOrCallback,
|
|
14
|
+
OriginType,
|
|
15
|
+
SliceNumberOrCallback,
|
|
16
|
+
StringOrNumberOrCallback,
|
|
17
|
+
VictoryCommonProps,
|
|
18
|
+
VictoryLabelableProps,
|
|
19
|
+
VictoryMultiLabelableProps,
|
|
20
|
+
VictoryStyleInterface,
|
|
21
|
+
EventsMixinClass,
|
|
22
|
+
VictoryDatableProps,
|
|
23
|
+
} from "victory-core";
|
|
24
|
+
import { isNil } from "lodash";
|
|
25
|
+
import { getBaseProps } from "./helper-methods";
|
|
26
|
+
import {
|
|
27
|
+
Slice,
|
|
28
|
+
SliceProps,
|
|
29
|
+
VictorySliceTTargetType,
|
|
30
|
+
VictorySliceLabelPlacementType,
|
|
31
|
+
VictorySliceLabelPositionType,
|
|
32
|
+
} from "./slice";
|
|
33
|
+
|
|
34
|
+
export interface VictoryPieProps
|
|
35
|
+
extends Omit<VictoryCommonProps, "polar">,
|
|
36
|
+
VictoryDatableProps,
|
|
37
|
+
VictoryLabelableProps,
|
|
38
|
+
VictoryMultiLabelableProps {
|
|
39
|
+
colorScale?: ColorScalePropType;
|
|
40
|
+
cornerRadius?: SliceNumberOrCallback<SliceProps, "cornerRadius">;
|
|
41
|
+
endAngle?: number;
|
|
42
|
+
events?: EventPropTypeInterface<
|
|
43
|
+
VictorySliceTTargetType,
|
|
44
|
+
StringOrNumberOrCallback | string[] | number[]
|
|
45
|
+
>[];
|
|
46
|
+
eventKey?: StringOrNumberOrCallback;
|
|
47
|
+
innerRadius?: NumberOrCallback;
|
|
48
|
+
labelIndicator?: boolean | React.ReactElement;
|
|
49
|
+
labelIndicatorInnerOffset?: number;
|
|
50
|
+
labelIndicatorOuterOffset?: number;
|
|
51
|
+
labelPlacement?:
|
|
52
|
+
| VictorySliceLabelPlacementType
|
|
53
|
+
| ((props: SliceProps) => VictorySliceLabelPlacementType);
|
|
54
|
+
labelPosition?:
|
|
55
|
+
| VictorySliceLabelPositionType
|
|
56
|
+
| ((props: SliceProps) => VictorySliceLabelPositionType);
|
|
57
|
+
|
|
58
|
+
labelIndicatorComponent?: React.ReactElement;
|
|
59
|
+
labelRadius?: number | ((props: SliceProps) => number);
|
|
60
|
+
origin?: OriginType;
|
|
61
|
+
padAngle?: NumberOrCallback;
|
|
62
|
+
radius?: NumberOrCallback;
|
|
63
|
+
startAngle?: number;
|
|
64
|
+
style?: VictoryStyleInterface;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const fallbackProps = {
|
|
68
|
+
endAngle: 360,
|
|
69
|
+
height: 400,
|
|
70
|
+
innerRadius: 0,
|
|
71
|
+
cornerRadius: 0,
|
|
72
|
+
padAngle: 0,
|
|
73
|
+
padding: 30,
|
|
74
|
+
width: 400,
|
|
75
|
+
startAngle: 0,
|
|
76
|
+
colorScale: [
|
|
77
|
+
"#ffffff",
|
|
78
|
+
"#f0f0f0",
|
|
79
|
+
"#d9d9d9",
|
|
80
|
+
"#bdbdbd",
|
|
81
|
+
"#969696",
|
|
82
|
+
"#737373",
|
|
83
|
+
"#525252",
|
|
84
|
+
"#252525",
|
|
85
|
+
"#000000",
|
|
86
|
+
],
|
|
87
|
+
labelPosition: "centroid",
|
|
88
|
+
labelIndicatorInnerOffset: 15,
|
|
89
|
+
labelIndicatorOuterOffset: 5,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const datumHasXandY = (datum) => {
|
|
93
|
+
return !isNil(datum._x) && !isNil(datum._y);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
97
|
+
interface VictoryPieBase extends EventsMixinClass<VictoryPieProps> {}
|
|
98
|
+
|
|
99
|
+
class VictoryPieBase extends React.Component<VictoryPieProps> {
|
|
100
|
+
static animationWhitelist: (keyof VictoryPieProps)[] = [
|
|
101
|
+
"data",
|
|
102
|
+
"endAngle",
|
|
103
|
+
"height",
|
|
104
|
+
"innerRadius",
|
|
105
|
+
"cornerRadius",
|
|
106
|
+
"padAngle",
|
|
107
|
+
"padding",
|
|
108
|
+
"colorScale",
|
|
109
|
+
"startAngle",
|
|
110
|
+
"style",
|
|
111
|
+
"width",
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
static displayName = "VictoryPie";
|
|
115
|
+
|
|
116
|
+
static role = "pie";
|
|
117
|
+
|
|
118
|
+
static defaultTransitions = {
|
|
119
|
+
onExit: {
|
|
120
|
+
duration: 500,
|
|
121
|
+
before: () => ({ _y: 0, label: " " }),
|
|
122
|
+
},
|
|
123
|
+
onEnter: {
|
|
124
|
+
duration: 500,
|
|
125
|
+
before: () => ({ _y: 0, label: " " }),
|
|
126
|
+
after: (datum) => ({
|
|
127
|
+
y_: datum._y,
|
|
128
|
+
label: datum.label,
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
static defaultProps: VictoryPieProps = {
|
|
134
|
+
data: [
|
|
135
|
+
{ x: "A", y: 1 },
|
|
136
|
+
{ x: "B", y: 2 },
|
|
137
|
+
{ x: "C", y: 3 },
|
|
138
|
+
{ x: "D", y: 1 },
|
|
139
|
+
{ x: "E", y: 2 },
|
|
140
|
+
],
|
|
141
|
+
standalone: true,
|
|
142
|
+
dataComponent: <Slice />,
|
|
143
|
+
labelComponent: <VictoryLabel />,
|
|
144
|
+
containerComponent: <VictoryContainer />,
|
|
145
|
+
groupComponent: <g />,
|
|
146
|
+
sortOrder: "ascending",
|
|
147
|
+
theme: VictoryTheme.grayscale,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
static getBaseProps = (props: VictoryPieProps) =>
|
|
151
|
+
getBaseProps(props, fallbackProps);
|
|
152
|
+
static getData = Data.getData;
|
|
153
|
+
static expectedComponents: (keyof VictoryPieProps)[] = [
|
|
154
|
+
"dataComponent",
|
|
155
|
+
"labelComponent",
|
|
156
|
+
"groupComponent",
|
|
157
|
+
"containerComponent",
|
|
158
|
+
"labelIndicatorComponent",
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
// Overridden in victory-native
|
|
162
|
+
shouldAnimate() {
|
|
163
|
+
return Boolean(this.props.animate);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
renderComponents(props: VictoryPieProps, shouldRenderDatum = datumHasXandY) {
|
|
167
|
+
const {
|
|
168
|
+
dataComponent,
|
|
169
|
+
labelComponent,
|
|
170
|
+
groupComponent,
|
|
171
|
+
labelIndicator,
|
|
172
|
+
labelPosition,
|
|
173
|
+
} = props;
|
|
174
|
+
|
|
175
|
+
if (!groupComponent) {
|
|
176
|
+
throw new Error("VictoryPie expects a groupComponent prop");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const showIndicator = labelIndicator && labelPosition === "centroid";
|
|
180
|
+
|
|
181
|
+
const children: React.ReactElement[] = [];
|
|
182
|
+
|
|
183
|
+
if (dataComponent) {
|
|
184
|
+
const dataComponents = this.dataKeys.reduce<React.ReactElement[]>(
|
|
185
|
+
(validDataComponents, _dataKey, index) => {
|
|
186
|
+
const dataProps = this.getComponentProps(
|
|
187
|
+
dataComponent,
|
|
188
|
+
"data",
|
|
189
|
+
index,
|
|
190
|
+
);
|
|
191
|
+
if (shouldRenderDatum((dataProps as any).datum)) {
|
|
192
|
+
validDataComponents.push(
|
|
193
|
+
React.cloneElement(dataComponent, dataProps),
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return validDataComponents;
|
|
197
|
+
},
|
|
198
|
+
[],
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
children.push(...dataComponents);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (labelComponent) {
|
|
205
|
+
const labelComponents = this.dataKeys
|
|
206
|
+
.map((_dataKey, index) => {
|
|
207
|
+
const labelProps = this.getComponentProps(
|
|
208
|
+
labelComponent,
|
|
209
|
+
"labels",
|
|
210
|
+
index,
|
|
211
|
+
);
|
|
212
|
+
if (
|
|
213
|
+
(labelProps as any).text !== undefined &&
|
|
214
|
+
(labelProps as any).text !== null
|
|
215
|
+
) {
|
|
216
|
+
return React.cloneElement(labelComponent, labelProps);
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
})
|
|
220
|
+
.filter(
|
|
221
|
+
(comp: React.ReactElement | undefined): comp is React.ReactElement =>
|
|
222
|
+
comp !== undefined,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
children.push(...labelComponents);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (showIndicator && labelIndicator) {
|
|
229
|
+
let labelIndicatorComponent: React.ReactElement = <LineSegment />;
|
|
230
|
+
|
|
231
|
+
if (typeof labelIndicator === "object") {
|
|
232
|
+
// pass user provided react component
|
|
233
|
+
labelIndicatorComponent = labelIndicator;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const labelIndicatorComponents = this.dataKeys.map((_dataKey, index) => {
|
|
237
|
+
const labelIndicatorProps = this.getComponentProps(
|
|
238
|
+
labelIndicatorComponent,
|
|
239
|
+
"labelIndicators",
|
|
240
|
+
index,
|
|
241
|
+
);
|
|
242
|
+
return React.cloneElement(labelIndicatorComponent, labelIndicatorProps);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
children.push(...labelIndicatorComponents);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return this.renderContainer(groupComponent, children);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
render(): React.ReactElement {
|
|
252
|
+
const { animationWhitelist, role } = VictoryPie;
|
|
253
|
+
const props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
254
|
+
|
|
255
|
+
if (this.shouldAnimate()) {
|
|
256
|
+
return this.animateComponent(props, animationWhitelist);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const children = this.renderComponents(props);
|
|
260
|
+
|
|
261
|
+
const component = props.standalone
|
|
262
|
+
? this.renderContainer(props.containerComponent, children)
|
|
263
|
+
: children;
|
|
264
|
+
|
|
265
|
+
return UserProps.withSafeUserProps(component, props);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export const VictoryPie = addEvents(VictoryPieBase);
|
package/src/index.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
CategoryPropType,
|
|
4
|
-
ColorScalePropType,
|
|
5
|
-
DataGetterPropType,
|
|
6
|
-
EventPropTypeInterface,
|
|
7
|
-
StringOrCallback,
|
|
8
|
-
NumberOrCallback,
|
|
9
|
-
OriginType,
|
|
10
|
-
SliceNumberOrCallback,
|
|
11
|
-
StringOrNumberOrCallback,
|
|
12
|
-
VictoryCommonProps,
|
|
13
|
-
VictoryLabelableProps,
|
|
14
|
-
VictoryMultiLabelableProps,
|
|
15
|
-
VictoryStyleInterface,
|
|
16
|
-
} from "victory-core";
|
|
17
|
-
|
|
18
|
-
export type VictorySliceLabelPositionType =
|
|
19
|
-
| "startAngle"
|
|
20
|
-
| "centroid"
|
|
21
|
-
| "endAngle";
|
|
22
|
-
export type VictorySliceLabelPlacementType =
|
|
23
|
-
| "vertical"
|
|
24
|
-
| "parallel"
|
|
25
|
-
| "perpendicular";
|
|
26
|
-
export type VictorySliceTTargetType = "data" | "labels" | "parent";
|
|
27
|
-
|
|
28
|
-
export interface SliceProps extends VictoryCommonProps {
|
|
29
|
-
ariaLabel?: StringOrCallback;
|
|
30
|
-
cornerRadius?: SliceNumberOrCallback<SliceProps, "cornerRadius">;
|
|
31
|
-
datum?: any;
|
|
32
|
-
innerRadius?: NumberOrCallback;
|
|
33
|
-
padAngle?: SliceNumberOrCallback<SliceProps, "padAngle">;
|
|
34
|
-
pathComponent?: React.ReactElement;
|
|
35
|
-
pathFunction?: (props: SliceProps) => string;
|
|
36
|
-
radius?: SliceNumberOrCallback<SliceProps, "radius">;
|
|
37
|
-
slice?: {
|
|
38
|
-
startAngle?: number;
|
|
39
|
-
endAngle?: number;
|
|
40
|
-
padAngle?: number;
|
|
41
|
-
data?: any[];
|
|
42
|
-
};
|
|
43
|
-
sliceEndAngle?: SliceNumberOrCallback<SliceProps, "sliceEndAngle">;
|
|
44
|
-
sliceStartAngle?: SliceNumberOrCallback<SliceProps, "sliceStartAngle">;
|
|
45
|
-
style?: VictoryStyleInterface;
|
|
46
|
-
tabIndex?: NumberOrCallback;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class Slice extends React.Component<SliceProps, any> {}
|
|
50
|
-
|
|
51
|
-
export interface VictoryPieProps
|
|
52
|
-
extends Omit<VictoryCommonProps, "polar">,
|
|
53
|
-
VictoryLabelableProps,
|
|
54
|
-
VictoryMultiLabelableProps {
|
|
55
|
-
categories?: CategoryPropType;
|
|
56
|
-
colorScale?: ColorScalePropType;
|
|
57
|
-
cornerRadius?: SliceNumberOrCallback<SliceProps, "cornerRadius">;
|
|
58
|
-
data?: any[];
|
|
59
|
-
dataComponent?: React.ReactElement;
|
|
60
|
-
endAngle?: number;
|
|
61
|
-
events?: EventPropTypeInterface<
|
|
62
|
-
VictorySliceTTargetType,
|
|
63
|
-
StringOrNumberOrCallback | string[] | number[]
|
|
64
|
-
>[];
|
|
65
|
-
eventKey?: StringOrNumberOrCallback;
|
|
66
|
-
innerRadius?: NumberOrCallback;
|
|
67
|
-
labelPlacement?:
|
|
68
|
-
| VictorySliceLabelPlacementType
|
|
69
|
-
| ((props: SliceProps) => VictorySliceLabelPlacementType);
|
|
70
|
-
labelPosition?:
|
|
71
|
-
| VictorySliceLabelPositionType
|
|
72
|
-
| ((props: SliceProps) => VictorySliceLabelPositionType);
|
|
73
|
-
labelRadius?: number | ((props: SliceProps) => number);
|
|
74
|
-
origin?: OriginType;
|
|
75
|
-
padAngle?: NumberOrCallback;
|
|
76
|
-
radius?: NumberOrCallback;
|
|
77
|
-
startAngle?: number;
|
|
78
|
-
style?: VictoryStyleInterface;
|
|
79
|
-
x?: DataGetterPropType;
|
|
80
|
-
y?: DataGetterPropType;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export class VictoryPie extends React.Component<VictoryPieProps, any> {}
|
package/src/index.js
DELETED
package/src/victory-pie.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
|
|
2
|
-
import React from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import {
|
|
5
|
-
addEvents,
|
|
6
|
-
Helpers,
|
|
7
|
-
Data,
|
|
8
|
-
PropTypes as CustomPropTypes,
|
|
9
|
-
VictoryContainer,
|
|
10
|
-
VictoryLabel,
|
|
11
|
-
VictoryTheme,
|
|
12
|
-
UserProps,
|
|
13
|
-
} from "victory-core";
|
|
14
|
-
import Slice from "./slice";
|
|
15
|
-
import { getBaseProps } from "./helper-methods";
|
|
16
|
-
|
|
17
|
-
const fallbackProps = {
|
|
18
|
-
endAngle: 360,
|
|
19
|
-
height: 400,
|
|
20
|
-
innerRadius: 0,
|
|
21
|
-
cornerRadius: 0,
|
|
22
|
-
padAngle: 0,
|
|
23
|
-
padding: 30,
|
|
24
|
-
width: 400,
|
|
25
|
-
startAngle: 0,
|
|
26
|
-
colorScale: [
|
|
27
|
-
"#ffffff",
|
|
28
|
-
"#f0f0f0",
|
|
29
|
-
"#d9d9d9",
|
|
30
|
-
"#bdbdbd",
|
|
31
|
-
"#969696",
|
|
32
|
-
"#737373",
|
|
33
|
-
"#525252",
|
|
34
|
-
"#252525",
|
|
35
|
-
"#000000",
|
|
36
|
-
],
|
|
37
|
-
labelPosition: "centroid",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
class VictoryPie extends React.Component {
|
|
41
|
-
static animationWhitelist = [
|
|
42
|
-
"data",
|
|
43
|
-
"endAngle",
|
|
44
|
-
"height",
|
|
45
|
-
"innerRadius",
|
|
46
|
-
"cornerRadius",
|
|
47
|
-
"padAngle",
|
|
48
|
-
"padding",
|
|
49
|
-
"colorScale",
|
|
50
|
-
"startAngle",
|
|
51
|
-
"style",
|
|
52
|
-
"width",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
static displayName = "VictoryPie";
|
|
56
|
-
|
|
57
|
-
static role = "pie";
|
|
58
|
-
|
|
59
|
-
static defaultTransitions = {
|
|
60
|
-
onExit: {
|
|
61
|
-
duration: 500,
|
|
62
|
-
before: () => ({ _y: 0, label: " " }),
|
|
63
|
-
},
|
|
64
|
-
onEnter: {
|
|
65
|
-
duration: 500,
|
|
66
|
-
before: () => ({ _y: 0, label: " " }),
|
|
67
|
-
after: (datum) => ({
|
|
68
|
-
y_: datum._y,
|
|
69
|
-
label: datum.label,
|
|
70
|
-
}),
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
static propTypes = {
|
|
75
|
-
animate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
76
|
-
colorScale: PropTypes.oneOfType([
|
|
77
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
78
|
-
PropTypes.oneOf([
|
|
79
|
-
"grayscale",
|
|
80
|
-
"qualitative",
|
|
81
|
-
"heatmap",
|
|
82
|
-
"warm",
|
|
83
|
-
"cool",
|
|
84
|
-
"red",
|
|
85
|
-
"green",
|
|
86
|
-
"blue",
|
|
87
|
-
]),
|
|
88
|
-
]),
|
|
89
|
-
containerComponent: PropTypes.element,
|
|
90
|
-
cornerRadius: PropTypes.oneOfType([
|
|
91
|
-
CustomPropTypes.nonNegative,
|
|
92
|
-
PropTypes.func,
|
|
93
|
-
]),
|
|
94
|
-
data: PropTypes.array,
|
|
95
|
-
dataComponent: PropTypes.element,
|
|
96
|
-
disableInlineStyes: PropTypes.bool,
|
|
97
|
-
endAngle: PropTypes.number,
|
|
98
|
-
eventKey: PropTypes.oneOfType([
|
|
99
|
-
PropTypes.func,
|
|
100
|
-
CustomPropTypes.allOfType([
|
|
101
|
-
CustomPropTypes.integer,
|
|
102
|
-
CustomPropTypes.nonNegative,
|
|
103
|
-
]),
|
|
104
|
-
PropTypes.string,
|
|
105
|
-
]),
|
|
106
|
-
events: PropTypes.arrayOf(
|
|
107
|
-
PropTypes.shape({
|
|
108
|
-
target: PropTypes.oneOf(["data", "labels", "parent"]),
|
|
109
|
-
eventKey: PropTypes.oneOfType([
|
|
110
|
-
PropTypes.array,
|
|
111
|
-
PropTypes.func,
|
|
112
|
-
CustomPropTypes.allOfType([
|
|
113
|
-
CustomPropTypes.integer,
|
|
114
|
-
CustomPropTypes.nonNegative,
|
|
115
|
-
]),
|
|
116
|
-
PropTypes.string,
|
|
117
|
-
]),
|
|
118
|
-
eventHandlers: PropTypes.object,
|
|
119
|
-
}),
|
|
120
|
-
),
|
|
121
|
-
externalEventMutations: PropTypes.arrayOf(
|
|
122
|
-
PropTypes.shape({
|
|
123
|
-
callback: PropTypes.func,
|
|
124
|
-
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
125
|
-
eventKey: PropTypes.oneOfType([
|
|
126
|
-
PropTypes.array,
|
|
127
|
-
CustomPropTypes.allOfType([
|
|
128
|
-
CustomPropTypes.integer,
|
|
129
|
-
CustomPropTypes.nonNegative,
|
|
130
|
-
]),
|
|
131
|
-
PropTypes.string,
|
|
132
|
-
]),
|
|
133
|
-
mutation: PropTypes.func,
|
|
134
|
-
target: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
135
|
-
}),
|
|
136
|
-
),
|
|
137
|
-
groupComponent: PropTypes.element,
|
|
138
|
-
height: CustomPropTypes.nonNegative,
|
|
139
|
-
innerRadius: PropTypes.oneOfType([
|
|
140
|
-
CustomPropTypes.nonNegative,
|
|
141
|
-
PropTypes.func,
|
|
142
|
-
]),
|
|
143
|
-
labelComponent: PropTypes.element,
|
|
144
|
-
labelPlacement: PropTypes.oneOfType([
|
|
145
|
-
PropTypes.func,
|
|
146
|
-
PropTypes.oneOf(["parallel", "perpendicular", "vertical"]),
|
|
147
|
-
]),
|
|
148
|
-
labelPosition: PropTypes.oneOfType([
|
|
149
|
-
PropTypes.func,
|
|
150
|
-
PropTypes.oneOf(["startAngle", "centroid", "endAngle"]),
|
|
151
|
-
]),
|
|
152
|
-
labelRadius: PropTypes.oneOfType([
|
|
153
|
-
CustomPropTypes.nonNegative,
|
|
154
|
-
PropTypes.func,
|
|
155
|
-
]),
|
|
156
|
-
labels: PropTypes.oneOfType([PropTypes.func, PropTypes.array]),
|
|
157
|
-
name: PropTypes.string,
|
|
158
|
-
origin: PropTypes.shape({
|
|
159
|
-
x: CustomPropTypes.nonNegative,
|
|
160
|
-
y: CustomPropTypes.nonNegative,
|
|
161
|
-
}),
|
|
162
|
-
padAngle: PropTypes.oneOfType([
|
|
163
|
-
CustomPropTypes.nonNegative,
|
|
164
|
-
PropTypes.func,
|
|
165
|
-
]),
|
|
166
|
-
padding: PropTypes.oneOfType([
|
|
167
|
-
PropTypes.number,
|
|
168
|
-
PropTypes.shape({
|
|
169
|
-
top: PropTypes.number,
|
|
170
|
-
bottom: PropTypes.number,
|
|
171
|
-
left: PropTypes.number,
|
|
172
|
-
right: PropTypes.number,
|
|
173
|
-
}),
|
|
174
|
-
]),
|
|
175
|
-
radius: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]),
|
|
176
|
-
sharedEvents: PropTypes.shape({
|
|
177
|
-
events: PropTypes.array,
|
|
178
|
-
getEventState: PropTypes.func,
|
|
179
|
-
}),
|
|
180
|
-
sortKey: PropTypes.oneOfType([
|
|
181
|
-
PropTypes.func,
|
|
182
|
-
CustomPropTypes.allOfType([
|
|
183
|
-
CustomPropTypes.integer,
|
|
184
|
-
CustomPropTypes.nonNegative,
|
|
185
|
-
]),
|
|
186
|
-
PropTypes.string,
|
|
187
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
188
|
-
]),
|
|
189
|
-
sortOrder: PropTypes.oneOf(["ascending", "descending"]),
|
|
190
|
-
standalone: PropTypes.bool,
|
|
191
|
-
startAngle: PropTypes.number,
|
|
192
|
-
style: PropTypes.shape({
|
|
193
|
-
parent: PropTypes.object,
|
|
194
|
-
data: PropTypes.object,
|
|
195
|
-
labels: PropTypes.object,
|
|
196
|
-
}),
|
|
197
|
-
theme: PropTypes.object,
|
|
198
|
-
width: CustomPropTypes.nonNegative,
|
|
199
|
-
x: PropTypes.oneOfType([
|
|
200
|
-
PropTypes.func,
|
|
201
|
-
CustomPropTypes.allOfType([
|
|
202
|
-
CustomPropTypes.integer,
|
|
203
|
-
CustomPropTypes.nonNegative,
|
|
204
|
-
]),
|
|
205
|
-
PropTypes.string,
|
|
206
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
207
|
-
]),
|
|
208
|
-
y: PropTypes.oneOfType([
|
|
209
|
-
PropTypes.func,
|
|
210
|
-
CustomPropTypes.allOfType([
|
|
211
|
-
CustomPropTypes.integer,
|
|
212
|
-
CustomPropTypes.nonNegative,
|
|
213
|
-
]),
|
|
214
|
-
PropTypes.string,
|
|
215
|
-
PropTypes.arrayOf(PropTypes.string),
|
|
216
|
-
]),
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
static defaultProps = {
|
|
220
|
-
data: [
|
|
221
|
-
{ x: "A", y: 1 },
|
|
222
|
-
{ x: "B", y: 2 },
|
|
223
|
-
{ x: "C", y: 3 },
|
|
224
|
-
{ x: "D", y: 1 },
|
|
225
|
-
{ x: "E", y: 2 },
|
|
226
|
-
],
|
|
227
|
-
standalone: true,
|
|
228
|
-
dataComponent: <Slice />,
|
|
229
|
-
labelComponent: <VictoryLabel />,
|
|
230
|
-
containerComponent: <VictoryContainer />,
|
|
231
|
-
groupComponent: <g />,
|
|
232
|
-
sortOrder: "ascending",
|
|
233
|
-
theme: VictoryTheme.grayscale,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
|
|
237
|
-
static getData = Data.getData;
|
|
238
|
-
static expectedComponents = [
|
|
239
|
-
"dataComponent",
|
|
240
|
-
"labelComponent",
|
|
241
|
-
"groupComponent",
|
|
242
|
-
"containerComponent",
|
|
243
|
-
];
|
|
244
|
-
|
|
245
|
-
// Overridden in victory-native
|
|
246
|
-
shouldAnimate() {
|
|
247
|
-
return Boolean(this.props.animate);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
render() {
|
|
251
|
-
const { animationWhitelist, role } = VictoryPie;
|
|
252
|
-
const props = Helpers.modifyProps(this.props, fallbackProps, role);
|
|
253
|
-
|
|
254
|
-
if (this.shouldAnimate()) {
|
|
255
|
-
return this.animateComponent(props, animationWhitelist);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const children = this.renderData(props);
|
|
259
|
-
|
|
260
|
-
const component = props.standalone
|
|
261
|
-
? this.renderContainer(props.containerComponent, children)
|
|
262
|
-
: children;
|
|
263
|
-
|
|
264
|
-
return UserProps.withSafeUserProps(component, props);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export default addEvents(VictoryPie);
|