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.
Files changed (53) hide show
  1. package/package.json +5 -1
  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,1008 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ var _a, _b;
29
+ import { AxesAndRulesDefaults, BarDefaults, RANGE_ENTER, RANGE_EXIT, STOP, defaultCurvature, defaultLineConfig, loc } from './constants';
30
+ import { CurveType, Framework } from './types';
31
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
32
+ var versionString = require('react-native/package.json').version;
33
+ var versionAr = (_b = (_a = versionString === null || versionString === void 0 ? void 0 : versionString.split) === null || _a === void 0 ? void 0 : _a.call(versionString, '.')) !== null && _b !== void 0 ? _b : '';
34
+ var msb = Number(versionAr[0]);
35
+ var mid = Number(versionAr[1]);
36
+ var lsb = Number(versionAr[2]);
37
+ export var rnVersion = (!isNaN(msb) ? msb : 0) * 1000000 +
38
+ (!isNaN(mid) ? mid : 0) * 10000 +
39
+ (!isNaN(lsb) ? lsb : 0);
40
+ export var getCumulativeWidth = function (data, index, spacing) {
41
+ var cumWidth = 0;
42
+ for (var i = 0; i < index; i++) {
43
+ var barWidth = data[i].barWidth;
44
+ barWidth = barWidth !== null && barWidth !== void 0 ? barWidth : 30;
45
+ cumWidth += barWidth + (spacing !== null && spacing !== void 0 ? spacing : 20);
46
+ }
47
+ return cumWidth;
48
+ };
49
+ export var getLighterColor = function (color) {
50
+ var r;
51
+ var g;
52
+ var b;
53
+ var lighter = '#';
54
+ if (color.startsWith('#')) {
55
+ if (color.length < 7) {
56
+ r = parseInt(color[1], 16);
57
+ g = parseInt(color[2], 16);
58
+ b = parseInt(color[3], 16);
59
+ if (r < 14) {
60
+ r += 2;
61
+ lighter += r.toString(16);
62
+ }
63
+ if (g < 14) {
64
+ g += 2;
65
+ lighter += g.toString(16);
66
+ }
67
+ if (b < 14) {
68
+ b += 2;
69
+ lighter += b.toString(16);
70
+ }
71
+ }
72
+ else {
73
+ r = parseInt(color[1] + color[2], 16);
74
+ g = parseInt(color[3] + color[4], 16);
75
+ b = parseInt(color[5] + color[6], 16);
76
+ if (r < 224) {
77
+ r += 32;
78
+ lighter += r.toString(16);
79
+ }
80
+ if (g < 224) {
81
+ g += 32;
82
+ lighter += g.toString(16);
83
+ }
84
+ if (b < 224) {
85
+ b += 32;
86
+ lighter += b.toString(16);
87
+ }
88
+ }
89
+ }
90
+ return lighter;
91
+ };
92
+ export var svgQuadraticCurvePath = function (points) {
93
+ var path = 'M' + points[0][0] + ',' + points[0][1];
94
+ for (var i = 0; i < points.length - 1; i++) {
95
+ var xMid = (points[i][0] + points[i + 1][0]) / 2;
96
+ var yMid = (points[i][1] + points[i + 1][1]) / 2;
97
+ var cpX1 = (xMid + points[i][0]) / 2;
98
+ var cpX2 = (xMid + points[i + 1][0]) / 2;
99
+ path +=
100
+ 'Q ' +
101
+ cpX1 +
102
+ ', ' +
103
+ points[i][1] +
104
+ ', ' +
105
+ xMid +
106
+ ', ' +
107
+ yMid +
108
+ (' Q ' +
109
+ cpX2 +
110
+ ', ' +
111
+ points[i + 1][1] +
112
+ ', ' +
113
+ points[i + 1][0] +
114
+ ', ' +
115
+ points[i + 1][1]);
116
+ }
117
+ return path;
118
+ };
119
+ export var svgPath = function (points, curveType, curvature) {
120
+ if (!(points === null || points === void 0 ? void 0 : points.length))
121
+ return '';
122
+ if (curveType === CurveType.QUADRATIC) {
123
+ return svgQuadraticCurvePath(points);
124
+ }
125
+ // build the d attributes by looping over the points
126
+ var d = points.reduce(function (acc, point, i, a) {
127
+ return i === 0
128
+ ? "M".concat(point[0], ",").concat(point[1])
129
+ : "".concat(acc, " ").concat(bezierCommand(point, i, a, curvature !== null && curvature !== void 0 ? curvature : defaultCurvature));
130
+ }, '');
131
+ return d;
132
+ };
133
+ var line = function (pointA, pointB) {
134
+ var lengthX = pointB[0] - pointA[0];
135
+ var lengthY = pointB[1] - pointA[1];
136
+ return {
137
+ length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
138
+ angle: Math.atan2(lengthY, lengthX)
139
+ };
140
+ };
141
+ var controlPoint = function (curvature, current, previous, next, reverse) {
142
+ // When 'current' is the first or last point of the array
143
+ // 'previous' or 'next' don't exist.
144
+ // Replace with 'current'
145
+ var p = previous !== null && previous !== void 0 ? previous : current;
146
+ var n = next !== null && next !== void 0 ? next : current;
147
+ // The smoothing ratio
148
+ var smoothing = curvature;
149
+ // Properties of the opposed-line
150
+ var o = line(p, n);
151
+ // If is end-control-point, add PI to the angle to go backward
152
+ var angle = o.angle + (reverse ? Math.PI : 0);
153
+ var length = o.length * smoothing;
154
+ // The control point position is relative to the current point
155
+ var x = current[0] + Math.cos(angle) * length;
156
+ var y = current[1] + Math.sin(angle) * length;
157
+ return [x, y];
158
+ };
159
+ export var bezierCommand = function (point, i, a, curvature) {
160
+ // start control point
161
+ var _a = __read(controlPoint(curvature, a[i - 1], a[i - 2], point), 2), cpsX = _a[0], cpsY = _a[1];
162
+ // end control point
163
+ var _b = __read(controlPoint(curvature, point, a[i - 1], a[i + 1], true), 2), cpeX = _b[0], cpeY = _b[1];
164
+ return "C".concat(cpsX, ",").concat(cpsY, " ").concat(cpeX, ",").concat(cpeY, " ").concat(point[0], ",").concat(point[1]);
165
+ };
166
+ export var getSegmentString = function (lineSegment, index, startDelimeter, endDelimeter) {
167
+ var segment = lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.find(function (segment) { return segment.startIndex === index; });
168
+ return segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '';
169
+ };
170
+ export var getCurvePathWithSegments = function (path, lineSegment, startDelimeter, endDelimeter) {
171
+ if (!(lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.length))
172
+ return path;
173
+ var newPath = '';
174
+ var pathArray = path.split('C');
175
+ var _loop_1 = function (i) {
176
+ var segment = lineSegment === null || lineSegment === void 0 ? void 0 : lineSegment.find(function (segment) { return segment.startIndex === i; });
177
+ newPath +=
178
+ (pathArray[i].startsWith('M') ? '' : 'C') +
179
+ pathArray[i] +
180
+ (segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '');
181
+ };
182
+ for (var i = 0; i < pathArray.length; i++) {
183
+ _loop_1(i);
184
+ }
185
+ return newPath;
186
+ };
187
+ export var getPreviousSegmentsLastPoint = function (isCurved, previousSegment) {
188
+ var prevSegmentLastPoint = isCurved
189
+ ? previousSegment.substring(previousSegment.trim().lastIndexOf(' '))
190
+ : previousSegment
191
+ .substring(previousSegment.lastIndexOf('L'))
192
+ .replace('L', 'M');
193
+ return ((prevSegmentLastPoint.trim()[0] === 'M' ? '' : 'M') + prevSegmentLastPoint);
194
+ };
195
+ export var getPathWithHighlight = function (data, i, highlightedRange, startIndex, endIndex, getX, getY) {
196
+ var path = '';
197
+ var from = highlightedRange.from, to = highlightedRange.to;
198
+ var currentPointRegion = data[i].value < from ? loc.DOWN : data[i].value > to ? loc.UP : loc.IN;
199
+ if (i !== endIndex) {
200
+ var nextPointRegion = data[i + 1].value < from
201
+ ? loc.DOWN
202
+ : data[i + 1].value > to
203
+ ? loc.UP
204
+ : loc.IN;
205
+ if (currentPointRegion !== nextPointRegion ||
206
+ (i === startIndex && currentPointRegion === loc.IN)) {
207
+ var x1 = getX(i);
208
+ var y1 = getY(data[i].value);
209
+ var x2 = getX(i + 1);
210
+ var y2 = getY(data[i + 1].value);
211
+ var m = (y2 - y1) / (x2 - x1);
212
+ var x = 0;
213
+ var y = 0;
214
+ if (i === startIndex && currentPointRegion === loc.IN) {
215
+ // If the 1st point lies IN
216
+ y = y1;
217
+ x = x1;
218
+ path +=
219
+ 'L' +
220
+ x +
221
+ ' ' +
222
+ y +
223
+ ' ' +
224
+ RANGE_ENTER +
225
+ JSON.stringify(highlightedRange) +
226
+ STOP;
227
+ if (nextPointRegion === loc.UP) {
228
+ y = getY(to);
229
+ x = (y - y1) / m + x1;
230
+ path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
231
+ }
232
+ else if (nextPointRegion === loc.DOWN) {
233
+ y = getY(from);
234
+ x = (y - y1) / m + x1;
235
+ path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
236
+ }
237
+ }
238
+ else if (currentPointRegion !== nextPointRegion) {
239
+ if (currentPointRegion === loc.DOWN && nextPointRegion === loc.UP) {
240
+ // if current point is in DOWN and next point is in UP, then we will add 2 points to the the path
241
+ y = getY(from);
242
+ x = (y - y1) / m + x1;
243
+ path +=
244
+ 'L' +
245
+ x +
246
+ ' ' +
247
+ y +
248
+ ' ' +
249
+ RANGE_ENTER +
250
+ JSON.stringify(highlightedRange) +
251
+ STOP;
252
+ y = getY(to);
253
+ x = (y - y1) / m + x1;
254
+ path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
255
+ }
256
+ else if (currentPointRegion === loc.UP &&
257
+ nextPointRegion === loc.DOWN) {
258
+ // if current point is in UP and next point is in DOWN, then we will add 2 points to the the path
259
+ y = getY(to);
260
+ x = (y - y1) / m + x1;
261
+ path +=
262
+ 'L' +
263
+ x +
264
+ ' ' +
265
+ y +
266
+ ' ' +
267
+ RANGE_ENTER +
268
+ JSON.stringify(highlightedRange) +
269
+ STOP;
270
+ y = getY(from);
271
+ x = (y - y1) / m + x1;
272
+ path += 'L' + x + ' ' + y + ' ' + RANGE_EXIT;
273
+ }
274
+ else {
275
+ if ((currentPointRegion === loc.UP && nextPointRegion === loc.IN) ||
276
+ (currentPointRegion === loc.IN && nextPointRegion === loc.UP)) {
277
+ y = getY(to);
278
+ }
279
+ else if ((currentPointRegion === loc.IN && nextPointRegion === loc.DOWN) ||
280
+ (currentPointRegion === loc.DOWN && nextPointRegion === loc.IN)) {
281
+ y = getY(from);
282
+ }
283
+ m = (y2 - y1) / (x2 - x1);
284
+ x = (y - y1) / m + x1;
285
+ var prefix = nextPointRegion === loc.IN
286
+ ? RANGE_ENTER + JSON.stringify(highlightedRange) + STOP
287
+ : RANGE_EXIT;
288
+ path += 'L' + x + ' ' + y + ' ' + prefix;
289
+ }
290
+ }
291
+ }
292
+ }
293
+ else if (currentPointRegion === loc.IN) {
294
+ // If the last point lies IN, add RANGE_EXIT
295
+ path += RANGE_EXIT;
296
+ }
297
+ return path;
298
+ };
299
+ export var getRegionPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, stop, endDelimeter) {
300
+ var _a, _b;
301
+ var ar = [{ d: '', color: '', strokeWidth: 0 }];
302
+ var tempStr = points;
303
+ if (!points.startsWith(startDelimeter)) {
304
+ /** ******************** line upto first segment *****************/
305
+ var lineSvgProps = {
306
+ d: points.substring(0, points.indexOf(startDelimeter)),
307
+ color: color,
308
+ strokeWidth: currentLineThickness || thickness
309
+ };
310
+ if (strokeDashArray) {
311
+ lineSvgProps.strokeDashArray = strokeDashArray;
312
+ }
313
+ ar.push(lineSvgProps);
314
+ }
315
+ while (tempStr.includes(startDelimeter)) {
316
+ var startDelimeterIndex = tempStr.indexOf(startDelimeter);
317
+ var stopIndex = tempStr.indexOf(stop);
318
+ var endDelimeterIndex = tempStr.indexOf(endDelimeter);
319
+ var segmentConfigString = tempStr.substring(startDelimeterIndex + startDelimeter.length, stopIndex);
320
+ var segmentConfig = JSON.parse(segmentConfigString);
321
+ var segment = tempStr.substring(stopIndex + stop.length, endDelimeterIndex);
322
+ var previousSegment = ar[ar.length - 1].d;
323
+ var moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(isCurved, previousSegment);
324
+ /** ******************** segment line *****************/
325
+ var lineSvgProps = {
326
+ d: moveToLastPointOfPreviousSegment + segment,
327
+ color: (_a = segmentConfig.color) !== null && _a !== void 0 ? _a : color,
328
+ strokeWidth: (_b = segmentConfig.thickness) !== null && _b !== void 0 ? _b : (currentLineThickness || thickness)
329
+ };
330
+ if (segmentConfig.strokeDashArray) {
331
+ lineSvgProps.strokeDashArray = segmentConfig.strokeDashArray;
332
+ }
333
+ ar.push(lineSvgProps);
334
+ tempStr = tempStr.substring(endDelimeterIndex + endDelimeter.length);
335
+ var nextDelimiterIndex = tempStr.indexOf(startDelimeter);
336
+ var stringUptoNextSegment = tempStr.substring(0, nextDelimiterIndex);
337
+ /** ******************** line upto the next segment *****************/
338
+ if (nextDelimiterIndex !== -1 &&
339
+ stringUptoNextSegment.includes(isCurved ? 'C' : 'L')) {
340
+ var previousSegment_1 = ar[ar.length - 1].d;
341
+ var moveToLastPointOfPreviousSegment_1 = getPreviousSegmentsLastPoint(isCurved, previousSegment_1);
342
+ var lineSvgProps_1 = {
343
+ d: moveToLastPointOfPreviousSegment_1 + ' ' + stringUptoNextSegment,
344
+ color: color,
345
+ strokeWidth: currentLineThickness || thickness
346
+ };
347
+ if (strokeDashArray) {
348
+ lineSvgProps_1.strokeDashArray = strokeDashArray;
349
+ }
350
+ ar.push(lineSvgProps_1);
351
+ }
352
+ }
353
+ /** ******************** line after the last segment *****************/
354
+ if (tempStr.length) {
355
+ var previousSegment = ar[ar.length - 1].d;
356
+ var moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(isCurved, previousSegment);
357
+ var lineSvgProps = {
358
+ d: moveToLastPointOfPreviousSegment + tempStr,
359
+ color: color,
360
+ strokeWidth: currentLineThickness || thickness
361
+ };
362
+ if (strokeDashArray) {
363
+ lineSvgProps.strokeDashArray = strokeDashArray;
364
+ }
365
+ ar.push(lineSvgProps);
366
+ }
367
+ ar.shift();
368
+ return ar;
369
+ };
370
+ export var getSegmentedPathObjects = function (points, color, currentLineThickness, thickness, strokeDashArray, isCurved, startDelimeter, endDelimeter) {
371
+ var _a, _b;
372
+ var ar = [{ d: '', color: '', strokeWidth: 0 }];
373
+ var tempStr = points;
374
+ if (!points.startsWith(startDelimeter)) {
375
+ /** ******************** line upto first segment *****************/
376
+ var lineSvgProps = {
377
+ d: points.substring(0, points.indexOf(startDelimeter)),
378
+ color: color,
379
+ strokeWidth: currentLineThickness || thickness
380
+ };
381
+ if (strokeDashArray) {
382
+ lineSvgProps.strokeDashArray = strokeDashArray;
383
+ }
384
+ ar.push(lineSvgProps);
385
+ }
386
+ while (tempStr.includes(startDelimeter)) {
387
+ var startDelimeterIndex = tempStr.indexOf(startDelimeter);
388
+ var endDelimeterIndex = tempStr.indexOf(endDelimeter);
389
+ var segmentConfigString = tempStr.substring(startDelimeterIndex + startDelimeter.length, endDelimeterIndex);
390
+ var segmentConfig = JSON.parse(segmentConfigString);
391
+ var startIndex = segmentConfig.startIndex, endIndex = segmentConfig.endIndex;
392
+ var segmentLength = endIndex - startIndex;
393
+ var segment = tempStr.substring(endDelimeterIndex + endDelimeter.length);
394
+ var c = 0;
395
+ var s = 0;
396
+ var i = void 0;
397
+ for (i = 0; i < segment.length; i++) {
398
+ if (segment[i] === (isCurved ? 'C' : 'L'))
399
+ c++;
400
+ if (c === segmentLength) {
401
+ if (segment[i] === ' ')
402
+ s++;
403
+ if (s === (isCurved ? 3 : 2))
404
+ break;
405
+ }
406
+ }
407
+ segment = segment.substring(0, i);
408
+ var previousSegment = ar[ar.length - 1].d;
409
+ var moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(isCurved, previousSegment);
410
+ /** ******************** segment line *****************/
411
+ var lineSvgProps = {
412
+ d: moveToLastPointOfPreviousSegment + segment,
413
+ color: (_a = segmentConfig.color) !== null && _a !== void 0 ? _a : color,
414
+ strokeWidth: (_b = segmentConfig.thickness) !== null && _b !== void 0 ? _b : (currentLineThickness || thickness)
415
+ };
416
+ if (segmentConfig.strokeDashArray) {
417
+ lineSvgProps.strokeDashArray = segmentConfig.strokeDashArray;
418
+ }
419
+ ar.push(lineSvgProps);
420
+ tempStr = tempStr.substring(endDelimeterIndex + endDelimeter.length + i);
421
+ var nextDelimiterIndex = tempStr.indexOf(startDelimeter);
422
+ var stringUptoNextSegment = tempStr.substring(0, nextDelimiterIndex);
423
+ /** ******************** line upto the next segment *****************/
424
+ if (nextDelimiterIndex !== -1 &&
425
+ stringUptoNextSegment.includes(isCurved ? 'C' : 'L')) {
426
+ var previousSegment_2 = ar[ar.length - 1].d;
427
+ var moveToLastPointOfPreviousSegment_2 = getPreviousSegmentsLastPoint(isCurved, previousSegment_2);
428
+ var lineSvgProps_2 = {
429
+ d: moveToLastPointOfPreviousSegment_2 + ' ' + stringUptoNextSegment,
430
+ color: color,
431
+ strokeWidth: currentLineThickness || thickness
432
+ };
433
+ if (strokeDashArray) {
434
+ lineSvgProps_2.strokeDashArray = strokeDashArray;
435
+ }
436
+ ar.push(lineSvgProps_2);
437
+ }
438
+ }
439
+ /** ******************** line after the last segment *****************/
440
+ if (tempStr.length) {
441
+ var previousSegment = ar[ar.length - 1].d;
442
+ var moveToLastPointOfPreviousSegment = getPreviousSegmentsLastPoint(isCurved, previousSegment);
443
+ var lineSvgProps = {
444
+ d: moveToLastPointOfPreviousSegment + tempStr,
445
+ color: color,
446
+ strokeWidth: currentLineThickness || thickness
447
+ };
448
+ if (strokeDashArray) {
449
+ lineSvgProps.strokeDashArray = strokeDashArray;
450
+ }
451
+ ar.push(lineSvgProps);
452
+ }
453
+ ar.shift();
454
+ return ar;
455
+ };
456
+ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength, arrowWidth, showArrowBase) {
457
+ var dataLineSlope = (arrowTipY - y1) / (arrowTipX - x1);
458
+ var d = arrowLength !== null && arrowLength !== void 0 ? arrowLength : 0;
459
+ var d2 = (arrowWidth !== null && arrowWidth !== void 0 ? arrowWidth : 0) / 2;
460
+ var interSectionX = arrowTipX - Math.sqrt((d * d) / (dataLineSlope * dataLineSlope + 1));
461
+ var interSectionY = arrowTipY - dataLineSlope * (arrowTipX - interSectionX);
462
+ var arrowBasex1, arrowBaseY1, arrowBaseX2, arrowBaseY2;
463
+ if (dataLineSlope === 0) {
464
+ arrowBasex1 = interSectionX;
465
+ arrowBaseY1 = interSectionY - d2;
466
+ arrowBaseX2 = interSectionX;
467
+ arrowBaseY2 = interSectionY + d2;
468
+ }
469
+ else {
470
+ var arrowBaseSlope = -1 / dataLineSlope;
471
+ arrowBasex1 =
472
+ interSectionX -
473
+ Math.sqrt((d2 * d2) / (arrowBaseSlope * arrowBaseSlope + 1));
474
+ arrowBaseY1 = interSectionY - arrowBaseSlope * (interSectionX - arrowBasex1);
475
+ arrowBaseX2 =
476
+ interSectionX +
477
+ Math.sqrt((d2 * d2) / (arrowBaseSlope * arrowBaseSlope + 1));
478
+ arrowBaseY2 = interSectionY + arrowBaseSlope * (interSectionX - arrowBasex1);
479
+ }
480
+ var arrowPoints = " M".concat(interSectionX, " ").concat(interSectionY);
481
+ arrowPoints += " ".concat(showArrowBase ? 'L' : 'M').concat(arrowBasex1, " ").concat(arrowBaseY1);
482
+ arrowPoints += " L".concat(arrowTipX, " ").concat(arrowTipY);
483
+ arrowPoints += " M".concat(interSectionX, " ").concat(interSectionY);
484
+ arrowPoints += " ".concat(showArrowBase ? 'L' : 'M').concat(arrowBaseX2, " ").concat(arrowBaseY2);
485
+ arrowPoints += " L".concat(arrowTipX, " ").concat(arrowTipY);
486
+ return arrowPoints;
487
+ };
488
+ export var getAxesAndRulesProps = function (props, stepValue, maxValue) {
489
+ var _a, _b, _c;
490
+ var secondaryYAxis = !props.secondaryYAxis || props.secondaryYAxis === true
491
+ ? {}
492
+ : props.secondaryYAxis;
493
+ var axesAndRulesProps = {
494
+ yAxisSide: props.yAxisSide,
495
+ yAxisLabelContainerStyle: props.yAxisLabelContainerStyle,
496
+ yAxisColor: props.yAxisColor,
497
+ yAxisExtraHeight: props.yAxisExtraHeight,
498
+ trimYAxisAtTop: props.trimYAxisAtTop,
499
+ overflowTop: props.overflowTop,
500
+ yAxisThickness: props.yAxisThickness,
501
+ xAxisColor: props.xAxisColor,
502
+ xAxisLength: props.xAxisLength,
503
+ xAxisType: props.xAxisType,
504
+ xAxisTextNumberOfLines: (_a = props.xAxisTextNumberOfLines) !== null && _a !== void 0 ? _a : 1,
505
+ xAxisLabelsHeight: props.xAxisLabelsHeight,
506
+ xAxisLabelsVerticalShift: props.xAxisLabelsVerticalShift,
507
+ dashWidth: props.dashWidth,
508
+ dashGap: props.dashGap,
509
+ backgroundColor: props.backgroundColor,
510
+ hideRules: props.hideRules,
511
+ rulesLength: props.rulesLength,
512
+ rulesType: props.rulesType,
513
+ rulesThickness: props.rulesThickness,
514
+ rulesColor: props.rulesColor,
515
+ rulesConfigArray: props.rulesConfigArray,
516
+ showYAxisIndices: props.showYAxisIndices,
517
+ yAxisIndicesHeight: props.yAxisIndicesHeight,
518
+ yAxisIndicesWidth: props.yAxisIndicesWidth,
519
+ yAxisIndicesColor: props.yAxisIndicesColor,
520
+ hideOrigin: props.hideOrigin,
521
+ hideYAxisText: props.hideYAxisText,
522
+ yAxisTextNumberOfLines: props.yAxisTextNumberOfLines,
523
+ yAxisLabelPrefix: props.yAxisLabelPrefix,
524
+ yAxisLabelSuffix: props.yAxisLabelSuffix,
525
+ yAxisTextStyle: props.yAxisTextStyle,
526
+ referenceLinesConfig: {
527
+ showReferenceLine1: props.showReferenceLine1,
528
+ referenceLine1Position: props.referenceLine1Position,
529
+ referenceLine1Config: props.referenceLine1Config,
530
+ showReferenceLine2: props.showReferenceLine2,
531
+ referenceLine2Position: props.referenceLine2Position,
532
+ referenceLine2Config: props.referenceLine2Config,
533
+ showReferenceLine3: props.showReferenceLine3,
534
+ referenceLine3Position: props.referenceLine3Position,
535
+ referenceLine3Config: props.referenceLine3Config,
536
+ referenceLinesOverChartContent: props.referenceLinesOverChartContent
537
+ },
538
+ showVerticalLines: props.showVerticalLines,
539
+ verticalLinesThickness: props.verticalLinesThickness,
540
+ verticalLinesHeight: props.verticalLinesHeight,
541
+ verticalLinesColor: props.verticalLinesColor,
542
+ verticalLinesShift: props.verticalLinesShift,
543
+ verticalLinesZIndex: props.verticalLinesZIndex,
544
+ verticalLinesSpacing: props.verticalLinesSpacing,
545
+ noOfVerticalLines: props.noOfVerticalLines,
546
+ // specific to Line charts-
547
+ verticalLinesUptoDataPoint: props.verticalLinesUptoDataPoint,
548
+ roundToDigits: props.roundToDigits,
549
+ stepValue: stepValue,
550
+ secondaryYAxis: props.secondaryYAxis,
551
+ formatYLabel: props.formatYLabel
552
+ };
553
+ if (((_b = props.secondaryYAxis) !== null && _b !== void 0 ? _b : (_c = props.lineConfig) === null || _c === void 0 ? void 0 : _c.isSecondary) &&
554
+ maxValue !== undefined) {
555
+ axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: maxValue });
556
+ }
557
+ return axesAndRulesProps;
558
+ };
559
+ export var getExtendedContainerHeightWithPadding = function (containerHeight, overflowTop) { return containerHeight + (overflowTop !== null && overflowTop !== void 0 ? overflowTop : 0) + 10; };
560
+ export var getSecondaryDataWithOffsetIncluded = function (secondaryData, secondaryYAxis, showDataPointsForMissingValues, interpolateMissingValues, onlyPositive) {
561
+ if (!secondaryData)
562
+ return secondaryData;
563
+ var nullishHandledData = getInterpolatedData(secondaryData, showDataPointsForMissingValues, interpolateMissingValues, onlyPositive);
564
+ if (secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset) {
565
+ return nullishHandledData.map(function (item) {
566
+ var _a;
567
+ item.value = item.value - ((_a = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset) !== null && _a !== void 0 ? _a : 0);
568
+ return item;
569
+ });
570
+ }
571
+ return nullishHandledData;
572
+ };
573
+ export var getArrowProperty = function (property, count, props, defaultArrowConfig) {
574
+ var _a, _b, _c, _d;
575
+ var arrowNumber = "arrowConfig".concat(count);
576
+ return ((_d = (_b = (_a = props[arrowNumber]) === null || _a === void 0 ? void 0 : _a[property]) !== null && _b !== void 0 ? _b : (_c = props['arrowConfig']) === null || _c === void 0 ? void 0 : _c[property]) !== null && _d !== void 0 ? _d : defaultArrowConfig[property]);
577
+ };
578
+ export var getAllArrowProperties = function (props, defaultArrowConfig) {
579
+ var _a, _b, _c, _d, _e, _f;
580
+ var arrowLength1 = getArrowProperty('length', 1, props, defaultArrowConfig);
581
+ var arrowWidth1 = getArrowProperty('width', 1, props, defaultArrowConfig);
582
+ var arrowStrokeWidth1 = getArrowProperty('strokeWidth', 1, props, defaultArrowConfig);
583
+ var arrowStrokeColor1 = getArrowProperty('strokeColor', 1, props, defaultArrowConfig);
584
+ var arrowFillColor1 = getArrowProperty('fillColor', 1, props, defaultArrowConfig);
585
+ var showArrowBase1 = getArrowProperty('showArrowBase', 1, props, defaultArrowConfig);
586
+ var arrowLength2 = getArrowProperty('length', 2, props, defaultArrowConfig);
587
+ var arrowWidth2 = getArrowProperty('width', 2, props, defaultArrowConfig);
588
+ var arrowStrokeWidth2 = getArrowProperty('strokeWidth', 2, props, defaultArrowConfig);
589
+ var arrowStrokeColor2 = getArrowProperty('strokeColor', 2, props, defaultArrowConfig);
590
+ var arrowFillColor2 = getArrowProperty('fillColor', 2, props, defaultArrowConfig);
591
+ var showArrowBase2 = getArrowProperty('showArrowBase', 2, props, defaultArrowConfig);
592
+ var arrowLength3 = getArrowProperty('length', 3, props, defaultArrowConfig);
593
+ var arrowWidth3 = getArrowProperty('width', 3, props, defaultArrowConfig);
594
+ var arrowStrokeWidth3 = getArrowProperty('strokeWidth', 3, props, defaultArrowConfig);
595
+ var arrowStrokeColor3 = getArrowProperty('strokeColor', 3, props, defaultArrowConfig);
596
+ var arrowFillColor3 = getArrowProperty('fillColor', 3, props, defaultArrowConfig);
597
+ var showArrowBase3 = getArrowProperty('showArrowBase', 3, props, defaultArrowConfig);
598
+ var arrowLength4 = getArrowProperty('length', 4, props, defaultArrowConfig);
599
+ var arrowWidth4 = getArrowProperty('width', 4, props, defaultArrowConfig);
600
+ var arrowStrokeWidth4 = getArrowProperty('strokeWidth', 4, props, defaultArrowConfig);
601
+ var arrowStrokeColor4 = getArrowProperty('strokeColor', 4, props, defaultArrowConfig);
602
+ var arrowFillColor4 = getArrowProperty('fillColor', 4, props, defaultArrowConfig);
603
+ var showArrowBase4 = getArrowProperty('showArrowBase', 4, props, defaultArrowConfig);
604
+ var arrowLength5 = getArrowProperty('length', 5, props, defaultArrowConfig);
605
+ var arrowWidth5 = getArrowProperty('width', 5, props, defaultArrowConfig);
606
+ var arrowStrokeWidth5 = getArrowProperty('strokeWidth', 5, props, defaultArrowConfig);
607
+ var arrowStrokeColor5 = getArrowProperty('strokeColor', 5, props, defaultArrowConfig);
608
+ var arrowFillColor5 = getArrowProperty('fillColor', 5, props, defaultArrowConfig);
609
+ var showArrowBase5 = getArrowProperty('showArrowBase', 5, props, defaultArrowConfig);
610
+ var arrowLengthsFromSet = (_a = props.dataSet) === null || _a === void 0 ? void 0 : _a.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : arrowLength1; });
611
+ var arrowWidthsFromSet = (_b = props.dataSet) === null || _b === void 0 ? void 0 : _b.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : arrowWidth1; });
612
+ var arrowStrokeWidthsFromSet = (_c = props.dataSet) === null || _c === void 0 ? void 0 : _c.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.strokeWidth) !== null && _b !== void 0 ? _b : arrowStrokeWidth1; });
613
+ var arrowStrokeColorsFromSet = (_d = props.dataSet) === null || _d === void 0 ? void 0 : _d.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.strokeColor) !== null && _b !== void 0 ? _b : arrowStrokeColor1; });
614
+ var arrowFillColorsFromSet = (_e = props.dataSet) === null || _e === void 0 ? void 0 : _e.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor) !== null && _b !== void 0 ? _b : arrowFillColor1; });
615
+ var showArrowBasesFromSet = (_f = props.dataSet) === null || _f === void 0 ? void 0 : _f.map(function (item) { var _a, _b; return (_b = (_a = item === null || item === void 0 ? void 0 : item.arrowConfig) === null || _a === void 0 ? void 0 : _a.showArrowBase) !== null && _b !== void 0 ? _b : showArrowBase1; });
616
+ return {
617
+ arrowLength1: arrowLength1,
618
+ arrowWidth1: arrowWidth1,
619
+ arrowStrokeWidth1: arrowStrokeWidth1,
620
+ arrowStrokeColor1: arrowStrokeColor1,
621
+ arrowFillColor1: arrowFillColor1,
622
+ showArrowBase1: showArrowBase1,
623
+ arrowLength2: arrowLength2,
624
+ arrowWidth2: arrowWidth2,
625
+ arrowStrokeWidth2: arrowStrokeWidth2,
626
+ arrowStrokeColor2: arrowStrokeColor2,
627
+ arrowFillColor2: arrowFillColor2,
628
+ showArrowBase2: showArrowBase2,
629
+ arrowLength3: arrowLength3,
630
+ arrowWidth3: arrowWidth3,
631
+ arrowStrokeWidth3: arrowStrokeWidth3,
632
+ arrowStrokeColor3: arrowStrokeColor3,
633
+ arrowFillColor3: arrowFillColor3,
634
+ showArrowBase3: showArrowBase3,
635
+ arrowLength4: arrowLength4,
636
+ arrowWidth4: arrowWidth4,
637
+ arrowStrokeWidth4: arrowStrokeWidth4,
638
+ arrowStrokeColor4: arrowStrokeColor4,
639
+ arrowFillColor4: arrowFillColor4,
640
+ showArrowBase4: showArrowBase4,
641
+ arrowLength5: arrowLength5,
642
+ arrowWidth5: arrowWidth5,
643
+ arrowStrokeWidth5: arrowStrokeWidth5,
644
+ arrowStrokeColor5: arrowStrokeColor5,
645
+ arrowFillColor5: arrowFillColor5,
646
+ showArrowBase5: showArrowBase5,
647
+ arrowLengthsFromSet: arrowLengthsFromSet,
648
+ arrowWidthsFromSet: arrowWidthsFromSet,
649
+ arrowStrokeWidthsFromSet: arrowStrokeWidthsFromSet,
650
+ arrowStrokeColorsFromSet: arrowStrokeColorsFromSet,
651
+ arrowFillColorsFromSet: arrowFillColorsFromSet,
652
+ showArrowBasesFromSet: showArrowBasesFromSet
653
+ };
654
+ };
655
+ export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFractionalValues) {
656
+ if (showFractionalValues !== null && showFractionalValues !== void 0 ? showFractionalValues : roundToDigits) {
657
+ maxItem *= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
658
+ maxItem = maxItem + (10 - (maxItem % 10));
659
+ maxItem /= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
660
+ maxItem = parseFloat(maxItem.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1));
661
+ if (minItem !== 0) {
662
+ minItem *= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
663
+ minItem = minItem - (10 + (minItem % 10));
664
+ minItem /= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
665
+ minItem = parseFloat(minItem.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1));
666
+ }
667
+ }
668
+ else {
669
+ maxItem = maxItem + (10 - (maxItem % 10));
670
+ if (minItem !== 0) {
671
+ minItem = minItem - (10 + (minItem % 10));
672
+ }
673
+ }
674
+ return { maxItem: maxItem, minItem: minItem };
675
+ };
676
+ export var computeMaxAndMinItems = function (data, roundToDigits, showFractionalValues) {
677
+ if (!(data === null || data === void 0 ? void 0 : data.length)) {
678
+ return { maxItem: 0, minItem: 0 };
679
+ }
680
+ var maxItem = 0;
681
+ var minItem = 0;
682
+ data.forEach(function (item) {
683
+ if (item.value > maxItem) {
684
+ maxItem = item.value;
685
+ }
686
+ if (item.value < minItem) {
687
+ minItem = item.value;
688
+ }
689
+ });
690
+ return maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
691
+ };
692
+ export var getLabelTextUtil = function (val, index, showFractionalValues, yAxisLabelTexts, yAxisOffset, yAxisLabelPrefix, yAxisLabelSuffix, roundToDigits, formatYLabel) {
693
+ var _a, _b;
694
+ var label = '';
695
+ if (showFractionalValues !== null && showFractionalValues !== void 0 ? showFractionalValues : (yAxisLabelTexts === null || yAxisLabelTexts === void 0 ? void 0 : yAxisLabelTexts[index]) !== undefined) {
696
+ if (yAxisLabelTexts === null || yAxisLabelTexts === void 0 ? void 0 : yAxisLabelTexts[index])
697
+ return val;
698
+ if (val) {
699
+ label = isNaN(Number(val))
700
+ ? val
701
+ : (Number(val) + (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)).toFixed(roundToDigits);
702
+ }
703
+ else {
704
+ label = (_a = yAxisOffset === null || yAxisOffset === void 0 ? void 0 : yAxisOffset.toString()) !== null && _a !== void 0 ? _a : '0';
705
+ }
706
+ }
707
+ else {
708
+ if (val) {
709
+ label = val.toString().split('.')[0];
710
+ label = (Number(label) + (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)).toString();
711
+ }
712
+ else {
713
+ label = (_b = yAxisOffset === null || yAxisOffset === void 0 ? void 0 : yAxisOffset.toString()) !== null && _b !== void 0 ? _b : '0';
714
+ }
715
+ }
716
+ return (yAxisLabelPrefix +
717
+ (formatYLabel ? formatYLabel(label) : label) +
718
+ yAxisLabelSuffix);
719
+ };
720
+ export var getXForLineInBar = function (index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) {
721
+ var _a;
722
+ return yAxisLabelWidth +
723
+ firstBarWidth / 2 +
724
+ lineConfig.initialSpacing +
725
+ (currentBarWidth + ((_a = lineConfig.spacing) !== null && _a !== void 0 ? _a : spacing)) * index +
726
+ lineConfig.shiftX -
727
+ lineConfig.dataPointsWidth / 2 -
728
+ 4;
729
+ };
730
+ export var getYForLineInBar = function (value, shiftY, containerHeight, maxValue) {
731
+ return containerHeight - (shiftY !== null && shiftY !== void 0 ? shiftY : 0) - ((value !== null && value !== void 0 ? value : 0) * containerHeight) / maxValue;
732
+ };
733
+ export var clone = function (obj) {
734
+ if (obj === null || typeof obj !== 'object' || 'isActiveClone' in obj) {
735
+ return obj;
736
+ }
737
+ var temp;
738
+ if (obj instanceof Date)
739
+ temp = new Date(obj);
740
+ else
741
+ temp = obj.constructor();
742
+ for (var key in obj) {
743
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
744
+ obj.isActiveClone = null;
745
+ temp[key] = clone(obj[key]);
746
+ delete obj.isActiveClone;
747
+ }
748
+ }
749
+ return temp;
750
+ };
751
+ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing) {
752
+ 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;
753
+ return {
754
+ initialSpacing: (_b = (_a = lineConfig.initialSpacing) !== null && _a !== void 0 ? _a : barInitialSpacing) !== null && _b !== void 0 ? _b : defaultLineConfig.initialSpacing,
755
+ spacing: lineConfig.spacing,
756
+ curved: (_c = lineConfig.curved) !== null && _c !== void 0 ? _c : defaultLineConfig.curved,
757
+ curvature: (_d = lineConfig.curvature) !== null && _d !== void 0 ? _d : defaultLineConfig.curvature,
758
+ curveType: (_e = lineConfig.curveType) !== null && _e !== void 0 ? _e : defaultLineConfig.curveType,
759
+ isAnimated: (_f = lineConfig.isAnimated) !== null && _f !== void 0 ? _f : defaultLineConfig.isAnimated,
760
+ animationDuration: (_g = lineConfig.animationDuration) !== null && _g !== void 0 ? _g : defaultLineConfig.animationDuration,
761
+ thickness: (_h = lineConfig.thickness) !== null && _h !== void 0 ? _h : defaultLineConfig.thickness,
762
+ color: (_j = lineConfig.color) !== null && _j !== void 0 ? _j : defaultLineConfig.color,
763
+ hideDataPoints: (_k = lineConfig.hideDataPoints) !== null && _k !== void 0 ? _k : defaultLineConfig.hideDataPoints,
764
+ dataPointsShape: (_l = lineConfig.dataPointsShape) !== null && _l !== void 0 ? _l : defaultLineConfig.dataPointsShape,
765
+ dataPointsHeight: (_m = lineConfig.dataPointsHeight) !== null && _m !== void 0 ? _m : defaultLineConfig.dataPointsHeight,
766
+ dataPointsWidth: (_o = lineConfig.dataPointsWidth) !== null && _o !== void 0 ? _o : defaultLineConfig.dataPointsWidth,
767
+ dataPointsColor: (_p = lineConfig.dataPointsColor) !== null && _p !== void 0 ? _p : defaultLineConfig.dataPointsColor,
768
+ dataPointsRadius: (_q = lineConfig.dataPointsRadius) !== null && _q !== void 0 ? _q : defaultLineConfig.dataPointsRadius,
769
+ textColor: (_r = lineConfig.textColor) !== null && _r !== void 0 ? _r : defaultLineConfig.textColor,
770
+ textFontSize: (_s = lineConfig.textFontSize) !== null && _s !== void 0 ? _s : defaultLineConfig.textFontSize,
771
+ textShiftX: (_t = lineConfig.textShiftX) !== null && _t !== void 0 ? _t : defaultLineConfig.textShiftX,
772
+ textShiftY: (_u = lineConfig.textShiftY) !== null && _u !== void 0 ? _u : defaultLineConfig.textShiftY,
773
+ shiftX: (_v = lineConfig.shiftX) !== null && _v !== void 0 ? _v : defaultLineConfig.shiftX,
774
+ shiftY: (_w = lineConfig.shiftY) !== null && _w !== void 0 ? _w : defaultLineConfig.shiftY,
775
+ delay: (_x = lineConfig.delay) !== null && _x !== void 0 ? _x : defaultLineConfig.delay,
776
+ startIndex: (_y = lineConfig.startIndex) !== null && _y !== void 0 ? _y : defaultLineConfig.startIndex,
777
+ endIndex: lineConfig.endIndex === 0
778
+ ? 0
779
+ : (_z = lineConfig.endIndex) !== null && _z !== void 0 ? _z : defaultLineConfig.endIndex,
780
+ showArrow: (_0 = lineConfig.showArrow) !== null && _0 !== void 0 ? _0 : defaultLineConfig.showArrow,
781
+ arrowConfig: {
782
+ length: (_2 = (_1 = lineConfig.arrowConfig) === null || _1 === void 0 ? void 0 : _1.length) !== null && _2 !== void 0 ? _2 : (_3 = defaultLineConfig.arrowConfig) === null || _3 === void 0 ? void 0 : _3.length,
783
+ width: (_5 = (_4 = lineConfig.arrowConfig) === null || _4 === void 0 ? void 0 : _4.width) !== null && _5 !== void 0 ? _5 : (_6 = defaultLineConfig.arrowConfig) === null || _6 === void 0 ? void 0 : _6.width,
784
+ strokeWidth: (_8 = (_7 = lineConfig.arrowConfig) === null || _7 === void 0 ? void 0 : _7.strokeWidth) !== null && _8 !== void 0 ? _8 : (_9 = defaultLineConfig.arrowConfig) === null || _9 === void 0 ? void 0 : _9.strokeWidth,
785
+ strokeColor: (_11 = (_10 = lineConfig.arrowConfig) === null || _10 === void 0 ? void 0 : _10.strokeColor) !== null && _11 !== void 0 ? _11 : (_12 = defaultLineConfig.arrowConfig) === null || _12 === void 0 ? void 0 : _12.strokeColor,
786
+ fillColor: (_14 = (_13 = lineConfig.arrowConfig) === null || _13 === void 0 ? void 0 : _13.fillColor) !== null && _14 !== void 0 ? _14 : (_15 = defaultLineConfig.arrowConfig) === null || _15 === void 0 ? void 0 : _15.fillColor,
787
+ showArrowBase: (_17 = (_16 = lineConfig.arrowConfig) === null || _16 === void 0 ? void 0 : _16.showArrowBase) !== null && _17 !== void 0 ? _17 : (_18 = defaultLineConfig.arrowConfig) === null || _18 === void 0 ? void 0 : _18.showArrowBase
788
+ },
789
+ customDataPoint: lineConfig.customDataPoint,
790
+ isSecondary: (_19 = lineConfig.isSecondary) !== null && _19 !== void 0 ? _19 : defaultLineConfig.isSecondary
791
+ };
792
+ };
793
+ export var getNoOfSections = function (noOfSections, maxValue, stepValue) {
794
+ return maxValue && stepValue
795
+ ? maxValue / stepValue
796
+ : noOfSections !== null && noOfSections !== void 0 ? noOfSections : AxesAndRulesDefaults.noOfSections;
797
+ };
798
+ export var getMaxValue = function (maxValue, stepValue, noOfSections, maxItem) { return maxValue !== null && maxValue !== void 0 ? maxValue : (stepValue ? stepValue * noOfSections : maxItem); };
799
+ export var getBarFrontColor = function (isFocused, focusedBarConfig, itemFrontColor, frontColor, isThreeD) {
800
+ var _a, _b;
801
+ if (isFocused) {
802
+ return ((_a = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.color) !== null && _a !== void 0 ? _a : (isThreeD
803
+ ? BarDefaults.focusedThreeDBarFrontColor
804
+ : BarDefaults.focusedBarFrontColor));
805
+ }
806
+ return ((_b = itemFrontColor !== null && itemFrontColor !== void 0 ? itemFrontColor : frontColor) !== null && _b !== void 0 ? _b : (isThreeD ? BarDefaults.threeDBarFrontColor : BarDefaults.frontColor));
807
+ };
808
+ export var getBarSideColor = function (isFocused, focusedBarConfig, itemSideColor, sideColor) {
809
+ var _a;
810
+ if (isFocused) {
811
+ return (_a = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.sideColor) !== null && _a !== void 0 ? _a : BarDefaults.focusedBarSideColor;
812
+ }
813
+ return itemSideColor !== null && itemSideColor !== void 0 ? itemSideColor : sideColor;
814
+ };
815
+ export var getBarTopColor = function (isFocused, focusedBarConfig, itemTopColor, topColor) {
816
+ var _a;
817
+ if (isFocused) {
818
+ return (_a = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.topColor) !== null && _a !== void 0 ? _a : BarDefaults.focusedBarTopColor;
819
+ }
820
+ return itemTopColor !== null && itemTopColor !== void 0 ? itemTopColor : topColor;
821
+ };
822
+ export var getBarWidth = function (isFocused, focusedBarConfig, itemBarWidth, barWidth) {
823
+ var _a, _b;
824
+ var localBarWidth = (_a = itemBarWidth !== null && itemBarWidth !== void 0 ? itemBarWidth : barWidth) !== null && _a !== void 0 ? _a : BarDefaults.barWidth;
825
+ if (isFocused) {
826
+ return (_b = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.width) !== null && _b !== void 0 ? _b : localBarWidth;
827
+ }
828
+ return localBarWidth;
829
+ };
830
+ export var getInterpolatedData = function (dataParam, showDataPointsForMissingValues, interpolateMissingValues, onlyPositive) {
831
+ if (!interpolateMissingValues) {
832
+ return dataParam.map(function (item) {
833
+ if (typeof item.value !== 'number') {
834
+ if (showDataPointsForMissingValues)
835
+ return __assign(__assign({}, item), { value: 0 });
836
+ return __assign(__assign({}, item), { value: 0, hideDataPoint: true });
837
+ }
838
+ return item;
839
+ });
840
+ }
841
+ if (!interpolateMissingValues)
842
+ return dataParam;
843
+ var data = clone(dataParam);
844
+ var n = data.length;
845
+ /** ************ PRE-PROCESSING **************/
846
+ var numericValue;
847
+ var numericValuesLength = data.filter(function (item) {
848
+ var isNum = typeof item.value === 'number';
849
+ if (isNum) {
850
+ numericValue = item.value;
851
+ return true;
852
+ }
853
+ return false;
854
+ }).length;
855
+ if (!numericValuesLength)
856
+ return [];
857
+ if (numericValuesLength === 1) {
858
+ data.forEach(function (item) {
859
+ if (!showDataPointsForMissingValues && typeof item.value !== 'number') {
860
+ item.hideDataPoint = true;
861
+ }
862
+ item.value = numericValue;
863
+ });
864
+ return data;
865
+ }
866
+ /**********************************************************************/
867
+ data.forEach(function (item, index) {
868
+ if (typeof item.value === 'number')
869
+ return;
870
+ // Cut the line in 2 halves-> pre and post
871
+ // Now there are 4 possibilities-
872
+ // 1. Both pre and post have valid values
873
+ // 2. Only pre has valid value
874
+ // 3. Only post has valid value
875
+ // 4. None has valid value -> this is already handled in preprocessing
876
+ var pre = data.slice(0, index);
877
+ var post = data.slice(index + 1, n);
878
+ var preValidIndex = pre.findLastIndex(function (item) { return typeof item.value === 'number'; });
879
+ var postValidInd = post.findIndex(function (item) { return typeof item.value === 'number'; });
880
+ var postValidIndex = postValidInd + index + 1;
881
+ var count, step;
882
+ // 1. Both pre and post have valid values
883
+ if (preValidIndex !== -1 && postValidInd !== -1) {
884
+ count = postValidIndex - preValidIndex;
885
+ step = (data[postValidIndex].value - data[preValidIndex].value) / count;
886
+ data[index].value =
887
+ data[preValidIndex].value + step * (index - preValidIndex);
888
+ }
889
+ else if (preValidIndex !== -1 && postValidInd === -1) {
890
+ // 2. Only pre has valid value
891
+ // Now there are 2 possibilities-
892
+ // 1. There's only 1 valid value in the pre -> this is already handled in preprocessing
893
+ // 2. There are more than valid values in pre
894
+ var secondPre = data.slice(0, preValidIndex);
895
+ var secondPreIndex = secondPre.findLastIndex(function (item) { return typeof item.value === 'number'; });
896
+ count = preValidIndex - secondPreIndex;
897
+ step = (data[secondPreIndex].value - data[preValidIndex].value) / count;
898
+ data[index].value =
899
+ data[preValidIndex].value - step * (index - preValidIndex);
900
+ }
901
+ else if (preValidIndex === -1 && postValidInd !== -1) {
902
+ // 3. Only post has valid value
903
+ // Now there are 2 possibilities-
904
+ // 1. There's only 1 valid value in the post -> this is already handled in preprocessing
905
+ // 2. There are more than valid values in post
906
+ var secondPost = data.slice(postValidIndex + 1, n);
907
+ var secondPostInd = secondPost.findIndex(function (item) { return typeof item.value === 'number'; });
908
+ var secondPostIndex = secondPostInd + postValidIndex + 1;
909
+ count = secondPostIndex - postValidIndex;
910
+ step = (data[secondPostIndex].value - data[postValidIndex].value) / count;
911
+ data[index].value =
912
+ data[postValidIndex].value - step * (postValidIndex - index);
913
+ }
914
+ // hide data point (since it is interpolated)
915
+ if (!showDataPointsForMissingValues) {
916
+ item.hideDataPoint = true;
917
+ }
918
+ });
919
+ return onlyPositive
920
+ ? data.map(function (item) { return (__assign(__assign({}, item), { value: Math.max(item.value, 0) })); })
921
+ : data;
922
+ };
923
+ export var getLineSegmentsForMissingValues = function (data) {
924
+ if (!(data === null || data === void 0 ? void 0 : data.length))
925
+ return undefined;
926
+ var i;
927
+ var n = data.length;
928
+ var numericValuesLength = data.filter(function (item) { return typeof item.value === 'number'; }).length;
929
+ if (!numericValuesLength)
930
+ return undefined;
931
+ var segments = [];
932
+ for (i = 0; i < n; i++) {
933
+ if (typeof data[i].value !== 'number') {
934
+ var nextValidInd = data
935
+ .slice(i + 1, n)
936
+ .findIndex(function (item) { return typeof item.value === 'number'; });
937
+ if (nextValidInd === -1) {
938
+ segments.push({
939
+ startIndex: Math.max(i - 1, 0),
940
+ endIndex: n,
941
+ color: 'transparent'
942
+ });
943
+ break;
944
+ }
945
+ var nextValidIndex = nextValidInd + i + 1;
946
+ segments.push({
947
+ startIndex: Math.max(i - 1, 0),
948
+ endIndex: nextValidIndex,
949
+ color: 'transparent'
950
+ });
951
+ i = nextValidIndex;
952
+ }
953
+ }
954
+ return segments;
955
+ };
956
+ export var getTextSizeForPieLabels = function (textSize, radius) { return (textSize ? Math.min(textSize, radius / 5) : 16); };
957
+ export var adjustToOffset = function (data, yAxisOffset) {
958
+ return data.map(function (item) { return (__assign(__assign({}, item), { value: item.value - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0) })); });
959
+ };
960
+ export var getSanitisedData = function (data, dataSanitisationProps) {
961
+ if (!data) {
962
+ return [];
963
+ }
964
+ var showDataPointsForMissingValues = dataSanitisationProps.showDataPointsForMissingValues, interpolateMissingValues = dataSanitisationProps.interpolateMissingValues, onlyPositive = dataSanitisationProps.onlyPositive, yAxisOffset = dataSanitisationProps.yAxisOffset;
965
+ var nullishHandledData = getInterpolatedData(data, showDataPointsForMissingValues, interpolateMissingValues, onlyPositive);
966
+ if (yAxisOffset) {
967
+ return adjustToOffset(nullishHandledData, yAxisOffset);
968
+ }
969
+ return nullishHandledData;
970
+ };
971
+ export var getStrokeDashArray = function (strokeDash, framework) {
972
+ var strokeDashArrayOrString;
973
+ if (framework === Framework.reactJS) {
974
+ if (strokeDash instanceof Array) {
975
+ strokeDashArrayOrString = strokeDash.toString().replace(',', ' ');
976
+ }
977
+ else if (typeof strokeDash === 'string') {
978
+ strokeDashArrayOrString = strokeDash
979
+ .replace(',', ' ')
980
+ .replace('[', '')
981
+ .replace(']', '')
982
+ .replace('{', '')
983
+ .replace('}', '');
984
+ }
985
+ }
986
+ else {
987
+ if (strokeDash instanceof Array) {
988
+ strokeDashArrayOrString = strokeDash;
989
+ }
990
+ else if (typeof strokeDash === 'string') {
991
+ var ar = strokeDash
992
+ .replace(',', ' ')
993
+ .replace('[', '')
994
+ .replace(']', '')
995
+ .replace('{', '')
996
+ .replace('}', '')
997
+ .split(' ');
998
+ if (ar[0] && ar[1]) {
999
+ var n1 = Number(ar[0]);
1000
+ var n2 = Number(ar[1]);
1001
+ if (!isNaN(n1) && !isNaN(n2)) {
1002
+ strokeDashArrayOrString = [n1, n2];
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ return strokeDashArrayOrString;
1008
+ };