gifted-charts-core 0.0.16 → 0.0.17

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