gifted-charts-core 0.0.39 → 0.0.41
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/index.d.ts +5 -1
- package/src/PieChart/index.js +7 -6
- package/src/PieChart/index.ts +10 -2
- package/src/PieChart/main.d.ts +1 -1
- package/src/PieChart/types.d.ts +11 -1
- package/src/PieChart/types.ts +11 -1
- package/src/utils/types.d.ts +1 -0
- package/src/utils/types.ts +2 -0
package/package.json
CHANGED
package/src/PieChart/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ interface IusePieChart {
|
|
|
7
7
|
selectedIndex: number;
|
|
8
8
|
setSelectedIndex: (index: number) => void;
|
|
9
9
|
startAngle: number;
|
|
10
|
+
endAngle: number;
|
|
10
11
|
setStartAngle: (angle: number) => void;
|
|
11
12
|
total: number;
|
|
12
13
|
setTotal: (total: number) => void;
|
|
@@ -29,5 +30,8 @@ interface IusePieChart {
|
|
|
29
30
|
paddingHorizontal: number;
|
|
30
31
|
paddingVertical: number;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
interface IPieChartPropsType extends PieChartPropsType {
|
|
34
|
+
pro?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const usePieChart: (props: IPieChartPropsType) => IusePieChart;
|
|
33
37
|
export {};
|
package/src/PieChart/index.js
CHANGED
|
@@ -17,14 +17,14 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
17
17
|
import { useEffect, useState } from 'react';
|
|
18
18
|
import { getTextSizeForPieLabels } from '../utils';
|
|
19
19
|
export var usePieChart = function (props) {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
21
21
|
var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
|
|
22
22
|
var extraRadiusForFocused = (_b = props.extraRadiusForFocused) !== null && _b !== void 0 ? _b : (((_c = props.focusOnPress) !== null && _c !== void 0 ? _c : props.sectionAutoFocus) ? radius / 10 : 0);
|
|
23
23
|
var pi = props.semiCircle ? Math.PI / 2 : Math.PI;
|
|
24
|
-
var
|
|
24
|
+
var _w = __read(useState(-1), 2), selectedIndex = _w[0], setSelectedIndex = _w[1]; // at the start, nothing is selected
|
|
25
25
|
// because we're going to use a useEffect, we need startAngle and total to be state variables
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var _x = __read(useState((_d = props.initialAngle) !== null && _d !== void 0 ? _d : (props.semiCircle ? -pi : 0)), 2), startAngle = _x[0], setStartAngle = _x[1];
|
|
27
|
+
var _y = __read(useState(0), 2), total = _y[0], setTotal = _y[1];
|
|
28
28
|
useEffect(function () {
|
|
29
29
|
var _a;
|
|
30
30
|
// Update the total, this could be use to replace the forEach : const newTotal = props.data.reduce((acc, item) => acc + item.value, 0);
|
|
@@ -63,7 +63,7 @@ export var usePieChart = function (props) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}, [selectedIndex]);
|
|
66
|
-
var data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle,
|
|
66
|
+
var pro = props.pro, data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle, _z = props.inwardExtraLengthForFocused, inwardExtraLengthForFocused = _z === void 0 ? 0 : _z;
|
|
67
67
|
var canvasWidth = radius * 2;
|
|
68
68
|
var canvasHeight = isThreeD ? radius * 2.3 : radius * 2;
|
|
69
69
|
var strokeWidth = (_e = props.strokeWidth) !== null && _e !== void 0 ? _e : 0;
|
|
@@ -93,7 +93,8 @@ export var usePieChart = function (props) {
|
|
|
93
93
|
pi: pi,
|
|
94
94
|
selectedIndex: selectedIndex,
|
|
95
95
|
setSelectedIndex: setSelectedIndex,
|
|
96
|
-
startAngle: startAngle,
|
|
96
|
+
startAngle: pro ? (_u = props.startAngle) !== null && _u !== void 0 ? _u : 0 : startAngle,
|
|
97
|
+
endAngle: (_v = props.endAngle) !== null && _v !== void 0 ? _v : startAngle + (semiCircle ? Math.PI : Math.PI * 2),
|
|
97
98
|
setStartAngle: setStartAngle,
|
|
98
99
|
total: total,
|
|
99
100
|
setTotal: setTotal,
|
package/src/PieChart/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface IusePieChart {
|
|
|
10
10
|
selectedIndex: number
|
|
11
11
|
setSelectedIndex: (index: number) => void
|
|
12
12
|
startAngle: number
|
|
13
|
+
endAngle: number
|
|
13
14
|
setStartAngle: (angle: number) => void
|
|
14
15
|
total: number
|
|
15
16
|
setTotal: (total: number) => void
|
|
@@ -33,7 +34,11 @@ interface IusePieChart {
|
|
|
33
34
|
paddingVertical: number
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
interface IPieChartPropsType extends PieChartPropsType {
|
|
38
|
+
pro?: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const usePieChart = (props: IPieChartPropsType): IusePieChart => {
|
|
37
42
|
const radius = props.radius ?? 120
|
|
38
43
|
const extraRadiusForFocused =
|
|
39
44
|
props.extraRadiusForFocused ??
|
|
@@ -90,6 +95,7 @@ export const usePieChart = (props: PieChartPropsType): IusePieChart => {
|
|
|
90
95
|
}, [selectedIndex])
|
|
91
96
|
|
|
92
97
|
const {
|
|
98
|
+
pro,
|
|
93
99
|
data,
|
|
94
100
|
donut,
|
|
95
101
|
isThreeD,
|
|
@@ -137,7 +143,9 @@ export const usePieChart = (props: PieChartPropsType): IusePieChart => {
|
|
|
137
143
|
pi,
|
|
138
144
|
selectedIndex,
|
|
139
145
|
setSelectedIndex,
|
|
140
|
-
startAngle,
|
|
146
|
+
startAngle: pro ? props.startAngle ?? 0 : startAngle,
|
|
147
|
+
endAngle:
|
|
148
|
+
props.endAngle ?? startAngle + (semiCircle ? Math.PI : Math.PI * 2),
|
|
141
149
|
setStartAngle,
|
|
142
150
|
total,
|
|
143
151
|
setTotal,
|
package/src/PieChart/main.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
|
24
24
|
textColor: string;
|
|
25
25
|
textSize: number;
|
|
26
26
|
tiltAngle: string;
|
|
27
|
-
labelsPosition: "
|
|
27
|
+
labelsPosition: import("../utils/types").LabelsPosition;
|
|
28
28
|
showTextBackground: boolean;
|
|
29
29
|
textBackgroundColor: string;
|
|
30
30
|
showValuesAsLabels: boolean;
|
package/src/PieChart/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native';
|
|
2
2
|
import { type FontStyle } from 'react-native-svg';
|
|
3
|
+
import { LabelsPosition } from '../utils/types';
|
|
3
4
|
export interface PieChartPropsType {
|
|
4
5
|
radius?: number;
|
|
5
6
|
isThreeD?: boolean;
|
|
@@ -31,7 +32,7 @@ export interface PieChartPropsType {
|
|
|
31
32
|
centerLabelComponent?: Function;
|
|
32
33
|
tiltAngle?: string;
|
|
33
34
|
initialAngle?: number;
|
|
34
|
-
labelsPosition?:
|
|
35
|
+
labelsPosition?: LabelsPosition;
|
|
35
36
|
showGradient?: boolean;
|
|
36
37
|
gradientCenterColor?: string;
|
|
37
38
|
onPress?: Function;
|
|
@@ -48,6 +49,11 @@ export interface PieChartPropsType {
|
|
|
48
49
|
pieInnerComponentWidth?: number;
|
|
49
50
|
paddingHorizontal?: number;
|
|
50
51
|
paddingVertical?: number;
|
|
52
|
+
isAnimated?: boolean;
|
|
53
|
+
startAngle?: number;
|
|
54
|
+
endAngle?: number;
|
|
55
|
+
curvedEdges?: boolean;
|
|
56
|
+
edgesRadius?: number;
|
|
51
57
|
}
|
|
52
58
|
export interface pieDataItem {
|
|
53
59
|
value: number;
|
|
@@ -75,6 +81,10 @@ export interface pieDataItem {
|
|
|
75
81
|
focused?: boolean;
|
|
76
82
|
peripheral?: boolean;
|
|
77
83
|
pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
|
|
84
|
+
isStartEdgeCurved?: boolean;
|
|
85
|
+
isEndEdgeCurved?: boolean;
|
|
86
|
+
startEdgeRadius?: number;
|
|
87
|
+
endEdgeRadius?: number;
|
|
78
88
|
}
|
|
79
89
|
export interface PieChartMainProps extends PieChartPropsType {
|
|
80
90
|
setSelectedIndex: Function;
|
package/src/PieChart/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ColorValue } from 'react-native'
|
|
2
2
|
import { type FontStyle } from 'react-native-svg'
|
|
3
|
+
import { LabelsPosition } from '../utils/types'
|
|
3
4
|
|
|
4
5
|
export interface PieChartPropsType {
|
|
5
6
|
radius?: number
|
|
@@ -34,7 +35,7 @@ export interface PieChartPropsType {
|
|
|
34
35
|
centerLabelComponent?: Function
|
|
35
36
|
tiltAngle?: string
|
|
36
37
|
initialAngle?: number
|
|
37
|
-
labelsPosition?:
|
|
38
|
+
labelsPosition?: LabelsPosition
|
|
38
39
|
showGradient?: boolean
|
|
39
40
|
gradientCenterColor?: string
|
|
40
41
|
onPress?: Function
|
|
@@ -51,6 +52,11 @@ export interface PieChartPropsType {
|
|
|
51
52
|
pieInnerComponentWidth?: number
|
|
52
53
|
paddingHorizontal?: number
|
|
53
54
|
paddingVertical?: number
|
|
55
|
+
isAnimated?: boolean
|
|
56
|
+
startAngle?: number
|
|
57
|
+
endAngle?: number
|
|
58
|
+
curvedEdges?: boolean
|
|
59
|
+
edgesRadius?: number
|
|
54
60
|
}
|
|
55
61
|
export interface pieDataItem {
|
|
56
62
|
value: number
|
|
@@ -78,6 +84,10 @@ export interface pieDataItem {
|
|
|
78
84
|
focused?: boolean
|
|
79
85
|
peripheral?: boolean
|
|
80
86
|
pieInnerComponent?: (item?: pieDataItem, index?: number) => any
|
|
87
|
+
isStartEdgeCurved?: boolean
|
|
88
|
+
isEndEdgeCurved?: boolean
|
|
89
|
+
startEdgeRadius?: number
|
|
90
|
+
endEdgeRadius?: number
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
export interface PieChartMainProps extends PieChartPropsType {
|
package/src/utils/types.d.ts
CHANGED
package/src/utils/types.ts
CHANGED