gifted-charts-core 0.0.25 → 0.0.26
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 +6 -2
- package/src/BarChart/Animated2DWithGradient.d.ts +24 -0
- package/src/BarChart/Animated2DWithGradient.js +108 -0
- package/src/BarChart/RenderStackBars.d.ts +27 -0
- package/src/BarChart/RenderStackBars.js +99 -0
- package/src/BarChart/index.d.ts +175 -0
- package/src/BarChart/index.js +611 -0
- package/src/BarChart/types.d.ts +570 -0
- package/src/BarChart/types.js +1 -0
- package/src/LineChart/LineChartBiColor.d.ts +104 -0
- package/src/LineChart/LineChartBiColor.js +520 -0
- package/src/LineChart/index.d.ts +383 -0
- package/src/LineChart/index.js +1397 -0
- package/src/LineChart/index.ts +4 -3
- package/src/LineChart/types.d.ts +531 -0
- package/src/LineChart/types.js +1 -0
- package/src/PieChart/index.d.ts +33 -0
- package/src/PieChart/index.js +119 -0
- package/src/PieChart/main.d.ts +49 -0
- package/src/PieChart/main.js +185 -0
- package/src/PieChart/types.d.ts +85 -0
- package/src/PieChart/types.js +1 -0
- package/src/PopulationPyramid/index.d.ts +137 -0
- package/src/PopulationPyramid/index.js +233 -0
- package/src/PopulationPyramid/index.ts +3 -3
- package/src/PopulationPyramid/types.d.ts +235 -0
- package/src/PopulationPyramid/types.js +1 -0
- package/src/PopulationPyramid/types.ts +4 -0
- package/src/components/AnimatedThreeDBar/index.d.ts +12 -0
- package/src/components/AnimatedThreeDBar/index.js +53 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.d.ts +20 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +217 -0
- package/src/components/BarAndLineChartsWrapper/index.d.ts +97 -0
- package/src/components/BarAndLineChartsWrapper/index.js +266 -0
- package/src/components/BarAndLineChartsWrapper/index.ts +5 -4
- package/src/components/common/StripAndLabel.d.ts +7 -0
- package/src/components/common/StripAndLabel.js +53 -0
- package/src/components/common/StripAndLabel.ts +2 -2
- package/src/components/common/types.d.ts +31 -0
- package/src/components/common/types.js +1 -0
- package/src/components/common/types.ts +1 -0
- package/src/index.d.ts +37 -0
- package/src/index.js +32 -0
- package/src/index.ts +146 -0
- package/src/utils/constants.d.ts +248 -0
- package/src/utils/constants.js +299 -0
- package/src/utils/constants.ts +0 -4
- package/src/utils/index.d.ts +89 -0
- package/src/utils/index.js +1008 -0
- package/src/utils/types.d.ts +337 -0
- package/src/utils/types.js +16 -0
- package/src/utils/types.ts +1 -0
- package/index.ts +0 -141
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
import { useEffect, useState } from 'react';
|
|
18
|
+
import { getTextSizeForPieLabels } from '../utils';
|
|
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;
|
|
21
|
+
var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
|
|
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
|
+
var pi = props.semiCircle ? Math.PI / 2 : Math.PI;
|
|
24
|
+
var _u = __read(useState(-1), 2), selectedIndex = _u[0], setSelectedIndex = _u[1]; // at the start, nothing is selected
|
|
25
|
+
// because we're going to use a useEffect, we need startAngle and total to be state variables
|
|
26
|
+
var _v = __read(useState((_d = props.initialAngle) !== null && _d !== void 0 ? _d : (props.semiCircle ? -pi : 0)), 2), startAngle = _v[0], setStartAngle = _v[1];
|
|
27
|
+
var _w = __read(useState(0), 2), total = _w[0], setTotal = _w[1];
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
var _a;
|
|
30
|
+
// Update the total, this could be use to replace the forEach : const newTotal = props.data.reduce((acc, item) => acc + item.value, 0);
|
|
31
|
+
var newTotal = 0;
|
|
32
|
+
props.data.forEach(function (item) {
|
|
33
|
+
newTotal += item.value;
|
|
34
|
+
});
|
|
35
|
+
setTotal(newTotal);
|
|
36
|
+
// Update selectedIndex based on focused item
|
|
37
|
+
var newSelectedIndex = props.data.findIndex(function (item) { return item.focused === true; });
|
|
38
|
+
setSelectedIndex(newSelectedIndex);
|
|
39
|
+
// Calculate the new start angle
|
|
40
|
+
var newStartAngle = (_a = props.initialAngle) !== null && _a !== void 0 ? _a : (props.semiCircle ? -pi : 0);
|
|
41
|
+
if (newSelectedIndex !== -1) {
|
|
42
|
+
// it was !== 0 here before, which would not work, it's either !==-1 or >=0
|
|
43
|
+
// This could be used to replace the for loop that was used before
|
|
44
|
+
var sumBeforeSelectedIndex = props.data
|
|
45
|
+
.slice(0, newSelectedIndex)
|
|
46
|
+
.reduce(function (acc, item) { return acc + item.value; }, 0);
|
|
47
|
+
setStartAngle(newStartAngle + (2 * pi * sumBeforeSelectedIndex) / (newTotal || 1));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setStartAngle(newStartAngle);
|
|
51
|
+
}
|
|
52
|
+
}, [props.data, props.initialAngle, props.semiCircle]);
|
|
53
|
+
useEffect(function () {
|
|
54
|
+
var _a;
|
|
55
|
+
if (selectedIndex !== -1) {
|
|
56
|
+
var newStartAngle = (_a = props.initialAngle) !== null && _a !== void 0 ? _a : (props.semiCircle ? -pi : 0);
|
|
57
|
+
var start = 0;
|
|
58
|
+
for (var i = 0; i < selectedIndex; i++) {
|
|
59
|
+
start += props.data[i].value;
|
|
60
|
+
}
|
|
61
|
+
if (total) {
|
|
62
|
+
setStartAngle(newStartAngle + (2 * pi * start) / (total || 1));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [selectedIndex]);
|
|
66
|
+
var data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle, _x = props.inwardExtraLengthForFocused, inwardExtraLengthForFocused = _x === void 0 ? 0 : _x;
|
|
67
|
+
var canvasWidth = radius * 2;
|
|
68
|
+
var canvasHeight = isThreeD ? radius * 2.3 : radius * 2;
|
|
69
|
+
var strokeWidth = (_e = props.strokeWidth) !== null && _e !== void 0 ? _e : 0;
|
|
70
|
+
var innerRadius = (_f = props.innerRadius) !== null && _f !== void 0 ? _f : radius / 2.5;
|
|
71
|
+
var innerCircleColor = (_h = (_g = props.innerCircleColor) !== null && _g !== void 0 ? _g : props.backgroundColor) !== null && _h !== void 0 ? _h : 'white';
|
|
72
|
+
var innerCircleBorderWidth = (_j = props.innerCircleBorderWidth) !== null && _j !== void 0 ? _j : (props.innerCircleBorderColor ? strokeWidth || 2 : 0);
|
|
73
|
+
var innerCircleBorderColor = (_k = props.innerCircleBorderColor) !== null && _k !== void 0 ? _k : 'lightgray';
|
|
74
|
+
var shiftInnerCenterX = (_l = props.shiftInnerCenterX) !== null && _l !== void 0 ? _l : 0;
|
|
75
|
+
var shiftInnerCenterY = (_m = props.shiftInnerCenterY) !== null && _m !== void 0 ? _m : 0;
|
|
76
|
+
var tiltAngle = (_o = props.tiltAngle) !== null && _o !== void 0 ? _o : '55deg';
|
|
77
|
+
var isDataShifted = false;
|
|
78
|
+
data.forEach(function (item) {
|
|
79
|
+
if (item.shiftX || item.shiftY) {
|
|
80
|
+
isDataShifted = true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
var textSize = getTextSizeForPieLabels((_p = props.textSize) !== null && _p !== void 0 ? _p : 0, radius);
|
|
84
|
+
var paddingHorizontal = ((_q = props.paddingHorizontal) !== null && _q !== void 0 ? _q : props.labelsPosition === 'onBorder')
|
|
85
|
+
? ((_r = props.textBackgroundRadius) !== null && _r !== void 0 ? _r : textSize) * 2 + 6
|
|
86
|
+
: 0;
|
|
87
|
+
var paddingVertical = ((_s = props.paddingVertical) !== null && _s !== void 0 ? _s : props.labelsPosition === 'onBorder')
|
|
88
|
+
? ((_t = props.textBackgroundRadius) !== null && _t !== void 0 ? _t : textSize) * 2 + 6
|
|
89
|
+
: 0;
|
|
90
|
+
return {
|
|
91
|
+
radius: radius,
|
|
92
|
+
extraRadiusForFocused: extraRadiusForFocused,
|
|
93
|
+
pi: pi,
|
|
94
|
+
selectedIndex: selectedIndex,
|
|
95
|
+
setSelectedIndex: setSelectedIndex,
|
|
96
|
+
startAngle: startAngle,
|
|
97
|
+
setStartAngle: setStartAngle,
|
|
98
|
+
total: total,
|
|
99
|
+
setTotal: setTotal,
|
|
100
|
+
data: data,
|
|
101
|
+
donut: donut,
|
|
102
|
+
isThreeD: isThreeD,
|
|
103
|
+
semiCircle: semiCircle,
|
|
104
|
+
inwardExtraLengthForFocused: inwardExtraLengthForFocused,
|
|
105
|
+
canvasWidth: canvasWidth,
|
|
106
|
+
canvasHeight: canvasHeight,
|
|
107
|
+
strokeWidth: strokeWidth,
|
|
108
|
+
innerRadius: innerRadius,
|
|
109
|
+
innerCircleColor: innerCircleColor,
|
|
110
|
+
innerCircleBorderWidth: innerCircleBorderWidth,
|
|
111
|
+
innerCircleBorderColor: innerCircleBorderColor,
|
|
112
|
+
shiftInnerCenterX: shiftInnerCenterX,
|
|
113
|
+
shiftInnerCenterY: shiftInnerCenterY,
|
|
114
|
+
tiltAngle: tiltAngle,
|
|
115
|
+
isDataShifted: isDataShifted,
|
|
116
|
+
paddingHorizontal: paddingHorizontal,
|
|
117
|
+
paddingVertical: paddingVertical
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type PieChartMainProps, type pieDataItem } from './types';
|
|
2
|
+
export declare const getPieChartMainProps: (props: PieChartMainProps) => {
|
|
3
|
+
isThreeD: boolean | undefined;
|
|
4
|
+
isBiggerPie: boolean | undefined;
|
|
5
|
+
propData: pieDataItem[];
|
|
6
|
+
data: pieDataItem[];
|
|
7
|
+
itemHasInnerComponent: boolean;
|
|
8
|
+
showInnerComponent: boolean;
|
|
9
|
+
radius: number;
|
|
10
|
+
canvasWidth: number;
|
|
11
|
+
canvasHeight: number;
|
|
12
|
+
shadowWidth: number;
|
|
13
|
+
backgroundColor: string;
|
|
14
|
+
shadowColor: string;
|
|
15
|
+
semiCircle: boolean;
|
|
16
|
+
pi: number;
|
|
17
|
+
initialAngle: number;
|
|
18
|
+
shadow: boolean;
|
|
19
|
+
donut: boolean;
|
|
20
|
+
strokeWidth: number;
|
|
21
|
+
strokeColor: string;
|
|
22
|
+
innerRadius: number;
|
|
23
|
+
showText: boolean;
|
|
24
|
+
textColor: string;
|
|
25
|
+
textSize: number;
|
|
26
|
+
tiltAngle: string;
|
|
27
|
+
labelsPosition: "onBorder" | "outward" | "inward" | "mid";
|
|
28
|
+
showTextBackground: boolean;
|
|
29
|
+
textBackgroundColor: string;
|
|
30
|
+
showValuesAsLabels: boolean;
|
|
31
|
+
showGradient: boolean;
|
|
32
|
+
gradientCenterColor: string;
|
|
33
|
+
toggleFocusOnPress: boolean;
|
|
34
|
+
minShiftX: number;
|
|
35
|
+
maxShiftX: number;
|
|
36
|
+
minShiftY: number;
|
|
37
|
+
maxShiftY: number;
|
|
38
|
+
total: number;
|
|
39
|
+
horizAdjustment: number;
|
|
40
|
+
vertAdjustment: number;
|
|
41
|
+
cx: number;
|
|
42
|
+
cy: number;
|
|
43
|
+
pData: number[];
|
|
44
|
+
mData: number[];
|
|
45
|
+
acc: number;
|
|
46
|
+
paddingHorizontal: number;
|
|
47
|
+
paddingVertical: number;
|
|
48
|
+
extraRadiusForFocused: number;
|
|
49
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
import { getTextSizeForPieLabels } from '../utils';
|
|
38
|
+
export var getPieChartMainProps = function (props) {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
40
|
+
var isThreeD = props.isThreeD, isBiggerPie = props.isBiggerPie, paddingHorizontal = props.paddingHorizontal, paddingVertical = props.paddingVertical, extraRadiusForFocused = props.extraRadiusForFocused;
|
|
41
|
+
var propData = props.data;
|
|
42
|
+
var data = [];
|
|
43
|
+
var itemHasInnerComponent = false;
|
|
44
|
+
if (propData) {
|
|
45
|
+
for (var i = 0; i < propData.length; i++) {
|
|
46
|
+
if (propData[i].pieInnerComponent)
|
|
47
|
+
itemHasInnerComponent = true;
|
|
48
|
+
if (propData[i].value !== 0) {
|
|
49
|
+
data.push(propData[i]);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
data.push(__assign(__assign({}, propData[i]), { value: props.data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; }) /
|
|
53
|
+
160000 }));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var showInnerComponent = !!props.pieInnerComponent || itemHasInnerComponent;
|
|
58
|
+
var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
|
|
59
|
+
var canvasWidth = radius * 2;
|
|
60
|
+
var canvasHeight = isThreeD ? radius * 2.3 : radius * 2;
|
|
61
|
+
var shadowWidth = (_b = props.shadowWidth) !== null && _b !== void 0 ? _b : radius / 5;
|
|
62
|
+
var backgroundColor = (_c = props.backgroundColor) !== null && _c !== void 0 ? _c : 'transparent';
|
|
63
|
+
var shadowColor = (_d = props.shadowColor) !== null && _d !== void 0 ? _d : 'lightgray';
|
|
64
|
+
var semiCircle = (_e = props.semiCircle) !== null && _e !== void 0 ? _e : false;
|
|
65
|
+
var pi = Math.PI;
|
|
66
|
+
var initialAngle = (_f = props.initialAngle) !== null && _f !== void 0 ? _f : (semiCircle ? pi / -2 : 0);
|
|
67
|
+
var shadow = (_g = props.shadow) !== null && _g !== void 0 ? _g : false;
|
|
68
|
+
var donut = (_h = props.donut) !== null && _h !== void 0 ? _h : false;
|
|
69
|
+
var strokeWidth = (_j = props.strokeWidth) !== null && _j !== void 0 ? _j : 0;
|
|
70
|
+
var strokeColor = (_k = props.strokeColor) !== null && _k !== void 0 ? _k : (strokeWidth ? 'gray' : 'transparent');
|
|
71
|
+
var innerRadius = (_l = props.innerRadius) !== null && _l !== void 0 ? _l : radius / 2.5;
|
|
72
|
+
var showText = (_m = props.showText) !== null && _m !== void 0 ? _m : false;
|
|
73
|
+
var textColor = (_o = props.textColor) !== null && _o !== void 0 ? _o : '';
|
|
74
|
+
var textSize = getTextSizeForPieLabels((_p = props.textSize) !== null && _p !== void 0 ? _p : 0, radius);
|
|
75
|
+
var tiltAngle = (_q = props.tiltAngle) !== null && _q !== void 0 ? _q : '55deg';
|
|
76
|
+
if (tiltAngle &&
|
|
77
|
+
!isNaN(Number(tiltAngle)) &&
|
|
78
|
+
!(tiltAngle + '').endsWith('deg')) {
|
|
79
|
+
tiltAngle += 'deg';
|
|
80
|
+
}
|
|
81
|
+
// const tilt = props.tilt ? Math.min(props.tilt, 1) : props.isThreeD ? 0.5 : 1;
|
|
82
|
+
var labelsPosition = props.labelsPosition
|
|
83
|
+
? props.labelsPosition
|
|
84
|
+
: donut || props.centerLabelComponent
|
|
85
|
+
? 'outward'
|
|
86
|
+
: 'mid';
|
|
87
|
+
var showTextBackground = (_r = props.showTextBackground) !== null && _r !== void 0 ? _r : false;
|
|
88
|
+
var textBackgroundColor = (_s = props.textBackgroundColor) !== null && _s !== void 0 ? _s : 'white';
|
|
89
|
+
var showValuesAsLabels = (_t = props.showValuesAsLabels) !== null && _t !== void 0 ? _t : false;
|
|
90
|
+
var showGradient = (_u = props.showGradient) !== null && _u !== void 0 ? _u : false;
|
|
91
|
+
var gradientCenterColor = (_v = props.gradientCenterColor) !== null && _v !== void 0 ? _v : 'white';
|
|
92
|
+
var toggleFocusOnPress = (_w = props.toggleFocusOnPress) !== null && _w !== void 0 ? _w : true;
|
|
93
|
+
var minShiftX = 0;
|
|
94
|
+
var maxShiftX = 0;
|
|
95
|
+
var minShiftY = 0;
|
|
96
|
+
var maxShiftY = 0;
|
|
97
|
+
var total = 0;
|
|
98
|
+
data.forEach(function (item) {
|
|
99
|
+
if (item.shiftX || item.shiftY) {
|
|
100
|
+
if (minShiftX > item.shiftX) {
|
|
101
|
+
minShiftX = item.shiftX;
|
|
102
|
+
}
|
|
103
|
+
if (minShiftY > item.shiftY) {
|
|
104
|
+
minShiftY = item.shiftY;
|
|
105
|
+
}
|
|
106
|
+
if (maxShiftX < item.shiftX) {
|
|
107
|
+
maxShiftX = item.shiftX;
|
|
108
|
+
}
|
|
109
|
+
if (maxShiftY < item.shiftY) {
|
|
110
|
+
maxShiftY = item.shiftY;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var horizAdjustment = maxShiftX - minShiftX;
|
|
115
|
+
var vertAdjustment = maxShiftY - minShiftY;
|
|
116
|
+
if (semiCircle) {
|
|
117
|
+
pi = Math.PI / 2;
|
|
118
|
+
}
|
|
119
|
+
var cx = radius;
|
|
120
|
+
var cy = radius;
|
|
121
|
+
total =
|
|
122
|
+
data && data.length > 0
|
|
123
|
+
? data.map(function (item) { return item.value; }).reduce(function (v, a) { return v + a; })
|
|
124
|
+
: 0;
|
|
125
|
+
var acc = 0;
|
|
126
|
+
var pData = data.map(function (item) {
|
|
127
|
+
acc += item.value / total;
|
|
128
|
+
return acc;
|
|
129
|
+
});
|
|
130
|
+
acc = 0;
|
|
131
|
+
var mData = data.map(function (item) {
|
|
132
|
+
var pAcc = acc;
|
|
133
|
+
acc += item.value / total;
|
|
134
|
+
return pAcc + (acc - pAcc) / 2;
|
|
135
|
+
});
|
|
136
|
+
pData = __spreadArray([0], __read(pData), false);
|
|
137
|
+
return {
|
|
138
|
+
isThreeD: isThreeD,
|
|
139
|
+
isBiggerPie: isBiggerPie,
|
|
140
|
+
propData: propData,
|
|
141
|
+
data: data,
|
|
142
|
+
itemHasInnerComponent: itemHasInnerComponent,
|
|
143
|
+
showInnerComponent: showInnerComponent,
|
|
144
|
+
radius: radius,
|
|
145
|
+
canvasWidth: canvasWidth,
|
|
146
|
+
canvasHeight: canvasHeight,
|
|
147
|
+
shadowWidth: shadowWidth,
|
|
148
|
+
backgroundColor: backgroundColor,
|
|
149
|
+
shadowColor: shadowColor,
|
|
150
|
+
semiCircle: semiCircle,
|
|
151
|
+
pi: pi,
|
|
152
|
+
initialAngle: initialAngle,
|
|
153
|
+
shadow: shadow,
|
|
154
|
+
donut: donut,
|
|
155
|
+
strokeWidth: strokeWidth,
|
|
156
|
+
strokeColor: strokeColor,
|
|
157
|
+
innerRadius: innerRadius,
|
|
158
|
+
showText: showText,
|
|
159
|
+
textColor: textColor,
|
|
160
|
+
textSize: textSize,
|
|
161
|
+
tiltAngle: tiltAngle,
|
|
162
|
+
labelsPosition: labelsPosition,
|
|
163
|
+
showTextBackground: showTextBackground,
|
|
164
|
+
textBackgroundColor: textBackgroundColor,
|
|
165
|
+
showValuesAsLabels: showValuesAsLabels,
|
|
166
|
+
showGradient: showGradient,
|
|
167
|
+
gradientCenterColor: gradientCenterColor,
|
|
168
|
+
toggleFocusOnPress: toggleFocusOnPress,
|
|
169
|
+
minShiftX: minShiftX,
|
|
170
|
+
maxShiftX: maxShiftX,
|
|
171
|
+
minShiftY: minShiftY,
|
|
172
|
+
maxShiftY: maxShiftY,
|
|
173
|
+
total: total,
|
|
174
|
+
horizAdjustment: horizAdjustment,
|
|
175
|
+
vertAdjustment: vertAdjustment,
|
|
176
|
+
cx: cx,
|
|
177
|
+
cy: cy,
|
|
178
|
+
pData: pData,
|
|
179
|
+
mData: mData,
|
|
180
|
+
acc: acc,
|
|
181
|
+
paddingHorizontal: paddingHorizontal,
|
|
182
|
+
paddingVertical: paddingVertical,
|
|
183
|
+
extraRadiusForFocused: extraRadiusForFocused
|
|
184
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ColorValue } from 'react-native';
|
|
2
|
+
import { type FontStyle } from 'react-native-svg';
|
|
3
|
+
export interface PieChartPropsType {
|
|
4
|
+
radius?: number;
|
|
5
|
+
isThreeD?: boolean;
|
|
6
|
+
donut?: boolean;
|
|
7
|
+
innerRadius?: number;
|
|
8
|
+
shadow?: boolean;
|
|
9
|
+
innerCircleColor?: ColorValue;
|
|
10
|
+
innerCircleBorderWidth?: number;
|
|
11
|
+
innerCircleBorderColor?: ColorValue;
|
|
12
|
+
shiftInnerCenterX?: number;
|
|
13
|
+
shiftInnerCenterY?: number;
|
|
14
|
+
shadowColor?: string;
|
|
15
|
+
shadowWidth?: number;
|
|
16
|
+
strokeWidth?: number;
|
|
17
|
+
strokeColor?: string;
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
data: pieDataItem[];
|
|
20
|
+
semiCircle?: boolean;
|
|
21
|
+
showText?: boolean;
|
|
22
|
+
textColor?: string;
|
|
23
|
+
textSize?: number;
|
|
24
|
+
fontStyle?: FontStyle;
|
|
25
|
+
fontWeight?: string;
|
|
26
|
+
font?: string;
|
|
27
|
+
showTextBackground?: boolean;
|
|
28
|
+
textBackgroundColor?: string;
|
|
29
|
+
textBackgroundRadius?: number;
|
|
30
|
+
showValuesAsLabels?: boolean;
|
|
31
|
+
centerLabelComponent?: Function;
|
|
32
|
+
tiltAngle?: string;
|
|
33
|
+
initialAngle?: number;
|
|
34
|
+
labelsPosition?: 'onBorder' | 'outward' | 'inward' | 'mid';
|
|
35
|
+
showGradient?: boolean;
|
|
36
|
+
gradientCenterColor?: string;
|
|
37
|
+
onPress?: Function;
|
|
38
|
+
focusOnPress?: boolean;
|
|
39
|
+
toggleFocusOnPress?: boolean;
|
|
40
|
+
selectedIndex?: number;
|
|
41
|
+
setSelectedIndex?: Function;
|
|
42
|
+
sectionAutoFocus?: boolean;
|
|
43
|
+
onLabelPress?: Function;
|
|
44
|
+
extraRadiusForFocused?: number;
|
|
45
|
+
inwardExtraLengthForFocused?: number;
|
|
46
|
+
pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
|
|
47
|
+
pieInnerComponentHeight?: number;
|
|
48
|
+
pieInnerComponentWidth?: number;
|
|
49
|
+
paddingHorizontal?: number;
|
|
50
|
+
paddingVertical?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface pieDataItem {
|
|
53
|
+
value: number;
|
|
54
|
+
shiftX?: number;
|
|
55
|
+
shiftY?: number;
|
|
56
|
+
color?: string;
|
|
57
|
+
gradientCenterColor?: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
textColor?: string;
|
|
60
|
+
textSize?: number;
|
|
61
|
+
fontStyle?: FontStyle;
|
|
62
|
+
fontWeight?: string;
|
|
63
|
+
font?: string;
|
|
64
|
+
textBackgroundColor?: string;
|
|
65
|
+
textBackgroundRadius?: number;
|
|
66
|
+
shiftTextX?: number;
|
|
67
|
+
shiftTextY?: number;
|
|
68
|
+
shiftTextBackgroundX?: number;
|
|
69
|
+
shiftTextBackgroundY?: number;
|
|
70
|
+
labelPosition?: 'onBorder' | 'outward' | 'inward' | 'mid';
|
|
71
|
+
onPress?: Function;
|
|
72
|
+
onLabelPress?: Function;
|
|
73
|
+
strokeWidth?: number;
|
|
74
|
+
strokeColor?: string;
|
|
75
|
+
focused?: boolean;
|
|
76
|
+
peripheral?: boolean;
|
|
77
|
+
pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
|
|
78
|
+
}
|
|
79
|
+
export interface PieChartMainProps extends PieChartPropsType {
|
|
80
|
+
setSelectedIndex: Function;
|
|
81
|
+
isBiggerPie?: boolean;
|
|
82
|
+
paddingHorizontal: number;
|
|
83
|
+
paddingVertical: number;
|
|
84
|
+
extraRadiusForFocused: number;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Framework } from '../utils/types';
|
|
2
|
+
import { type extendedPopulationPyramidPropsType } from './types';
|
|
3
|
+
export declare const usePopulationPyramid: (props: extendedPopulationPyramidPropsType) => {
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
verticalMarginBetweenBars: number;
|
|
7
|
+
barsMapToYAxisSections: boolean;
|
|
8
|
+
data: import("./types").popnPyramidDataItem[] | (import("./types").popnPyramidDataItem[] & import("./types").popnPyramidDataItemReactJS[]);
|
|
9
|
+
hideRules: boolean;
|
|
10
|
+
hideYAxisText: boolean;
|
|
11
|
+
yAxisColor: import("react-native").ColorValue;
|
|
12
|
+
yAxisThickness: number;
|
|
13
|
+
xAxisColor: import("react-native").ColorValue;
|
|
14
|
+
xAxisThickness: number;
|
|
15
|
+
xAxisType: string | import("../utils/types").RuleTypes;
|
|
16
|
+
xAxisNoOfSections: number;
|
|
17
|
+
showXAxisIndices: boolean;
|
|
18
|
+
xAxisIndicesWidth: number;
|
|
19
|
+
xAxisIndicesHeight: number;
|
|
20
|
+
xAxisIndicesColor: import("react-native").ColorValue;
|
|
21
|
+
xAxisIndicesShiftY: number;
|
|
22
|
+
showXAxisLabelTexts: boolean;
|
|
23
|
+
xAxisLabelFontSize: number;
|
|
24
|
+
xAxisLabelFontStyle: import("react-native-svg").FontStyle;
|
|
25
|
+
xAxisLabelFontWeight: import("react-native-svg").FontWeight;
|
|
26
|
+
xAxisLabelFontFamily: string;
|
|
27
|
+
xAxisLabelColor: import("react-native").ColorValue;
|
|
28
|
+
xAxisLabelShiftX: number;
|
|
29
|
+
xAxisLabelShiftY: number;
|
|
30
|
+
xAxisLabelPrefix: string;
|
|
31
|
+
xAxisLabelSuffix: string;
|
|
32
|
+
formatXAxisLabels: ((label: string) => string) | undefined;
|
|
33
|
+
showVerticalLines: boolean;
|
|
34
|
+
verticalLinesColor: import("react-native").ColorValue;
|
|
35
|
+
verticalLinesThickness: number;
|
|
36
|
+
verticalLinesType: string | import("../utils/types").RuleTypes;
|
|
37
|
+
verticalLinesStrokeDashArray: string | number[];
|
|
38
|
+
showYAxisIndices: boolean;
|
|
39
|
+
yAxisIndicesWidth: number;
|
|
40
|
+
yAxisIndicesHeight: number;
|
|
41
|
+
yAxisIndicesColor: import("react-native").ColorValue;
|
|
42
|
+
yAxisLabelFontSize: number;
|
|
43
|
+
yAxisLabelFontStyle: import("react-native-svg").FontStyle;
|
|
44
|
+
yAxisLabelFontWeight: import("react-native-svg").FontWeight;
|
|
45
|
+
yAxisLabelFontFamily: string;
|
|
46
|
+
yAxisLabelColor: import("react-native").ColorValue;
|
|
47
|
+
yAxisLabelTextMarginRight: number;
|
|
48
|
+
yAxisLabelTexts: string[];
|
|
49
|
+
showValuesAsBarLabels: boolean;
|
|
50
|
+
rulesThickness: number;
|
|
51
|
+
rulesColor: import("react-native").ColorValue;
|
|
52
|
+
rulesType: string | import("../utils/types").RuleTypes;
|
|
53
|
+
dashWidth: number;
|
|
54
|
+
dashGap: number;
|
|
55
|
+
leftBarLabelWidth: number;
|
|
56
|
+
leftBarLabelFontSize: number;
|
|
57
|
+
leftBarLabelColor: import("react-native").ColorValue;
|
|
58
|
+
leftBarLabelFontStyle: import("react-native-svg").FontStyle;
|
|
59
|
+
leftBarLabelFontWeight: import("react-native-svg").FontWeight;
|
|
60
|
+
leftBarLabelFontFamily: string;
|
|
61
|
+
leftBarLabelPrefix: string;
|
|
62
|
+
leftBarLabelSuffix: string;
|
|
63
|
+
rightBarLabelWidth: number;
|
|
64
|
+
rightBarLabelFontSize: number;
|
|
65
|
+
rightBarLabelColor: import("react-native").ColorValue;
|
|
66
|
+
rightBarLabelFontStyle: import("react-native-svg").FontStyle;
|
|
67
|
+
rightBarLabelFontWeight: import("react-native-svg").FontWeight;
|
|
68
|
+
rightBarLabelFontFamily: string;
|
|
69
|
+
rightBarLabelPrefix: string;
|
|
70
|
+
rightBarLabelSuffix: string;
|
|
71
|
+
formatBarLabels: ((label: string) => string) | undefined;
|
|
72
|
+
showMidAxis: boolean;
|
|
73
|
+
midAxisLabelWidth: number;
|
|
74
|
+
midAxisLabelFontSize: number;
|
|
75
|
+
midAxisLabelColor: import("react-native").ColorValue;
|
|
76
|
+
midAxisLabelFontStyle: import("react-native-svg").FontStyle;
|
|
77
|
+
midAxisLabelFontWeight: import("react-native-svg").FontWeight;
|
|
78
|
+
midAxisLabelFontFamily: string;
|
|
79
|
+
leftBarColor: import("react-native").ColorValue;
|
|
80
|
+
rightBarColor: import("react-native").ColorValue;
|
|
81
|
+
leftBarBorderColor: import("react-native").ColorValue;
|
|
82
|
+
rightBarBorderColor: import("react-native").ColorValue;
|
|
83
|
+
leftBarBorderWidth: number;
|
|
84
|
+
rightBarBorderWidth: number;
|
|
85
|
+
leftBarBorderRadius: number;
|
|
86
|
+
rightBarBorderRadius: number;
|
|
87
|
+
allCornersRounded: boolean;
|
|
88
|
+
showSurplus: boolean;
|
|
89
|
+
showSurplusLeft: boolean;
|
|
90
|
+
showSurplusRight: boolean;
|
|
91
|
+
leftSurplusColor: import("react-native").ColorValue;
|
|
92
|
+
leftSurplusBorderColor: import("react-native").ColorValue;
|
|
93
|
+
rightSurplusColor: import("react-native").ColorValue;
|
|
94
|
+
rightSurplusBorderColor: import("react-native").ColorValue;
|
|
95
|
+
leftSurplusBorderWidth: number;
|
|
96
|
+
rightSurplusBorderWidth: number;
|
|
97
|
+
yAxisLabelWidth: number;
|
|
98
|
+
noOfSections: number;
|
|
99
|
+
containerHeight: number;
|
|
100
|
+
stepHeight: number;
|
|
101
|
+
xAxisLabelsHeight: number;
|
|
102
|
+
containerHeightWithXaxisLabels: number;
|
|
103
|
+
mid: number;
|
|
104
|
+
leftMax: number;
|
|
105
|
+
rightMax: number;
|
|
106
|
+
max: number;
|
|
107
|
+
xAxisRoundToDigits: number;
|
|
108
|
+
midAxisAndLabelWidth: number;
|
|
109
|
+
barWidthFactor: number;
|
|
110
|
+
leftXAfterMid: number;
|
|
111
|
+
rightXAfterMid: number;
|
|
112
|
+
yAxisLineProps: {
|
|
113
|
+
framework?: Framework.reactNative | undefined;
|
|
114
|
+
} & import("./types").RulesProps;
|
|
115
|
+
midAxisLineCommonProps: {
|
|
116
|
+
framework?: Framework.reactNative | undefined;
|
|
117
|
+
} & import("./types").RulesProps;
|
|
118
|
+
xAxisLabelY: number;
|
|
119
|
+
xAxisIndicesCommonProps: {
|
|
120
|
+
y1: number;
|
|
121
|
+
y2: number;
|
|
122
|
+
stroke: import("react-native").ColorValue;
|
|
123
|
+
strokeWidth: number;
|
|
124
|
+
};
|
|
125
|
+
verticalLinesCommonProps: {
|
|
126
|
+
framework?: Framework.reactNative | undefined;
|
|
127
|
+
} & import("./types").RulesProps;
|
|
128
|
+
xAxisLabelsCommonProps: {
|
|
129
|
+
y: number;
|
|
130
|
+
stroke: import("react-native").ColorValue;
|
|
131
|
+
fontSize: number;
|
|
132
|
+
fontStyle: import("react-native-svg").FontStyle;
|
|
133
|
+
fontWeight: import("react-native-svg").FontWeight;
|
|
134
|
+
fontFamily: string;
|
|
135
|
+
};
|
|
136
|
+
getXLabel: (index: number) => string;
|
|
137
|
+
};
|