gifted-charts-core 0.0.16 → 0.0.17
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/index.js +133 -0
- package/package.json +6 -3
- package/src/BarChart/Animated2DWithGradient.js +106 -0
- package/src/BarChart/Animated2DWithGradient.js.map +1 -0
- package/src/BarChart/RenderStackBars.js +97 -0
- package/src/BarChart/RenderStackBars.js.map +1 -0
- package/src/BarChart/index.js +599 -0
- package/src/BarChart/index.js.map +1 -0
- package/src/BarChart/types.js +10 -0
- package/src/BarChart/types.js.map +1 -0
- package/src/LineChart/LineChartBiColor.js +512 -0
- package/src/LineChart/LineChartBiColor.js.map +1 -0
- package/src/LineChart/index.js +1484 -0
- package/src/LineChart/index.js.map +1 -0
- package/src/LineChart/types.js +10 -0
- package/src/LineChart/types.js.map +1 -0
- package/src/PieChart/index.js +118 -0
- package/src/PieChart/index.js.map +1 -0
- package/src/PieChart/main.js +178 -0
- package/src/PieChart/main.js.map +1 -0
- package/src/PieChart/types.js +10 -0
- package/src/PieChart/types.js.map +1 -0
- package/src/PopulationPyramid/index.js +204 -0
- package/src/PopulationPyramid/index.js.map +1 -0
- package/src/PopulationPyramid/types.js +10 -0
- package/src/PopulationPyramid/types.js.map +1 -0
- package/src/components/AnimatedThreeDBar/index.js +55 -0
- package/src/components/AnimatedThreeDBar/index.js.map +1 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +233 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js.map +1 -0
- package/src/components/BarAndLineChartsWrapper/index.js +269 -0
- package/src/components/BarAndLineChartsWrapper/index.js.map +1 -0
- package/src/components/common/StripAndLabel.js +69 -0
- package/src/components/common/StripAndLabel.js.map +1 -0
- package/src/utils/constants.js +315 -0
- package/src/utils/constants.js.map +1 -0
- package/src/utils/index.js +946 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/types.js +20 -0
- package/src/utils/types.js.map +1 -0
- package/index.ts +0 -136
package/index.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/***********************************************************************************************************************/
|
|
2
|
+
/***************************************** Bar Chart *****************************************/
|
|
3
|
+
/***********************************************************************************************************************/
|
|
4
|
+
System.register(["./src/BarChart", "./src/BarChart/Animated2DWithGradient", "./src/BarChart/RenderStackBars", "./src/LineChart", "./src/LineChart/LineChartBiColor", "./src/PieChart", "./src/PieChart/main", "./src/PopulationPyramid", "./src/components/AnimatedThreeDBar", "./src/components/BarAndLineChartsWrapper/getHorizSectionsVals", "./src/components/BarAndLineChartsWrapper", "./src/components/common/StripAndLabel", "./src/utils", "./src/utils/constants", "./src/utils/types"], function (exports_1, context_1) {
|
|
5
|
+
"use strict";
|
|
6
|
+
var __moduleName = context_1 && context_1.id;
|
|
7
|
+
return {
|
|
8
|
+
setters: [
|
|
9
|
+
function (BarChart_1_1) {
|
|
10
|
+
exports_1({
|
|
11
|
+
"useBarChart": BarChart_1_1["useBarChart"]
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
function (Animated2DWithGradient_1_1) {
|
|
15
|
+
exports_1({
|
|
16
|
+
"getPropsForAnimated2DWithGradient": Animated2DWithGradient_1_1["getPropsForAnimated2DWithGradient"]
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
function (RenderStackBars_1_1) {
|
|
20
|
+
exports_1({
|
|
21
|
+
"useRenderStackBars": RenderStackBars_1_1["useRenderStackBars"]
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
function (LineChart_1_1) {
|
|
25
|
+
exports_1({
|
|
26
|
+
"useLineChart": LineChart_1_1["useLineChart"]
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
function (LineChartBiColor_1_1) {
|
|
30
|
+
exports_1({
|
|
31
|
+
"useLineChartBiColor": LineChartBiColor_1_1["useLineChartBiColor"]
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
function (PieChart_1_1) {
|
|
35
|
+
exports_1({
|
|
36
|
+
"usePieChart": PieChart_1_1["usePieChart"]
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
function (main_1_1) {
|
|
40
|
+
exports_1({
|
|
41
|
+
"getPieChartMainProps": main_1_1["getPieChartMainProps"]
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
function (PopulationPyramid_1_1) {
|
|
45
|
+
exports_1({
|
|
46
|
+
"usePopulationPyramid": PopulationPyramid_1_1["usePopulationPyramid"]
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
function (AnimatedThreeDBar_1_1) {
|
|
50
|
+
exports_1({
|
|
51
|
+
"useAnimatedThreeDBar": AnimatedThreeDBar_1_1["useAnimatedThreeDBar"]
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
function (getHorizSectionsVals_1_1) {
|
|
55
|
+
exports_1({
|
|
56
|
+
"getHorizSectionVals": getHorizSectionsVals_1_1["getHorizSectionVals"]
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
function (BarAndLineChartsWrapper_1_1) {
|
|
60
|
+
exports_1({
|
|
61
|
+
"useBarAndLineChartsWrapper": BarAndLineChartsWrapper_1_1["useBarAndLineChartsWrapper"]
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
function (StripAndLabel_1_1) {
|
|
65
|
+
exports_1({
|
|
66
|
+
"getTopAndLeftForStripAndLabel": StripAndLabel_1_1["getTopAndLeftForStripAndLabel"]
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
function (utils_1_1) {
|
|
70
|
+
exports_1({
|
|
71
|
+
"rnVersion": utils_1_1["rnVersion"],
|
|
72
|
+
"getCumulativeWidth": utils_1_1["getCumulativeWidth"],
|
|
73
|
+
"getLighterColor": utils_1_1["getLighterColor"],
|
|
74
|
+
"svgQuadraticCurvePath": utils_1_1["svgQuadraticCurvePath"],
|
|
75
|
+
"svgPath": utils_1_1["svgPath"],
|
|
76
|
+
"bezierCommand": utils_1_1["bezierCommand"],
|
|
77
|
+
"getSegmentString": utils_1_1["getSegmentString"],
|
|
78
|
+
"getCurvePathWithSegments": utils_1_1["getCurvePathWithSegments"],
|
|
79
|
+
"getPreviousSegmentsLastPoint": utils_1_1["getPreviousSegmentsLastPoint"],
|
|
80
|
+
"getPathWithHighlight": utils_1_1["getPathWithHighlight"],
|
|
81
|
+
"getRegionPathObjects": utils_1_1["getRegionPathObjects"],
|
|
82
|
+
"getSegmentedPathObjects": utils_1_1["getSegmentedPathObjects"],
|
|
83
|
+
"getArrowPoints": utils_1_1["getArrowPoints"],
|
|
84
|
+
"getAxesAndRulesProps": utils_1_1["getAxesAndRulesProps"],
|
|
85
|
+
"getExtendedContainerHeightWithPadding": utils_1_1["getExtendedContainerHeightWithPadding"],
|
|
86
|
+
"getSecondaryDataWithOffsetIncluded": utils_1_1["getSecondaryDataWithOffsetIncluded"],
|
|
87
|
+
"getArrowProperty": utils_1_1["getArrowProperty"],
|
|
88
|
+
"getAllArrowProperties": utils_1_1["getAllArrowProperties"],
|
|
89
|
+
"maxAndMinUtil": utils_1_1["maxAndMinUtil"],
|
|
90
|
+
"computeMaxAndMinItems": utils_1_1["computeMaxAndMinItems"],
|
|
91
|
+
"getLabelTextUtil": utils_1_1["getLabelTextUtil"],
|
|
92
|
+
"getXForLineInBar": utils_1_1["getXForLineInBar"],
|
|
93
|
+
"getYForLineInBar": utils_1_1["getYForLineInBar"],
|
|
94
|
+
"clone": utils_1_1["clone"],
|
|
95
|
+
"getLineConfigForBarChart": utils_1_1["getLineConfigForBarChart"]
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
function (constants_1_1) {
|
|
99
|
+
exports_1({
|
|
100
|
+
"chartTypes": constants_1_1["chartTypes"],
|
|
101
|
+
"screenWidth": constants_1_1["screenWidth"],
|
|
102
|
+
"yAxisSides": constants_1_1["yAxisSides"],
|
|
103
|
+
"loc": constants_1_1["loc"],
|
|
104
|
+
"SEGMENT_START": constants_1_1["SEGMENT_START"],
|
|
105
|
+
"SEGMENT_END": constants_1_1["SEGMENT_END"],
|
|
106
|
+
"RANGE_ENTER": constants_1_1["RANGE_ENTER"],
|
|
107
|
+
"RANGE_EXIT": constants_1_1["RANGE_EXIT"],
|
|
108
|
+
"STOP": constants_1_1["STOP"],
|
|
109
|
+
"ruleTypes": constants_1_1["ruleTypes"],
|
|
110
|
+
"AxesAndRulesDefaults": constants_1_1["AxesAndRulesDefaults"],
|
|
111
|
+
"defaultArrowConfig": constants_1_1["defaultArrowConfig"],
|
|
112
|
+
"BarDefaults": constants_1_1["BarDefaults"],
|
|
113
|
+
"defaultLineConfig": constants_1_1["defaultLineConfig"],
|
|
114
|
+
"LineDefaults": constants_1_1["LineDefaults"],
|
|
115
|
+
"defaultPointerConfig": constants_1_1["defaultPointerConfig"],
|
|
116
|
+
"pieColors": constants_1_1["pieColors"],
|
|
117
|
+
"populationDefaults": constants_1_1["populationDefaults"]
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
function (types_1_1) {
|
|
121
|
+
exports_1({
|
|
122
|
+
"CurveType": types_1_1["CurveType"],
|
|
123
|
+
"EdgePosition": types_1_1["EdgePosition"]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
execute: function () {/***********************************************************************************************************************/
|
|
128
|
+
/***************************************** Bar Chart *****************************************/
|
|
129
|
+
/***********************************************************************************************************************/
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gifted-charts-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
|
|
5
|
-
"main": "index.
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
+
"build": "tsc -p .",
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
12
|
},
|
|
12
|
-
"dependencies": {
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"typescript": "^5.3.3"
|
|
15
|
+
},
|
|
13
16
|
"devDependencies": {
|
|
14
17
|
"@testing-library/jest-dom": "^5.17.0",
|
|
15
18
|
"@testing-library/react": "^13.4.0",
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
System.register(["../utils"], function (exports_1, context_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
4
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
5
|
+
if (ar || !(i in from)) {
|
|
6
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
7
|
+
ar[i] = from[i];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11
|
+
};
|
|
12
|
+
var utils_1, getPropsForAnimated2DWithGradient;
|
|
13
|
+
var __moduleName = context_1 && context_1.id;
|
|
14
|
+
return {
|
|
15
|
+
setters: [
|
|
16
|
+
function (utils_1_1) {
|
|
17
|
+
utils_1 = utils_1_1;
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
execute: function () {
|
|
21
|
+
exports_1("getPropsForAnimated2DWithGradient", getPropsForAnimated2DWithGradient = function (props) {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
23
|
+
var barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, barBorderRadius = props.barBorderRadius, item = props.item, barBorderTopLeftRadius = props.barBorderTopLeftRadius, barBorderTopRightRadius = props.barBorderTopRightRadius, barBorderBottomLeftRadius = props.barBorderBottomLeftRadius, barBorderBottomRightRadius = props.barBorderBottomRightRadius, barWidth = props.barWidth, barInnerComponent = props.barInnerComponent, barStyle = props.barStyle, index = props.index, opacity = props.opacity, barHeight = props.barHeight, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, roundedBottom = props.roundedBottom, cappedBars = props.cappedBars, capRadius = props.capRadius, roundedTop = props.roundedTop, barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, frontColor = props.frontColor, showGradient = props.showGradient, gradientColor = props.gradientColor, selectedIndex = props.selectedIndex, focusBarOnPress = props.focusBarOnPress, focusedBarConfig = props.focusedBarConfig, isThreeD = props.isThreeD;
|
|
24
|
+
var isFocused = focusBarOnPress && selectedIndex === index;
|
|
25
|
+
var itemOrPropsBarBorderRadius = (_b = (_a = item.barBorderRadius) !== null && _a !== void 0 ? _a : barBorderRadius) !== null && _b !== void 0 ? _b : 0;
|
|
26
|
+
var localBarBorderRadius = isFocused
|
|
27
|
+
? (_c = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.borderRadius) !== null && _c !== void 0 ? _c : itemOrPropsBarBorderRadius
|
|
28
|
+
: itemOrPropsBarBorderRadius;
|
|
29
|
+
var localBarWidth = utils_1.getBarWidth(isFocused, focusedBarConfig, item.barWidth, barWidth);
|
|
30
|
+
var localFrontColor = utils_1.getBarFrontColor(isFocused, focusedBarConfig, item.frontColor, frontColor, isThreeD);
|
|
31
|
+
var localGradientColor = item.gradientColor || gradientColor;
|
|
32
|
+
var localOpacity = opacity || 1;
|
|
33
|
+
var commonStyleForBar = [
|
|
34
|
+
{
|
|
35
|
+
position: "absolute",
|
|
36
|
+
width: "100%",
|
|
37
|
+
height: "100%",
|
|
38
|
+
borderWidth: barBorderWidth !== null && barBorderWidth !== void 0 ? barBorderWidth : 0,
|
|
39
|
+
borderColor: barBorderColor,
|
|
40
|
+
borderRadius: localBarBorderRadius,
|
|
41
|
+
borderTopLeftRadius: (_e = (_d = item.barBorderTopLeftRadius) !== null && _d !== void 0 ? _d : barBorderTopLeftRadius) !== null && _e !== void 0 ? _e : localBarBorderRadius,
|
|
42
|
+
borderTopRightRadius: (_g = (_f = item.barBorderTopRightRadius) !== null && _f !== void 0 ? _f : barBorderTopRightRadius) !== null && _g !== void 0 ? _g : localBarBorderRadius,
|
|
43
|
+
borderBottomLeftRadius: (_j = (_h = item.barBorderBottomLeftRadius) !== null && _h !== void 0 ? _h : barBorderBottomLeftRadius) !== null && _j !== void 0 ? _j : localBarBorderRadius,
|
|
44
|
+
borderBottomRightRadius: (_l = (_k = item.barBorderBottomRightRadius) !== null && _k !== void 0 ? _k : barBorderBottomRightRadius) !== null && _l !== void 0 ? _l : localBarBorderRadius,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
if (roundedBottom || (isFocused && (focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.roundedBottom))) {
|
|
48
|
+
commonStyleForBar.push({
|
|
49
|
+
borderBottomLeftRadius: localBarWidth / 2,
|
|
50
|
+
borderBottomRightRadius: localBarWidth / 2,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (cappedBars) {
|
|
54
|
+
commonStyleForBar.push({
|
|
55
|
+
borderTopLeftRadius: item.capRadius === 0 ? 0 : item.capRadius || capRadius || 0,
|
|
56
|
+
borderTopRightRadius: item.capRadius === 0 ? 0 : item.capRadius || capRadius || 0,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (roundedTop || (isFocused && (focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.roundedTop))) {
|
|
60
|
+
commonStyleForBar.push({
|
|
61
|
+
borderTopLeftRadius: localBarWidth / 2,
|
|
62
|
+
borderTopRightRadius: localBarWidth / 2,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
var barStyleWithBackground = __spreadArray(__spreadArray([], commonStyleForBar, true), [
|
|
66
|
+
{
|
|
67
|
+
backgroundColor: localFrontColor,
|
|
68
|
+
},
|
|
69
|
+
], false);
|
|
70
|
+
var commonPropsFor2Dand3Dbars = {
|
|
71
|
+
barBackgroundPattern: item.barBackgroundPattern || barBackgroundPattern,
|
|
72
|
+
barInnerComponent: isFocused
|
|
73
|
+
? (_m = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.barInnerComponent) !== null && _m !== void 0 ? _m : barInnerComponent
|
|
74
|
+
: barInnerComponent,
|
|
75
|
+
patternId: item.patternId || patternId,
|
|
76
|
+
barWidth: localBarWidth,
|
|
77
|
+
barStyle: barStyle,
|
|
78
|
+
item: item,
|
|
79
|
+
index: index,
|
|
80
|
+
frontColor: localFrontColor,
|
|
81
|
+
showGradient: item.showGradient || showGradient || false,
|
|
82
|
+
gradientColor: isFocused
|
|
83
|
+
? (_o = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.gradientColor) !== null && _o !== void 0 ? _o : localGradientColor
|
|
84
|
+
: localGradientColor,
|
|
85
|
+
opacity: isFocused
|
|
86
|
+
? (_p = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.opacity) !== null && _p !== void 0 ? _p : localOpacity
|
|
87
|
+
: localOpacity,
|
|
88
|
+
height: barHeight,
|
|
89
|
+
intactTopLabel: intactTopLabel,
|
|
90
|
+
showValuesAsTopLabel: !!showValuesAsTopLabel,
|
|
91
|
+
topLabelContainerStyle: topLabelContainerStyle,
|
|
92
|
+
topLabelTextStyle: topLabelTextStyle,
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
commonStyleForBar: commonStyleForBar,
|
|
96
|
+
barStyleWithBackground: barStyleWithBackground,
|
|
97
|
+
commonPropsFor2Dand3Dbars: commonPropsFor2Dand3Dbars,
|
|
98
|
+
isFocused: isFocused,
|
|
99
|
+
focusedBarConfig: focusedBarConfig,
|
|
100
|
+
localFrontColor: localFrontColor,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=Animated2DWithGradient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Animated2DWithGradient.js","sourceRoot":"","sources":["Animated2DWithGradient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;YAIA,+CAAa,iCAAiC,GAAG,UAAC,KAAK;;gBAEnD,IAAA,cAAc,GA+BZ,KAAK,eA/BO,EACd,cAAc,GA8BZ,KAAK,eA9BO,EACd,eAAe,GA6Bb,KAAK,gBA7BQ,EACf,IAAI,GA4BF,KAAK,KA5BH,EACJ,sBAAsB,GA2BpB,KAAK,uBA3Be,EACtB,uBAAuB,GA0BrB,KAAK,wBA1BgB,EACvB,yBAAyB,GAyBvB,KAAK,0BAzBkB,EACzB,0BAA0B,GAwBxB,KAAK,2BAxBmB,EAC1B,QAAQ,GAuBN,KAAK,SAvBC,EACR,iBAAiB,GAsBf,KAAK,kBAtBU,EACjB,QAAQ,GAqBN,KAAK,SArBC,EACR,KAAK,GAoBH,KAAK,MApBF,EACL,OAAO,GAmBL,KAAK,QAnBA,EACP,SAAS,GAkBP,KAAK,UAlBE,EACT,cAAc,GAiBZ,KAAK,eAjBO,EACd,oBAAoB,GAgBlB,KAAK,qBAhBa,EACpB,sBAAsB,GAepB,KAAK,uBAfe,EACtB,iBAAiB,GAcf,KAAK,kBAdU,EACjB,aAAa,GAaX,KAAK,cAbM,EACb,UAAU,GAYR,KAAK,WAZG,EACV,SAAS,GAWP,KAAK,UAXE,EACT,UAAU,GAUR,KAAK,WAVG,EACV,oBAAoB,GASlB,KAAK,qBATa,EACpB,SAAS,GAQP,KAAK,UARE,EACT,UAAU,GAOR,KAAK,WAPG,EACV,YAAY,GAMV,KAAK,aANK,EACZ,aAAa,GAKX,KAAK,cALM,EACb,aAAa,GAIX,KAAK,cAJM,EACb,eAAe,GAGb,KAAK,gBAHQ,EACf,gBAAgB,GAEd,KAAK,iBAFS,EAChB,QAAQ,GACN,KAAK,SADC,CACA;gBAEV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B;oBACrB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,SAAS;oBACtC,QAAQ,EAAE,aAAa;oBACvB,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE,KAAK;oBAEZ,UAAU,EAAE,eAAe;oBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,YAAY,IAAI,KAAK;oBACxD,aAAa,EAAE,SAAS;wBACtB,CAAC,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,aAAa,mCAAI,kBAAkB;wBACvD,CAAC,CAAC,kBAAkB;oBACtB,OAAO,EAAE,SAAS;wBAChB,CAAC,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO,mCAAI,YAAY;wBAC3C,CAAC,CAAC,YAAY;oBAChB,MAAM,EAAE,SAAS;oBACjB,cAAc,gBAAA;oBACd,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;oBAC5C,sBAAsB,wBAAA;oBACtB,iBAAiB,mBAAA;iBAClB,CAAC;gBAEF,OAAO;oBACL,iBAAiB,mBAAA;oBACjB,sBAAsB,wBAAA;oBACtB,yBAAyB,2BAAA;oBACzB,SAAS,WAAA;oBACT,gBAAgB,kBAAA;oBAChB,eAAe,iBAAA;iBAChB,CAAC;YACJ,CAAC,EAAC;QACF,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
System.register(["react"], function (exports_1, context_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
var react_1, useRenderStackBars;
|
|
4
|
+
var __moduleName = context_1 && context_1.id;
|
|
5
|
+
return {
|
|
6
|
+
setters: [
|
|
7
|
+
function (react_1_1) {
|
|
8
|
+
react_1 = react_1_1;
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
execute: function () {
|
|
12
|
+
exports_1("useRenderStackBars", useRenderStackBars = function (props) {
|
|
13
|
+
var _a, _b, _c, _d, _e;
|
|
14
|
+
var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, propSpacing = props.propSpacing, initialSpacing = props.initialSpacing, stackData = props.stackData, isAnimated = props.isAnimated;
|
|
15
|
+
var cotainsNegative = item.stacks.some(function (item) { return item.value < 0; });
|
|
16
|
+
var noAnimation = cotainsNegative || !isAnimated;
|
|
17
|
+
var localBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
|
|
18
|
+
var borderRadius = item.borderRadius, borderTopLeftRadius = item.borderTopLeftRadius, borderTopRightRadius = item.borderTopRightRadius, borderBottomLeftRadius = item.borderBottomLeftRadius, borderBottomRightRadius = item.borderBottomRightRadius;
|
|
19
|
+
var leftSpacing = initialSpacing;
|
|
20
|
+
for (var i = 0; i < index; i++) {
|
|
21
|
+
leftSpacing +=
|
|
22
|
+
((_c = (_b = stackData[i].spacing) !== null && _b !== void 0 ? _b : propSpacing) !== null && _c !== void 0 ? _c : 0) +
|
|
23
|
+
((_e = (_d = stackData[i].stacks[0].barWidth) !== null && _d !== void 0 ? _d : props.barWidth) !== null && _e !== void 0 ? _e : 30);
|
|
24
|
+
}
|
|
25
|
+
var disablePress = props.disablePress || false;
|
|
26
|
+
var totalHeight = props.item.stacks.reduce(function (acc, stack) {
|
|
27
|
+
return acc +
|
|
28
|
+
(Math.abs(stack.value) * (containerHeight || 200)) / (maxValue || 200);
|
|
29
|
+
}, 0);
|
|
30
|
+
var _f = react_1.useState(noAnimation ? totalHeight : 1), height = _f[0], setHeight = _f[1];
|
|
31
|
+
var getBarHeight = function (value, marginBottom) {
|
|
32
|
+
return ((Math.abs(value) * (containerHeight || 200)) / (maxValue || 200) -
|
|
33
|
+
(marginBottom || 0));
|
|
34
|
+
};
|
|
35
|
+
var getPosition = function (index) {
|
|
36
|
+
/* Returns bottom position for stack item
|
|
37
|
+
negative values are below origin (-> negative position) */
|
|
38
|
+
var height = getBarHeight(item.stacks[index].value, item.stacks[index].marginBottom);
|
|
39
|
+
var itemValue = item.stacks[index].value;
|
|
40
|
+
var isNegative = itemValue <= 0;
|
|
41
|
+
var position = isNegative ? -(height || 0) : 0;
|
|
42
|
+
for (var i = 0; i < index; i++) {
|
|
43
|
+
var valueOnIndex = item.stacks[i].value;
|
|
44
|
+
if (isNegative && valueOnIndex <= 0) {
|
|
45
|
+
position +=
|
|
46
|
+
(valueOnIndex * (containerHeight || 200)) / (maxValue || 200);
|
|
47
|
+
}
|
|
48
|
+
else if (!isNegative && valueOnIndex >= 0) {
|
|
49
|
+
position +=
|
|
50
|
+
(valueOnIndex * (containerHeight || 200)) / (maxValue || 200);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return position;
|
|
54
|
+
};
|
|
55
|
+
var getLowestPosition = function () {
|
|
56
|
+
var _a;
|
|
57
|
+
return (((_a = item.stacks
|
|
58
|
+
.map(function (_, index) { return getPosition(index); })
|
|
59
|
+
.sort(function (a, b) { return a - b; })) === null || _a === void 0 ? void 0 : _a[0]) || 0);
|
|
60
|
+
};
|
|
61
|
+
var lowestBarPosition = getLowestPosition();
|
|
62
|
+
var getStackBorderRadii = function (item, index) {
|
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
64
|
+
var stackItem = item.stacks[index];
|
|
65
|
+
var borderRadii = {
|
|
66
|
+
borderTopLeftRadius: (_d = (_c = (_b = (_a = stackItem.borderTopLeftRadius) !== null && _a !== void 0 ? _a : stackItem.borderRadius) !== null && _b !== void 0 ? _b : props.barBorderTopLeftRadius) !== null && _c !== void 0 ? _c : props.barBorderRadius) !== null && _d !== void 0 ? _d : 0,
|
|
67
|
+
borderTopRightRadius: (_h = (_g = (_f = (_e = stackItem.borderTopRightRadius) !== null && _e !== void 0 ? _e : stackItem.borderRadius) !== null && _f !== void 0 ? _f : props.barBorderTopRightRadius) !== null && _g !== void 0 ? _g : props.barBorderRadius) !== null && _h !== void 0 ? _h : 0,
|
|
68
|
+
borderBottomLeftRadius: (_m = (_l = (_k = (_j = stackItem.borderBottomLeftRadius) !== null && _j !== void 0 ? _j : stackItem.borderRadius) !== null && _k !== void 0 ? _k : props.barBorderBottomLeftRadius) !== null && _l !== void 0 ? _l : props.barBorderRadius) !== null && _m !== void 0 ? _m : 0,
|
|
69
|
+
borderBottomRightRadius: (_r = (_q = (_p = (_o = stackItem.borderBottomRightRadius) !== null && _o !== void 0 ? _o : stackItem.borderRadius) !== null && _p !== void 0 ? _p : props.barBorderBottomRightRadius) !== null && _q !== void 0 ? _q : props.barBorderRadius) !== null && _r !== void 0 ? _r : 0,
|
|
70
|
+
};
|
|
71
|
+
return borderRadii;
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
cotainsNegative: cotainsNegative,
|
|
75
|
+
noAnimation: noAnimation,
|
|
76
|
+
localBarInnerComponent: localBarInnerComponent,
|
|
77
|
+
borderRadius: borderRadius,
|
|
78
|
+
borderTopLeftRadius: borderTopLeftRadius,
|
|
79
|
+
borderTopRightRadius: borderTopRightRadius,
|
|
80
|
+
borderBottomLeftRadius: borderBottomLeftRadius,
|
|
81
|
+
borderBottomRightRadius: borderBottomRightRadius,
|
|
82
|
+
leftSpacing: leftSpacing,
|
|
83
|
+
disablePress: disablePress,
|
|
84
|
+
totalHeight: totalHeight,
|
|
85
|
+
height: height,
|
|
86
|
+
setHeight: setHeight,
|
|
87
|
+
getBarHeight: getBarHeight,
|
|
88
|
+
getPosition: getPosition,
|
|
89
|
+
getLowestPosition: getLowestPosition,
|
|
90
|
+
lowestBarPosition: lowestBarPosition,
|
|
91
|
+
getStackBorderRadii: getStackBorderRadii,
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=RenderStackBars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderStackBars.js","sourceRoot":"","sources":["RenderStackBars.ts"],"names":[],"mappings":";;;;;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