gifted-charts-core 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/package.json +6 -2
  2. package/src/BarChart/Animated2DWithGradient.d.ts +24 -0
  3. package/src/BarChart/Animated2DWithGradient.js +108 -0
  4. package/src/BarChart/RenderStackBars.d.ts +27 -0
  5. package/src/BarChart/RenderStackBars.js +99 -0
  6. package/src/BarChart/index.d.ts +175 -0
  7. package/src/BarChart/index.js +611 -0
  8. package/src/BarChart/types.d.ts +570 -0
  9. package/src/BarChart/types.js +1 -0
  10. package/src/LineChart/LineChartBiColor.d.ts +104 -0
  11. package/src/LineChart/LineChartBiColor.js +520 -0
  12. package/src/LineChart/index.d.ts +383 -0
  13. package/src/LineChart/index.js +1397 -0
  14. package/src/LineChart/index.ts +4 -3
  15. package/src/LineChart/types.d.ts +531 -0
  16. package/src/LineChart/types.js +1 -0
  17. package/src/PieChart/index.d.ts +33 -0
  18. package/src/PieChart/index.js +119 -0
  19. package/src/PieChart/main.d.ts +49 -0
  20. package/src/PieChart/main.js +185 -0
  21. package/src/PieChart/types.d.ts +85 -0
  22. package/src/PieChart/types.js +1 -0
  23. package/src/PopulationPyramid/index.d.ts +137 -0
  24. package/src/PopulationPyramid/index.js +233 -0
  25. package/src/PopulationPyramid/index.ts +3 -3
  26. package/src/PopulationPyramid/types.d.ts +235 -0
  27. package/src/PopulationPyramid/types.js +1 -0
  28. package/src/PopulationPyramid/types.ts +4 -0
  29. package/src/components/AnimatedThreeDBar/index.d.ts +12 -0
  30. package/src/components/AnimatedThreeDBar/index.js +53 -0
  31. package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.d.ts +20 -0
  32. package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +217 -0
  33. package/src/components/BarAndLineChartsWrapper/index.d.ts +97 -0
  34. package/src/components/BarAndLineChartsWrapper/index.js +266 -0
  35. package/src/components/BarAndLineChartsWrapper/index.ts +5 -4
  36. package/src/components/common/StripAndLabel.d.ts +7 -0
  37. package/src/components/common/StripAndLabel.js +53 -0
  38. package/src/components/common/StripAndLabel.ts +2 -2
  39. package/src/components/common/types.d.ts +31 -0
  40. package/src/components/common/types.js +1 -0
  41. package/src/components/common/types.ts +1 -0
  42. package/src/index.d.ts +37 -0
  43. package/src/index.js +32 -0
  44. package/src/index.ts +146 -0
  45. package/src/utils/constants.d.ts +248 -0
  46. package/src/utils/constants.js +299 -0
  47. package/src/utils/constants.ts +0 -4
  48. package/src/utils/index.d.ts +89 -0
  49. package/src/utils/index.js +1008 -0
  50. package/src/utils/types.d.ts +337 -0
  51. package/src/utils/types.js +16 -0
  52. package/src/utils/types.ts +1 -0
  53. package/index.ts +0 -141
