gifted-charts-core 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/PieChart/pro.js +7 -32
- package/src/PieChart/pro.ts +7 -9
package/package.json
CHANGED
package/src/PieChart/pro.js
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
1
|
import { defaultAnimationDuration } from '../utils/constants';
|
|
27
2
|
export var usePiePro = function (props) {
|
|
28
3
|
var _a, _b;
|
|
@@ -131,7 +106,11 @@ export var usePiePro = function (props) {
|
|
|
131
106
|
var cropAtEnd = !!(index === data.length - 1 &&
|
|
132
107
|
(item.isEndEdgeCurved || item.endEdgeRadius));
|
|
133
108
|
var _c = getCoordinates(index, cropAtEnd ? additionalForEnd : additionalForStart, !cropAtEnd, cropAtEnd, totalParam), startInnerX = _c.startInnerX, startInnerY = _c.startInnerY, endOuterX = _c.endOuterX, endOuterY = _c.endOuterY, endInnerX = _c.endInnerX, endInnerY = _c.endInnerY;
|
|
134
|
-
var isLargeArc =
|
|
109
|
+
var isLargeArc = semiCircle
|
|
110
|
+
? 0
|
|
111
|
+
: ((_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) / (totalParam !== null && totalParam !== void 0 ? totalParam : total) > 0.5
|
|
112
|
+
? 1
|
|
113
|
+
: 0;
|
|
135
114
|
var innerArc = "A".concat(innerRadius, ",").concat(innerRadius, " 0 ").concat(isLargeArc, " 1 ");
|
|
136
115
|
var outerArc = "A".concat(radius + ((_b = props.strokeWidth) !== null && _b !== void 0 ? _b : 0) / 2, ",").concat(radius, " 0 ").concat(isLargeArc, " 0 ");
|
|
137
116
|
var path = "".concat(outerArc, " ").concat(endOuterX, ", ").concat(endOuterY, "\n L").concat(endInnerX, ",").concat(endInnerY, " M").concat(endInnerX, ",").concat(endInnerY, " ").concat(innerArc, " ").concat(startInnerX, ",").concat(startInnerY);
|
|
@@ -160,17 +139,13 @@ export var usePiePro = function (props) {
|
|
|
160
139
|
var path = "M".concat(endInnerX, ",").concat(endInnerY, " A").concat(edgeRadius, ",").concat(edgeRadius, " 0 0 1 ").concat(endOuterX, ",").concat(endOuterY);
|
|
161
140
|
return path;
|
|
162
141
|
};
|
|
163
|
-
var
|
|
164
|
-
? data
|
|
165
|
-
: __spreadArray(__spreadArray([], __read(data), false), [{ value: total * 100 }], false);
|
|
166
|
-
var dataForFinalPath = isAnimated ? data : __spreadArray(__spreadArray([], __read(data), false), [{ value: 0 }], false);
|
|
167
|
-
var dInitial = dataForInitialPath.map(function (item, index) {
|
|
142
|
+
var dInitial = data.map(function (item, index) {
|
|
168
143
|
return "".concat(initial || getInitial(item), " ").concat(donut
|
|
169
144
|
? getDonutPath(index, item, total * 101)
|
|
170
145
|
: getPath(index, total * 101));
|
|
171
146
|
});
|
|
172
147
|
initial = '';
|
|
173
|
-
var dFinal =
|
|
148
|
+
var dFinal = data.map(function (item, index) {
|
|
174
149
|
return "".concat(initial || getInitial(item), " ").concat(donut ? getDonutPath(index, item) : getPath(index));
|
|
175
150
|
});
|
|
176
151
|
return {
|
package/src/PieChart/pro.ts
CHANGED
|
@@ -190,8 +190,11 @@ export const usePiePro = (props: PieChartPropsType): IusePiePro => {
|
|
|
190
190
|
cropAtEnd,
|
|
191
191
|
totalParam
|
|
192
192
|
)
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
const isLargeArc = semiCircle
|
|
194
|
+
? 0
|
|
195
|
+
: data[index]?.value / (totalParam ?? total) > 0.5
|
|
196
|
+
? 1
|
|
197
|
+
: 0
|
|
195
198
|
|
|
196
199
|
const innerArc = `A${innerRadius},${innerRadius} 0 ${isLargeArc} 1 `
|
|
197
200
|
const outerArc = `A${
|
|
@@ -233,12 +236,7 @@ export const usePiePro = (props: PieChartPropsType): IusePiePro => {
|
|
|
233
236
|
return path
|
|
234
237
|
}
|
|
235
238
|
|
|
236
|
-
const
|
|
237
|
-
? data
|
|
238
|
-
: [...data, { value: total * 100 }]
|
|
239
|
-
const dataForFinalPath = isAnimated ? data : [...data, { value: 0 }]
|
|
240
|
-
|
|
241
|
-
const dInitial = dataForInitialPath.map(
|
|
239
|
+
const dInitial = data.map(
|
|
242
240
|
(item, index) =>
|
|
243
241
|
`${initial || getInitial(item)} ${
|
|
244
242
|
donut
|
|
@@ -248,7 +246,7 @@ export const usePiePro = (props: PieChartPropsType): IusePiePro => {
|
|
|
248
246
|
)
|
|
249
247
|
|
|
250
248
|
initial = ''
|
|
251
|
-
const dFinal =
|
|
249
|
+
const dFinal = data.map(
|
|
252
250
|
(item, index) =>
|
|
253
251
|
`${initial || getInitial(item)} ${
|
|
254
252
|
donut ? getDonutPath(index, item) : getPath(index)
|