@harveylx/react-native-gifted-charts 1.4.70

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  4. package/dist/BarChart/Animated2DWithGradient.js +78 -0
  5. package/dist/BarChart/RenderBars.d.ts +3 -0
  6. package/dist/BarChart/RenderBars.js +222 -0
  7. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  8. package/dist/BarChart/RenderStackBars.js +214 -0
  9. package/dist/BarChart/index.d.ts +2 -0
  10. package/dist/BarChart/index.js +256 -0
  11. package/dist/BarChart/styles.d.ts +45 -0
  12. package/dist/BarChart/styles.js +46 -0
  13. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  14. package/dist/Components/AnimatedThreeDBar/index.js +103 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
  16. package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  18. package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  30. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  31. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  32. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
  33. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  34. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  35. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  36. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  37. package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
  38. package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
  39. package/dist/Components/common/LinearGradient.d.ts +16 -0
  40. package/dist/Components/common/LinearGradient.js +15 -0
  41. package/dist/Components/common/Pointer.d.ts +1 -0
  42. package/dist/Components/common/Pointer.js +18 -0
  43. package/dist/Components/common/StripAndLabel.d.ts +2 -0
  44. package/dist/Components/common/StripAndLabel.js +60 -0
  45. package/dist/Components/lineSvg.d.ts +14 -0
  46. package/dist/Components/lineSvg.js +22 -0
  47. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  48. package/dist/LineChart/LineChartBicolor.js +298 -0
  49. package/dist/LineChart/index.d.ts +2 -0
  50. package/dist/LineChart/index.js +1137 -0
  51. package/dist/LineChart/styles.d.ts +43 -0
  52. package/dist/LineChart/styles.js +46 -0
  53. package/dist/PieChart/index.d.ts +2 -0
  54. package/dist/PieChart/index.js +146 -0
  55. package/dist/PieChart/main.d.ts +2 -0
  56. package/dist/PieChart/main.js +178 -0
  57. package/dist/PieChartPro/index.d.ts +2 -0
  58. package/dist/PieChartPro/index.js +124 -0
  59. package/dist/PopulationPyramid/index.d.ts +2 -0
  60. package/dist/PopulationPyramid/index.js +132 -0
  61. package/dist/RadarChart/index.d.ts +2 -0
  62. package/dist/RadarChart/index.js +113 -0
  63. package/dist/index.d.ts +8 -0
  64. package/dist/index.js +8 -0
  65. package/dist/utils/index.d.ts +5 -0
  66. package/dist/utils/index.js +22 -0
  67. package/package.json +89 -0