@@ -0,0 +1,233 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ import { getStrokeDashArray } from '../utils';
27
+ import { AxesAndRulesDefaults, populationDefaults } from '../utils/constants';
28
+ import { Framework } from '../utils/types';
29
+ export var usePopulationPyramid = function (props) {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
31
+ var framework = props.framework, _v = props.height, height = _v === void 0 ? populationDefaults.height : _v, _w = props.width, width = _w === void 0 ? props.screenWidth : _w, _x = props.verticalMarginBetweenBars, verticalMarginBetweenBars = _x === void 0 ? populationDefaults.verticalMarginBetweenBars : _x, _y = props.barsMapToYAxisSections, barsMapToYAxisSections = _y === void 0 ? populationDefaults.barsMapToYAxisSections : _y, data = props.data, _z = props.hideRules, hideRules = _z === void 0 ? AxesAndRulesDefaults.hideRules : _z, _0 = props.hideYAxisText, hideYAxisText = _0 === void 0 ? AxesAndRulesDefaults.hideYAxisText : _0, _1 = props.yAxisThickness, yAxisThickness = _1 === void 0 ? AxesAndRulesDefaults.yAxisThickness : _1, _2 = props.xAxisThickness, xAxisThickness = _2 === void 0 ? AxesAndRulesDefaults.xAxisThickness : _2, _3 = props.xAxisType, xAxisType = _3 === void 0 ? AxesAndRulesDefaults.xAxisType : _3, _4 = props.xAxisNoOfSections, xAxisNoOfSections = _4 === void 0 ? populationDefaults.xAxisNoOfSections : _4, _5 = props.showXAxisIndices, showXAxisIndices = _5 === void 0 ? populationDefaults.showXAxisIndices : _5, _6 = props.xAxisIndicesWidth, xAxisIndicesWidth = _6 === void 0 ? populationDefaults.xAxisIndicesWidth : _6, _7 = props.xAxisIndicesHeight, xAxisIndicesHeight = _7 === void 0 ? populationDefaults.xAxisIndicesHeight : _7, _8 = props.xAxisIndicesShiftY, xAxisIndicesShiftY = _8 === void 0 ? 0 : _8, _9 = props.showXAxisLabelTexts, showXAxisLabelTexts = _9 === void 0 ? populationDefaults.showXAxisLabelTexts : _9, _10 = props.xAxisLabelFontSize, xAxisLabelFontSize = _10 === void 0 ? populationDefaults.defaultFontSize : _10, _11 = props.xAxisLabelFontStyle, xAxisLabelFontStyle = _11 === void 0 ? populationDefaults.defaultFontStyle : _11, _12 = props.xAxisLabelFontWeight, xAxisLabelFontWeight = _12 === void 0 ? populationDefaults.defaultFontWeight : _12, _13 = props.xAxisLabelFontFamily, xAxisLabelFontFamily = _13 === void 0 ? populationDefaults.defaultFontFamily : _13, _14 = props.xAxisLabelShiftX, xAxisLabelShiftX = _14 === void 0 ? 0 : _14, _15 = props.xAxisLabelShiftY, xAxisLabelShiftY = _15 === void 0 ? 0 : _15, _16 = props.xAxisLabelPrefix, xAxisLabelPrefix = _16 === void 0 ? populationDefaults.prefix : _16, _17 = props.xAxisLabelSuffix, xAxisLabelSuffix = _17 === void 0 ? populationDefaults.suffix : _17, formatXAxisLabels = props.formatXAxisLabels, _18 = props.showVerticalLines, showVerticalLines = _18 === void 0 ? populationDefaults.showVerticalLines : _18, _19 = props.verticalLinesThickness, verticalLinesThickness = _19 === void 0 ? populationDefaults.verticalLinesThickness : _19, _20 = props.verticalLinesType, verticalLinesType = _20 === void 0 ? populationDefaults.verticalLinesType : _20, _21 = props.verticalLinesStrokeDashArray, verticalLinesStrokeDashArray = _21 === void 0 ? populationDefaults.verticalLinesStrokeDashArray : _21, _22 = props.showYAxisIndices, showYAxisIndices = _22 === void 0 ? AxesAndRulesDefaults.showYAxisIndices : _22, _23 = props.yAxisIndicesWidth, yAxisIndicesWidth = _23 === void 0 ? AxesAndRulesDefaults.yAxisIndicesWidth : _23, _24 = props.yAxisIndicesHeight, yAxisIndicesHeight = _24 === void 0 ? AxesAndRulesDefaults.yAxisIndicesHeight : _24, _25 = props.yAxisLabelFontSize, yAxisLabelFontSize = _25 === void 0 ? populationDefaults.defaultFontSize : _25, _26 = props.yAxisLabelFontStyle, yAxisLabelFontStyle = _26 === void 0 ? populationDefaults.defaultFontStyle : _26, _27 = props.yAxisLabelFontWeight, yAxisLabelFontWeight = _27 === void 0 ? populationDefaults.defaultFontWeight : _27, _28 = props.yAxisLabelFontFamily, yAxisLabelFontFamily = _28 === void 0 ? populationDefaults.defaultFontFamily : _28, _29 = props.yAxisLabelTextMarginRight, yAxisLabelTextMarginRight = _29 === void 0 ? populationDefaults.yAxisLabelTextMarginRight : _29, _30 = props.yAxisLabelTexts, yAxisLabelTexts = _30 === void 0 ? [] : _30, _31 = props.showValuesAsBarLabels, showValuesAsBarLabels = _31 === void 0 ? populationDefaults.showValuesAsBarLabels : _31, _32 = props.rulesThickness, rulesThickness = _32 === void 0 ? AxesAndRulesDefaults.rulesThickness : _32, _33 = props.rulesType, rulesType = _33 === void 0 ? AxesAndRulesDefaults.rulesType : _33, _34 = props.dashWidth, dashWidth = _34 === void 0 ? AxesAndRulesDefaults.dashWidth : _34, _35 = props.dashGap, dashGap = _35 === void 0 ? AxesAndRulesDefaults.dashGap : _35, _36 = props.leftBarLabelWidth, leftBarLabelWidth = _36 === void 0 ? populationDefaults.leftBarLabelWidth : _36, _37 = props.leftBarLabelFontSize, leftBarLabelFontSize = _37 === void 0 ? (_a = props.barLabelFontSize) !== null && _a !== void 0 ? _a : populationDefaults.defaultFontSize : _37, _38 = props.leftBarLabelFontStyle, leftBarLabelFontStyle = _38 === void 0 ? (_b = props.barLabelFontStyle) !== null && _b !== void 0 ? _b : populationDefaults.defaultFontStyle : _38, _39 = props.leftBarLabelFontWeight, leftBarLabelFontWeight = _39 === void 0 ? (_c = props.barLabelFontWeight) !== null && _c !== void 0 ? _c : populationDefaults.defaultFontWeight : _39, _40 = props.leftBarLabelFontFamily, leftBarLabelFontFamily = _40 === void 0 ? (_d = props.barLabelFontFamily) !== null && _d !== void 0 ? _d : populationDefaults.defaultFontFamily : _40, _41 = props.leftBarLabelPrefix, leftBarLabelPrefix = _41 === void 0 ? populationDefaults.prefix : _41, _42 = props.leftBarLabelSuffix, leftBarLabelSuffix = _42 === void 0 ? populationDefaults.suffix : _42, _43 = props.rightBarLabelWidth, rightBarLabelWidth = _43 === void 0 ? populationDefaults.rightBarLabelWidth : _43, _44 = props.rightBarLabelFontSize, rightBarLabelFontSize = _44 === void 0 ? (_e = props.barLabelFontSize) !== null && _e !== void 0 ? _e : populationDefaults.defaultFontSize : _44, _45 = props.rightBarLabelFontStyle, rightBarLabelFontStyle = _45 === void 0 ? (_f = props.barLabelFontStyle) !== null && _f !== void 0 ? _f : populationDefaults.defaultFontStyle : _45, _46 = props.rightBarLabelFontWeight, rightBarLabelFontWeight = _46 === void 0 ? (_g = props.barLabelFontWeight) !== null && _g !== void 0 ? _g : populationDefaults.defaultFontWeight : _46, _47 = props.rightBarLabelFontFamily, rightBarLabelFontFamily = _47 === void 0 ? (_h = props.barLabelFontFamily) !== null && _h !== void 0 ? _h : populationDefaults.defaultFontFamily : _47, _48 = props.rightBarLabelPrefix, rightBarLabelPrefix = _48 === void 0 ? populationDefaults.prefix : _48, _49 = props.rightBarLabelSuffix, rightBarLabelSuffix = _49 === void 0 ? populationDefaults.suffix : _49, formatBarLabels = props.formatBarLabels, _50 = props.showMidAxis, showMidAxis = _50 === void 0 ? populationDefaults.showMidAxis : _50, _51 = props.midAxisLabelWidth, midAxisLabelWidth = _51 === void 0 ? populationDefaults.midAxisLabelWidth : _51, _52 = props.midAxisLabelFontSize, midAxisLabelFontSize = _52 === void 0 ? populationDefaults.defaultFontSize : _52, _53 = props.midAxisLabelFontStyle, midAxisLabelFontStyle = _53 === void 0 ? populationDefaults.defaultFontStyle : _53, _54 = props.midAxisLabelFontWeight, midAxisLabelFontWeight = _54 === void 0 ? populationDefaults.defaultFontWeight : _54, _55 = props.midAxisLabelFontFamily, midAxisLabelFontFamily = _55 === void 0 ? populationDefaults.defaultFontFamily : _55, _56 = props.leftBarBorderWidth, leftBarBorderWidth = _56 === void 0 ? (_j = props.barBorderWidth) !== null && _j !== void 0 ? _j : populationDefaults.leftBarBorderWidth : _56, _57 = props.rightBarBorderWidth, rightBarBorderWidth = _57 === void 0 ? (_k = props.barBorderWidth) !== null && _k !== void 0 ? _k : populationDefaults.rightBarBorderWidth : _57, _58 = props.leftBarBorderRadius, leftBarBorderRadius = _58 === void 0 ? (_l = props.barBorderRadius) !== null && _l !== void 0 ? _l : populationDefaults.leftBarBorderRadius : _58, _59 = props.rightBarBorderRadius, rightBarBorderRadius = _59 === void 0 ? (_m = props.barBorderRadius) !== null && _m !== void 0 ? _m : populationDefaults.rightBarBorderRadius : _59, _60 = props.allCornersRounded, allCornersRounded = _60 === void 0 ? populationDefaults.allCornersRounded : _60, _61 = props.showSurplus, showSurplus = _61 === void 0 ? populationDefaults.showSurplus : _61, _62 = props.showSurplusLeft, showSurplusLeft = _62 === void 0 ? populationDefaults.showSurplusLeft : _62, _63 = props.showSurplusRight, showSurplusRight = _63 === void 0 ? populationDefaults.showSurplusRight : _63, _64 = props.leftSurplusBorderWidth, leftSurplusBorderWidth = _64 === void 0 ? populationDefaults.leftSurplusBorderWidth : _64, _65 = props.rightSurplusBorderWidth, rightSurplusBorderWidth = _65 === void 0 ? populationDefaults.rightSurplusBorderWidth : _65;
32
+ var _66 = props.yAxisColor, yAxisColor = _66 === void 0 ? AxesAndRulesDefaults.yAxisColor : _66, _67 = props.xAxisColor, xAxisColor = _67 === void 0 ? AxesAndRulesDefaults.xAxisColor : _67, _68 = props.xAxisIndicesColor, xAxisIndicesColor = _68 === void 0 ? populationDefaults.xAxisIndicesColor : _68, _69 = props.xAxisLabelColor, xAxisLabelColor = _69 === void 0 ? populationDefaults.defaultFontColor : _69, _70 = props.verticalLinesColor, verticalLinesColor = _70 === void 0 ? populationDefaults.verticalLinesColor : _70, _71 = props.yAxisIndicesColor, yAxisIndicesColor = _71 === void 0 ? AxesAndRulesDefaults.yAxisIndicesColor : _71, _72 = props.yAxisLabelColor, yAxisLabelColor = _72 === void 0 ? populationDefaults.defaultFontColor : _72, _73 = props.rulesColor, rulesColor = _73 === void 0 ? AxesAndRulesDefaults.rulesColor : _73, _74 = props.leftBarLabelColor, leftBarLabelColor = _74 === void 0 ? (_o = props.barLabelColor) !== null && _o !== void 0 ? _o : populationDefaults.defaultFontColor : _74, _75 = props.rightBarLabelColor, rightBarLabelColor = _75 === void 0 ? (_p = props.barLabelColor) !== null && _p !== void 0 ? _p : populationDefaults.defaultFontColor : _75, _76 = props.midAxisLabelColor, midAxisLabelColor = _76 === void 0 ? populationDefaults.defaultFontColor : _76, _77 = props.leftBarColor, leftBarColor = _77 === void 0 ? populationDefaults.leftBarColor : _77, _78 = props.rightBarColor, rightBarColor = _78 === void 0 ? populationDefaults.rightBarColor : _78, _79 = props.leftBarBorderColor, leftBarBorderColor = _79 === void 0 ? populationDefaults.leftBarBorderColor : _79, _80 = props.rightBarBorderColor, rightBarBorderColor = _80 === void 0 ? populationDefaults.rightBarBorderColor : _80, _81 = props.leftSurplusColor, leftSurplusColor = _81 === void 0 ? populationDefaults.leftSurplusColor : _81, _82 = props.leftSurplusBorderColor, leftSurplusBorderColor = _82 === void 0 ? populationDefaults.leftSurplusBorderColor : _82, _83 = props.rightSurplusColor, rightSurplusColor = _83 === void 0 ? populationDefaults.rightSurplusColor : _83, _84 = props.rightSurplusBorderColor, rightSurplusBorderColor = _84 === void 0 ? populationDefaults.rightSurplusBorderColor : _84;
33
+ if (framework === Framework.reactJS) {
34
+ yAxisColor = yAxisColor.toString();
35
+ xAxisColor = xAxisColor.toString();
36
+ xAxisIndicesColor = xAxisIndicesColor.toString();
37
+ xAxisLabelColor = xAxisLabelColor.toString();
38
+ verticalLinesColor = verticalLinesColor.toString();
39
+ yAxisIndicesColor = yAxisIndicesColor.toString();
40
+ yAxisLabelColor = yAxisLabelColor.toString();
41
+ rulesColor = rulesColor.toString();
42
+ leftBarLabelColor = leftBarLabelColor.toString();
43
+ rightBarLabelColor = rightBarLabelColor.toString();
44
+ midAxisLabelColor = midAxisLabelColor.toString();
45
+ leftBarColor = leftBarColor.toString();
46
+ rightBarColor = rightBarColor.toString();
47
+ leftBarBorderColor = leftBarBorderColor.toString();
48
+ rightBarBorderColor = rightBarBorderColor.toString();
49
+ leftSurplusColor = leftSurplusColor.toString();
50
+ leftSurplusBorderColor = leftSurplusBorderColor.toString();
51
+ rightSurplusColor = rightSurplusColor.toString();
52
+ rightSurplusBorderColor = rightSurplusBorderColor.toString();
53
+ }
54
+ var yAxisLabelWidth = hideYAxisText
55
+ ? yAxisThickness
56
+ : (_q = props.yAxisLabelWidth) !== null && _q !== void 0 ? _q : AxesAndRulesDefaults.yAxisLabelWidth;
57
+ var noOfSections = (_r = props.noOfSections) !== null && _r !== void 0 ? _r : data.length;
58
+ var containerHeight = props.stepHeight
59
+ ? props.stepHeight * noOfSections
60
+ : height;
61
+ var stepHeight = (_s = props.stepHeight) !== null && _s !== void 0 ? _s : containerHeight / noOfSections;
62
+ var xAxisLabelsHeight = 80;
63
+ var containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight;
64
+ var mid = (width + yAxisLabelWidth) / 2;
65
+ var leftMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.left; })), false));
66
+ var rightMax = Math.max.apply(Math, __spreadArray([], __read(data.map(function (item) { return item.right; })), false));
67
+ var max = Math.max(leftMax, rightMax);
68
+ var xAxisRoundToDigits = (_t = props.xAxisRoundToDigits) !== null && _t !== void 0 ? _t : (max < 0.1 ? 3 : max < 1 ? 2 : max < 10 ? 1 : 0);
69
+ var midAxisAndLabelWidth = (showMidAxis ? midAxisLabelWidth : 0) / 2 +
70
+ Math.max(leftBarLabelWidth, rightBarLabelWidth);
71
+ var barWidthFactor = ((width - yAxisLabelWidth) / 2 - midAxisAndLabelWidth) / max;
72
+ var leftXAfterMid = mid - (showMidAxis ? midAxisLabelWidth / 2 : 0);
73
+ var rightXAfterMid = mid + (showMidAxis ? midAxisLabelWidth / 2 : 0);
74
+ var yAxisLineProps = {
75
+ x1: yAxisLabelWidth,
76
+ y1: 0,
77
+ x2: yAxisLabelWidth,
78
+ y2: containerHeight,
79
+ stroke: yAxisColor,
80
+ strokeWidth: yAxisThickness
81
+ };
82
+ yAxisLineProps.strokeDasharray = getStrokeDashArray(props.yAxisStrokeDashArray, framework);
83
+ var midAxisLineCommonProps = {
84
+ y1: 0,
85
+ y2: containerHeight,
86
+ strokeWidth: (_u = props.midAxisThickness) !== null && _u !== void 0 ? _u : yAxisThickness
87
+ };
88
+ midAxisLineCommonProps.strokeDasharray = getStrokeDashArray(props.midAxisStrokeDashArray, framework);
89
+ var xAxisLabelY = containerHeight + xAxisLabelFontSize + 6 + xAxisLabelShiftY;
90
+ var xAxisIndicesCommonProps = {
91
+ y1: containerHeight - xAxisIndicesHeight / 2 + xAxisIndicesShiftY,
92
+ y2: containerHeight + xAxisIndicesHeight / 2 + xAxisIndicesShiftY,
93
+ stroke: xAxisIndicesColor,
94
+ strokeWidth: xAxisIndicesWidth
95
+ };
96
+ var verticalLinesCommonProps = {
97
+ y1: 0,
98
+ y2: containerHeight,
99
+ stroke: verticalLinesColor,
100
+ strokeWidth: verticalLinesThickness
101
+ };
102
+ verticalLinesCommonProps.strokeDasharray = getStrokeDashArray(verticalLinesStrokeDashArray);
103
+ var xAxisLabelsCommonProps = {
104
+ y: xAxisLabelY + xAxisLabelShiftY,
105
+ stroke: xAxisLabelColor,
106
+ fontSize: xAxisLabelFontSize,
107
+ fontStyle: xAxisLabelFontStyle,
108
+ fontWeight: xAxisLabelFontWeight,
109
+ fontFamily: xAxisLabelFontFamily
110
+ };
111
+ var getXLabel = function (index) {
112
+ return ((leftXAfterMid * index) / xAxisNoOfSections / barWidthFactor)
113
+ .toFixed(xAxisRoundToDigits)
114
+ .toString();
115
+ };
116
+ return {
117
+ height: height,
118
+ width: width,
119
+ verticalMarginBetweenBars: verticalMarginBetweenBars,
120
+ barsMapToYAxisSections: barsMapToYAxisSections,
121
+ data: data,
122
+ hideRules: hideRules,
123
+ hideYAxisText: hideYAxisText,
124
+ yAxisColor: yAxisColor,
125
+ yAxisThickness: yAxisThickness,
126
+ xAxisColor: xAxisColor,
127
+ xAxisThickness: xAxisThickness,
128
+ xAxisType: xAxisType,
129
+ xAxisNoOfSections: xAxisNoOfSections,
130
+ showXAxisIndices: showXAxisIndices,
131
+ xAxisIndicesWidth: xAxisIndicesWidth,
132
+ xAxisIndicesHeight: xAxisIndicesHeight,
133
+ xAxisIndicesColor: xAxisIndicesColor,
134
+ xAxisIndicesShiftY: xAxisIndicesShiftY,
135
+ showXAxisLabelTexts: showXAxisLabelTexts,
136
+ xAxisLabelFontSize: xAxisLabelFontSize,
137
+ xAxisLabelFontStyle: xAxisLabelFontStyle,
138
+ xAxisLabelFontWeight: xAxisLabelFontWeight,
139
+ xAxisLabelFontFamily: xAxisLabelFontFamily,
140
+ xAxisLabelColor: xAxisLabelColor,
141
+ xAxisLabelShiftX: xAxisLabelShiftX,
142
+ xAxisLabelShiftY: xAxisLabelShiftY,
143
+ xAxisLabelPrefix: xAxisLabelPrefix,
144
+ xAxisLabelSuffix: xAxisLabelSuffix,
145
+ formatXAxisLabels: formatXAxisLabels,
146
+ showVerticalLines: showVerticalLines,
147
+ verticalLinesColor: verticalLinesColor,
148
+ verticalLinesThickness: verticalLinesThickness,
149
+ verticalLinesType: verticalLinesType,
150
+ verticalLinesStrokeDashArray: verticalLinesStrokeDashArray,
151
+ showYAxisIndices: showYAxisIndices,
152
+ yAxisIndicesWidth: yAxisIndicesWidth,
153
+ yAxisIndicesHeight: yAxisIndicesHeight,
154
+ yAxisIndicesColor: yAxisIndicesColor,
155
+ yAxisLabelFontSize: yAxisLabelFontSize,
156
+ yAxisLabelFontStyle: yAxisLabelFontStyle,
157
+ yAxisLabelFontWeight: yAxisLabelFontWeight,
158
+ yAxisLabelFontFamily: yAxisLabelFontFamily,
159
+ yAxisLabelColor: yAxisLabelColor,
160
+ yAxisLabelTextMarginRight: yAxisLabelTextMarginRight,
161
+ yAxisLabelTexts: yAxisLabelTexts,
162
+ showValuesAsBarLabels: showValuesAsBarLabels,
163
+ rulesThickness: rulesThickness,
164
+ rulesColor: rulesColor,
165
+ rulesType: rulesType,
166
+ dashWidth: dashWidth,
167
+ dashGap: dashGap,
168
+ leftBarLabelWidth: leftBarLabelWidth,
169
+ leftBarLabelFontSize: leftBarLabelFontSize,
170
+ leftBarLabelColor: leftBarLabelColor,
171
+ leftBarLabelFontStyle: leftBarLabelFontStyle,
172
+ leftBarLabelFontWeight: leftBarLabelFontWeight,
173
+ leftBarLabelFontFamily: leftBarLabelFontFamily,
174
+ leftBarLabelPrefix: leftBarLabelPrefix,
175
+ leftBarLabelSuffix: leftBarLabelSuffix,
176
+ rightBarLabelWidth: rightBarLabelWidth,
177
+ rightBarLabelFontSize: rightBarLabelFontSize,
178
+ rightBarLabelColor: rightBarLabelColor,
179
+ rightBarLabelFontStyle: rightBarLabelFontStyle,
180
+ rightBarLabelFontWeight: rightBarLabelFontWeight,
181
+ rightBarLabelFontFamily: rightBarLabelFontFamily,
182
+ rightBarLabelPrefix: rightBarLabelPrefix,
183
+ rightBarLabelSuffix: rightBarLabelSuffix,
184
+ formatBarLabels: formatBarLabels,
185
+ showMidAxis: showMidAxis,
186
+ midAxisLabelWidth: midAxisLabelWidth,
187
+ midAxisLabelFontSize: midAxisLabelFontSize,
188
+ midAxisLabelColor: midAxisLabelColor,
189
+ midAxisLabelFontStyle: midAxisLabelFontStyle,
190
+ midAxisLabelFontWeight: midAxisLabelFontWeight,
191
+ midAxisLabelFontFamily: midAxisLabelFontFamily,
192
+ leftBarColor: leftBarColor,
193
+ rightBarColor: rightBarColor,
194
+ leftBarBorderColor: leftBarBorderColor,
195
+ rightBarBorderColor: rightBarBorderColor,
196
+ leftBarBorderWidth: leftBarBorderWidth,
197
+ rightBarBorderWidth: rightBarBorderWidth,
198
+ leftBarBorderRadius: leftBarBorderRadius,
199
+ rightBarBorderRadius: rightBarBorderRadius,
200
+ allCornersRounded: allCornersRounded,
201
+ showSurplus: showSurplus,
202
+ showSurplusLeft: showSurplusLeft,
203
+ showSurplusRight: showSurplusRight,
204
+ leftSurplusColor: leftSurplusColor,
205
+ leftSurplusBorderColor: leftSurplusBorderColor,
206
+ rightSurplusColor: rightSurplusColor,
207
+ rightSurplusBorderColor: rightSurplusBorderColor,
208
+ leftSurplusBorderWidth: leftSurplusBorderWidth,
209
+ rightSurplusBorderWidth: rightSurplusBorderWidth,
210
+ yAxisLabelWidth: yAxisLabelWidth,
211
+ noOfSections: noOfSections,
212
+ containerHeight: containerHeight,
213
+ stepHeight: stepHeight,
214
+ xAxisLabelsHeight: xAxisLabelsHeight,
215
+ containerHeightWithXaxisLabels: containerHeightWithXaxisLabels,
216
+ mid: mid,
217
+ leftMax: leftMax,
218
+ rightMax: rightMax,
219
+ max: max,
220
+ xAxisRoundToDigits: xAxisRoundToDigits,
221
+ midAxisAndLabelWidth: midAxisAndLabelWidth,
222
+ barWidthFactor: barWidthFactor,
223
+ leftXAfterMid: leftXAfterMid,
224
+ rightXAfterMid: rightXAfterMid,
225
+ yAxisLineProps: yAxisLineProps,
226
+ midAxisLineCommonProps: midAxisLineCommonProps,
227
+ xAxisLabelY: xAxisLabelY,
228
+ xAxisIndicesCommonProps: xAxisIndicesCommonProps,
229
+ verticalLinesCommonProps: verticalLinesCommonProps,
230
+ xAxisLabelsCommonProps: xAxisLabelsCommonProps,
231
+ getXLabel: getXLabel
232
+ };
233
+ };
@@ -1,13 +1,13 @@
1
1
  import { getStrokeDashArray } from '../utils'
