@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.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +78 -0
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +222 -0
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +214 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +256 -0
- package/dist/BarChart/styles.d.ts +45 -0
- package/dist/BarChart/styles.js +46 -0
- package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
- package/dist/Components/AnimatedThreeDBar/index.js +103 -0
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
- package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
- package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
- package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/cap.js +16 -0
- package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
- package/dist/Components/common/LinearGradient.d.ts +16 -0
- package/dist/Components/common/LinearGradient.js +15 -0
- package/dist/Components/common/Pointer.d.ts +1 -0
- package/dist/Components/common/Pointer.js +18 -0
- package/dist/Components/common/StripAndLabel.d.ts +2 -0
- package/dist/Components/common/StripAndLabel.js +60 -0
- package/dist/Components/lineSvg.d.ts +14 -0
- package/dist/Components/lineSvg.js +22 -0
- package/dist/LineChart/LineChartBicolor.d.ts +2 -0
- package/dist/LineChart/LineChartBicolor.js +298 -0
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1137 -0
- package/dist/LineChart/styles.d.ts +43 -0
- package/dist/LineChart/styles.js +46 -0
- package/dist/PieChart/index.d.ts +2 -0
- package/dist/PieChart/index.js +146 -0
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +178 -0
- package/dist/PieChartPro/index.d.ts +2 -0
- package/dist/PieChartPro/index.js +124 -0
- package/dist/PopulationPyramid/index.d.ts +2 -0
- package/dist/PopulationPyramid/index.js +132 -0
- package/dist/RadarChart/index.d.ts +2 -0
- package/dist/RadarChart/index.js +113 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +22 -0
- package/package.json +89 -0
|
@@ -0,0 +1,132 @@
|
|
|
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 { Fragment } from 'react';
|
|
14
|
+
import { View } from 'react-native';
|
|
15
|
+
import { ruleTypes, usePopulationPyramid, } from '@harveylx/gifted-charts-core';
|
|
16
|
+
import { ClipPath, Line, Rect, Svg, Text as SvgText, Use, } from 'react-native-svg';
|
|
17
|
+
import { screenWidth } from '../utils';
|
|
18
|
+
export var PopulationPyramid = function (props) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
var _e = usePopulationPyramid(__assign(__assign({}, props), { screenWidth: screenWidth })), width = _e.width, verticalMarginBetweenBars = _e.verticalMarginBetweenBars, barsMapToYAxisSections = _e.barsMapToYAxisSections, data = _e.data, hideRules = _e.hideRules, yAxisColor = _e.yAxisColor, xAxisColor = _e.xAxisColor, xAxisThickness = _e.xAxisThickness, xAxisType = _e.xAxisType, xAxisNoOfSections = _e.xAxisNoOfSections, showXAxisIndices = _e.showXAxisIndices, showXAxisLabelTexts = _e.showXAxisLabelTexts, xAxisLabelShiftX = _e.xAxisLabelShiftX, xAxisLabelPrefix = _e.xAxisLabelPrefix, xAxisLabelSuffix = _e.xAxisLabelSuffix, formatXAxisLabels = _e.formatXAxisLabels, showVerticalLines = _e.showVerticalLines, showYAxisIndices = _e.showYAxisIndices, yAxisIndicesWidth = _e.yAxisIndicesWidth, yAxisIndicesHeight = _e.yAxisIndicesHeight, yAxisIndicesColor = _e.yAxisIndicesColor, yAxisLabelFontSize = _e.yAxisLabelFontSize, yAxisLabelFontStyle = _e.yAxisLabelFontStyle, yAxisLabelFontWeight = _e.yAxisLabelFontWeight, yAxisLabelFontFamily = _e.yAxisLabelFontFamily, yAxisLabelColor = _e.yAxisLabelColor, yAxisLabelTextMarginRight = _e.yAxisLabelTextMarginRight, yAxisLabelTexts = _e.yAxisLabelTexts, showValuesAsBarLabels = _e.showValuesAsBarLabels, rulesThickness = _e.rulesThickness, rulesColor = _e.rulesColor, rulesType = _e.rulesType, dashWidth = _e.dashWidth, dashGap = _e.dashGap, leftBarLabelWidth = _e.leftBarLabelWidth, leftBarLabelFontSize = _e.leftBarLabelFontSize, leftBarLabelColor = _e.leftBarLabelColor, leftBarLabelFontStyle = _e.leftBarLabelFontStyle, leftBarLabelFontWeight = _e.leftBarLabelFontWeight, leftBarLabelFontFamily = _e.leftBarLabelFontFamily, leftBarLabelPrefix = _e.leftBarLabelPrefix, leftBarLabelSuffix = _e.leftBarLabelSuffix, rightBarLabelFontSize = _e.rightBarLabelFontSize, rightBarLabelColor = _e.rightBarLabelColor, rightBarLabelFontStyle = _e.rightBarLabelFontStyle, rightBarLabelFontWeight = _e.rightBarLabelFontWeight, rightBarLabelFontFamily = _e.rightBarLabelFontFamily, rightBarLabelPrefix = _e.rightBarLabelPrefix, rightBarLabelSuffix = _e.rightBarLabelSuffix, formatBarLabels = _e.formatBarLabels, showMidAxis = _e.showMidAxis, midAxisLabelFontSize = _e.midAxisLabelFontSize, midAxisLabelColor = _e.midAxisLabelColor, midAxisLabelFontStyle = _e.midAxisLabelFontStyle, midAxisLabelFontWeight = _e.midAxisLabelFontWeight, midAxisLabelFontFamily = _e.midAxisLabelFontFamily, leftBarColor = _e.leftBarColor, rightBarColor = _e.rightBarColor, leftBarBorderColor = _e.leftBarBorderColor, rightBarBorderColor = _e.rightBarBorderColor, leftBarBorderWidth = _e.leftBarBorderWidth, rightBarBorderWidth = _e.rightBarBorderWidth, leftBarBorderRadius = _e.leftBarBorderRadius, rightBarBorderRadius = _e.rightBarBorderRadius, allCornersRounded = _e.allCornersRounded, showSurplus = _e.showSurplus, showSurplusLeft = _e.showSurplusLeft, showSurplusRight = _e.showSurplusRight, leftSurplusColor = _e.leftSurplusColor, leftSurplusBorderColor = _e.leftSurplusBorderColor, rightSurplusColor = _e.rightSurplusColor, rightSurplusBorderColor = _e.rightSurplusBorderColor, leftSurplusBorderWidth = _e.leftSurplusBorderWidth, rightSurplusBorderWidth = _e.rightSurplusBorderWidth, yAxisLabelWidth = _e.yAxisLabelWidth, noOfSections = _e.noOfSections, stepHeight = _e.stepHeight, containerHeightWithXaxisLabels = _e.containerHeightWithXaxisLabels, mid = _e.mid, barWidthFactor = _e.barWidthFactor, leftXAfterMid = _e.leftXAfterMid, rightXAfterMid = _e.rightXAfterMid, yAxisLineProps = _e.yAxisLineProps, midAxisLineCommonProps = _e.midAxisLineCommonProps, xAxisIndicesCommonProps = _e.xAxisIndicesCommonProps, verticalLinesCommonProps = _e.verticalLinesCommonProps, xAxisLabelsCommonProps = _e.xAxisLabelsCommonProps, getXLabel = _e.getXLabel, midAxisLabelWidth = _e.midAxisLabelWidth;
|
|
21
|
+
return (_jsx(View, { style: { height: containerHeightWithXaxisLabels, width: width }, children: _jsxs(Svg, { fill: 'none', children: [_jsx(Line, __assign({}, yAxisLineProps)), Array.from(Array(noOfSections)).map(function (item, index) {
|
|
22
|
+
var _a;
|
|
23
|
+
var isLast = index === noOfSections - 1;
|
|
24
|
+
var y = stepHeight * (index + 1);
|
|
25
|
+
var rulesProps = {
|
|
26
|
+
x1: yAxisLabelWidth,
|
|
27
|
+
y1: y,
|
|
28
|
+
x2: width,
|
|
29
|
+
y2: y,
|
|
30
|
+
stroke: isLast ? xAxisColor : rulesColor,
|
|
31
|
+
strokeWidth: isLast ? xAxisThickness : rulesThickness,
|
|
32
|
+
};
|
|
33
|
+
if ((isLast && xAxisType !== ruleTypes.SOLID) ||
|
|
34
|
+
(!isLast && rulesType !== ruleTypes.SOLID)) {
|
|
35
|
+
rulesProps.strokeDasharray = [dashWidth, dashGap];
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
delete rulesProps.strokeDasharray;
|
|
39
|
+
}
|
|
40
|
+
return (_jsxs(Fragment, { children: [!hideRules || isLast ? _jsx(Line, __assign({}, rulesProps)) : null, showYAxisIndices ? (_jsx(Line, { x1: yAxisLabelWidth - yAxisIndicesWidth / 2, y1: y, x2: yAxisLabelWidth + yAxisIndicesWidth / 2, y2: y, stroke: yAxisIndicesColor, strokeWidth: yAxisIndicesHeight })) : null, !barsMapToYAxisSections ? (_jsx(SvgText, { x: yAxisLabelWidth - yAxisLabelTextMarginRight, y: stepHeight * (index + 0.5) + yAxisLabelFontSize / 2 - 2, stroke: yAxisLabelColor, fontSize: yAxisLabelFontSize, fontStyle: yAxisLabelFontStyle, fontWeight: yAxisLabelFontWeight, fontFamily: yAxisLabelFontFamily, textAnchor: "end", children: (_a = yAxisLabelTexts[index]) !== null && _a !== void 0 ? _a : '' })) : null] }, 'rule' + index));
|
|
41
|
+
}), Array.from(Array(xAxisNoOfSections)).map(function (item, index) {
|
|
42
|
+
var x = leftXAfterMid - (leftXAfterMid * index) / xAxisNoOfSections;
|
|
43
|
+
var unformattedXLabel = getXLabel(index);
|
|
44
|
+
var xLabel = formatXAxisLabels
|
|
45
|
+
? formatXAxisLabels(unformattedXLabel)
|
|
46
|
+
: unformattedXLabel;
|
|
47
|
+
return (_jsxs(Fragment, { children: [showVerticalLines ? (_jsx(Line, __assign({}, verticalLinesCommonProps, { x1: x, x2: x }))) : null, showXAxisIndices ? (_jsx(Line, __assign({}, xAxisIndicesCommonProps, { x1: x, x2: x }))) : null, showXAxisLabelTexts ? (_jsx(SvgText, __assign({}, xAxisLabelsCommonProps, { x: x + xAxisLabelShiftX, textAnchor: "middle", children: xAxisLabelPrefix + xLabel + xAxisLabelSuffix }))) : null] }, 'x-axis' + index));
|
|
48
|
+
}), Array.from(Array(xAxisNoOfSections)).map(function (item, index) {
|
|
49
|
+
if (!index && !showMidAxis)
|
|
50
|
+
return null;
|
|
51
|
+
var x = midAxisLabelWidth +
|
|
52
|
+
leftXAfterMid +
|
|
53
|
+
(leftXAfterMid * index) / xAxisNoOfSections;
|
|
54
|
+
var unformattedXLabel = getXLabel(index);
|
|
55
|
+
var xLabel = formatXAxisLabels
|
|
56
|
+
? formatXAxisLabels(unformattedXLabel)
|
|
57
|
+
: unformattedXLabel;
|
|
58
|
+
return (_jsxs(Fragment, { children: [showVerticalLines ? (_jsx(Line, __assign({}, verticalLinesCommonProps, { x1: x, x2: x }))) : null, showXAxisIndices ? (_jsx(Line, __assign({}, xAxisIndicesCommonProps, { x1: x, x2: x }))) : null, showXAxisLabelTexts ? (_jsx(SvgText, __assign({}, xAxisLabelsCommonProps, { x: x + xAxisLabelShiftX, textAnchor: "middle", children: xAxisLabelPrefix + xLabel + xAxisLabelSuffix }))) : null] }, 'x-axis' + index));
|
|
59
|
+
}), data.map(function (item, index) {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
|
|
61
|
+
var leftWidth = item.left * barWidthFactor;
|
|
62
|
+
var rightWidth = item.right * barWidthFactor;
|
|
63
|
+
var y = stepHeight * index + verticalMarginBetweenBars;
|
|
64
|
+
var leftSurplusWidth = leftWidth - rightWidth;
|
|
65
|
+
var rightSurplusWidth = rightWidth - leftWidth;
|
|
66
|
+
var leftRadius = (_b = (_a = item.leftBarBorderRadius) !== null && _a !== void 0 ? _a : item.barBorderRadius) !== null && _b !== void 0 ? _b : leftBarBorderRadius;
|
|
67
|
+
var rightRadius = (_d = (_c = item.rightBarBorderRadius) !== null && _c !== void 0 ? _c : item.barBorderRadius) !== null && _d !== void 0 ? _d : rightBarBorderRadius;
|
|
68
|
+
var leftBorderWidth = (_f = (_e = item.leftBarBorderWidth) !== null && _e !== void 0 ? _e : item.barBorderWidth) !== null && _f !== void 0 ? _f : leftBarBorderWidth;
|
|
69
|
+
var rightBorderWidth = (_h = (_g = item.rightBarBorderWidth) !== null && _g !== void 0 ? _g : item.barBorderWidth) !== null && _h !== void 0 ? _h : rightBarBorderWidth;
|
|
70
|
+
var unFormattedLeftBarLabel = (_j = item.leftBarLabel) !== null && _j !== void 0 ? _j : (showValuesAsBarLabels ? item.left.toString() : '');
|
|
71
|
+
var leftBarLabel = formatBarLabels
|
|
72
|
+
? formatBarLabels(unFormattedLeftBarLabel)
|
|
73
|
+
: unFormattedLeftBarLabel;
|
|
74
|
+
var unFormattedRightBarLabel = (_k = item.rightBarLabel) !== null && _k !== void 0 ? _k : (showValuesAsBarLabels ? item.right.toString() : '');
|
|
75
|
+
var rightBarLabel = formatBarLabels
|
|
76
|
+
? formatBarLabels(unFormattedRightBarLabel)
|
|
77
|
+
: unFormattedRightBarLabel;
|
|
78
|
+
var leftLabelFontSize = (_l = item.leftBarLabelFontSize) !== null && _l !== void 0 ? _l : leftBarLabelFontSize;
|
|
79
|
+
var leftLabelX = leftXAfterMid -
|
|
80
|
+
leftWidth -
|
|
81
|
+
leftBarBorderWidth / 2 -
|
|
82
|
+
yAxisLabelWidth / 2 -
|
|
83
|
+
leftBarLabelWidth / 2 +
|
|
84
|
+
28 -
|
|
85
|
+
(leftBarLabel.length * leftLabelFontSize) / 2 +
|
|
86
|
+
((_o = (_m = item.leftBarLabelShift) !== null && _m !== void 0 ? _m : props.leftBarLabelShift) !== null && _o !== void 0 ? _o : 0);
|
|
87
|
+
var rightLabelX = rightXAfterMid +
|
|
88
|
+
rightBarBorderWidth / 2 +
|
|
89
|
+
rightWidth +
|
|
90
|
+
3 +
|
|
91
|
+
((_q = (_p = item.rightBarLabelShift) !== null && _p !== void 0 ? _p : props.rightBarLabelShift) !== null && _q !== void 0 ? _q : 0);
|
|
92
|
+
var leftBarCommonProps = {
|
|
93
|
+
x: leftXAfterMid - leftWidth - leftBarBorderWidth / 2,
|
|
94
|
+
y: y,
|
|
95
|
+
width: leftWidth,
|
|
96
|
+
height: stepHeight - verticalMarginBetweenBars * 2,
|
|
97
|
+
rx: leftRadius,
|
|
98
|
+
ry: leftRadius,
|
|
99
|
+
};
|
|
100
|
+
var rightBarCommonProps = {
|
|
101
|
+
x: rightXAfterMid + rightBarBorderWidth / 2,
|
|
102
|
+
y: y,
|
|
103
|
+
width: rightWidth,
|
|
104
|
+
height: stepHeight - verticalMarginBetweenBars * 2,
|
|
105
|
+
rx: rightRadius,
|
|
106
|
+
ry: rightRadius,
|
|
107
|
+
};
|
|
108
|
+
return (_jsxs(Fragment, { children: [barsMapToYAxisSections ? (_jsx(SvgText, { x: yAxisLabelWidth - yAxisLabelTextMarginRight, y: stepHeight * (index + 0.5) + yAxisLabelFontSize / 2 - 2, stroke: yAxisLabelColor, fontSize: yAxisLabelFontSize, fontStyle: yAxisLabelFontStyle, fontWeight: yAxisLabelFontWeight, fontFamily: yAxisLabelFontFamily, textAnchor: "end", children: (_s = (_r = item.yAxisLabel) !== null && _r !== void 0 ? _r : yAxisLabelTexts[index]) !== null && _s !== void 0 ? _s : '' })) : null, _jsx(Rect, __assign({}, leftBarCommonProps, { fill: (_t = item.leftBarColor) !== null && _t !== void 0 ? _t : leftBarColor, stroke: (_u = item.leftBarBorderColor) !== null && _u !== void 0 ? _u : leftBarBorderColor, strokeWidth: leftBorderWidth, onPress: function () { var _a; return (_a = props.onLeftPress) === null || _a === void 0 ? void 0 : _a.call(props, item, index); } })), _jsx(ClipPath, { id: 'cp-left' + index, children: _jsx(Rect, __assign({}, leftBarCommonProps)) }), !allCornersRounded && leftWidth >= leftRadius ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: leftXAfterMid - leftRadius, y: y, width: leftRadius, height: stepHeight - verticalMarginBetweenBars * 2, fill: (_v = item.leftBarColor) !== null && _v !== void 0 ? _v : leftBarColor }), leftBorderWidth ? (_jsxs(_Fragment, { children: [_jsx(Line, { x1: leftXAfterMid - leftRadius, y1: y, x2: leftXAfterMid, y2: y, stroke: (_w = item.leftBarBorderColor) !== null && _w !== void 0 ? _w : leftBarBorderColor, strokeWidth: leftBorderWidth }), _jsx(Line, { x1: leftXAfterMid - leftRadius, y1: y + stepHeight - verticalMarginBetweenBars * 2, x2: leftXAfterMid, y2: y + stepHeight - verticalMarginBetweenBars * 2, stroke: (_x = item.leftBarBorderColor) !== null && _x !== void 0 ? _x : leftBarBorderColor, strokeWidth: leftBorderWidth })] })) : null] })) : null, leftBarLabel !== '' ? (_jsx(SvgText, { x: leftLabelX, y: stepHeight * (index + 0.5) + yAxisLabelFontSize / 2 - 2, stroke: (_y = item.leftBarLabelColor) !== null && _y !== void 0 ? _y : leftBarLabelColor, fontSize: leftLabelFontSize, fontStyle: (_z = item.leftBarLabelFontStyle) !== null && _z !== void 0 ? _z : leftBarLabelFontStyle, fontWeight: (_0 = item.leftBarLabelFontWeight) !== null && _0 !== void 0 ? _0 : leftBarLabelFontWeight, fontFamily: (_1 = item.leftBarLabelFontFamily) !== null && _1 !== void 0 ? _1 : leftBarLabelFontFamily, textAnchor: "start", children: leftBarLabelPrefix + leftBarLabel + leftBarLabelSuffix })) : null, _jsx(Rect, __assign({}, rightBarCommonProps, { fill: (_2 = item.rightBarColor) !== null && _2 !== void 0 ? _2 : rightBarColor, stroke: (_3 = item.rightBarBorderColor) !== null && _3 !== void 0 ? _3 : rightBarBorderColor, strokeWidth: rightBorderWidth, onPress: function () { var _a; return (_a = props.onRightPress) === null || _a === void 0 ? void 0 : _a.call(props, item, index); } })), _jsx(ClipPath, { id: 'cp-right' + index, children: _jsx(Rect, __assign({}, rightBarCommonProps)) }), !allCornersRounded && rightWidth >= rightRadius ? (_jsxs(_Fragment, { children: [_jsx(Rect, { x: rightXAfterMid, y: y, width: rightRadius, height: stepHeight - verticalMarginBetweenBars * 2, fill: (_4 = item.rightBarColor) !== null && _4 !== void 0 ? _4 : rightBarColor }), rightBorderWidth ? (_jsxs(_Fragment, { children: [_jsx(Line, { x1: rightXAfterMid, y1: y, x2: rightXAfterMid + rightRadius, y2: y, stroke: (_5 = item.rightBarBorderColor) !== null && _5 !== void 0 ? _5 : rightBarBorderColor, strokeWidth: rightBorderWidth }), _jsx(Line, { x1: rightXAfterMid, y1: y + stepHeight - verticalMarginBetweenBars * 2, x2: rightXAfterMid + rightRadius, y2: y + stepHeight - verticalMarginBetweenBars * 2, stroke: (_6 = item.rightBarBorderColor) !== null && _6 !== void 0 ? _6 : rightBarBorderColor, strokeWidth: rightBorderWidth })] })) : null] })) : null, rightBarLabel !== '' ? (_jsx(SvgText, { x: rightLabelX, y: stepHeight * (index + 0.5) + yAxisLabelFontSize / 2 - 2, stroke: (_7 = item.rightBarLabelColor) !== null && _7 !== void 0 ? _7 : rightBarLabelColor, fontSize: (_8 = item.rightBarLabelFontSize) !== null && _8 !== void 0 ? _8 : rightBarLabelFontSize, fontStyle: (_9 = item.rightBarLabelFontStyle) !== null && _9 !== void 0 ? _9 : rightBarLabelFontStyle, fontWeight: (_10 = item.rightBarLabelFontWeight) !== null && _10 !== void 0 ? _10 : rightBarLabelFontWeight, fontFamily: (_11 = item.rightBarLabelFontFamily) !== null && _11 !== void 0 ? _11 : rightBarLabelFontFamily, textAnchor: "start", children: rightBarLabelPrefix + rightBarLabel + rightBarLabelSuffix })) : null, (showSurplus ||
|
|
109
|
+
showSurplusLeft ||
|
|
110
|
+
item.showSurplus ||
|
|
111
|
+
item.showSurplusLeft) &&
|
|
112
|
+
leftSurplusWidth > 0 ? (_jsxs(_Fragment, { children: [_jsx(Rect, { id: 'l-spls' + index, x: leftXAfterMid - leftWidth - leftBarBorderWidth / 2, y: y, width: leftSurplusWidth, height: stepHeight - verticalMarginBetweenBars * 2, stroke: (_12 = item.leftSurplusBorderColor) !== null && _12 !== void 0 ? _12 : leftSurplusBorderColor, strokeWidth: (_13 = item.leftSurplusBorderWidth) !== null && _13 !== void 0 ? _13 : leftSurplusBorderWidth }), _jsx(Use, { fill: (_14 = item.leftSurplusColor) !== null && _14 !== void 0 ? _14 : leftSurplusColor, clipPath: '#cp-left' + index, href: '#l-spls' + index }), leftSurplusWidth >= leftRadius ? (_jsxs(_Fragment, { children: [_jsx(Rect, { id: 'hide-in-left' + index, x: leftXAfterMid -
|
|
113
|
+
leftWidth -
|
|
114
|
+
leftBarBorderWidth +
|
|
115
|
+
leftSurplusWidth -
|
|
116
|
+
leftRadius, y: y, width: leftRadius, height: stepHeight - verticalMarginBetweenBars * 2 }), _jsx(Use, { fill: (_15 = item.leftSurplusColor) !== null && _15 !== void 0 ? _15 : leftSurplusColor, clipPath: "url(#cp-left".concat(index, ")"), href: '#hide-in-left' + index })] })) : null] })) : null, (showSurplus ||
|
|
117
|
+
showSurplusRight ||
|
|
118
|
+
item.showSurplus ||
|
|
119
|
+
item.showSurplusRight) &&
|
|
120
|
+
rightSurplusWidth > 0 ? (_jsxs(_Fragment, { children: [_jsx(Rect, { id: 'r-spls' + index, x: rightXAfterMid +
|
|
121
|
+
rightBarBorderWidth / 2 +
|
|
122
|
+
rightWidth -
|
|
123
|
+
rightSurplusWidth, y: y, width: rightSurplusWidth, height: stepHeight - verticalMarginBetweenBars * 2, stroke: (_16 = item.rightSurplusBorderColor) !== null && _16 !== void 0 ? _16 : rightSurplusBorderColor, strokeWidth: (_17 = item.rightSurplusBorderWidth) !== null && _17 !== void 0 ? _17 : rightSurplusBorderWidth }), _jsx(Use, { fill: (_18 = item.rightSurplusColor) !== null && _18 !== void 0 ? _18 : rightSurplusColor, clipPath: '#cp-right' + index, href: '#r-spls' + index }), rightSurplusWidth >= rightRadius ? (_jsxs(_Fragment, { children: [_jsx(Rect, { id: 'hide-in-right' + index, x: rightXAfterMid +
|
|
124
|
+
rightBarBorderWidth / 2 +
|
|
125
|
+
rightWidth -
|
|
126
|
+
rightSurplusWidth, y: y, width: rightRadius, height: stepHeight - verticalMarginBetweenBars * 2 }), _jsx(Use, { fill: (_19 = item.rightSurplusColor) !== null && _19 !== void 0 ? _19 : rightSurplusColor, clipPath: "url(#cp-right".concat(index, ")"), href: '#hide-in-right' + index })] })) : null] })) : null] }, 'bars' + index));
|
|
127
|
+
}), showMidAxis ? (_jsxs(_Fragment, { children: [_jsx(Line, __assign({}, midAxisLineCommonProps, { stroke: (_b = (_a = props.midAxisLeftColor) !== null && _a !== void 0 ? _a : props.midAxisColor) !== null && _b !== void 0 ? _b : yAxisColor, x1: leftXAfterMid, x2: leftXAfterMid })), _jsx(Line, __assign({}, midAxisLineCommonProps, { stroke: (_d = (_c = props.midAxisRightColor) !== null && _c !== void 0 ? _c : props.midAxisColor) !== null && _d !== void 0 ? _d : yAxisColor, x1: rightXAfterMid, x2: rightXAfterMid })), data.map(function (item, index) {
|
|
128
|
+
var _a, _b, _c, _d, _e, _f;
|
|
129
|
+
var y = stepHeight * (index + 0.5);
|
|
130
|
+
return (_jsx(SvgText, { x: mid, y: y + midAxisLabelFontSize / 2, stroke: (_a = item.midAxisLabelColor) !== null && _a !== void 0 ? _a : midAxisLabelColor, fontSize: (_b = item.midAxisLabelFontSize) !== null && _b !== void 0 ? _b : midAxisLabelFontSize, fontStyle: (_c = item.midAxisLabelFontStyle) !== null && _c !== void 0 ? _c : midAxisLabelFontStyle, fontWeight: (_d = item.midAxisLabelFontWeight) !== null && _d !== void 0 ? _d : midAxisLabelFontWeight, fontFamily: (_e = item.midAxisLabelFontFamily) !== null && _e !== void 0 ? _e : midAxisLabelFontFamily, textAnchor: "middle", children: (_f = item.midAxisLabel) !== null && _f !== void 0 ? _f : '' }, 'ml' + index));
|
|
131
|
+
})] })) : null] }) }));
|
|
132
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useEffect } from 'react';
|
|
3
|
+
import { Animated, View } from 'react-native';
|
|
4
|
+
import Svg, { Line, Polygon, Circle, Text as SvgText, Defs, RadialGradient, Stop, TSpan, } from 'react-native-svg';
|
|
5
|
+
import { useRadarChart } from '@harveylx/gifted-charts-core';
|
|
6
|
+
export var RadarChart = function (props) {
|
|
7
|
+
var _a = useRadarChart(props), data = _a.data, dataSet = _a.dataSet, center = _a.center, radius = _a.radius, chartSize = _a.chartSize, polarToCartesian = _a.polarToCartesian, labels = _a.labels, labelConfigArray = _a.labelConfigArray, labelsPositionOffset = _a.labelsPositionOffset, dataLabelsConfigArray = _a.dataLabelsConfigArray, maxValue = _a.maxValue, dataLabels = _a.dataLabels, dataLabelsArray = _a.dataLabelsArray, gridSections = _a.gridSections, gridFill = _a.gridFill, fontSize = _a.fontSize, stroke = _a.stroke, textAnchor = _a.textAnchor, alignmentBaseline = _a.alignmentBaseline, fontWeight = _a.fontWeight, fontFamily = _a.fontFamily, dataLabelsPositionOffset = _a.dataLabelsPositionOffset, polygonStroke = _a.polygonStroke, polygonStrokeWidth = _a.polygonStrokeWidth, polygonStrokeDashArray = _a.polygonStrokeDashArray, polygonFill = _a.polygonFill, polygonGradientColor = _a.polygonGradientColor, polygonShowGradient = _a.polygonShowGradient, polygonOpacity = _a.polygonOpacity, polygonGradientOpacity = _a.polygonGradientOpacity, polygonIsAnimated = _a.polygonIsAnimated, polygonAnimationDuration = _a.polygonAnimationDuration, asterLinesStroke = _a.asterLinesStroke, asterLinesStrokeWidth = _a.asterLinesStrokeWidth, asterLinesStrokeDashArray = _a.asterLinesStrokeDashArray, polygonPoints = _a.polygonPoints, initialPolygonPoints = _a.initialPolygonPoints, polygonPointsArray = _a.polygonPointsArray, initialPolygonPointsArray = _a.initialPolygonPointsArray, polygonConfigArray = _a.polygonConfigArray, angleStep = _a.angleStep, circular = _a.circular, hideGrid = _a.hideGrid, hideLabels = _a.hideLabels, hideAsterLines = _a.hideAsterLines, getGridLevelProps = _a.getGridLevelProps, animateTogether = _a.animateTogether, startAngle = _a.startAngle;
|
|
8
|
+
var initialPolygonPointsAr = initialPolygonPoints.split(' ');
|
|
9
|
+
var finalPolygonPointsAr = polygonPoints.split(' ');
|
|
10
|
+
var AnimatedPolygon = Animated.createAnimatedComponent(Polygon);
|
|
11
|
+
var animatedValues = data.map(function (_) { return new Animated.Value(0); });
|
|
12
|
+
var animatedPaths = data.map(function (_, index) {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = animatedValues[index]) === null || _a === void 0 ? void 0 : _a.interpolate({
|
|
15
|
+
inputRange: [0, 1],
|
|
16
|
+
outputRange: [initialPolygonPointsAr[index], finalPolygonPointsAr[index]],
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
if (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length)
|
|
21
|
+
return;
|
|
22
|
+
animatedValues.forEach(function (animatedValue) {
|
|
23
|
+
return Animated.timing(animatedValue, {
|
|
24
|
+
toValue: 1,
|
|
25
|
+
duration: polygonAnimationDuration,
|
|
26
|
+
useNativeDriver: false,
|
|
27
|
+
}).start();
|
|
28
|
+
});
|
|
29
|
+
}, [data]);
|
|
30
|
+
/******************************************************************************************/
|
|
31
|
+
/********************* Animation handling for dataSet *********************/
|
|
32
|
+
var animatedValuesForSet = [];
|
|
33
|
+
var animatedPathsForSet = [];
|
|
34
|
+
if (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) {
|
|
35
|
+
polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.forEach(function (_, index) {
|
|
36
|
+
var set = dataSet[index];
|
|
37
|
+
var initialPolygonPointsAr = initialPolygonPointsArray[index].split(' ');
|
|
38
|
+
var finalPolygonPointsAr = polygonPointsArray[index].split(' ');
|
|
39
|
+
var animatedValues = set.map(function (_) { return new Animated.Value(0); });
|
|
40
|
+
animatedValuesForSet.push(animatedValues);
|
|
41
|
+
var animatedPaths = set.map(function (i, ind) {
|
|
42
|
+
return animatedValues[ind].interpolate({
|
|
43
|
+
inputRange: [0, 1],
|
|
44
|
+
outputRange: [initialPolygonPointsAr[ind], finalPolygonPointsAr[ind]],
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
animatedPathsForSet.push(animatedPaths);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
useEffect(function () {
|
|
51
|
+
if (!(dataSet === null || dataSet === void 0 ? void 0 : dataSet.length))
|
|
52
|
+
return;
|
|
53
|
+
animatedValuesForSet === null || animatedValuesForSet === void 0 ? void 0 : animatedValuesForSet.forEach(function (animatedValues, index) {
|
|
54
|
+
setTimeout(function () {
|
|
55
|
+
animatedValues === null || animatedValues === void 0 ? void 0 : animatedValues.forEach(function (animatedValue) {
|
|
56
|
+
return Animated.timing(animatedValue, {
|
|
57
|
+
toValue: 1,
|
|
58
|
+
duration: polygonAnimationDuration,
|
|
59
|
+
useNativeDriver: false,
|
|
60
|
+
}).start();
|
|
61
|
+
});
|
|
62
|
+
}, animateTogether ? 0 : index * polygonAnimationDuration);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
/******************************************************************************************/
|
|
66
|
+
/******************************************************************************************/
|
|
67
|
+
return (_jsx(View, { style: { justifyContent: 'center', alignItems: 'center' }, children: _jsxs(Svg, { height: chartSize, width: chartSize, children: [(polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.length) ? (polygonConfigArray.map(function (polygonConfigItem, index) {
|
|
68
|
+
var fill = polygonConfigItem.fill, gradientColor = polygonConfigItem.gradientColor, opacity = polygonConfigItem.opacity, gradientOpacity = polygonConfigItem.gradientOpacity;
|
|
69
|
+
return (_jsx(Defs, { children: _jsxs(RadialGradient, { id: "polygon-".concat(index), cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: gradientColor, stopOpacity: gradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: fill, stopOpacity: opacity })] }, "polygon-".concat(index)) }, "defs-".concat(index)));
|
|
70
|
+
})) : polygonShowGradient ? (_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'polygon', cx: center, cy: center, rx: radius, ry: radius, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: polygonGradientColor, stopOpacity: polygonGradientOpacity }), _jsx(Stop, { offset: "100%", stopColor: polygonFill, stopOpacity: polygonOpacity })] }, 'polygon') })) : null, hideGrid
|
|
71
|
+
? null
|
|
72
|
+
: gridSections.map(function (l, ind) {
|
|
73
|
+
var _a = getGridLevelProps(l, ind), level = _a.level, gridGradientColorLocal = _a.gridGradientColorLocal, gridFillColorLocal = _a.gridFillColorLocal, gridOpacityLocal = _a.gridOpacityLocal, gridGradientOpacityLocal = _a.gridGradientOpacityLocal, gridStrokeLocal = _a.gridStrokeLocal, gridStrokeWidthLocal = _a.gridStrokeWidthLocal, gridShowGradientLocal = _a.gridShowGradientLocal, gridStrokeDashArrayLocal = _a.gridStrokeDashArrayLocal, levelPolygonPoints = _a.levelPolygonPoints, r = _a.r;
|
|
74
|
+
return (_jsxs(Fragment, { children: [_jsx(Defs, { children: _jsxs(RadialGradient, { id: 'grad' + level, cx: center, cy: center, rx: r, ry: r, fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "".concat(100 - 100 / level, "%"), stopColor: gridGradientColorLocal, stopOpacity: gridGradientOpacityLocal }), _jsx(Stop, { offset: "100%", stopColor: gridFillColorLocal, stopOpacity: gridOpacityLocal })] }, level + '') }), circular ? (_jsx(Circle, { cx: center, cy: center, r: r, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal ? "url(#grad".concat(level, ")") : gridFill }, "grid-".concat(level))) : (_jsx(Polygon, { points: levelPolygonPoints, stroke: gridStrokeLocal, strokeWidth: gridStrokeWidthLocal, strokeDasharray: gridStrokeDashArrayLocal, fill: gridShowGradientLocal ? "url(#grad".concat(level, ")") : gridFill }, "grid-".concat(level)))] }, "fragment-".concat(level)));
|
|
75
|
+
}), dataSet ? (polygonConfigArray === null || polygonConfigArray === void 0 ? void 0 : polygonConfigArray.map(function (item, index) {
|
|
76
|
+
var polygonPoints = polygonPointsArray[index];
|
|
77
|
+
var animatedPolygonPoints = animatedPathsForSet[index];
|
|
78
|
+
var stroke = item.stroke, strokeWidth = item.strokeWidth, strokeDashArray = item.strokeDashArray, fill = item.fill, showGradient = item.showGradient, opacity = item.opacity, _a = item.isAnimated, isAnimated = _a === void 0 ? polygonIsAnimated : _a;
|
|
79
|
+
return (_jsx(AnimatedPolygon, { points: isAnimated ? animatedPolygonPoints : polygonPoints, fill: showGradient ? 'url(#polygon)' : fill, stroke: stroke, strokeWidth: strokeWidth, strokeDasharray: strokeDashArray, opacity: opacity }, "polygon-".concat(index)));
|
|
80
|
+
})) : (_jsx(AnimatedPolygon, { points: polygonIsAnimated ? animatedPaths : polygonPoints, fill: polygonShowGradient ? 'url(#polygon)' : polygonFill, stroke: polygonStroke, strokeWidth: polygonStrokeWidth, strokeDasharray: polygonStrokeDashArray, opacity: polygonOpacity })), (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) && (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.length) ? (dataLabelsArray === null || dataLabelsArray === void 0 ? void 0 : dataLabelsArray.map(function (labels, index) {
|
|
81
|
+
var dataItem = dataSet[index];
|
|
82
|
+
return labels === null || labels === void 0 ? void 0 : labels.map(function (label, labelIndex) {
|
|
83
|
+
var _a, _b, _c;
|
|
84
|
+
var _d = polarToCartesian(labelIndex * angleStep, dataItem[labelIndex] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
|
|
85
|
+
var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[labelIndex]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
|
|
86
|
+
return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index, "-").concat(labelIndex)));
|
|
87
|
+
});
|
|
88
|
+
})) : (dataLabels === null || dataLabels === void 0 ? void 0 : dataLabels.length) ? (_jsx(SvgText, { children: dataLabels.map(function (label, index) {
|
|
89
|
+
var _a, _b, _c;
|
|
90
|
+
var _d = polarToCartesian(index * angleStep, data[index] + dataLabelsPositionOffset), x = _d.x, y = _d.y;
|
|
91
|
+
var _e = (_a = dataLabelsConfigArray === null || dataLabelsConfigArray === void 0 ? void 0 : dataLabelsConfigArray[index]) !== null && _a !== void 0 ? _a : {}, dataLabelsFontSize = _e.fontSize, dataLabelsColor = _e.stroke, dataLabelsTextAnchor = _e.textAnchor, dataLabelsAlignmentBaseline = _e.alignmentBaseline, dataLabelsFontWeight = _e.fontWeight, dataLabelsFontFamily = _e.fontFamily;
|
|
92
|
+
return (_jsx(SvgText, { x: x, y: y, fontSize: dataLabelsFontSize, fill: dataLabelsColor, fontWeight: dataLabelsFontWeight, fontFamily: dataLabelsFontFamily, textAnchor: (_b = dataLabelsTextAnchor) !== null && _b !== void 0 ? _b : 'middle', alignmentBaseline: (_c = dataLabelsAlignmentBaseline) !== null && _c !== void 0 ? _c : 'middle', children: label }, "data-label-".concat(index)));
|
|
93
|
+
}) })) : null, hideAsterLines
|
|
94
|
+
? null
|
|
95
|
+
: labels.map(function (_, index) {
|
|
96
|
+
var angle = index * angleStep + startAngle;
|
|
97
|
+
var _a = polarToCartesian(angle, maxValue), x = _a.x, y = _a.y;
|
|
98
|
+
return (_jsx(Line, { x1: center, y1: center, x2: x, y2: y, stroke: asterLinesStroke, strokeWidth: asterLinesStrokeWidth, strokeDasharray: asterLinesStrokeDashArray }, "axis-".concat(index)));
|
|
99
|
+
}), hideLabels
|
|
100
|
+
? null
|
|
101
|
+
: labels.map(function (category, index) {
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
103
|
+
var angle = index * angleStep + startAngle;
|
|
104
|
+
var _q = polarToCartesian(angle, maxValue + labelsPositionOffset), x = _q.x, y = _q.y; // Offset for label position
|
|
105
|
+
var fontSizeLocal = (_b = (_a = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _a === void 0 ? void 0 : _a.fontSize) !== null && _b !== void 0 ? _b : fontSize;
|
|
106
|
+
var fontWeightLocal = (_d = (_c = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _c === void 0 ? void 0 : _c.fontWeight) !== null && _d !== void 0 ? _d : fontWeight;
|
|
107
|
+
var fontFamilyLocal = (_f = (_e = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _e === void 0 ? void 0 : _e.fontFamily) !== null && _f !== void 0 ? _f : fontFamily;
|
|
108
|
+
var colorLocal = (_h = (_g = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _g === void 0 ? void 0 : _g.stroke) !== null && _h !== void 0 ? _h : stroke;
|
|
109
|
+
var textAnchorLocal = (_k = (_j = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _j === void 0 ? void 0 : _j.textAnchor) !== null && _k !== void 0 ? _k : textAnchor;
|
|
110
|
+
var alignmentBaselineLocal = (_m = (_l = labelConfigArray === null || labelConfigArray === void 0 ? void 0 : labelConfigArray[index]) === null || _l === void 0 ? void 0 : _l.alignmentBaseline) !== null && _m !== void 0 ? _m : alignmentBaseline;
|
|
111
|
+
return (_jsx(SvgText, { x: x, y: y, fontSize: fontSizeLocal, fontWeight: fontWeightLocal, fontFamily: fontFamilyLocal, fill: colorLocal, textAnchor: (_o = textAnchorLocal) !== null && _o !== void 0 ? _o : 'middle', alignmentBaseline: (_p = alignmentBaselineLocal) !== null && _p !== void 0 ? _p : 'middle', children: category.split('\n').map(function (line, idx) { return (_jsx(TSpan, { x: x, dy: idx === 0 ? 0 : fontSizeLocal, children: line }, idx)); }) }, "label-".concat(index)));
|
|
112
|
+
})] }) }));
|
|
113
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BarChart } from './BarChart';
|
|
2
|
+
export { PieChart } from './PieChart';
|
|
3
|
+
export { PieChartPro } from './PieChartPro';
|
|
4
|
+
export { LineChart } from './LineChart';
|
|
5
|
+
export { LineChartBicolor } from './LineChart/LineChartBicolor';
|
|
6
|
+
export { PopulationPyramid } from './PopulationPyramid';
|
|
7
|
+
export { RadarChart } from './RadarChart';
|
|
8
|
+
export { type barDataItem, type barDataItemNullSafe, type stackDataItem, type BarChartPropsType, type StackedBarChartPropsType, type pieDataItem, type PieChartPropsType, type lineDataItem, type lineDataItemNullSafe, type bicolorLineDataItem, type LineChartPropsType, type LineChartBicolorPropsType, type popnPyramidDataItem, type PopulationPyramidPropsType, chartTypes, ruleTypes, CurveType, yAxisSides, EdgePosition, type DataSet, type DataSetNullSafe, type Linecap, type RulesConfig, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type Pointer, type HighlightedRange, type LineSegment, type LineProperties, Framework, type XAxisConfig, type DataPointProps, type IntersectionAreaConfig, type LabelLineConfig, type TooltipProps, type RadarChartProps, type PolygonConfig, type GridConfig, type GridSectionConfig, type AsterLinesConfig, } from '@harveylx/gifted-charts-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BarChart } from './BarChart';
|
|
2
|
+
export { PieChart } from './PieChart';
|
|
3
|
+
export { PieChartPro } from './PieChartPro';
|
|
4
|
+
export { LineChart } from './LineChart';
|
|
5
|
+
export { LineChartBicolor } from './LineChart/LineChartBicolor';
|
|
6
|
+
export { PopulationPyramid } from './PopulationPyramid';
|
|
7
|
+
export { RadarChart } from './RadarChart';
|
|
8
|
+
export { chartTypes, ruleTypes, CurveType, yAxisSides, EdgePosition, Framework, } from '@harveylx/gifted-charts-core';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { Dimensions, Platform } from 'react-native';
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
5
|
+
var versionString = require('react-native/package.json').version;
|
|
6
|
+
var versionAr = (_b = (_a = versionString === null || versionString === void 0 ? void 0 : versionString.split) === null || _a === void 0 ? void 0 : _a.call(versionString, '.')) !== null && _b !== void 0 ? _b : '';
|
|
7
|
+
var msb = Number(versionAr[0]);
|
|
8
|
+
var mid = Number(versionAr[1]);
|
|
9
|
+
var lsb = Number(versionAr[2]);
|
|
10
|
+
export var rnVersion = (!isNaN(msb) ? msb : 0) * 1000000 +
|
|
11
|
+
(!isNaN(mid) ? mid : 0) * 10000 +
|
|
12
|
+
(!isNaN(lsb) ? lsb : 0);
|
|
13
|
+
export var screenWidth = Dimensions.get('window').width;
|
|
14
|
+
export function usePrevious(value) {
|
|
15
|
+
var ref = useRef('');
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
ref.current = value; //assign the value of ref to the argument
|
|
18
|
+
}, [value]); //this code will run when the value of 'value' changes
|
|
19
|
+
return ref.current; //in the end, return the current ref value.
|
|
20
|
+
}
|
|
21
|
+
export var isWebApp = Platform.OS === 'web';
|
|
22
|
+
export var isIos = Platform.OS === 'ios';
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@harveylx/react-native-gifted-charts",
|
|
3
|
+
"version": "1.4.70",
|
|
4
|
+
"description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar, Population Pyramid and Radar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"android": "react-native run-android",
|
|
11
|
+
"build": "rm -rf ./dist && tsc -p . && ./build.sh",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"ios": "react-native run-ios",
|
|
14
|
+
"start": "react-native start",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"lint": "eslint ."
|
|
17
|
+
},
|
|
18
|
+
"repository": "https://github.com/harveylx/react-native-gifted-charts",
|
|
19
|
+
"author": "Harvey Singh <dev@harveysingh.xyz>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/harveylx/react-native-gifted-charts/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/harveylx/react-native-gifted-charts#readme",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@react-native/babel-preset": "^0.76.9",
|
|
30
|
+
"@harveylx/gifted-charts-core": "0.1.72"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/cli": "^7.24.8",
|
|
34
|
+
"@babel/core": "^7.25.2",
|
|
35
|
+
"@babel/runtime": "^7.25.0",
|
|
36
|
+
"@react-native-community/cli": "^15.0.1",
|
|
37
|
+
"@react-native-community/cli-platform-android": "15.0.1",
|
|
38
|
+
"@react-native-community/cli-platform-ios": "15.0.1",
|
|
39
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
40
|
+
"@react-native/metro-config": "^0.76.9",
|
|
41
|
+
"@types/jest": "^29.5.12",
|
|
42
|
+
"@types/node": "^22.0.0",
|
|
43
|
+
"@types/react": "^18.3.3",
|
|
44
|
+
"@types/react-dom": "^18.3.0",
|
|
45
|
+
"babel-jest": "^29.7.0",
|
|
46
|
+
"eslint": "^9.8.0",
|
|
47
|
+
"jest": "^29.7.0",
|
|
48
|
+
"react": "^18.3.1",
|
|
49
|
+
"react-native": "^0.76.9",
|
|
50
|
+
"react-native-linear-gradient": "^2.8.3",
|
|
51
|
+
"react-native-svg": "^15.5.0",
|
|
52
|
+
"react-test-renderer": "18.3.1",
|
|
53
|
+
"ts-jest": "^29.2.3",
|
|
54
|
+
"typescript": "^5.5.4"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"expo-linear-gradient": "*",
|
|
58
|
+
"react": "*",
|
|
59
|
+
"react-native": "*",
|
|
60
|
+
"react-native-linear-gradient": "*",
|
|
61
|
+
"react-native-svg": "*"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"react-native-linear-gradient": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"expo-linear-gradient": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"chart",
|
|
73
|
+
"charts",
|
|
74
|
+
"graph",
|
|
75
|
+
"data visualization",
|
|
76
|
+
"bar",
|
|
77
|
+
"pie",
|
|
78
|
+
"donut",
|
|
79
|
+
"area",
|
|
80
|
+
"line",
|
|
81
|
+
"radar",
|
|
82
|
+
"star",
|
|
83
|
+
"population",
|
|
84
|
+
"pyramid",
|
|
85
|
+
"react",
|
|
86
|
+
"react native",
|
|
87
|
+
"react-native"
|
|
88
|
+
]
|
|
89
|
+
}
|