@@ -0,0 +1,43 @@
1
+ export declare const styles: {
2
+ container: {
3
+ width: "100%";
4
+ marginBottom: number;
5
+ marginRight: number;
6
+ };
7
+ horizBar: {
8
+ flexDirection: "row";
9
+ };
10
+ leftLabel: {
11
+ justifyContent: "center";
12
+ alignItems: "center";
13
+ };
14
+ lastLeftLabel: {
15
+ justifyContent: "center";
16
+ alignItems: "center";
17
+ };
18
+ leftPart: {
19
+ justifyContent: "center";
20
+ };
21
+ lastLeftPart: {
22
+ justifyContent: "flex-end";
23
+ };
24
+ line: {
25
+ width: "100%";
26
+ height: number;
27
+ backgroundColor: string;
28
+ opacity: number;
29
+ };
30
+ lastLine: {
31
+ width: "100%";
32
+ height: number;
33
+ backgroundColor: string;
34
+ };
35
+ bottomLabel: {
36
+ width: "100%";
37
+ };
38
+ customDataPointContainer: {
39
+ position: "absolute";
40
+ justifyContent: "center";
41
+ alignItems: "center";
42
+ };
43
+ };
@@ -0,0 +1,46 @@
1
+ import { StyleSheet } from 'react-native';
2
+ export var styles = StyleSheet.create({
3
+ container: {
4
+ width: '100%',
5
+ marginBottom: 40,
6
+ marginRight: 40,
7
+ },
8
+ horizBar: {
9
+ flexDirection: 'row',
10
+ },
11
+ leftLabel: {
12
+ justifyContent: 'center',
13
+ alignItems: 'center',
14
+ },
15
+ lastLeftLabel: {
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ },
19
+ leftPart: {
20
+ justifyContent: 'center',
21
+ // width: '100%',
22
+ },
23
+ lastLeftPart: {
24
+ justifyContent: 'flex-end',
25
+ // width: '100%',
26
+ },
27
+ line: {
28
+ width: '100%',
29
+ height: 1,
30
+ backgroundColor: 'gray',
31
+ opacity: 0.5,
32
+ },
33
+ lastLine: {
34
+ width: '100%',
35
+ height: 1,
36
+ backgroundColor: 'black',
37
+ },
38
+ bottomLabel: {
39
+ width: '100%',
40
+ },
41
+ customDataPointContainer: {
42
+ position: 'absolute',
43
+ justifyContent: 'center',
44
+ alignItems: 'center',
45
+ },
46
+ });
@@ -0,0 +1,2 @@
1
+ import { PieChartPropsType } from '@harveylx/gifted-charts-core';
2
+ export declare const PieChart: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,146 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
+ import { View, Text } from 'react-native';
30
+ import { PieChartMain } from './main';
31
+ import { pieColors, usePieChart } from '@harveylx/gifted-charts-core';
32
+ import { isWebApp } from '../utils';
33
+ import { useState } from 'react';
34
+ export var PieChart = function (props) {
35
+ if (!props.data)
36
+ return null;
37
+ var _a = usePieChart(props), radius = _a.radius, extraRadius = _a.extraRadius, selectedIndex = _a.selectedIndex, setSelectedIndex = _a.setSelectedIndex, startAngle = _a.startAngle, total = _a.total, donut = _a.donut, isThreeD = _a.isThreeD, semiCircle = _a.semiCircle, inwardExtraLengthForFocused = _a.inwardExtraLengthForFocused, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight, innerRadius = _a.innerRadius, innerCircleColor = _a.innerCircleColor, innerCircleBorderWidth = _a.innerCircleBorderWidth, innerCircleBorderColor = _a.innerCircleBorderColor, shiftInnerCenterX = _a.shiftInnerCenterX, shiftInnerCenterY = _a.shiftInnerCenterY, tiltAngle = _a.tiltAngle, isDataShifted = _a.isDataShifted, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical, data = _a.data, showTooltip = _a.showTooltip, tooltipHorizontalShift = _a.tooltipHorizontalShift, tooltipVerticalShift = _a.tooltipVerticalShift, tooltipComponent = _a.tooltipComponent, getTooltipText = _a.getTooltipText, tooltipBackgroundColor = _a.tooltipBackgroundColor, tooltipBorderRadius = _a.tooltipBorderRadius, tooltipWidth = _a.tooltipWidth, tooltipTextNoOfLines = _a.tooltipTextNoOfLines, textColor = _a.textColor, textSize = _a.textSize, font = _a.font, fontWeight = _a.fontWeight, fontStyle = _a.fontStyle, tooltipSelectedIndex = _a.tooltipSelectedIndex, setTooltipSelectedIndex = _a.setTooltipSelectedIndex;
38
+ var _b = __read(useState(0), 2), touchX = _b[0], setTouchX = _b[1];
39
+ var _c = __read(useState(0), 2), touchY = _c[0], setTouchY = _c[1];
40
+ var renderInnerCircle = function (innerRadius, innerCircleBorderWidth) {
41
+ var _a, _b;
42
+ if (props.centerLabelComponent || (donut && !isDataShifted)) {
43
+ return (_jsx(View, { style: [
44
+ {
45
+ height: innerRadius * 2,
46
+ width: innerRadius * 2,
47
+ borderRadius: innerRadius,
48
+ position: 'absolute',
49
+ // zIndex: 100,
50
+ alignSelf: 'center',
51
+ backgroundColor: innerCircleColor,
52
+ left: canvasWidth / 2 -
53
+ innerRadius +
54
+ shiftInnerCenterX +
55
+ extraRadius +
56
+ paddingHorizontal / 2,
57
+ top: canvasHeight / 2 -
58
+ innerRadius +
59
+ shiftInnerCenterY +
60
+ extraRadius +
61
+ paddingVertical / 2,
62
+ borderWidth: innerCircleBorderWidth,
63
+ borderColor: innerCircleBorderColor,
64
+ justifyContent: 'center',
65
+ alignItems: 'center',
66
+ },
67
+ isThreeD && {
68
+ borderTopWidth: innerCircleBorderWidth * 5,
69
+ borderLeftWidth: shiftInnerCenterX
70
+ ? innerCircleBorderWidth * 2
71
+ : innerCircleBorderWidth,
72
+ transform: [{ rotateX: tiltAngle }],
73
+ },
74
+ semiCircle &&
75
+ isThreeD && {
76
+ borderTopWidth: isThreeD
77
+ ? innerCircleBorderWidth * 5
78
+ : innerCircleBorderWidth,
79
+ borderLeftWidth: 0.5,
80
+ borderLeftColor: innerCircleColor,
81
+ borderBottomWidth: 0,
82
+ borderRightWidth: 0.5,
83
+ borderRightColor: innerCircleColor,
84
+ },
85
+ ], pointerEvents: "box-none", children: _jsx(View, { style: { marginTop: semiCircle ? -0.5 * innerRadius : 0 }, children: (_b = (_a = props.centerLabelComponent) === null || _a === void 0 ? void 0 : _a.call(props, selectedIndex)) !== null && _b !== void 0 ? _b : null }) }));
86
+ }
87
+ return null;
88
+ };
89
+ var renderTooltip = function () {
90
+ var _a, _b;
91
+ return (_jsx(View, { style: {
92
+ position: 'absolute',
93
+ left: touchX > (radius + extraRadius) * 1.5
94
+ ? props.tooltipHorizontalShift
95
+ ? touchX - tooltipHorizontalShift
96
+ : touchX -
97
+ (tooltipWidth !== null && tooltipWidth !== void 0 ? tooltipWidth : getTooltipText(tooltipSelectedIndex).length * 10)
98
+ : touchX - tooltipHorizontalShift,
99
+ top: touchY < 30
100
+ ? props.tooltipVerticalShift
101
+ ? touchY - tooltipVerticalShift
102
+ : touchY
103
+ : touchY - tooltipVerticalShift,
104
+ }, children: data[tooltipSelectedIndex].tooltipComponent ? ((_b = (_a = data[tooltipSelectedIndex]).tooltipComponent) === null || _b === void 0 ? void 0 : _b.call(_a)) : tooltipComponent ? (tooltipComponent(tooltipSelectedIndex)) : (_jsx(View, { style: {
105
+ backgroundColor: tooltipBackgroundColor,
106
+ borderRadius: tooltipBorderRadius,
107
+ paddingHorizontal: 8,
108
+ paddingBottom: 8,
109
+ paddingTop: 4,
110
+ width: tooltipWidth,
111
+ }, children: _jsx(Text, { numberOfLines: tooltipTextNoOfLines, style: {
112
+ color: data[tooltipSelectedIndex].textColor ||
113
+ textColor ||
114
+ 'white',
115
+ textAlign: 'center',
116
+ fontSize: textSize,
117
+ fontFamily: font,
118
+ fontWeight: fontWeight,
119
+ fontStyle: fontStyle,
120
+ }, children: getTooltipText(tooltipSelectedIndex) }) })) }));
121
+ };
122
+ return (_jsxs(View, { style: {
123
+ height: (radius + extraRadius + paddingVertical / 2) *
124
+ (props.semiCircle ? 1 : 2),
125
+ width: (radius + extraRadius + paddingHorizontal / 2) * 2,
126
+ overflow: 'hidden',
127
+ }, children: [_jsx(View, { style: { position: 'absolute' }, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) }), renderInnerCircle(innerRadius, innerCircleBorderWidth), props.data.length > 1 &&
128
+ props.data[selectedIndex] && // don't forget to add this one so there are no errors when the data is empty / updating
129
+ (props.focusOnPress || props.sectionAutoFocus) &&
130
+ selectedIndex !== -1 && (_jsx(View, { pointerEvents: "box-none", style: {
131
+ position: 'absolute',
132
+ top: -extraRadius,
133
+ left: -extraRadius,
134
+ zIndex: isWebApp ? -1 : 0, // was not getting displayed in web (using Expo)
135
+ }, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, data: [
136
+ __assign(__assign({}, props.data[selectedIndex]), { color: props.showGradient
137
+ ? "url(#grad".concat(selectedIndex, ")")
138
+ : props.data[selectedIndex].color ||
139
+ pieColors[selectedIndex % 9] }),
140
+ {
141
+ value: total - props.data[selectedIndex].value,
142
+ peripheral: true,
143
+ strokeWidth: 0,
144
+ },
145
+ ], radius: radius + extraRadius, initialAngle: startAngle, innerRadius: props.innerRadius || radius / 2.5, isBiggerPie: true, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) })), renderInnerCircle(innerRadius - inwardExtraLengthForFocused, inwardExtraLengthForFocused ? 0 : innerCircleBorderWidth), showTooltip && tooltipSelectedIndex !== -1 ? renderTooltip() : null] }));
146
+ };
@@ -0,0 +1,2 @@
1
+ import { PieChartMainProps } from '@harveylx/gifted-charts-core';
2
+ export declare const PieChartMain: (props: PieChartMainProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,178 @@
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
+ import React, { useState } from 'react';
19
+ import { Pressable, View } from 'react-native';
20
+ import Svg, { Path, Circle, Text as SvgText, Defs, RadialGradient, Stop, G, Line, } from 'react-native-svg';
21
+ import { getPieChartMainProps, pieColors, } from '@harveylx/gifted-charts-core';
22
+ import { isWebApp, rnVersion } from '../utils';
23
+ export var PieChartMain = function (props) {
24
+ var _a;
25
+ var _b = getPieChartMainProps(props), isThreeD = _b.isThreeD, isBiggerPie = _b.isBiggerPie, data = _b.data, showInnerComponent = _b.showInnerComponent, radius = _b.radius, canvasWidth = _b.canvasWidth, canvasHeight = _b.canvasHeight, shadowWidth = _b.shadowWidth, backgroundColor = _b.backgroundColor, shadowColor = _b.shadowColor, semiCircle = _b.semiCircle, pi = _b.pi, initialAngle = _b.initialAngle, shadow = _b.shadow, donut = _b.donut, strokeWidth = _b.strokeWidth, strokeColor = _b.strokeColor, innerRadius = _b.innerRadius, showText = _b.showText, textColor = _b.textColor, textSize = _b.textSize, tiltAngle = _b.tiltAngle, labelsPosition = _b.labelsPosition, showTextBackground = _b.showTextBackground, textBackgroundColor = _b.textBackgroundColor, showValuesAsLabels = _b.showValuesAsLabels, showGradient = _b.showGradient, gradientCenterColor = _b.gradientCenterColor, minShiftX = _b.minShiftX, minShiftY = _b.minShiftY, total = _b.total, horizAdjustment = _b.horizAdjustment, vertAdjustment = _b.vertAdjustment, cx = _b.cx, cy = _b.cy, mData = _b.mData, paddingHorizontal = _b.paddingHorizontal, paddingVertical = _b.paddingVertical, extraRadius = _b.extraRadius, showExternalLabels = _b.showExternalLabels, getExternaLabelProperties = _b.getExternaLabelProperties, coordinates = _b.coordinates, onPressed = _b.onPressed, font = _b.font, fontWeight = _b.fontWeight, fontStyle = _b.fontStyle, edgesPressable = _b.edgesPressable;
26
+ var setTouchX = props.setTouchX, setTouchY = props.setTouchY;
27
+ var prevSide = 'right';
28
+ var prevLabelComponentX = 0;
29
+ var wasFirstItemOnPole = false;
30
+ var _c = __read(useState(0), 2), top = _c[0], setTop = _c[1];
31
+ var _d = __read(useState(0), 2), left = _d[0], setLeft = _d[1];
32
+ var onPressHandler = function (e) {
33
+ var x = 0, y = 0;
34
+ if (isWebApp) {
35
+ x = e.clientX - left;
36
+ y = e.clientY - top;
37
+ }
38
+ else {
39
+ x = e.nativeEvent.locationX;
40
+ y = e.nativeEvent.locationY;
41
+ }
42
+ x -= extraRadius;
43
+ y -= extraRadius;
44
+ setTouchX(x);
45
+ setTouchY(y);
46
+ var r = Math.sqrt(Math.pow((x - cx), 2) + Math.pow((y - cy), 2));
47
+ if (r > radius || (donut && r < innerRadius))
48
+ return;
49
+ var a = Math.atan2(y - cy, x - cx);
50
+ for (var index = 0; index < data.length; index++) {
51
+ var angle = coordinates[index];
52
+ var sx = angle.sx, sy = angle.sy, ax = angle.ax, ay = angle.ay;
53
+ var startAngle = Math.atan2(sy - cy, sx - cx);
54
+ var endAngle = Math.atan2(ay - cy, ax - cx);
55
+ if (startAngle < endAngle) {
56
+ if (startAngle < a && a < endAngle) {
57
+ onPressed(data[index], index);
58
+ break;
59
+ }
60
+ }
61
+ else {
62
+ if (a > startAngle || a < endAngle) {
63
+ onPressed(data[index], index);
64
+ break;
65
+ }
66
+ }
67
+ }
68
+ };
69
+ return (_jsx(Pressable, { onPress: onPressHandler, pointerEvents: isBiggerPie && !edgesPressable ? 'none' : 'auto', children: _jsxs(View, { pointerEvents: "box-only", onLayout: function (e) {
70
+ if (!isWebApp)
71
+ return;
72
+ setTop(e.nativeEvent.layout.top);
73
+ setLeft(e.nativeEvent.layout.left);
74
+ }, style: [
75
+ {
76
+ backgroundColor: backgroundColor,
77
+ height: semiCircle
78
+ ? (canvasHeight + paddingVertical) / 2 + extraRadius
79
+ : canvasHeight + paddingVertical + extraRadius * 2,
80
+ width: canvasWidth + paddingHorizontal + extraRadius * 2,
81
+ overflow: 'hidden',
82
+ },
83
+ isThreeD && { transform: [{ rotateX: tiltAngle }] },
84
+ ], children: [_jsxs(Svg, { pointerEvents: rnVersion >= 720000 ? 'box-none' : 'auto', viewBox: "".concat(strokeWidth / -2 + minShiftX - extraRadius - paddingHorizontal / 2, " ").concat(strokeWidth / -2 + minShiftY - extraRadius - paddingVertical / 2, " ").concat((radius + extraRadius + strokeWidth) * 2 +
85
+ paddingHorizontal +
86
+ horizAdjustment +
87
+ (horizAdjustment ? strokeWidth : 0), " ").concat((radius + extraRadius + strokeWidth) * 2 +
88
+ paddingVertical +
89
+ vertAdjustment +
90
+ (vertAdjustment ? strokeWidth : 0)), height: (radius + extraRadius) * 2 + strokeWidth + paddingVertical, width: (radius + extraRadius) * 2 + strokeWidth + paddingHorizontal, children: [_jsx(Defs, { children: data.map(function (item, index) {
91
+ return (_jsxs(RadialGradient, { id: 'grad' + index, cx: "50%", cy: "50%", rx: "50%", ry: "50%", fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: item.gradientCenterColor || gradientCenterColor, stopOpacity: "1" }), _jsx(Stop, { offset: "100%", stopColor: item.color || pieColors[index % 9], stopOpacity: "1" })] }, index + ''));
92
+ }) }), data.length === 1 || !total ? (_jsx(_Fragment, { children: _jsx(Circle, { cx: cx, cy: cy, r: radius, fill: showGradient
93
+ ? "url(#grad".concat(0, ")")
94
+ : ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.color) || pieColors[0 % 9] }) })) : (data.map(function (item, index) {
95
+ var _a = coordinates[index], sx = _a.sx, sy = _a.sy, ax = _a.ax, ay = _a.ay;
96
+ if (isBiggerPie && index)
97
+ return null;
98
+ return (_jsx(Path, { d: "M ".concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0), " L ").concat(sx, " ").concat(sy, " A ").concat(radius, " ").concat(radius, " 0 ").concat(semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0, " 1 ").concat(ax, " ").concat(ay, " L ").concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0)), stroke: item.strokeColor || strokeColor, strokeWidth: props.focusOnPress && props.selectedIndex === index
99
+ ? 0
100
+ : item.strokeWidth === 0
101
+ ? 0
102
+ : item.strokeWidth || strokeWidth, fill: props.selectedIndex === index || item.peripheral
103
+ ? 'none'
104
+ : showGradient
105
+ ? "url(#grad".concat(index, ")")
106
+ : item.color || pieColors[index % 9] }, index + 'a'));
107
+ })), (showText || showInnerComponent || showExternalLabels) &&
108
+ data.map(function (item, index) {
109
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
110
+ var localPieInnerComponent = (_a = item.pieInnerComponent) !== null && _a !== void 0 ? _a : props.pieInnerComponent;
111
+ var pieInnerComponentHeight = (_b = props.pieInnerComponentHeight) !== null && _b !== void 0 ? _b : 0;
112
+ var pieInnerComponentWidth = (_c = props.pieInnerComponentWidth) !== null && _c !== void 0 ? _c : 0;
113
+ if (isBiggerPie && index)
114
+ return null;
115
+ if (!props.data[index].value)
116
+ return null;
117
+ var mx = cx * (1 + Math.sin(2 * pi * mData[index] + initialAngle));
118
+ var my = cy * (1 - Math.cos(2 * pi * mData[index] + initialAngle));
119
+ var midx = (mx + cx) / 2;
120
+ var midy = (my + cy) / 2;
121
+ var x = midx, y = midy;
122
+ var labelPosition = item.labelPosition || labelsPosition;
123
+ if (labelPosition === 'onBorder') {
124
+ x = mx;
125
+ y = my;
126
+ }
127
+ else if (labelPosition === 'outward') {
128
+ x = (midx + mx) / 2;
129
+ y = (midy + my) / 2;
130
+ }
131
+ else if (labelPosition === 'inward') {
132
+ x = (midx + cx) / 2;
133
+ y = (midy + cy) / 2;
134
+ }
135
+ x += item.shiftX || 0;
136
+ y += item.shiftY || 0;
137
+ if (data.length === 1) {
138
+ if (donut) {
139
+ y =
140
+ (radius -
141
+ innerRadius +
142
+ (item.textBackgroundRadius ||
143
+ props.textBackgroundRadius ||
144
+ item.textSize ||
145
+ textSize)) /
146
+ 2;
147
+ }
148
+ else {
149
+ y = cy;
150
+ }
151
+ }
152
+ var _k = getExternaLabelProperties(item, mx, my, cx, cy, prevSide, prevLabelComponentX, index === data.length - 1, // isLast
153
+ wasFirstItemOnPole), labelLineColor = _k.labelLineColor, labelLineThickness = _k.labelLineThickness, labelComponentHeight = _k.labelComponentHeight, inX = _k.inX, inY = _k.inY, outX = _k.outX, outY = _k.outY, finalX = _k.finalX, labelComponentX = _k.labelComponentX, labelComponentY = _k.labelComponentY, localExternalLabelComponent = _k.localExternalLabelComponent, isRightHalf = _k.isRightHalf;
154
+ prevSide = isRightHalf ? 'right' : 'left';
155
+ prevLabelComponentX = labelComponentX;
156
+ if (index === 0)
157
+ wasFirstItemOnPole = labelComponentY !== outY;
158
+ return (_jsxs(React.Fragment, { children: [showExternalLabels ? (_jsxs(G, { children: [_jsx(Line, { x1: inX, x2: outX, y1: inY, y2: outY, stroke: labelLineColor, strokeWidth: labelLineThickness }), _jsx(Line, { x1: outX, x2: finalX, y1: outY, y2: outY, stroke: labelLineColor, strokeWidth: labelLineThickness }), localExternalLabelComponent ? (_jsx(G, { x: labelComponentX, y: labelComponentY + labelComponentHeight / 2, children: (_d = localExternalLabelComponent === null || localExternalLabelComponent === void 0 ? void 0 : localExternalLabelComponent(item, index)) !== null && _d !== void 0 ? _d : null })) : null] })) : null, showTextBackground ? (_jsx(Circle, { cx: x + ((_f = (_e = item.shiftTextBackgroundX) !== null && _e !== void 0 ? _e : item.shiftTextX) !== null && _f !== void 0 ? _f : 0), cy: y +
159
+ ((_h = (_g = item.shiftTextBackgroundY) !== null && _g !== void 0 ? _g : item.shiftTextY) !== null && _h !== void 0 ? _h : 0) -
160
+ (item.textSize || textSize) / 4, r: item.textBackgroundRadius ||
161
+ props.textBackgroundRadius ||
162
+ item.textSize ||
163
+ textSize, fill: item.textBackgroundColor || textBackgroundColor })) : null, showText && (_jsx(SvgText, { fill: item.textColor ||
164
+ textColor ||
165
+ pieColors[(index + 2) % 9], fontSize: item.textSize || textSize, fontFamily: item.font || font, fontWeight: item.fontWeight || fontWeight, fontStyle: item.fontStyle || fontStyle || 'normal', x: x +
166
+ (item.shiftTextX || 0) -
167
+ (item.textSize || textSize) / 1.8, y: y + (item.shiftTextY || 0), children: item.text || (showValuesAsLabels ? item.value + '' : '') })), localPieInnerComponent ? (_jsx(G, { x: x - pieInnerComponentHeight / 2, y: y - pieInnerComponentWidth / 2, children: (_j = localPieInnerComponent === null || localPieInnerComponent === void 0 ? void 0 : localPieInnerComponent(item, index)) !== null && _j !== void 0 ? _j : null })) : null] }, index));
168
+ })] }), isThreeD && shadow && !semiCircle ? (_jsx(View, { style: {
169
+ width: radius * 2,
170
+ height: radius * 2,
171
+ backgroundColor: shadowColor,
172
+ borderRadius: radius,
173
+ position: 'absolute',
174
+ top: shadowWidth + paddingVertical / 2,
175
+ left: paddingHorizontal / 2,
176
+ zIndex: -1,
177
+ } })) : null] }) }));
178
+ };
@@ -0,0 +1,2 @@
1
+ import { PieChartPropsType } from '@harveylx/gifted-charts-core';
2
+ export declare const PieChartPro: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,124 @@
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
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useEffect } from 'react';
14
+ import { pieColors, usePiePro, } from '@harveylx/gifted-charts-core';
15
+ import { Defs, Path, Stop, Svg, Text as SvgText, RadialGradient, } from 'react-native-svg';
16
+ import { Animated, View } from 'react-native';
17
+ export var PieChartPro = function (props) {
18
+ var _a = usePiePro(props), radius = _a.radius, total = _a.total, donut = _a.donut, strokeWidth = _a.strokeWidth, maxStrokeWidth = _a.maxStrokeWidth, animationDuration = _a.animationDuration, initial = _a.initial, dInitial = _a.dInitial, dFinal = _a.dFinal, getStartCaps = _a.getStartCaps, getEndCaps = _a.getEndCaps, getTextCoordinates = _a.getTextCoordinates, height = _a.height, heightFactor = _a.heightFactor, svgProps = _a.svgProps;
19
+ var data = props.data, curvedStartEdges = props.curvedStartEdges, curvedEndEdges = props.curvedEndEdges, _b = props.edgesRadius, edgesRadius = _b === void 0 ? 0 : _b, showGradient = props.showGradient, ring = props.ring, centerLabelComponent = props.centerLabelComponent, strokeDashArray = props.strokeDashArray, semiCircle = props.semiCircle;
20
+ var isAnimated = props.isAnimated;
21
+ if (!props.semiCircle && data.some(function (dataItem) { return dataItem.value > total / 2; })) {
22
+ // if we have an obtuse arc, we cant animate
23
+ isAnimated = false;
24
+ }
25
+ var AnimatedPath = Animated.createAnimatedComponent(Path);
26
+ var AnimatedText = Animated.createAnimatedComponent(SvgText);
27
+ var animatedValues = data.map(function (i) { return new Animated.Value(0); });
28
+ var animatedOpacityValue = new Animated.Value(0);
29
+ var animatedPaths = data.map(function (item, index) {
30
+ var _a;
31
+ return (_a = animatedValues[index]) === null || _a === void 0 ? void 0 : _a.interpolate({
32
+ inputRange: [0, 1],
33
+ outputRange: [dInitial[index], dFinal[index]],
34
+ });
35
+ });
36
+ var animatedOpacity = animatedOpacityValue.interpolate({
37
+ inputRange: [0, 1],
38
+ outputRange: [0, 1],
39
+ });
40
+ useEffect(function () {
41
+ Animated.timing(animatedOpacityValue, {
42
+ toValue: 1,
43
+ duration: 10,
44
+ useNativeDriver: true,
45
+ delay: animationDuration,
46
+ }).start();
47
+ animatedValues.forEach(function (animatedValue) {
48
+ return Animated.timing(animatedValue, {
49
+ toValue: 1,
50
+ duration: animationDuration,
51
+ useNativeDriver: true,
52
+ }).start();
53
+ });
54
+ }, [data]);
55
+ var adjustHeight = height * heightFactor;
56
+ var rnSvgProps = semiCircle ? {} : svgProps;
57
+ return (_jsxs(View, { style: {
58
+ display: 'flex',
59
+ justifyContent: 'center',
60
+ alignItems: 'center',
61
+ height: adjustHeight,
62
+ width: height * 2,
63
+ }, children: [_jsx(View, { style: semiCircle
64
+ ? { position: 'absolute', bottom: 0 }
65
+ : { position: 'absolute' }, children: centerLabelComponent ? centerLabelComponent() : null }), _jsx(Svg, __assign({}, rnSvgProps, { viewBox: semiCircle
66
+ ? ""
67
+ : "".concat(-maxStrokeWidth * 1.5, " ").concat(-maxStrokeWidth - (semiCircle ? height / 2 : 0), " ").concat(adjustHeight, " ").concat(adjustHeight), transform: semiCircle
68
+ ? []
69
+ : [{ scaleY: maxStrokeWidth ? 1 + maxStrokeWidth / (radius * 2) : 1 }], children: total ? (_jsxs(_Fragment, { children: [_jsx(Defs, { children: data.map(function (item, index) {
70
+ return (_jsxs(RadialGradient, { id: 'grad' + index, cx: "50%", cy: "50%", rx: "50%", ry: "50%", fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: item.gradientCenterColor, stopOpacity: "1" }), _jsx(Stop, { offset: "100%", stopColor: item.color || pieColors[index % 9], stopOpacity: "1" })] }, index + ''));
71
+ }) }), data.map(function (item, index) {
72
+ var _a, _b, _c, _d;
73
+ var borderWidth = (_a = item.strokeWidth) !== null && _a !== void 0 ? _a : strokeWidth;
74
+ var borderColor = (_c = (_b = item.strokeColor) !== null && _b !== void 0 ? _b : props.strokeColor) !== null && _c !== void 0 ? _c : (borderWidth ? 'black' : 'none');
75
+ var strokeDashArrayLocal = (_d = item.strokeDashArray) !== null && _d !== void 0 ? _d : strokeDashArray;
76
+ return (_jsx(AnimatedPath, { id: "renderPath", d: isAnimated ? animatedPaths[index] : dFinal[index], fill: ring
77
+ ? 'none'
78
+ : showGradient
79
+ ? "url(#grad".concat(index, ")")
80
+ : data[index].color || pieColors[index % 9], strokeWidth: borderWidth, strokeDasharray: strokeDashArrayLocal, stroke: borderColor }, "path".concat(index)));
81
+ }), donut
82
+ ? data.map(function (item, index) {
83
+ if (curvedStartEdges ||
84
+ edgesRadius ||
85
+ item.isStartEdgeCurved ||
86
+ item.startEdgeRadius)
87
+ return (_jsx(AnimatedPath, { d: "".concat(initial, " ").concat(getStartCaps(index, item)), opacity: isAnimated ? animatedOpacity : 1, fill: showGradient
88
+ ? "url(#grad".concat(index, ")")
89
+ : data[index].color || pieColors[index % 9] }, "cap".concat(index)));
90
+ return null;
91
+ })
92
+ : null, donut
93
+ ? data.map(function (item, index) {
94
+ if (curvedEndEdges ||
95
+ edgesRadius ||
96
+ item.isEndEdgeCurved ||
97
+ item.endEdgeRadius)
98
+ return (_jsx(Path, { d: "".concat(initial, " ").concat(getEndCaps(index, item)), fill: showGradient
99
+ ? "url(#grad".concat(index, ")")
100
+ : data[index].color || pieColors[index % 9] }, "cap".concat(index)));
101
+ return null;
102
+ })
103
+ : null, data.map(function (item, index) {
104
+ var _a, _b;
105
+ var _c = getTextCoordinates(index, item.labelPosition), x = _c.x, y = _c.y;
106
+ return (_jsx(AnimatedText, {
107
+ // style={{ pointerEvents: 'all' }}
108
+ fill: item.textColor ||
109
+ props.textColor ||
110
+ pieColors[(index + 2) % 9], opacity: isAnimated ? animatedOpacity : 1, fontSize: item.textSize || props.textSize, fontFamily: item.font || props.font, fontWeight: item.fontWeight || props.fontWeight, fontStyle: item.fontStyle || props.fontStyle || 'normal', x: x +
111
+ (item.shiftTextX || 0) -
112
+ ((_b = (_a = item.textSize) !== null && _a !== void 0 ? _a : props.textSize) !== null && _b !== void 0 ? _b : 0) / 1.8, y: y + (item.shiftTextY || 0), onPress: function () {
113
+ var _a;
114
+ item.onLabelPress
115
+ ? item.onLabelPress()
116
+ : props.onLabelPress
117
+ ? props.onLabelPress(item, index)
118
+ : item.onPress
119
+ ? item.onPress()
120
+ : (_a = props.onPress) === null || _a === void 0 ? void 0 : _a.call(props, item, index);
121
+ }, children: item.text ||
122
+ (props.showValuesAsLabels ? item.value + '' : '') }, "label".concat(index)));
123
+ })] })) : null }))] }));
124
+ };
@@ -0,0 +1,2 @@
1
+ import { PopulationPyramidPropsType } from '@harveylx/gifted-charts-core';
2
+ export declare const PopulationPyramid: (props: PopulationPyramidPropsType) => import("react/jsx-runtime").JSX.Element;