2
2
  import { AxesAndRulesDefaults, populationDefaults } from '../utils/constants'
3
3
  import { Framework } from '../utils/types'
4
- import { type RulesPropsType, type TPopulationPyramidPropsType } from './types'
4
+ import { type extendedPopulationPyramidPropsType, type RulesPropsType } from './types'
5
5
 
6
- export const usePopulationPyramid = (props: TPopulationPyramidPropsType) => {
6
+ export const usePopulationPyramid = (props: extendedPopulationPyramidPropsType) => {
7
7
  const {
8
8
  framework,
9
9
  height = populationDefaults.height,
10
- width = populationDefaults.width,
10
+ width = props.screenWidth,
11
11
  verticalMarginBetweenBars = populationDefaults.verticalMarginBetweenBars,
12
12
  barsMapToYAxisSections = populationDefaults.barsMapToYAxisSections,
13
13
  data,
@@ -0,0 +1,235 @@
1
+ import { type ColorValue } from 'react-native';
2
+ import { type Framework, type RuleTypes } from '../utils/types';
3
+ import { type FontStyle, type FontWeight } from 'react-native-svg';
4
+ export interface popnPyramidDataItem {
5
+ left: number;
6
+ right: number;
7
+ leftBarColor?: ColorValue;
8
+ rightBarColor?: ColorValue;
9
+ leftBarBorderColor?: ColorValue;
10
+ rightBarBorderColor?: ColorValue;
11
+ barBorderWidth?: number;
12
+ leftBarBorderWidth?: number;
13
+ rightBarBorderWidth?: number;
14
+ barBorderRadius?: number;
15
+ leftBarBorderRadius?: number;
16
+ rightBarBorderRadius?: number;
17
+ barLabelWidth?: number;
18
+ barLabelFontSize?: number;
19
+ barLabelColor?: ColorValue;
20
+ barLabelFontStyle?: FontStyle;
21
+ barLabelFontWeight?: FontWeight;
22
+ barLabelFontFamily?: string;
23
+ leftBarLabel?: string;
24
+ leftBarLabelWidth?: number;
25
+ leftBarLabelFontSize?: number;
26
+ leftBarLabelColor?: ColorValue;
27
+ leftBarLabelFontStyle?: FontStyle;
28
+ leftBarLabelFontWeight?: FontWeight;
29
+ leftBarLabelFontFamily?: string;
30
+ leftBarLabelShift?: number;
31
+ rightBarLabel?: string;
32
+ rightBarLabelWidth?: number;
33
+ rightBarLabelFontSize?: number;
34
+ rightBarLabelColor?: ColorValue;
35
+ rightBarLabelFontStyle?: FontStyle;
36
+ rightBarLabelFontWeight?: FontWeight;
37
+ rightBarLabelFontFamily?: string;
38
+ rightBarLabelShift?: number;
39
+ yAxisLabel?: string;
40
+ midAxisLabel?: string;
41
+ midAxisLabelFontSize?: number;
42
+ midAxisLabelColor?: ColorValue;
43
+ midAxisLabelFontStyle?: FontStyle;
44
+ midAxisLabelFontWeight?: FontWeight;
45
+ midAxisLabelFontFamily?: string;
46
+ showSurplus?: boolean;
47
+ showSurplusLeft?: boolean;
48
+ showSurplusRight?: boolean;
49
+ leftSurplusColor?: ColorValue;
50
+ leftSurplusBorderColor?: ColorValue;
51
+ rightSurplusColor?: ColorValue;
52
+ rightSurplusBorderColor?: ColorValue;
53
+ leftSurplusBorderWidth?: number;
54
+ rightSurplusBorderWidth?: number;
55
+ }
56
+ export type popnPyramidDataItemReactJS = popnPyramidDataItem & {
57
+ leftBarColor?: string;
58
+ rightBarColor?: string;
59
+ leftBarBorderColor?: string;
60
+ rightBarBorderColor?: string;
61
+ barLabelColor?: string;
62
+ leftBarLabelColor?: string;
63
+ rightBarLabelColor?: string;
64
+ midAxisLabelColor?: string;
65
+ leftSurplusColor?: string;
66
+ leftSurplusBorderColor?: string;
67
+ rightSurplusColor?: string;
68
+ rightSurplusBorderColor?: string;
69
+ };
70
+ export interface RulesProps {
71
+ x1?: number;
72
+ y1?: number;
73
+ x2?: number;
74
+ y2?: number;
75
+ stroke?: ColorValue;
76
+ strokeWidth?: number;
77
+ strokeDasharray?: number[] | string;
78
+ }
79
+ export type RulesPropsReactJS = RulesProps & {
80
+ stroke?: string;
81
+ };
82
+ export interface PopulationPyramidPropsType {
83
+ height?: number;
84
+ width?: number;
85
+ data: popnPyramidDataItem[];
86
+ hideRules?: boolean;
87
+ stepHeight?: number;
88
+ verticalMarginBetweenBars?: number;
89
+ hideYAxisText?: boolean;
90
+ yAxisLabelWidth?: number;
91
+ yAxisColor?: ColorValue;
92
+ yAxisThickness?: number;
93
+ yAxisStrokeDashArray?: number[] | string;
94
+ xAxisColor?: ColorValue;
95
+ xAxisThickness?: number;
96
+ xAxisType?: RuleTypes;
97
+ xAxisNoOfSections?: number;
98
+ showXAxisIndices?: boolean;
99
+ xAxisIndicesWidth?: number;
100
+ xAxisIndicesHeight?: number;
101
+ xAxisIndicesColor?: ColorValue;
102
+ xAxisIndicesShiftY?: number;
103
+ showXAxisLabelTexts?: boolean;
104
+ xAxisLabelFontSize?: number;
105
+ xAxisLabelColor?: ColorValue;
106
+ xAxisLabelFontStyle?: FontStyle;
107
+ xAxisLabelFontWeight?: FontWeight;
108
+ xAxisLabelFontFamily?: string;
109
+ xAxisLabelShiftX?: number;
110
+ xAxisLabelShiftY?: number;
111
+ xAxisRoundToDigits?: number;
112
+ xAxisLabelPrefix?: string;
113
+ xAxisLabelSuffix?: string;
114
+ formatXAxisLabels?: (label: string) => string;
115
+ showVerticalLines?: boolean;
116
+ verticalLinesColor?: ColorValue;
117
+ verticalLinesThickness?: number;
118
+ verticalLinesType?: RuleTypes;
119
+ verticalLinesStrokeDashArray?: number[] | string;
120
+ noOfSections?: number;
121
+ barsMapToYAxisSections?: boolean;
122
+ showYAxisIndices?: boolean;
123
+ yAxisIndicesWidth?: number;
124
+ yAxisIndicesHeight?: number;
125
+ yAxisIndicesColor?: ColorValue;
126
+ yAxisLabelColor?: ColorValue;
127
+ yAxisLabelFontSize?: number;
128
+ yAxisLabelTextMarginRight?: number;
129
+ yAxisLabelTexts?: string[];
130
+ yAxisLabelFontStyle?: FontStyle;
131
+ yAxisLabelFontWeight?: FontWeight;
132
+ yAxisLabelFontFamily?: string;
133
+ showValuesAsBarLabels?: boolean;
134
+ rulesThickness?: number;
135
+ rulesColor?: ColorValue;
136
+ rulesType?: RuleTypes;
137
+ dashWidth?: number;
138
+ dashGap?: number;
139
+ showMidAxis?: boolean;
140
+ midAxisThickness?: number;
141
+ midAxisLabelWidth?: number;
142
+ midAxisColor?: ColorValue;
143
+ midAxisLeftColor?: ColorValue;
144
+ midAxisRightColor?: ColorValue;
145
+ midAxisStrokeDashArray?: number[] | string;
146
+ midAxisLabelFontSize?: number;
147
+ midAxisLabelColor?: ColorValue;
148
+ midAxisLabelFontStyle?: FontStyle;
149
+ midAxisLabelFontWeight?: FontWeight;
150
+ midAxisLabelFontFamily?: string;
151
+ barLabelWidth?: number;
152
+ barLabelFontSize?: number;
153
+ barLabelColor?: ColorValue;
154
+ barLabelFontStyle?: FontStyle;
155
+ barLabelFontWeight?: FontWeight;
156
+ barLabelFontFamily?: string;
157
+ leftBarLabelWidth?: number;
158
+ leftBarLabelFontSize?: number;
159
+ leftBarLabelColor?: ColorValue;
160
+ leftBarLabelFontStyle?: FontStyle;
161
+ leftBarLabelFontWeight?: FontWeight;
162
+ leftBarLabelFontFamily?: string;
163
+ leftBarLabelShift?: number;
164
+ leftBarLabelPrefix?: string;
165
+ leftBarLabelSuffix?: string;
166
+ rightBarLabelWidth?: number;
167
+ rightBarLabelFontSize?: number;
168
+ rightBarLabelColor?: ColorValue;
169
+ rightBarLabelFontStyle?: FontStyle;
170
+ rightBarLabelFontWeight?: FontWeight;
171
+ rightBarLabelFontFamily?: string;
172
+ rightBarLabelShift?: number;
173
+ rightBarLabelPrefix?: string;
174
+ rightBarLabelSuffix?: string;
175
+ formatBarLabels?: (label: string) => string;
176
+ leftBarColor?: ColorValue;
177
+ rightBarColor?: ColorValue;
178
+ leftBarBorderColor?: ColorValue;
179
+ rightBarBorderColor?: ColorValue;
180
+ barBorderWidth?: number;
181
+ leftBarBorderWidth?: number;
182
+ rightBarBorderWidth?: number;
183
+ barBorderRadius?: number;
184
+ leftBarBorderRadius?: number;
185
+ rightBarBorderRadius?: number;
186
+ allCornersRounded?: boolean;
187
+ showSurplus?: boolean;
188
+ showSurplusLeft?: boolean;
189
+ showSurplusRight?: boolean;
190
+ leftSurplusColor?: ColorValue;
191
+ leftSurplusBorderColor?: ColorValue;
192
+ rightSurplusColor?: ColorValue;
193
+ rightSurplusBorderColor?: ColorValue;
194
+ leftSurplusBorderWidth?: number;
195
+ rightSurplusBorderWidth?: number;
196
+ }
197
+ export type PopulationPyramidPropsTypeReactJS = PopulationPyramidPropsType & {
198
+ data: popnPyramidDataItemReactJS[];
199
+ yAxisColor?: string;
200
+ xAxisColor?: string;
201
+ xAxisIndicesColor?: string;
202
+ xAxisLabelColor?: string;
203
+ verticalLinesColor?: string;
204
+ yAxisIndicesColor?: string;
205
+ yAxisLabelColor?: string;
206
+ rulesColor?: string;
207
+ midAxisColor?: string;
208
+ midAxisLeftColor?: string;
209
+ midAxisRightColor?: string;
210
+ midAxisLabelColor?: string;
211
+ barLabelColor?: string;
212
+ leftBarLabelColor?: string;
213
+ rightBarLabelColor?: string;
214
+ leftBarColor?: string;
215
+ rightBarColor?: string;
216
+ leftBarBorderColor?: string;
217
+ rightBarBorderColor?: string;
218
+ leftSurplusColor?: string;
219
+ leftSurplusBorderColor?: string;
220
+ rightSurplusColor?: string;
221
+ rightSurplusBorderColor?: string;
222
+ };
223
+ export type RulesPropsType = ({
224
+ framework: Framework.reactJS;
225
+ } & RulesPropsReactJS) | ({
226
+ framework?: Framework.reactNative;
227
+ } & RulesProps);
228
+ export type TPopulationPyramidPropsType = ({
229
+ framework: Framework.reactJS;
230
+ } & PopulationPyramidPropsTypeReactJS) | ({
231
+ framework?: Framework.reactNative;
232
+ } & PopulationPyramidPropsType);
233
+ export type extendedPopulationPyramidPropsType = TPopulationPyramidPropsType & {
234
+ screenWidth: number;
235
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -250,3 +250,7 @@ export type RulesPropsType =
250
250
  export type TPopulationPyramidPropsType =
251
251
  | ({ framework: Framework.reactJS } & PopulationPyramidPropsTypeReactJS)
252
252
  | ({ framework?: Framework.reactNative } & PopulationPyramidPropsType)
253
+
254
+ export type extendedPopulationPyramidPropsType = TPopulationPyramidPropsType & {
255
+ screenWidth: number
256
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { type animatedBarPropTypes } from '../../BarChart/types';
3
+ export declare const useAnimatedThreeDBar: (props: animatedBarPropTypes) => {
4
+ showGradient: boolean;
5
+ gradientColor: any;
6
+ frontColor: import("react-native").ColorValue;
7
+ sideColor: import("react-native").ColorValue;
8
+ topColor: import("react-native").ColorValue;
9
+ opacity: number;
10
+ initialRender: boolean | undefined;
11
+ setInitialRender: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
12
+ };
@@ -0,0 +1,53 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ import { useState } from 'react';
18
+ import { BarDefaults } from '../../utils/constants';
19
+ import { getBarSideColor, getBarTopColor } from '../../utils';
20
+ export var useAnimatedThreeDBar = function (props) {
21
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
22
+ var focusBarOnPress = props.focusBarOnPress, index = props.index, selectedIndex = props.selectedIndex, focusedBarConfig = props.focusedBarConfig, item = props.item;
23
+ var isFocused = focusBarOnPress && index === selectedIndex;
24
+ var localFrontColor = props.frontColor || BarDefaults.threeDBarFrontColor;
25
+ var localGradientColor = props.gradientColor || BarDefaults.threeDBarGradientColor;
26
+ var localSideColor = props.sideColor || BarDefaults.threeDBarSideColor;
27
+ var localTopColor = props.topColor || BarDefaults.threeDBarTopColor;
28
+ var localOpacity = props.opacity || 1;
29
+ var isAnimated = props.isAnimated, _o = props.showGradient, showGradient = _o === void 0 ? props.showGradient || false : _o, _p = props.gradientColor, gradientColor = _p === void 0 ? isFocused
30
+ ? (_a = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.gradientColor) !== null && _a !== void 0 ? _a : localGradientColor
31
+ : localGradientColor : _p, _q = props.frontColor, frontColor = _q === void 0 ? isFocused
32
+ ? (_b = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.color) !== null && _b !== void 0 ? _b : localFrontColor
33
+ : localFrontColor : _q, _r = props.sideColor, sideColor = _r === void 0 ? getBarSideColor(isFocused, focusedBarConfig, item.sideColor, localSideColor) : _r, _s = props.topColor, topColor = _s === void 0 ? getBarTopColor(isFocused, focusedBarConfig, item.topColor, localTopColor) : _s, _t = props.opacity, opacity = _t === void 0 ? isFocused
34
+ ? (_c = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.opacity) !== null && _c !== void 0 ? _c : localOpacity
35
+ : localOpacity : _t;
36
+ var _u = __read(useState(isAnimated), 2), initialRender = _u[0], setInitialRender = _u[1];
37
+ return {
38
+ showGradient: showGradient,
39
+ gradientColor: gradientColor,
40
+ frontColor: ((_f = (_e = (_d = frontColor === null || frontColor === void 0 ? void 0 : frontColor.toString()) === null || _d === void 0 ? void 0 : _d.trim) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.length)
41
+ ? frontColor
42
+ : BarDefaults.threeDBarFrontColor,
43
+ sideColor: ((_j = (_h = (_g = sideColor === null || sideColor === void 0 ? void 0 : sideColor.toString()) === null || _g === void 0 ? void 0 : _g.trim) === null || _h === void 0 ? void 0 : _h.call(_g)) === null || _j === void 0 ? void 0 : _j.length)
44
+ ? sideColor
45
+ : BarDefaults.threeDBarSideColor,
46
+ topColor: ((_m = (_l = (_k = topColor === null || topColor === void 0 ? void 0 : topColor.toString()) === null || _k === void 0 ? void 0 : _k.trim) === null || _l === void 0 ? void 0 : _l.call(_k)) === null || _m === void 0 ? void 0 : _m.length)
47
+ ? topColor
48
+ : BarDefaults.threeDBarTopColor,
49
+ opacity: opacity,
50
+ initialRender: initialRender,
51
+ setInitialRender: setInitialRender
52
+ };
53
+ };
@@ -0,0 +1,20 @@
1
+ import { type HorizSectionsType, type horizSectionPropTypes, type secondaryYAxisType } from '../../utils/types';
2
+ export declare const getHorizSectionVals: (props: horizSectionPropTypes) => {
3
+ secondaryYAxisConfig: secondaryYAxisType;
4
+ horizSections: HorizSectionsType;
5
+ yAxisExtraHeightAtTop: number;
6
+ secondaryHorizSections: HorizSectionsType;
7
+ showReferenceLine1: any;
8
+ referenceLine1Config: any;
9
+ referenceLine1Position: any;
10
+ showReferenceLine2: any;
11
+ referenceLine2Config: any;
12
+ referenceLine2Position: any;
13
+ showReferenceLine3: any;
14
+ referenceLine3Config: any;
15
+ referenceLine3Position: any;
16
+ horizSectionsBelow: HorizSectionsType;
17
+ secondaryHorizSectionsBelow: HorizSectionsType;
18
+ getLabelTexts: (val: string, index: number) => string;
19
+ getLabelTextsForSecondaryYAxis: (val: string, index: number) => string;
20
+ };