gifted-charts-core 0.0.25 → 0.0.27
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/package.json +5 -1
- package/src/BarChart/Animated2DWithGradient.d.ts +24 -0
- package/src/BarChart/Animated2DWithGradient.js +108 -0
- package/src/BarChart/RenderStackBars.d.ts +27 -0
- package/src/BarChart/RenderStackBars.js +99 -0
- package/src/BarChart/index.d.ts +175 -0
- package/src/BarChart/index.js +611 -0
- package/src/BarChart/types.d.ts +570 -0
- package/src/BarChart/types.js +1 -0
- package/src/LineChart/LineChartBiColor.d.ts +104 -0
- package/src/LineChart/LineChartBiColor.js +520 -0
- package/src/LineChart/index.d.ts +383 -0
- package/src/LineChart/index.js +1397 -0
- package/src/LineChart/index.ts +4 -3
- package/src/LineChart/types.d.ts +531 -0
- package/src/LineChart/types.js +1 -0
- package/src/PieChart/index.d.ts +33 -0
- package/src/PieChart/index.js +119 -0
- package/src/PieChart/main.d.ts +49 -0
- package/src/PieChart/main.js +185 -0
- package/src/PieChart/types.d.ts +85 -0
- package/src/PieChart/types.js +1 -0
- package/src/PopulationPyramid/index.d.ts +137 -0
- package/src/PopulationPyramid/index.js +233 -0
- package/src/PopulationPyramid/index.ts +3 -3
- package/src/PopulationPyramid/types.d.ts +235 -0
- package/src/PopulationPyramid/types.js +1 -0
- package/src/PopulationPyramid/types.ts +4 -0
- package/src/components/AnimatedThreeDBar/index.d.ts +12 -0
- package/src/components/AnimatedThreeDBar/index.js +53 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.d.ts +20 -0
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +217 -0
- package/src/components/BarAndLineChartsWrapper/index.d.ts +97 -0
- package/src/components/BarAndLineChartsWrapper/index.js +266 -0
- package/src/components/BarAndLineChartsWrapper/index.ts +5 -4
- package/src/components/common/StripAndLabel.d.ts +7 -0
- package/src/components/common/StripAndLabel.js +53 -0
- package/src/components/common/StripAndLabel.ts +2 -2
- package/src/components/common/types.d.ts +31 -0
- package/src/components/common/types.js +1 -0
- package/src/components/common/types.ts +1 -0
- package/src/index.d.ts +37 -0
- package/src/index.js +32 -0
- package/src/index.ts +146 -0
- package/src/utils/constants.d.ts +248 -0
- package/src/utils/constants.js +299 -0
- package/src/utils/constants.ts +0 -4
- package/src/utils/index.d.ts +89 -0
- package/src/utils/index.js +1008 -0
- package/src/utils/types.d.ts +337 -0
- package/src/utils/types.js +16 -0
- package/src/utils/types.ts +1 -0
- package/index.ts +0 -141
|
@@ -0,0 +1,520 @@
|
|
|
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 { useEffect, useMemo, useState } from 'react';
|
|
27
|
+
import { AxesAndRulesDefaults, LineDefaults, chartTypes } from '../utils/constants';
|
|
28
|
+
import { getAxesAndRulesProps, getExtendedContainerHeightWithPadding } from '../utils';
|
|
29
|
+
var initialData = null;
|
|
30
|
+
export var useLineChartBiColor = function (props) {
|
|
31
|
+
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, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48;
|
|
32
|
+
var _49 = __read(useState(false), 2), toggle = _49[0], setToggle = _49[1];
|
|
33
|
+
var _50 = __read(useState([]), 2), pointsArray = _50[0], setPointsArray = _50[1];
|
|
34
|
+
var _51 = __read(useState([]), 2), fillPointsArray = _51[0], setFillPointsArray = _51[1];
|
|
35
|
+
var _52 = __read(useState(-1), 2), selectedIndex = _52[0], setSelectedIndex = _52[1];
|
|
36
|
+
var containerHeight = (_a = props.height) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.containerHeight;
|
|
37
|
+
var noOfSections = (_b = props.noOfSections) !== null && _b !== void 0 ? _b : AxesAndRulesDefaults.noOfSections;
|
|
38
|
+
var data = useMemo(function () {
|
|
39
|
+
if (!props.data) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (props.yAxisOffset) {
|
|
43
|
+
return props.data.map(function (item) {
|
|
44
|
+
var _a;
|
|
45
|
+
item.value = item.value - ((_a = props.yAxisOffset) !== null && _a !== void 0 ? _a : 0);
|
|
46
|
+
return item;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return props.data;
|
|
50
|
+
}, [props.yAxisOffset, props.data]);
|
|
51
|
+
var scrollToEnd = (_c = props.scrollToEnd) !== null && _c !== void 0 ? _c : LineDefaults.scrollToEnd;
|
|
52
|
+
var scrollAnimation = (_d = props.scrollAnimation) !== null && _d !== void 0 ? _d : LineDefaults.scrollAnimation;
|
|
53
|
+
var scrollEventThrottle = (_e = props.scrollEventThrottle) !== null && _e !== void 0 ? _e : LineDefaults.scrollEventThrottle;
|
|
54
|
+
var labelsExtraHeight = (_f = props.labelsExtraHeight) !== null && _f !== void 0 ? _f : 0;
|
|
55
|
+
var animationDuration = (_g = props.animationDuration) !== null && _g !== void 0 ? _g : LineDefaults.animationDuration;
|
|
56
|
+
var startIndex1 = (_h = props.startIndex) !== null && _h !== void 0 ? _h : 0;
|
|
57
|
+
var endIndex1;
|
|
58
|
+
if (props.endIndex === undefined || props.endIndex === null) {
|
|
59
|
+
endIndex1 = data.length - 1;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
endIndex1 = props.endIndex;
|
|
63
|
+
}
|
|
64
|
+
if (!initialData) {
|
|
65
|
+
initialData = __spreadArray([], __read(data), false);
|
|
66
|
+
}
|
|
67
|
+
var adjustToWidth = (_j = props.adjustToWidth) !== null && _j !== void 0 ? _j : false;
|
|
68
|
+
var initialSpacing = (_k = props.initialSpacing) !== null && _k !== void 0 ? _k : LineDefaults.initialSpacing;
|
|
69
|
+
var endSpacing = (_l = props.endSpacing) !== null && _l !== void 0 ? _l : (adjustToWidth ? 0 : LineDefaults.endSpacing);
|
|
70
|
+
var thickness = (_m = props.thickness) !== null && _m !== void 0 ? _m : LineDefaults.thickness;
|
|
71
|
+
var spacing = (_o = props.spacing) !== null && _o !== void 0 ? _o : (adjustToWidth
|
|
72
|
+
? (((_p = props.width) !== null && _p !== void 0 ? _p : AxesAndRulesDefaults.width) - initialSpacing) /
|
|
73
|
+
data.length
|
|
74
|
+
: LineDefaults.spacing);
|
|
75
|
+
var xAxisThickness = (_q = props.xAxisThickness) !== null && _q !== void 0 ? _q : AxesAndRulesDefaults.xAxisThickness;
|
|
76
|
+
var dataPointsHeight1 = (_r = props.dataPointsHeight) !== null && _r !== void 0 ? _r : LineDefaults.dataPointsHeight;
|
|
77
|
+
var dataPointsWidth1 = (_s = props.dataPointsWidth) !== null && _s !== void 0 ? _s : LineDefaults.dataPointsWidth;
|
|
78
|
+
var dataPointsRadius1 = (_t = props.dataPointsRadius) !== null && _t !== void 0 ? _t : LineDefaults.dataPointsRadius;
|
|
79
|
+
var dataPointsColor1 = (_u = props.dataPointsColor) !== null && _u !== void 0 ? _u : LineDefaults.dataPointsColor;
|
|
80
|
+
var dataPointsShape1 = (_v = props.dataPointsShape) !== null && _v !== void 0 ? _v : LineDefaults.dataPointsShape;
|
|
81
|
+
var areaChart = (_w = props.areaChart) !== null && _w !== void 0 ? _w : false;
|
|
82
|
+
var textFontSize1 = (_x = props.textFontSize) !== null && _x !== void 0 ? _x : LineDefaults.textFontSize;
|
|
83
|
+
var textColor1 = (_y = props.textColor) !== null && _y !== void 0 ? _y : LineDefaults.textColor;
|
|
84
|
+
var totalWidth = initialSpacing;
|
|
85
|
+
var maxItem = 0;
|
|
86
|
+
var minItem = 0;
|
|
87
|
+
data.forEach(function (item) {
|
|
88
|
+
if (item.value > maxItem) {
|
|
89
|
+
maxItem = item.value;
|
|
90
|
+
}
|
|
91
|
+
if (item.value < minItem) {
|
|
92
|
+
minItem = item.value;
|
|
93
|
+
}
|
|
94
|
+
totalWidth += spacing;
|
|
95
|
+
});
|
|
96
|
+
if ((_z = props.showFractionalValues) !== null && _z !== void 0 ? _z : props.roundToDigits) {
|
|
97
|
+
maxItem *= 10 * ((_0 = props.roundToDigits) !== null && _0 !== void 0 ? _0 : 1);
|
|
98
|
+
maxItem = maxItem + (10 - (maxItem % 10));
|
|
99
|
+
maxItem /= 10 * ((_1 = props.roundToDigits) !== null && _1 !== void 0 ? _1 : 1);
|
|
100
|
+
maxItem = parseFloat(maxItem.toFixed((_2 = props.roundToDigits) !== null && _2 !== void 0 ? _2 : 1));
|
|
101
|
+
if (minItem !== 0) {
|
|
102
|
+
minItem *= 10 * ((_3 = props.roundToDigits) !== null && _3 !== void 0 ? _3 : 1);
|
|
103
|
+
minItem = minItem - (10 + (minItem % 10));
|
|
104
|
+
minItem /= 10 * ((_4 = props.roundToDigits) !== null && _4 !== void 0 ? _4 : 1);
|
|
105
|
+
minItem = parseFloat(minItem.toFixed((_5 = props.roundToDigits) !== null && _5 !== void 0 ? _5 : 1));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
maxItem = maxItem + (10 - (maxItem % 10));
|
|
110
|
+
if (minItem !== 0) {
|
|
111
|
+
minItem = minItem - (10 + (minItem % 10));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var maxValue = (_6 = props.maxValue) !== null && _6 !== void 0 ? _6 : maxItem;
|
|
115
|
+
var mostNegativeValue = (_7 = props.mostNegativeValue) !== null && _7 !== void 0 ? _7 : minItem;
|
|
116
|
+
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, props.overflowTop);
|
|
117
|
+
var yAtxAxis = extendedContainerHeight - xAxisThickness / 2;
|
|
118
|
+
var getX = function (index) { return initialSpacing + spacing * index; };
|
|
119
|
+
var getY = function (index) {
|
|
120
|
+
return yAtxAxis - (data[index].value * containerHeight) / maxValue;
|
|
121
|
+
};
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
var ppArray = [];
|
|
124
|
+
var pp = 'M' + initialSpacing + ' ' + getY(0);
|
|
125
|
+
var prevValuev;
|
|
126
|
+
var nextValue;
|
|
127
|
+
for (var i_1 = 0; i_1 < data.length - 1; i_1++) {
|
|
128
|
+
prevValuev = data[i_1].value;
|
|
129
|
+
nextValue = data[i_1 + 1].value;
|
|
130
|
+
if (prevValuev < 0 && nextValue < 0) {
|
|
131
|
+
pp += 'L' + getX(i_1) + ' ' + getY(i_1) + ' ';
|
|
132
|
+
}
|
|
133
|
+
else if (prevValuev < 0 && nextValue > 0) {
|
|
134
|
+
pp += 'L' + getX(i_1) + ' ' + getY(i_1) + ' ';
|
|
135
|
+
var prevX = getX(i_1);
|
|
136
|
+
var prevY = getY(i_1);
|
|
137
|
+
var nextX = getX(i_1 + 1);
|
|
138
|
+
var nextY = getY(i_1 + 1);
|
|
139
|
+
var slope = (nextY - prevY) / (nextX - prevX);
|
|
140
|
+
var x = (yAtxAxis - prevY) / slope + prevX;
|
|
141
|
+
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' ';
|
|
142
|
+
var pointsOb_1 = {
|
|
143
|
+
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
144
|
+
color: 'red'
|
|
145
|
+
};
|
|
146
|
+
ppArray.push(pointsOb_1);
|
|
147
|
+
setPointsArray(__spreadArray([], __read(ppArray), false));
|
|
148
|
+
pp = 'M' + x + ' ' + yAtxAxis + ' L' + nextX + ' ' + nextY + ' ';
|
|
149
|
+
pointsOb_1 = {
|
|
150
|
+
points: pp,
|
|
151
|
+
color: 'green'
|
|
152
|
+
};
|
|
153
|
+
ppArray.push(pointsOb_1);
|
|
154
|
+
}
|
|
155
|
+
else if (prevValuev > 0 && nextValue < 0) {
|
|
156
|
+
pp += 'L' + getX(i_1) + ' ' + getY(i_1) + ' ';
|
|
157
|
+
var prevX = getX(i_1);
|
|
158
|
+
var prevY = getY(i_1);
|
|
159
|
+
var nextX = getX(i_1 + 1);
|
|
160
|
+
var nextY = getY(i_1 + 1);
|
|
161
|
+
var slope = (nextY - prevY) / (nextX - prevX);
|
|
162
|
+
var x = (yAtxAxis - prevY) / slope + prevX;
|
|
163
|
+
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' ';
|
|
164
|
+
var pointsOb_2 = {
|
|
165
|
+
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
166
|
+
color: 'green'
|
|
167
|
+
};
|
|
168
|
+
ppArray.push(pointsOb_2);
|
|
169
|
+
setPointsArray(__spreadArray([], __read(ppArray), false));
|
|
170
|
+
pp = 'M' + x + ' ' + yAtxAxis + ' L' + nextX + ' ' + nextY + ' ';
|
|
171
|
+
pointsOb_2 = {
|
|
172
|
+
points: pp,
|
|
173
|
+
color: 'red'
|
|
174
|
+
};
|
|
175
|
+
ppArray.push(pointsOb_2);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
pp += 'L' + getX(i_1) + ' ' + getY(i_1) + ' ';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
var i = data.length - 1;
|
|
182
|
+
prevValuev = data[i - 1].value;
|
|
183
|
+
nextValue = data[i].value;
|
|
184
|
+
if ((prevValuev > 0 && nextValue > 0) ||
|
|
185
|
+
(prevValuev < 0 && nextValue < 0)) {
|
|
186
|
+
pp += 'L' + getX(i) + ' ' + getY(i) + ' ';
|
|
187
|
+
}
|
|
188
|
+
var pointsOb = {
|
|
189
|
+
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
190
|
+
color: nextValue > 0 ? 'green' : 'red'
|
|
191
|
+
};
|
|
192
|
+
ppArray.push(pointsOb);
|
|
193
|
+
setPointsArray(__spreadArray([], __read(ppArray), false));
|
|
194
|
+
/** ************************* For Area Charts *************************/
|
|
195
|
+
var startIndex = -1;
|
|
196
|
+
var endIndex = -1;
|
|
197
|
+
var startX;
|
|
198
|
+
var startY;
|
|
199
|
+
var endY;
|
|
200
|
+
var color = 'green';
|
|
201
|
+
var localArray = [];
|
|
202
|
+
var broken = false;
|
|
203
|
+
pp = 'M' + initialSpacing + ' ' + yAtxAxis;
|
|
204
|
+
for (i = 0; i < data.length - 1; i++) {
|
|
205
|
+
prevValuev = data[i].value;
|
|
206
|
+
nextValue = data[i + 1].value;
|
|
207
|
+
pp += 'L' + getX(i) + ' ' + getY(i) + ' ';
|
|
208
|
+
if ((prevValuev > 0 && nextValue < 0) ||
|
|
209
|
+
(prevValuev < 0 && nextValue > 0)) {
|
|
210
|
+
var prevX = getX(i);
|
|
211
|
+
var prevY = getY(i);
|
|
212
|
+
var nextX = getX(i + 1);
|
|
213
|
+
var nextY = getY(i + 1);
|
|
214
|
+
var slope = (nextY - prevY) / (nextX - prevX);
|
|
215
|
+
var x = (yAtxAxis - prevY) / slope + prevX;
|
|
216
|
+
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' ';
|
|
217
|
+
broken = true;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!broken) {
|
|
222
|
+
i = data.length - 1;
|
|
223
|
+
pp +=
|
|
224
|
+
'L' +
|
|
225
|
+
getX(i) +
|
|
226
|
+
' ' +
|
|
227
|
+
getY(i) +
|
|
228
|
+
' L' +
|
|
229
|
+
getX(i) +
|
|
230
|
+
' ' +
|
|
231
|
+
(yAtxAxis - xAxisThickness / 2);
|
|
232
|
+
}
|
|
233
|
+
localArray.push({
|
|
234
|
+
points: pp,
|
|
235
|
+
color: data[0].value >= 0 ? 'green' : 'red'
|
|
236
|
+
});
|
|
237
|
+
var xs = [];
|
|
238
|
+
data.forEach(function (item, index) {
|
|
239
|
+
var x = getX(index);
|
|
240
|
+
xs.push(x + '');
|
|
241
|
+
});
|
|
242
|
+
pointsArray.forEach(function (item, index) {
|
|
243
|
+
var splitArray = item.points
|
|
244
|
+
.split(' ')
|
|
245
|
+
.filter(function (spItem) { return spItem && spItem !== ' '; });
|
|
246
|
+
if (splitArray[1] === yAtxAxis + '' &&
|
|
247
|
+
!xs.includes(splitArray[0].replace('M', '').replace('L', ''))) {
|
|
248
|
+
startIndex = index;
|
|
249
|
+
startX = splitArray[0].replace('M', '').replace('L', '');
|
|
250
|
+
if (splitArray.length > 3) {
|
|
251
|
+
startY = splitArray[1].replace('M', '').replace('L', '');
|
|
252
|
+
endY = splitArray[3].replace('M', '').replace('L', '');
|
|
253
|
+
if (Number(startY) < Number(endY)) {
|
|
254
|
+
color = 'red';
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
color = 'green';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (splitArray[splitArray.length - 1] === yAtxAxis + '' &&
|
|
262
|
+
!xs.includes(splitArray[splitArray.length - 2].replace('M', '').replace('L', ''))) {
|
|
263
|
+
endIndex = index;
|
|
264
|
+
}
|
|
265
|
+
if (startX) {
|
|
266
|
+
var filPts = '';
|
|
267
|
+
for (var j = startIndex; j <= endIndex; j++) {
|
|
268
|
+
if (pointsArray[j]) {
|
|
269
|
+
filPts += pointsArray[j].points.replaceAll('M', 'L');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
filPts += 'L ' + startX + ' ' + yAtxAxis;
|
|
273
|
+
localArray.push({ points: filPts.replace('L', 'M'), color: color });
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
if (broken) {
|
|
277
|
+
pp = 'M' + getX(data.length - 1) + ' ' + yAtxAxis;
|
|
278
|
+
for (var i_2 = data.length - 1; i_2 > 0; i_2--) {
|
|
279
|
+
prevValuev = data[i_2].value;
|
|
280
|
+
nextValue = data[i_2 - 1].value;
|
|
281
|
+
pp += 'L' + getX(i_2) + ' ' + getY(i_2) + ' ';
|
|
282
|
+
if ((prevValuev > 0 && nextValue < 0) ||
|
|
283
|
+
(prevValuev < 0 && nextValue > 0)) {
|
|
284
|
+
var prevX = getX(i_2);
|
|
285
|
+
var prevY = getY(i_2);
|
|
286
|
+
var nextX = getX(i_2 - 1);
|
|
287
|
+
var nextY = getY(i_2 - 1);
|
|
288
|
+
var slope = (nextY - prevY) / (nextX - prevX);
|
|
289
|
+
var x = (yAtxAxis - prevY) / slope + prevX;
|
|
290
|
+
pp += 'L' + x + ' ' + yAtxAxis + ' ';
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
localArray.push({
|
|
295
|
+
points: pp,
|
|
296
|
+
color: data[data.length - 1].value > 0 ? 'green' : 'red'
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
setFillPointsArray(__spreadArray([], __read(localArray), false));
|
|
300
|
+
setToggle(true);
|
|
301
|
+
}, [
|
|
302
|
+
areaChart,
|
|
303
|
+
containerHeight,
|
|
304
|
+
data,
|
|
305
|
+
dataPointsWidth1,
|
|
306
|
+
initialSpacing,
|
|
307
|
+
spacing,
|
|
308
|
+
xAxisThickness,
|
|
309
|
+
toggle,
|
|
310
|
+
maxValue
|
|
311
|
+
]);
|
|
312
|
+
var horizSections = [{ value: '0' }];
|
|
313
|
+
var stepHeight = (_8 = props.stepHeight) !== null && _8 !== void 0 ? _8 : containerHeight / noOfSections;
|
|
314
|
+
var stepValue = (_9 = props.stepValue) !== null && _9 !== void 0 ? _9 : maxValue / noOfSections;
|
|
315
|
+
var noOfSectionsBelowXAxis = (_10 = props.noOfSectionsBelowXAxis) !== null && _10 !== void 0 ? _10 : -mostNegativeValue / stepValue;
|
|
316
|
+
var thickness1 = (_11 = props.thickness) !== null && _11 !== void 0 ? _11 : LineDefaults.thickness;
|
|
317
|
+
var zIndex = (_12 = props.zIndex) !== null && _12 !== void 0 ? _12 : 0;
|
|
318
|
+
var strokeDashArray1 = props.strokeDashArray;
|
|
319
|
+
var rotateLabel = (_13 = props.rotateLabel) !== null && _13 !== void 0 ? _13 : AxesAndRulesDefaults.rotateLabel;
|
|
320
|
+
var isAnimated = (_14 = props.isAnimated) !== null && _14 !== void 0 ? _14 : LineDefaults.isAnimated;
|
|
321
|
+
var hideDataPoints1 = (_15 = props.hideDataPoints) !== null && _15 !== void 0 ? _15 : LineDefaults.hideDataPoints;
|
|
322
|
+
var color = (_16 = props.color) !== null && _16 !== void 0 ? _16 : 'green';
|
|
323
|
+
var colorNegative = (_17 = props.colorNegative) !== null && _17 !== void 0 ? _17 : 'red';
|
|
324
|
+
var startFillColor = (_18 = props.startFillColor) !== null && _18 !== void 0 ? _18 : 'lightgreen';
|
|
325
|
+
var endFillColor = (_19 = props.endFillColor) !== null && _19 !== void 0 ? _19 : 'white';
|
|
326
|
+
var startOpacity = (_20 = props.startOpacity) !== null && _20 !== void 0 ? _20 : LineDefaults.startOpacity;
|
|
327
|
+
var endOpacity = (_21 = props.endOpacity) !== null && _21 !== void 0 ? _21 : LineDefaults.endOpacity;
|
|
328
|
+
var startFillColorNegative = (_22 = props.startFillColorNegative) !== null && _22 !== void 0 ? _22 : 'pink';
|
|
329
|
+
var endFillColorNegative = (_23 = props.endFillColorNegative) !== null && _23 !== void 0 ? _23 : 'white';
|
|
330
|
+
var startOpacityNegative = (_24 = props.startOpacityNegative) !== null && _24 !== void 0 ? _24 : LineDefaults.startOpacity;
|
|
331
|
+
var endOpacityNegative = (_25 = props.endOpacityNegative) !== null && _25 !== void 0 ? _25 : LineDefaults.endOpacity;
|
|
332
|
+
var gradientDirection = (_26 = props.gradientDirection) !== null && _26 !== void 0 ? _26 : 'vertical';
|
|
333
|
+
var showXAxisIndices = (_27 = props.showXAxisIndices) !== null && _27 !== void 0 ? _27 : AxesAndRulesDefaults.showXAxisIndices;
|
|
334
|
+
var xAxisIndicesHeight = (_28 = props.xAxisIndicesHeight) !== null && _28 !== void 0 ? _28 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
335
|
+
var xAxisIndicesWidth = (_29 = props.xAxisIndicesWidth) !== null && _29 !== void 0 ? _29 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
336
|
+
var xAxisIndicesColor = (_30 = props.xAxisIndicesColor) !== null && _30 !== void 0 ? _30 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
337
|
+
var xAxisTextNumberOfLines = (_31 = props.xAxisTextNumberOfLines) !== null && _31 !== void 0 ? _31 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
338
|
+
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
339
|
+
var showFractionalValues = (_32 = props.showFractionalValues) !== null && _32 !== void 0 ? _32 : AxesAndRulesDefaults.showFractionalValues;
|
|
340
|
+
var yAxisLabelWidth = (_33 = props.yAxisLabelWidth) !== null && _33 !== void 0 ? _33 : (props.hideYAxisText
|
|
341
|
+
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
342
|
+
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
343
|
+
var horizontal = false;
|
|
344
|
+
var yAxisAtTop = false;
|
|
345
|
+
var disableScroll = (_34 = props.disableScroll) !== null && _34 !== void 0 ? _34 : LineDefaults.disableScroll;
|
|
346
|
+
var showScrollIndicator = (_35 = props.showScrollIndicator) !== null && _35 !== void 0 ? _35 : LineDefaults.showScrollIndicator;
|
|
347
|
+
var focusEnabled = (_36 = props.focusEnabled) !== null && _36 !== void 0 ? _36 : LineDefaults.focusEnabled;
|
|
348
|
+
var showDataPointOnFocus = (_37 = props.showDataPointOnFocus) !== null && _37 !== void 0 ? _37 : LineDefaults.showDataPointOnFocus;
|
|
349
|
+
var showStripOnFocus = (_38 = props.showStripOnFocus) !== null && _38 !== void 0 ? _38 : LineDefaults.showStripOnFocus;
|
|
350
|
+
var showTextOnFocus = (_39 = props.showTextOnFocus) !== null && _39 !== void 0 ? _39 : LineDefaults.showTextOnFocus;
|
|
351
|
+
var stripHeight = props.stripHeight;
|
|
352
|
+
var stripWidth = (_40 = props.stripWidth) !== null && _40 !== void 0 ? _40 : LineDefaults.stripWidth;
|
|
353
|
+
var stripColor = (_41 = props.stripColor) !== null && _41 !== void 0 ? _41 : color;
|
|
354
|
+
var stripOpacity = (_42 = props.stripOpacity) !== null && _42 !== void 0 ? _42 : (startOpacity + endOpacity) / 2;
|
|
355
|
+
var unFocusOnPressOut = (_43 = props.unFocusOnPressOut) !== null && _43 !== void 0 ? _43 : LineDefaults.unFocusOnPressOut;
|
|
356
|
+
var delayBeforeUnFocus = (_44 = props.delayBeforeUnFocus) !== null && _44 !== void 0 ? _44 : LineDefaults.delayBeforeUnFocus;
|
|
357
|
+
horizSections.pop();
|
|
358
|
+
for (var i = 0; i <= noOfSections; i++) {
|
|
359
|
+
var value = maxValue - stepValue * i;
|
|
360
|
+
if ((_45 = props.showFractionalValues) !== null && _45 !== void 0 ? _45 : props.roundToDigits) {
|
|
361
|
+
value = parseFloat(value.toFixed((_46 = props.roundToDigits) !== null && _46 !== void 0 ? _46 : 1));
|
|
362
|
+
}
|
|
363
|
+
horizSections.push({
|
|
364
|
+
value: props.yAxisLabelTexts
|
|
365
|
+
? (_47 = props.yAxisLabelTexts[noOfSections - i]) !== null && _47 !== void 0 ? _47 : value.toString()
|
|
366
|
+
: value.toString()
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
var barAndLineChartsWrapperProps = {
|
|
370
|
+
chartType: chartTypes.LINE_BI_COLOR,
|
|
371
|
+
containerHeight: containerHeight,
|
|
372
|
+
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
373
|
+
stepHeight: stepHeight,
|
|
374
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
375
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
376
|
+
horizontal: horizontal,
|
|
377
|
+
rtl: false,
|
|
378
|
+
shiftX: 0,
|
|
379
|
+
shiftY: 0,
|
|
380
|
+
yAxisAtTop: yAxisAtTop,
|
|
381
|
+
initialSpacing: initialSpacing,
|
|
382
|
+
data: data,
|
|
383
|
+
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
384
|
+
secondaryData: [],
|
|
385
|
+
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
386
|
+
xAxisThickness: xAxisThickness,
|
|
387
|
+
totalWidth: totalWidth,
|
|
388
|
+
disableScroll: disableScroll,
|
|
389
|
+
showScrollIndicator: showScrollIndicator,
|
|
390
|
+
scrollToEnd: scrollToEnd,
|
|
391
|
+
scrollToIndex: props.scrollToIndex,
|
|
392
|
+
scrollAnimation: scrollAnimation,
|
|
393
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
394
|
+
indicatorColor: props.indicatorColor,
|
|
395
|
+
setSelectedIndex: setSelectedIndex,
|
|
396
|
+
spacing: spacing,
|
|
397
|
+
showLine: false,
|
|
398
|
+
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
399
|
+
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
400
|
+
maxValue: maxValue,
|
|
401
|
+
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
402
|
+
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
403
|
+
lineBehindBars: false,
|
|
404
|
+
points: pointsArray,
|
|
405
|
+
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
406
|
+
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
407
|
+
remainingScrollViewProps: {},
|
|
408
|
+
// horizSectionProps-
|
|
409
|
+
width: props.width,
|
|
410
|
+
horizSections: horizSections,
|
|
411
|
+
endSpacing: endSpacing,
|
|
412
|
+
horizontalRulesStyle: horizontalRulesStyle,
|
|
413
|
+
noOfSections: noOfSections,
|
|
414
|
+
showFractionalValues: showFractionalValues,
|
|
415
|
+
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
|
416
|
+
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
417
|
+
yAxisOffset: props.yAxisOffset,
|
|
418
|
+
rotateYAxisTexts: 0,
|
|
419
|
+
hideAxesAndRules: props.hideAxesAndRules,
|
|
420
|
+
showXAxisIndices: showXAxisIndices,
|
|
421
|
+
xAxisIndicesHeight: xAxisIndicesHeight,
|
|
422
|
+
xAxisIndicesWidth: xAxisIndicesWidth,
|
|
423
|
+
xAxisIndicesColor: xAxisIndicesColor,
|
|
424
|
+
// These are Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
425
|
+
pointerConfig: undefined,
|
|
426
|
+
getPointerProps: null,
|
|
427
|
+
pointerIndex: 0,
|
|
428
|
+
pointerX: 0,
|
|
429
|
+
pointerY: 0,
|
|
430
|
+
endReachedOffset: (_48 = props.endReachedOffset) !== null && _48 !== void 0 ? _48 : LineDefaults.endReachedOffset
|
|
431
|
+
};
|
|
432
|
+
return {
|
|
433
|
+
toggle: toggle,
|
|
434
|
+
setToggle: setToggle,
|
|
435
|
+
pointsArray: pointsArray,
|
|
436
|
+
setPointsArray: setPointsArray,
|
|
437
|
+
fillPointsArray: fillPointsArray,
|
|
438
|
+
setFillPointsArray: setFillPointsArray,
|
|
439
|
+
selectedIndex: selectedIndex,
|
|
440
|
+
setSelectedIndex: setSelectedIndex,
|
|
441
|
+
containerHeight: containerHeight,
|
|
442
|
+
noOfSections: noOfSections,
|
|
443
|
+
data: data,
|
|
444
|
+
scrollToEnd: scrollToEnd,
|
|
445
|
+
scrollAnimation: scrollAnimation,
|
|
446
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
447
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
448
|
+
animationDuration: animationDuration,
|
|
449
|
+
startIndex1: startIndex1,
|
|
450
|
+
endIndex1: endIndex1,
|
|
451
|
+
initialData: initialData,
|
|
452
|
+
adjustToWidth: adjustToWidth,
|
|
453
|
+
initialSpacing: initialSpacing,
|
|
454
|
+
endSpacing: endSpacing,
|
|
455
|
+
thickness: thickness,
|
|
456
|
+
spacing: spacing,
|
|
457
|
+
xAxisThickness: xAxisThickness,
|
|
458
|
+
dataPointsHeight1: dataPointsHeight1,
|
|
459
|
+
dataPointsWidth1: dataPointsWidth1,
|
|
460
|
+
dataPointsRadius1: dataPointsRadius1,
|
|
461
|
+
dataPointsColor1: dataPointsColor1,
|
|
462
|
+
dataPointsShape1: dataPointsShape1,
|
|
463
|
+
areaChart: areaChart,
|
|
464
|
+
textFontSize1: textFontSize1,
|
|
465
|
+
textColor1: textColor1,
|
|
466
|
+
totalWidth: totalWidth,
|
|
467
|
+
maxItem: maxItem,
|
|
468
|
+
minItem: minItem,
|
|
469
|
+
maxValue: maxValue,
|
|
470
|
+
mostNegativeValue: mostNegativeValue,
|
|
471
|
+
extendedContainerHeight: extendedContainerHeight,
|
|
472
|
+
getX: getX,
|
|
473
|
+
getY: getY,
|
|
474
|
+
yAtxAxis: yAtxAxis,
|
|
475
|
+
stepHeight: stepHeight,
|
|
476
|
+
stepValue: stepValue,
|
|
477
|
+
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
478
|
+
thickness1: thickness1,
|
|
479
|
+
zIndex: zIndex,
|
|
480
|
+
strokeDashArray1: strokeDashArray1,
|
|
481
|
+
rotateLabel: rotateLabel,
|
|
482
|
+
isAnimated: isAnimated,
|
|
483
|
+
hideDataPoints1: hideDataPoints1,
|
|
484
|
+
color: color,
|
|
485
|
+
colorNegative: colorNegative,
|
|
486
|
+
startFillColor: startFillColor,
|
|
487
|
+
endFillColor: endFillColor,
|
|
488
|
+
startOpacity: startOpacity,
|
|
489
|
+
endOpacity: endOpacity,
|
|
490
|
+
startFillColorNegative: startFillColorNegative,
|
|
491
|
+
endFillColorNegative: endFillColorNegative,
|
|
492
|
+
startOpacityNegative: startOpacityNegative,
|
|
493
|
+
endOpacityNegative: endOpacityNegative,
|
|
494
|
+
gradientDirection: gradientDirection,
|
|
495
|
+
showXAxisIndices: showXAxisIndices,
|
|
496
|
+
xAxisIndicesHeight: xAxisIndicesHeight,
|
|
497
|
+
xAxisIndicesWidth: xAxisIndicesWidth,
|
|
498
|
+
xAxisIndicesColor: xAxisIndicesColor,
|
|
499
|
+
xAxisTextNumberOfLines: xAxisTextNumberOfLines,
|
|
500
|
+
horizontalRulesStyle: horizontalRulesStyle,
|
|
501
|
+
showFractionalValues: showFractionalValues,
|
|
502
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
503
|
+
horizontal: horizontal,
|
|
504
|
+
yAxisAtTop: yAxisAtTop,
|
|
505
|
+
disableScroll: disableScroll,
|
|
506
|
+
showScrollIndicator: showScrollIndicator,
|
|
507
|
+
focusEnabled: focusEnabled,
|
|
508
|
+
showDataPointOnFocus: showDataPointOnFocus,
|
|
509
|
+
showStripOnFocus: showStripOnFocus,
|
|
510
|
+
showTextOnFocus: showTextOnFocus,
|
|
511
|
+
stripHeight: stripHeight,
|
|
512
|
+
stripWidth: stripWidth,
|
|
513
|
+
stripColor: stripColor,
|
|
514
|
+
stripOpacity: stripOpacity,
|
|
515
|
+
unFocusOnPressOut: unFocusOnPressOut,
|
|
516
|
+
delayBeforeUnFocus: delayBeforeUnFocus,
|
|
517
|
+
horizSections: horizSections,
|
|
518
|
+
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps
|
|
519
|
+
};
|
|
520
|
+
};
|