react-native-gifted-charts 1.4.20 → 1.4.22
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/README.md +4 -3
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +113 -0
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +264 -0
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +172 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +233 -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 +129 -0
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +13 -0
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +128 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -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 +94 -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 +15 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +40 -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 +16 -0
- package/dist/Components/common/StripAndLabel.d.ts +1 -0
- package/dist/Components/common/StripAndLabel.js +43 -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 +294 -0
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1089 -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 +99 -0
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +182 -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 +130 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +12 -0
- package/package.json +21 -20
- package/src/BarChart/Animated2DWithGradient.tsx +0 -197
- package/src/BarChart/RenderBars.tsx +0 -527
- package/src/BarChart/RenderStackBars.tsx +0 -359
- package/src/BarChart/index.tsx +0 -391
- package/src/BarChart/styles.tsx +0 -47
- package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
- package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
- package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
- package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
- package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
- package/src/Components/BarSpecificComponents/cap.tsx +0 -34
- package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
- package/src/Components/common/LinearGradient.tsx +0 -27
- package/src/Components/common/Pointer.tsx +0 -37
- package/src/Components/common/StripAndLabel.tsx +0 -98
- package/src/Components/lineSvg.tsx +0 -42
- package/src/LineChart/LineChartBicolor.tsx +0 -740
- package/src/LineChart/index.tsx +0 -2231
- package/src/LineChart/styles.tsx +0 -47
- package/src/PieChart/index.tsx +0 -168
- package/src/PieChart/main.tsx +0 -363
- package/src/PieChartPro/index.tsx +0 -267
- package/src/PopulationPyramid/index.tsx +0 -603
- package/src/index.tsx +0 -26
- package/src/todos.md +0 -24
- package/src/utils/index.ts +0 -16
|
@@ -0,0 +1,130 @@
|
|
|
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 '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;
|
|
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 = leftXAfterMid + (leftXAfterMid * index) / xAxisNoOfSections;
|
|
52
|
+
var unformattedXLabel = getXLabel(index);
|
|
53
|
+
var xLabel = formatXAxisLabels
|
|
54
|
+
? formatXAxisLabels(unformattedXLabel)
|
|
55
|
+
: unformattedXLabel;
|
|
56
|
+
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));
|
|
57
|
+
}), data.map(function (item, index) {
|
|
58
|
+
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;
|
|
59
|
+
var leftWidth = item.left * barWidthFactor;
|
|
60
|
+
var rightWidth = item.right * barWidthFactor;
|
|
61
|
+
var y = stepHeight * index + verticalMarginBetweenBars;
|
|
62
|
+
var leftSurplusWidth = leftWidth - rightWidth;
|
|
63
|
+
var rightSurplusWidth = rightWidth - leftWidth;
|
|
64
|
+
var leftRadius = (_b = (_a = item.leftBarBorderRadius) !== null && _a !== void 0 ? _a : item.barBorderRadius) !== null && _b !== void 0 ? _b : leftBarBorderRadius;
|
|
65
|
+
var rightRadius = (_d = (_c = item.rightBarBorderRadius) !== null && _c !== void 0 ? _c : item.barBorderRadius) !== null && _d !== void 0 ? _d : rightBarBorderRadius;
|
|
66
|
+
var leftBorderWidth = (_f = (_e = item.leftBarBorderWidth) !== null && _e !== void 0 ? _e : item.barBorderWidth) !== null && _f !== void 0 ? _f : leftBarBorderWidth;
|
|
67
|
+
var rightBorderWidth = (_h = (_g = item.rightBarBorderWidth) !== null && _g !== void 0 ? _g : item.barBorderWidth) !== null && _h !== void 0 ? _h : rightBarBorderWidth;
|
|
68
|
+
var unFormattedLeftBarLabel = (_j = item.leftBarLabel) !== null && _j !== void 0 ? _j : (showValuesAsBarLabels ? item.left.toString() : '');
|
|
69
|
+
var leftBarLabel = formatBarLabels
|
|
70
|
+
? formatBarLabels(unFormattedLeftBarLabel)
|
|
71
|
+
: unFormattedLeftBarLabel;
|
|
72
|
+
var unFormattedRightBarLabel = (_k = item.rightBarLabel) !== null && _k !== void 0 ? _k : (showValuesAsBarLabels ? item.right.toString() : '');
|
|
73
|
+
var rightBarLabel = formatBarLabels
|
|
74
|
+
? formatBarLabels(unFormattedRightBarLabel)
|
|
75
|
+
: unFormattedRightBarLabel;
|
|
76
|
+
var leftLabelFontSize = (_l = item.leftBarLabelFontSize) !== null && _l !== void 0 ? _l : leftBarLabelFontSize;
|
|
77
|
+
var leftLabelX = leftXAfterMid -
|
|
78
|
+
leftWidth -
|
|
79
|
+
leftBarBorderWidth / 2 -
|
|
80
|
+
yAxisLabelWidth / 2 -
|
|
81
|
+
leftBarLabelWidth / 2 +
|
|
82
|
+
28 -
|
|
83
|
+
(leftBarLabel.length * leftLabelFontSize) / 2 +
|
|
84
|
+
((_o = (_m = item.leftBarLabelShift) !== null && _m !== void 0 ? _m : props.leftBarLabelShift) !== null && _o !== void 0 ? _o : 0);
|
|
85
|
+
var rightLabelX = rightXAfterMid +
|
|
86
|
+
rightBarBorderWidth / 2 +
|
|
87
|
+
rightWidth +
|
|
88
|
+
3 +
|
|
89
|
+
((_q = (_p = item.rightBarLabelShift) !== null && _p !== void 0 ? _p : props.rightBarLabelShift) !== null && _q !== void 0 ? _q : 0);
|
|
90
|
+
var leftBarCommonProps = {
|
|
91
|
+
x: leftXAfterMid - leftWidth - leftBarBorderWidth / 2,
|
|
92
|
+
y: y,
|
|
93
|
+
width: leftWidth,
|
|
94
|
+
height: stepHeight - verticalMarginBetweenBars * 2,
|
|
95
|
+
rx: leftRadius,
|
|
96
|
+
ry: leftRadius,
|
|
97
|
+
};
|
|
98
|
+
var rightBarCommonProps = {
|
|
99
|
+
x: rightXAfterMid + rightBarBorderWidth / 2,
|
|
100
|
+
y: y,
|
|
101
|
+
width: rightWidth,
|
|
102
|
+
height: stepHeight - verticalMarginBetweenBars * 2,
|
|
103
|
+
rx: rightRadius,
|
|
104
|
+
ry: rightRadius,
|
|
105
|
+
};
|
|
106
|
+
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 })), _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 })), _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 ||
|
|
107
|
+
showSurplusLeft ||
|
|
108
|
+
item.showSurplus ||
|
|
109
|
+
item.showSurplusLeft) &&
|
|
110
|
+
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 -
|
|
111
|
+
leftWidth -
|
|
112
|
+
leftBarBorderWidth +
|
|
113
|
+
leftSurplusWidth -
|
|
114
|
+
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 ||
|
|
115
|
+
showSurplusRight ||
|
|
116
|
+
item.showSurplus ||
|
|
117
|
+
item.showSurplusRight) &&
|
|
118
|
+
rightSurplusWidth > 0 ? (_jsxs(_Fragment, { children: [_jsx(Rect, { id: 'r-spls' + index, x: rightXAfterMid +
|
|
119
|
+
rightBarBorderWidth / 2 +
|
|
120
|
+
rightWidth -
|
|
121
|
+
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 +
|
|
122
|
+
rightBarBorderWidth / 2 +
|
|
123
|
+
rightWidth -
|
|
124
|
+
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));
|
|
125
|
+
}), 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) {
|
|
126
|
+
var _a, _b, _c, _d, _e, _f;
|
|
127
|
+
var y = stepHeight * (index + 0.5);
|
|
128
|
+
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));
|
|
129
|
+
})] })) : null] }) }));
|
|
130
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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 { type barDataItem, type stackDataItem, type BarChartPropsType, type StackedBarChartPropsType, type pieDataItem, type PieChartPropsType, type lineDataItem, type bicolorLineDataItem, type LineChartPropsType, type LineChartBicolorPropsType, type popnPyramidDataItem, type PopulationPyramidPropsType, chartTypes, ruleTypes, yAxisSides, EdgePosition, type DataSet, type Linecap } from 'gifted-charts-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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 { chartTypes, ruleTypes, yAxisSides, EdgePosition } from 'gifted-charts-core';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { Dimensions } from 'react-native';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
|
+
var versionString = require('react-native/package.json').version;
|
|
5
|
+
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 : '';
|
|
6
|
+
var msb = Number(versionAr[0]);
|
|
7
|
+
var mid = Number(versionAr[1]);
|
|
8
|
+
var lsb = Number(versionAr[2]);
|
|
9
|
+
export var rnVersion = (!isNaN(msb) ? msb : 0) * 1000000 +
|
|
10
|
+
(!isNaN(mid) ? mid : 0) * 10000 +
|
|
11
|
+
(!isNaN(lsb) ? lsb : 0);
|
|
12
|
+
export var screenWidth = Dimensions.get('window').width;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.22",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
|
-
"
|
|
7
|
+
"dist"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
10
|
"android": "react-native run-android",
|
|
11
|
-
"build": "tsc -p .",
|
|
11
|
+
"build": "tsc -p . && ./build.sh",
|
|
12
12
|
"ios": "react-native run-ios",
|
|
13
13
|
"start": "react-native start",
|
|
14
14
|
"test": "jest",
|
|
@@ -25,28 +25,29 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"gifted-charts-core": "^0.1.
|
|
28
|
+
"gifted-charts-core": "^0.1.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/
|
|
32
|
-
"@babel/
|
|
31
|
+
"@babel/cli": "^7.24.8",
|
|
32
|
+
"@babel/core": "^7.24.9",
|
|
33
|
+
"@babel/runtime": "^7.25.0",
|
|
33
34
|
"@react-native-community/eslint-config": "^3.2.0",
|
|
34
|
-
"@
|
|
35
|
-
"@types/
|
|
36
|
-
"@types/
|
|
37
|
-
"@types/react
|
|
38
|
-
"@types/react-
|
|
39
|
-
"babel-jest": "^29.
|
|
40
|
-
"eslint": "^8.
|
|
41
|
-
"jest": "^29.
|
|
42
|
-
"metro-react-native-babel-preset": "^0.
|
|
35
|
+
"@react-native/metro-config": "^0.74.85",
|
|
36
|
+
"@types/jest": "^29.5.12",
|
|
37
|
+
"@types/node": "^22.0.0",
|
|
38
|
+
"@types/react": "^18.3.3",
|
|
39
|
+
"@types/react-dom": "^18.3.0",
|
|
40
|
+
"babel-jest": "^29.7.0",
|
|
41
|
+
"eslint": "^9.8.0",
|
|
42
|
+
"jest": "^29.7.0",
|
|
43
|
+
"metro-react-native-babel-preset": "^0.77.0",
|
|
43
44
|
"react": "^18.2.0",
|
|
44
|
-
"react-native": "^0.
|
|
45
|
+
"react-native": "^0.74.3",
|
|
45
46
|
"react-native-linear-gradient": "^2.8.3",
|
|
46
|
-
"react-native-svg": "^
|
|
47
|
+
"react-native-svg": "^15.4.0",
|
|
47
48
|
"react-test-renderer": "18.2.0",
|
|
48
|
-
"ts-jest": "^29.
|
|
49
|
-
"typescript": "^5.
|
|
49
|
+
"ts-jest": "^29.2.3",
|
|
50
|
+
"typescript": "^5.5.4"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"react": "*",
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
2
|
-
import {View, LayoutAnimation, Platform, UIManager, Text} from 'react-native';
|
|
3
|
-
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
4
|
-
import Cap from '../Components/BarSpecificComponents/cap';
|
|
5
|
-
import LinearGradient from '../Components/common/LinearGradient';
|
|
6
|
-
import {Animated2DWithGradientPropsType} from 'gifted-charts-core';
|
|
7
|
-
|
|
8
|
-
if (Platform.OS === 'android') {
|
|
9
|
-
UIManager.setLayoutAnimationEnabledExperimental &&
|
|
10
|
-
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
|
|
14
|
-
const {
|
|
15
|
-
barBackgroundPattern,
|
|
16
|
-
patternId,
|
|
17
|
-
barWidth,
|
|
18
|
-
barStyle,
|
|
19
|
-
item,
|
|
20
|
-
index,
|
|
21
|
-
opacity,
|
|
22
|
-
animationDuration,
|
|
23
|
-
noGradient,
|
|
24
|
-
noAnimation,
|
|
25
|
-
barMarginBottom,
|
|
26
|
-
barInnerComponent,
|
|
27
|
-
intactTopLabel,
|
|
28
|
-
showValuesAsTopLabel,
|
|
29
|
-
topLabelContainerStyle,
|
|
30
|
-
topLabelTextStyle,
|
|
31
|
-
commonStyleForBar,
|
|
32
|
-
barStyleWithBackground,
|
|
33
|
-
yAxisOffset,
|
|
34
|
-
} = props;
|
|
35
|
-
const [height, setHeight] = useState(noAnimation ? props.height : 0.2);
|
|
36
|
-
const [initialRender, setInitialRender] = useState(
|
|
37
|
-
noAnimation ? false : true,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!noAnimation) {
|
|
42
|
-
if (initialRender) {
|
|
43
|
-
setTimeout(() => layoutAppear(), 20);
|
|
44
|
-
} else {
|
|
45
|
-
elevate();
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
setHeight(props.height);
|
|
49
|
-
}
|
|
50
|
-
}, [props.height]);
|
|
51
|
-
|
|
52
|
-
const elevate = () => {
|
|
53
|
-
LayoutAnimation.configureNext({
|
|
54
|
-
duration: animationDuration,
|
|
55
|
-
update: {type: 'linear', property: 'scaleXY'},
|
|
56
|
-
});
|
|
57
|
-
setHeight(props.height);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const layoutAppear = () => {
|
|
61
|
-
LayoutAnimation.configureNext({
|
|
62
|
-
duration: Platform.OS == 'ios' ? animationDuration : 20,
|
|
63
|
-
create: {type: 'linear', property: 'opacity'},
|
|
64
|
-
update: {type: 'linear', property: 'scaleXY'},
|
|
65
|
-
});
|
|
66
|
-
setInitialRender(false);
|
|
67
|
-
setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<>
|
|
72
|
-
{!initialRender && (
|
|
73
|
-
<View
|
|
74
|
-
style={{
|
|
75
|
-
position: 'absolute',
|
|
76
|
-
bottom: 0,
|
|
77
|
-
width: '100%',
|
|
78
|
-
overflow: 'hidden',
|
|
79
|
-
height:
|
|
80
|
-
(noAnimation
|
|
81
|
-
? Math.max(props.minHeight, Math.abs(height))
|
|
82
|
-
: height) - (barMarginBottom || 0),
|
|
83
|
-
}}>
|
|
84
|
-
<View
|
|
85
|
-
style={[
|
|
86
|
-
{
|
|
87
|
-
width: '100%',
|
|
88
|
-
height:
|
|
89
|
-
(noAnimation
|
|
90
|
-
? Math.max(props.minHeight, Math.abs(height))
|
|
91
|
-
: height) - (barMarginBottom || 0),
|
|
92
|
-
},
|
|
93
|
-
item.barStyle || barStyle,
|
|
94
|
-
]}>
|
|
95
|
-
{noGradient ? (
|
|
96
|
-
<View style={barStyleWithBackground}>
|
|
97
|
-
{props.cappedBars && item.value ? (
|
|
98
|
-
<Cap
|
|
99
|
-
capThicknessFromItem={item.capThickness}
|
|
100
|
-
capThicknessFromProps={props.capThickness}
|
|
101
|
-
capColorFromItem={item.capColor}
|
|
102
|
-
capColorFromProps={props.capColor}
|
|
103
|
-
capRadiusFromItem={item.capRadius}
|
|
104
|
-
capRadiusFromProps={props.capRadius}
|
|
105
|
-
/>
|
|
106
|
-
) : null}
|
|
107
|
-
</View>
|
|
108
|
-
) : (
|
|
109
|
-
<LinearGradient
|
|
110
|
-
style={commonStyleForBar}
|
|
111
|
-
start={{x: 0, y: 0}}
|
|
112
|
-
end={{x: 1, y: 1}}
|
|
113
|
-
colors={[
|
|
114
|
-
item.gradientColor || props.gradientColor || 'white',
|
|
115
|
-
item.frontColor || props.frontColor || 'black',
|
|
116
|
-
]}>
|
|
117
|
-
{props.cappedBars && (
|
|
118
|
-
<View
|
|
119
|
-
style={{
|
|
120
|
-
position: 'absolute',
|
|
121
|
-
width: '100%',
|
|
122
|
-
height:
|
|
123
|
-
item.capThickness === 0
|
|
124
|
-
? 0
|
|
125
|
-
: item.capThickness || props.capThickness || 6,
|
|
126
|
-
backgroundColor:
|
|
127
|
-
item.capColor || props.capColor || 'black',
|
|
128
|
-
borderTopLeftRadius:
|
|
129
|
-
item.capRadius === 0
|
|
130
|
-
? 0
|
|
131
|
-
: item.capRadius || props.capRadius || 0,
|
|
132
|
-
borderTopRightRadius:
|
|
133
|
-
item.capRadius === 0
|
|
134
|
-
? 0
|
|
135
|
-
: item.capRadius || props.capRadius || 0,
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
)}
|
|
139
|
-
</LinearGradient>
|
|
140
|
-
)}
|
|
141
|
-
{(item.barBackgroundPattern || barBackgroundPattern) && (
|
|
142
|
-
<Svg>
|
|
143
|
-
<Defs>
|
|
144
|
-
{item.barBackgroundPattern
|
|
145
|
-
? item.barBackgroundPattern()
|
|
146
|
-
: barBackgroundPattern?.()}
|
|
147
|
-
</Defs>
|
|
148
|
-
<Rect
|
|
149
|
-
stroke="transparent"
|
|
150
|
-
x="1"
|
|
151
|
-
y="1"
|
|
152
|
-
width={item.barWidth || props.barWidth || 30}
|
|
153
|
-
height={noAnimation ? Math.abs(height) : height}
|
|
154
|
-
fill={`url(#${item.patternId || patternId})`}
|
|
155
|
-
/>
|
|
156
|
-
</Svg>
|
|
157
|
-
)}
|
|
158
|
-
{barInnerComponent ? (
|
|
159
|
-
<View style={{height: '100%', width: '100%'}}>
|
|
160
|
-
{barInnerComponent(item, index)}
|
|
161
|
-
</View>
|
|
162
|
-
) : null}
|
|
163
|
-
</View>
|
|
164
|
-
</View>
|
|
165
|
-
)}
|
|
166
|
-
{item.topLabelComponent || showValuesAsTopLabel ? (
|
|
167
|
-
<View
|
|
168
|
-
style={[
|
|
169
|
-
{
|
|
170
|
-
position: 'absolute',
|
|
171
|
-
top: (item.barWidth || barWidth || 30) * -1,
|
|
172
|
-
height: item.barWidth || barWidth || 30,
|
|
173
|
-
width: item.barWidth || barWidth || 30,
|
|
174
|
-
justifyContent:
|
|
175
|
-
(props.horizontal && !intactTopLabel) || item.value < 0
|
|
176
|
-
? 'center'
|
|
177
|
-
: 'flex-end',
|
|
178
|
-
alignItems: 'center',
|
|
179
|
-
opacity: opacity,
|
|
180
|
-
},
|
|
181
|
-
item.value < 0 && {transform: [{rotate: '180deg'}]},
|
|
182
|
-
props.horizontal &&
|
|
183
|
-
!intactTopLabel && {transform: [{rotate: '270deg'}]},
|
|
184
|
-
topLabelContainerStyle ?? item.topLabelContainerStyle,
|
|
185
|
-
]}>
|
|
186
|
-
{showValuesAsTopLabel ? (
|
|
187
|
-
<Text style={topLabelTextStyle}>{item.value + yAxisOffset}</Text>
|
|
188
|
-
) : (
|
|
189
|
-
item.topLabelComponent?.()
|
|
190
|
-
)}
|
|
191
|
-
</View>
|
|
192
|
-
) : null}
|
|
193
|
-
</>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export default Animated2DWithGradient;
|