victory-pie 36.9.2 → 37.0.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/CHANGELOG.md +6 -0
- package/dist/victory-pie.js +3531 -4664
- package/dist/victory-pie.min.js +1 -1
- package/es/helper-methods.js +189 -219
- package/es/slice.js +48 -54
- package/es/victory-pie.js +118 -192
- package/lib/helper-methods.js +191 -252
- package/lib/index.js +0 -4
- package/lib/slice.js +50 -77
- package/lib/victory-pie.js +118 -200
- package/package.json +3 -3
package/lib/helper-methods.js
CHANGED
|
@@ -4,103 +4,85 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getYOffsetMultiplayerByAngle = exports.getYOffset = exports.getXOffsetMultiplayerByAngle = exports.getXOffset = exports.getLabelIndicatorPropsForLineSegment = exports.getBaseProps = exports.getAverage = void 0;
|
|
7
|
-
|
|
8
7
|
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
9
|
-
|
|
10
8
|
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
11
|
-
|
|
12
9
|
var d3Shape = _interopRequireWildcard(require("victory-vendor/d3-shape"));
|
|
13
|
-
|
|
14
10
|
var _victoryCore = require("victory-core");
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
/* eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 45, 90, 135, 180, 225, 270, 315, 360] }]*/
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
const checkForValidText = text => {
|
|
23
17
|
if (text === undefined || text === null || _victoryCore.Helpers.isFunction(text)) {
|
|
24
18
|
return text;
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
return "".concat(text);
|
|
20
|
+
return `${text}`;
|
|
28
21
|
};
|
|
29
|
-
|
|
30
|
-
var getColor = function (style, colors, index) {
|
|
22
|
+
const getColor = (style, colors, index) => {
|
|
31
23
|
if (style && style.data && style.data.fill) {
|
|
32
24
|
return style.data.fill;
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
return colors && colors[index % colors.length];
|
|
36
27
|
};
|
|
37
|
-
|
|
38
|
-
var getRadius = function (props, padding) {
|
|
28
|
+
const getRadius = (props, padding) => {
|
|
39
29
|
if (typeof props.radius === "number") {
|
|
40
30
|
return props.radius;
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
return Math.min(props.width - padding.left - padding.right, props.height - padding.top - padding.bottom) / 2;
|
|
44
33
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
const getOrigin = (props, padding) => {
|
|
35
|
+
const {
|
|
36
|
+
width,
|
|
37
|
+
height
|
|
38
|
+
} = props;
|
|
39
|
+
const origin = (0, _isPlainObject2.default)(props.origin) ? props.origin : {};
|
|
50
40
|
return {
|
|
51
41
|
x: origin.x !== undefined ? origin.x : (padding.left - padding.right + width) / 2,
|
|
52
42
|
y: origin.y !== undefined ? origin.y : (padding.top - padding.bottom + height) / 2
|
|
53
43
|
};
|
|
54
44
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var layoutFunction = d3Shape.pie().sort(null).startAngle(_victoryCore.Helpers.degreesToRadians(props.startAngle)).endAngle(_victoryCore.Helpers.degreesToRadians(props.endAngle)).padAngle(_victoryCore.Helpers.degreesToRadians(padAngle)).value(function (datum) {
|
|
45
|
+
const getSlices = (props, data) => {
|
|
46
|
+
const padAngle = _victoryCore.Helpers.isFunction(props.padAngle) ? 0 : props.padAngle;
|
|
47
|
+
const layoutFunction = d3Shape.pie().sort(null).startAngle(_victoryCore.Helpers.degreesToRadians(props.startAngle)).endAngle(_victoryCore.Helpers.degreesToRadians(props.endAngle)).padAngle(_victoryCore.Helpers.degreesToRadians(padAngle)).value(datum => {
|
|
59
48
|
return datum._y;
|
|
60
49
|
});
|
|
61
50
|
return layoutFunction(data);
|
|
62
51
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var defaultRadius = getRadius(props, padding);
|
|
76
|
-
var origin = getOrigin(props, padding);
|
|
77
|
-
|
|
78
|
-
var data = _victoryCore.Data.getData(props);
|
|
79
|
-
|
|
80
|
-
var slices = getSlices(props, data);
|
|
52
|
+
const getCalculatedValues = props => {
|
|
53
|
+
const {
|
|
54
|
+
colorScale
|
|
55
|
+
} = props;
|
|
56
|
+
const styleObject = _victoryCore.Helpers.getDefaultStyles(props, "pie");
|
|
57
|
+
const style = _victoryCore.Helpers.getStyles(props.style, styleObject);
|
|
58
|
+
const colors = Array.isArray(colorScale) ? colorScale : _victoryCore.Style.getColorScale(colorScale);
|
|
59
|
+
const padding = _victoryCore.Helpers.getPadding(props);
|
|
60
|
+
const defaultRadius = getRadius(props, padding);
|
|
61
|
+
const origin = getOrigin(props, padding);
|
|
62
|
+
const data = _victoryCore.Data.getData(props);
|
|
63
|
+
const slices = getSlices(props, data);
|
|
81
64
|
return Object.assign({}, props, {
|
|
82
|
-
style
|
|
83
|
-
colors
|
|
84
|
-
padding
|
|
85
|
-
defaultRadius
|
|
86
|
-
data
|
|
87
|
-
slices
|
|
88
|
-
origin
|
|
65
|
+
style,
|
|
66
|
+
colors,
|
|
67
|
+
padding,
|
|
68
|
+
defaultRadius,
|
|
69
|
+
data,
|
|
70
|
+
slices,
|
|
71
|
+
origin
|
|
89
72
|
});
|
|
90
73
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
const getSliceStyle = (index, calculatedValues) => {
|
|
75
|
+
const {
|
|
76
|
+
style,
|
|
77
|
+
colors
|
|
78
|
+
} = calculatedValues;
|
|
79
|
+
const fill = getColor(style, colors, index);
|
|
96
80
|
return Object.assign({
|
|
97
|
-
fill
|
|
81
|
+
fill
|
|
98
82
|
}, style.data);
|
|
99
83
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var text;
|
|
103
|
-
|
|
84
|
+
const getLabelText = (props, datum, index) => {
|
|
85
|
+
let text;
|
|
104
86
|
if (datum.label) {
|
|
105
87
|
text = datum.label;
|
|
106
88
|
} else if (Array.isArray(props.labels)) {
|
|
@@ -108,35 +90,29 @@ var getLabelText = function (props, datum, index) {
|
|
|
108
90
|
} else {
|
|
109
91
|
text = _victoryCore.Helpers.isFunction(props.labels) ? props.labels : datum.xName || datum._x;
|
|
110
92
|
}
|
|
111
|
-
|
|
112
93
|
return checkForValidText(text);
|
|
113
94
|
};
|
|
114
|
-
|
|
115
|
-
var getLabelArc = function (labelRadius) {
|
|
95
|
+
const getLabelArc = labelRadius => {
|
|
116
96
|
return d3Shape.arc().outerRadius(labelRadius).innerRadius(labelRadius);
|
|
117
97
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var padding = style && style.padding || 0;
|
|
98
|
+
const getCalculatedLabelRadius = (radius, labelRadius, style) => {
|
|
99
|
+
const padding = style && style.padding || 0;
|
|
121
100
|
return labelRadius || radius + padding;
|
|
122
101
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var construct = {
|
|
102
|
+
const getLabelPosition = (arc, slice, position) => {
|
|
103
|
+
const construct = {
|
|
126
104
|
startAngle: position === "startAngle" ? slice.startAngle : slice.endAngle,
|
|
127
105
|
endAngle: position === "endAngle" ? slice.endAngle : slice.startAngle
|
|
128
106
|
};
|
|
129
|
-
|
|
107
|
+
const clonedArc = Object.assign({}, slice, construct);
|
|
130
108
|
return arc.centroid(clonedArc);
|
|
131
109
|
};
|
|
132
|
-
|
|
133
|
-
var getLabelOrientation = function (degree, labelPlacement) {
|
|
110
|
+
const getLabelOrientation = (degree, labelPlacement) => {
|
|
134
111
|
if (labelPlacement === "perpendicular") {
|
|
135
112
|
return degree > 90 && degree < 270 ? "bottom" : "top";
|
|
136
113
|
} else if (labelPlacement === "parallel") {
|
|
137
114
|
return degree >= 0 && degree <= 180 ? "right" : "left";
|
|
138
115
|
}
|
|
139
|
-
|
|
140
116
|
if (degree < 45 || degree > 315) {
|
|
141
117
|
return "top";
|
|
142
118
|
} else if (degree >= 45 && degree < 135) {
|
|
@@ -144,29 +120,22 @@ var getLabelOrientation = function (degree, labelPlacement) {
|
|
|
144
120
|
} else if (degree >= 135 && degree < 225) {
|
|
145
121
|
return "bottom";
|
|
146
122
|
}
|
|
147
|
-
|
|
148
123
|
return "left";
|
|
149
124
|
};
|
|
150
|
-
|
|
151
|
-
var getTextAnchor = function (orientation) {
|
|
125
|
+
const getTextAnchor = orientation => {
|
|
152
126
|
if (orientation === "top" || orientation === "bottom") {
|
|
153
127
|
return "middle";
|
|
154
128
|
}
|
|
155
|
-
|
|
156
129
|
return orientation === "right" ? "start" : "end";
|
|
157
130
|
};
|
|
158
|
-
|
|
159
|
-
var getVerticalAnchor = function (orientation) {
|
|
131
|
+
const getVerticalAnchor = orientation => {
|
|
160
132
|
if (orientation === "left" || orientation === "right") {
|
|
161
133
|
return "middle";
|
|
162
134
|
}
|
|
163
|
-
|
|
164
135
|
return orientation === "bottom" ? "start" : "end";
|
|
165
136
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var baseAngle = 0;
|
|
169
|
-
|
|
137
|
+
const getBaseLabelAngle = (slice, labelPosition, labelStyle) => {
|
|
138
|
+
let baseAngle = 0;
|
|
170
139
|
if (labelPosition.angle !== undefined) {
|
|
171
140
|
baseAngle = labelStyle.angle;
|
|
172
141
|
} else if (labelPosition === "centroid") {
|
|
@@ -174,229 +143,199 @@ var getBaseLabelAngle = function (slice, labelPosition, labelStyle) {
|
|
|
174
143
|
} else {
|
|
175
144
|
baseAngle = labelPosition === "startAngle" ? _victoryCore.Helpers.radiansToDegrees(slice.startAngle) : _victoryCore.Helpers.radiansToDegrees(slice.endAngle);
|
|
176
145
|
}
|
|
177
|
-
|
|
178
|
-
var positiveAngle = baseAngle < 0 ? 360 - baseAngle : baseAngle;
|
|
146
|
+
const positiveAngle = baseAngle < 0 ? 360 - baseAngle : baseAngle;
|
|
179
147
|
return positiveAngle % 360;
|
|
180
148
|
};
|
|
181
|
-
|
|
182
|
-
var getLabelAngle = function (baseAngle, labelPlacement) {
|
|
149
|
+
const getLabelAngle = (baseAngle, labelPlacement) => {
|
|
183
150
|
if (labelPlacement === "vertical") {
|
|
184
151
|
return 0;
|
|
185
152
|
}
|
|
186
|
-
|
|
187
153
|
if (labelPlacement === "parallel") {
|
|
188
154
|
return baseAngle > 180 && baseAngle < 360 ? baseAngle + 90 : baseAngle - 90;
|
|
189
155
|
}
|
|
190
|
-
|
|
191
156
|
return baseAngle > 90 && baseAngle < 270 ? baseAngle - 180 : baseAngle;
|
|
192
157
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
158
|
+
const getLabelProps = (text, dataProps, calculatedValues) => {
|
|
159
|
+
const {
|
|
160
|
+
index,
|
|
161
|
+
datum,
|
|
162
|
+
data,
|
|
163
|
+
slice,
|
|
164
|
+
labelComponent,
|
|
165
|
+
theme
|
|
166
|
+
} = dataProps;
|
|
167
|
+
const {
|
|
168
|
+
style,
|
|
169
|
+
defaultRadius,
|
|
170
|
+
origin,
|
|
171
|
+
width,
|
|
172
|
+
height
|
|
173
|
+
} = calculatedValues;
|
|
174
|
+
const labelRadius = _victoryCore.Helpers.evaluateProp(calculatedValues.labelRadius, Object.assign({
|
|
175
|
+
text
|
|
209
176
|
}, dataProps));
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
text: text
|
|
177
|
+
const labelPosition = _victoryCore.Helpers.evaluateProp(calculatedValues.labelPosition, Object.assign({
|
|
178
|
+
text
|
|
213
179
|
}, dataProps)) || "centroid";
|
|
214
|
-
|
|
215
|
-
text
|
|
180
|
+
const labelPlacement = _victoryCore.Helpers.evaluateProp(calculatedValues.labelPlacement, Object.assign({
|
|
181
|
+
text
|
|
216
182
|
}, dataProps)) || "vertical";
|
|
217
|
-
|
|
183
|
+
const labelStyle = Object.assign({
|
|
218
184
|
padding: 0
|
|
219
185
|
}, style.labels);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
text: text
|
|
186
|
+
const evaluatedStyle = _victoryCore.Helpers.evaluateStyle(labelStyle, Object.assign({
|
|
187
|
+
labelRadius,
|
|
188
|
+
text
|
|
224
189
|
}, dataProps));
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
text: text,
|
|
190
|
+
const calculatedLabelRadius = getCalculatedLabelRadius(defaultRadius, labelRadius, evaluatedStyle);
|
|
191
|
+
const labelArc = getLabelArc(calculatedLabelRadius);
|
|
192
|
+
const position = getLabelPosition(labelArc, slice, labelPosition);
|
|
193
|
+
const baseAngle = getBaseLabelAngle(slice, labelPosition, labelStyle);
|
|
194
|
+
const labelAngle = getLabelAngle(baseAngle, labelPlacement);
|
|
195
|
+
const orientation = getLabelOrientation(baseAngle, labelPlacement);
|
|
196
|
+
const textAnchor = labelStyle.textAnchor || getTextAnchor(orientation);
|
|
197
|
+
const verticalAnchor = labelStyle.verticalAnchor || getVerticalAnchor(orientation);
|
|
198
|
+
const labelProps = {
|
|
199
|
+
width,
|
|
200
|
+
height,
|
|
201
|
+
index,
|
|
202
|
+
datum,
|
|
203
|
+
data,
|
|
204
|
+
slice,
|
|
205
|
+
orientation,
|
|
206
|
+
text,
|
|
243
207
|
style: labelStyle,
|
|
244
208
|
x: Math.round(position[0]) + origin.x,
|
|
245
209
|
y: Math.round(position[1]) + origin.y,
|
|
246
|
-
textAnchor
|
|
247
|
-
verticalAnchor
|
|
210
|
+
textAnchor,
|
|
211
|
+
verticalAnchor,
|
|
248
212
|
angle: labelAngle,
|
|
249
|
-
calculatedLabelRadius
|
|
213
|
+
calculatedLabelRadius
|
|
250
214
|
};
|
|
251
|
-
|
|
252
215
|
if (!_victoryCore.Helpers.isTooltip(labelComponent)) {
|
|
253
216
|
return labelProps;
|
|
254
217
|
}
|
|
255
|
-
|
|
256
|
-
var tooltipTheme = theme && theme.tooltip || {};
|
|
218
|
+
const tooltipTheme = theme && theme.tooltip || {};
|
|
257
219
|
return (0, _defaults2.default)({}, labelProps, _victoryCore.Helpers.omit(tooltipTheme, ["style"]));
|
|
258
220
|
};
|
|
259
|
-
|
|
260
|
-
var getXOffsetMultiplayerByAngle = function (angle) {
|
|
261
|
-
return Math.cos(angle - _victoryCore.Helpers.degreesToRadians(90));
|
|
262
|
-
};
|
|
263
|
-
|
|
221
|
+
const getXOffsetMultiplayerByAngle = angle => Math.cos(angle - _victoryCore.Helpers.degreesToRadians(90));
|
|
264
222
|
exports.getXOffsetMultiplayerByAngle = getXOffsetMultiplayerByAngle;
|
|
265
|
-
|
|
266
|
-
var getYOffsetMultiplayerByAngle = function (angle) {
|
|
267
|
-
return Math.sin(angle - _victoryCore.Helpers.degreesToRadians(90));
|
|
268
|
-
};
|
|
269
|
-
|
|
223
|
+
const getYOffsetMultiplayerByAngle = angle => Math.sin(angle - _victoryCore.Helpers.degreesToRadians(90));
|
|
270
224
|
exports.getYOffsetMultiplayerByAngle = getYOffsetMultiplayerByAngle;
|
|
271
|
-
|
|
272
|
-
var getXOffset = function (offset, angle) {
|
|
273
|
-
return offset * getXOffsetMultiplayerByAngle(angle);
|
|
274
|
-
};
|
|
275
|
-
|
|
225
|
+
const getXOffset = (offset, angle) => offset * getXOffsetMultiplayerByAngle(angle);
|
|
276
226
|
exports.getXOffset = getXOffset;
|
|
277
|
-
|
|
278
|
-
var getYOffset = function (offset, angle) {
|
|
279
|
-
return offset * getYOffsetMultiplayerByAngle(angle);
|
|
280
|
-
};
|
|
281
|
-
|
|
227
|
+
const getYOffset = (offset, angle) => offset * getYOffsetMultiplayerByAngle(angle);
|
|
282
228
|
exports.getYOffset = getYOffset;
|
|
283
|
-
|
|
284
|
-
var getAverage = function (array) {
|
|
285
|
-
return array.reduce(function (acc, cur) {
|
|
286
|
-
return acc + cur;
|
|
287
|
-
}, 0) / array.length;
|
|
288
|
-
};
|
|
289
|
-
|
|
229
|
+
const getAverage = array => array.reduce((acc, cur) => acc + cur, 0) / array.length;
|
|
290
230
|
exports.getAverage = getAverage;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
startAngle
|
|
297
|
-
endAngle
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
231
|
+
const getLabelIndicatorPropsForLineSegment = (props, calculatedValues, labelProps) => {
|
|
232
|
+
const {
|
|
233
|
+
innerRadius,
|
|
234
|
+
radius,
|
|
235
|
+
slice: {
|
|
236
|
+
startAngle,
|
|
237
|
+
endAngle
|
|
238
|
+
},
|
|
239
|
+
labelIndicatorInnerOffset,
|
|
240
|
+
labelIndicatorOuterOffset,
|
|
241
|
+
index
|
|
242
|
+
} = props;
|
|
243
|
+
const {
|
|
244
|
+
height,
|
|
245
|
+
width
|
|
246
|
+
} = calculatedValues;
|
|
247
|
+
const {
|
|
248
|
+
calculatedLabelRadius
|
|
249
|
+
} = labelProps;
|
|
250
|
+
// calculation
|
|
251
|
+
const middleRadius = getAverage([innerRadius, radius]);
|
|
252
|
+
const midAngle = getAverage([endAngle, startAngle]);
|
|
253
|
+
const centerX = width / 2;
|
|
254
|
+
const centerY = height / 2;
|
|
255
|
+
const innerOffset = middleRadius + labelIndicatorInnerOffset;
|
|
256
|
+
const outerOffset = calculatedLabelRadius - labelIndicatorOuterOffset;
|
|
257
|
+
const x1 = centerX + getXOffset(innerOffset, midAngle);
|
|
258
|
+
const y1 = centerY + getYOffset(innerOffset, midAngle);
|
|
259
|
+
const x2 = centerX + getXOffset(outerOffset, midAngle);
|
|
260
|
+
const y2 = centerY + getYOffset(outerOffset, midAngle);
|
|
261
|
+
const labelIndicatorProps = {
|
|
262
|
+
x1,
|
|
263
|
+
y1,
|
|
264
|
+
x2,
|
|
265
|
+
y2,
|
|
266
|
+
index
|
|
321
267
|
};
|
|
322
268
|
return (0, _defaults2.default)({}, labelIndicatorProps);
|
|
323
269
|
};
|
|
324
|
-
|
|
325
270
|
exports.getLabelIndicatorPropsForLineSegment = getLabelIndicatorPropsForLineSegment;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
271
|
+
const getBaseProps = (initialProps, fallbackProps) => {
|
|
272
|
+
const props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "pie");
|
|
273
|
+
const calculatedValues = getCalculatedValues(props);
|
|
274
|
+
const {
|
|
275
|
+
slices,
|
|
276
|
+
style,
|
|
277
|
+
data,
|
|
278
|
+
origin,
|
|
279
|
+
defaultRadius,
|
|
280
|
+
labels,
|
|
281
|
+
events,
|
|
282
|
+
sharedEvents,
|
|
283
|
+
height,
|
|
284
|
+
width,
|
|
285
|
+
standalone,
|
|
286
|
+
name,
|
|
287
|
+
innerRadius,
|
|
288
|
+
cornerRadius,
|
|
289
|
+
padAngle,
|
|
290
|
+
disableInlineStyles,
|
|
291
|
+
labelIndicator
|
|
292
|
+
} = calculatedValues;
|
|
293
|
+
const radius = props.radius || defaultRadius;
|
|
294
|
+
const initialChildProps = {
|
|
350
295
|
parent: {
|
|
351
|
-
standalone
|
|
352
|
-
height
|
|
353
|
-
width
|
|
354
|
-
slices
|
|
355
|
-
name
|
|
296
|
+
standalone,
|
|
297
|
+
height,
|
|
298
|
+
width,
|
|
299
|
+
slices,
|
|
300
|
+
name,
|
|
356
301
|
style: style.parent
|
|
357
302
|
}
|
|
358
303
|
};
|
|
359
|
-
return slices.reduce(
|
|
360
|
-
|
|
304
|
+
return slices.reduce((childProps, slice, index) => {
|
|
305
|
+
const datum = (0, _defaults2.default)({}, data[index], {
|
|
361
306
|
startAngle: _victoryCore.Helpers.radiansToDegrees(slice.startAngle),
|
|
362
307
|
endAngle: _victoryCore.Helpers.radiansToDegrees(slice.endAngle),
|
|
363
308
|
padAngle: _victoryCore.Helpers.radiansToDegrees(slice.padAngle)
|
|
364
309
|
});
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
index
|
|
368
|
-
slice
|
|
369
|
-
datum
|
|
370
|
-
data
|
|
371
|
-
origin
|
|
372
|
-
innerRadius
|
|
373
|
-
radius
|
|
374
|
-
cornerRadius
|
|
375
|
-
padAngle
|
|
310
|
+
const eventKey = !_victoryCore.Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
|
|
311
|
+
const dataProps = {
|
|
312
|
+
index,
|
|
313
|
+
slice,
|
|
314
|
+
datum,
|
|
315
|
+
data,
|
|
316
|
+
origin,
|
|
317
|
+
innerRadius,
|
|
318
|
+
radius,
|
|
319
|
+
cornerRadius,
|
|
320
|
+
padAngle,
|
|
376
321
|
style: disableInlineStyles ? {} : getSliceStyle(index, calculatedValues),
|
|
377
|
-
disableInlineStyles
|
|
322
|
+
disableInlineStyles
|
|
378
323
|
};
|
|
379
324
|
childProps[eventKey] = {
|
|
380
325
|
data: dataProps
|
|
381
326
|
};
|
|
382
|
-
|
|
383
|
-
|
|
327
|
+
const text = getLabelText(props, datum, index);
|
|
384
328
|
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
|
|
385
|
-
|
|
386
|
-
|
|
329
|
+
const evaluatedText = _victoryCore.Helpers.evaluateProp(text, dataProps);
|
|
387
330
|
childProps[eventKey].labels = getLabelProps(evaluatedText, Object.assign({}, props, dataProps), calculatedValues);
|
|
388
|
-
|
|
389
331
|
if (labelIndicator) {
|
|
390
|
-
|
|
391
|
-
|
|
332
|
+
const labelProps = childProps[eventKey].labels;
|
|
392
333
|
if (labelProps.calculatedLabelRadius > radius) {
|
|
393
334
|
childProps[eventKey].labelIndicators = getLabelIndicatorPropsForLineSegment(Object.assign({}, props, dataProps), calculatedValues, labelProps);
|
|
394
335
|
}
|
|
395
336
|
}
|
|
396
337
|
}
|
|
397
|
-
|
|
398
338
|
return childProps;
|
|
399
339
|
}, initialChildProps);
|
|
400
340
|
};
|
|
401
|
-
|
|
402
341
|
exports.getBaseProps = getBaseProps;
|
package/lib/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _victoryPie = require("./victory-pie");
|
|
8
|
-
|
|
9
7
|
Object.keys(_victoryPie).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _victoryPie[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_victoryPie).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _slice = require("./slice");
|
|
21
|
-
|
|
22
18
|
Object.keys(_slice).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _slice[key]) return;
|