gifted-charts-core 0.1.34 → 0.1.36

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.
@@ -11,6 +11,7 @@ export interface LineChartPropsType {
11
11
  mostNegativeValue?: number;
12
12
  stepHeight?: number;
13
13
  stepValue?: number;
14
+ negativeStepValue?: number;
14
15
  spacing?: number;
15
16
  initialSpacing?: number;
16
17
  endSpacing?: number;
@@ -298,6 +299,7 @@ export interface LineChartPropsType {
298
299
  onMomentumScrollEnd?: Function;
299
300
  showDataPointsForMissingValues?: boolean;
300
301
  interpolateMissingValues?: boolean;
302
+ extrapolateMissingValues?: boolean;
301
303
  onlyPositive?: boolean;
302
304
  parentWidth?: number;
303
305
  onChartAreaPress?: (event: GestureResponderEvent) => void;
@@ -1,8 +1,8 @@
1
1
  import { AxesAndRulesDefaults } from '../../utils/constants';
2
2
  import { getLabelTextUtil } from '../../utils';
3
3
  export var getHorizSectionVals = function (props) {
4
- 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;
5
- var width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, noOfSections = props.noOfSections, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, yAxisExtraHeight = props.yAxisExtraHeight, trimYAxisAtTop = props.trimYAxisAtTop, dashWidth = props.dashWidth, dashGap = props.dashGap, rulesType = props.rulesType, rulesThickness = props.rulesThickness, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, showFractionalValues = props.showFractionalValues, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisLabelPrefix = props.yAxisLabelPrefix, yAxisLabelSuffix = props.yAxisLabelSuffix, yAxisTextStyle = props.yAxisTextStyle, containerHeight = props.containerHeight, maxValue = props.maxValue, referenceLinesConfig = props.referenceLinesConfig, yAxisLabelTexts = props.yAxisLabelTexts, stepValue = props.stepValue, negativeStepValue = props.negativeStepValue, roundToDigits = props.roundToDigits, yAxisOffset = props.yAxisOffset, formatYLabel = props.formatYLabel, secondaryMaxItem = props.secondaryMaxItem, secondaryMinItem = props.secondaryMinItem, secondaryYAxis = props.secondaryYAxis, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepValue = props.secondaryNegativeStepValue, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis;
4
+ 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;
5
+ var width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, noOfSections = props.noOfSections, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, yAxisExtraHeight = props.yAxisExtraHeight, trimYAxisAtTop = props.trimYAxisAtTop, dashWidth = props.dashWidth, dashGap = props.dashGap, rulesType = props.rulesType, rulesThickness = props.rulesThickness, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, showFractionalValues = props.showFractionalValues, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisLabelPrefix = props.yAxisLabelPrefix, yAxisLabelSuffix = props.yAxisLabelSuffix, yAxisTextStyle = props.yAxisTextStyle, containerHeight = props.containerHeight, maxValue = props.maxValue, referenceLinesConfig = props.referenceLinesConfig, yAxisLabelTexts = props.yAxisLabelTexts, stepValue = props.stepValue, negativeStepValue = props.negativeStepValue, roundToDigits = props.roundToDigits, yAxisOffset = props.yAxisOffset, formatYLabel = props.formatYLabel, secondaryMaxItem = props.secondaryMaxItem, secondaryMinItem = props.secondaryMinItem, secondaryYAxis = props.secondaryYAxis, secondaryStepValue = props.secondaryStepValue, secondaryNegativeStepValue = props.secondaryNegativeStepValue, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis, showSecondaryFractionalValues = props.showSecondaryFractionalValues, secondaryRoundToDigits = props.secondaryRoundToDigits, secondaryStepHeight = props.secondaryStepHeight, secondaryNegativeStepHeight = props.secondaryNegativeStepHeight;
6
6
  var yAxisExtraHeightAtTop = trimYAxisAtTop ? 0 : yAxisExtraHeight;
7
7
  /***********************************************************************************************************************************
8
8
  * *
@@ -14,38 +14,38 @@ export var getHorizSectionVals = function (props) {
14
14
  maxValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue,
15
15
  mostNegativeValue: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue,
16
16
  stepValue: secondaryStepValue,
17
- stepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight,
17
+ stepHeight: secondaryStepHeight,
18
18
  negativeStepValue: secondaryNegativeStepValue,
19
- negativeStepHeight: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight,
20
- showFractionalValues: (_b = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _b !== void 0 ? _b : showFractionalValues,
21
- roundToDigits: (_c = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _c !== void 0 ? _c : roundToDigits,
19
+ negativeStepHeight: secondaryNegativeStepHeight,
20
+ showFractionalValues: showSecondaryFractionalValues,
21
+ roundToDigits: secondaryRoundToDigits,
22
22
  noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
23
- showYAxisIndices: (_d = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showYAxisIndices) !== null && _d !== void 0 ? _d : showYAxisIndices,
24
- yAxisIndicesHeight: (_e = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesHeight) !== null && _e !== void 0 ? _e : yAxisIndicesHeight,
25
- yAxisIndicesWidth: (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesWidth) !== null && _f !== void 0 ? _f : yAxisIndicesWidth,
26
- yAxisIndicesColor: (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesColor) !== null && _g !== void 0 ? _g : yAxisIndicesColor,
27
- yAxisSide: (_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisSide) !== null && _h !== void 0 ? _h : yAxisSide,
23
+ showYAxisIndices: (_b = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showYAxisIndices) !== null && _b !== void 0 ? _b : showYAxisIndices,
24
+ yAxisIndicesHeight: (_c = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesHeight) !== null && _c !== void 0 ? _c : yAxisIndicesHeight,
25
+ yAxisIndicesWidth: (_d = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesWidth) !== null && _d !== void 0 ? _d : yAxisIndicesWidth,
26
+ yAxisIndicesColor: (_e = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisIndicesColor) !== null && _e !== void 0 ? _e : yAxisIndicesColor,
27
+ yAxisSide: (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisSide) !== null && _f !== void 0 ? _f : yAxisSide,
28
28
  yAxisOffset: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisOffset,
29
- yAxisThickness: (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisThickness) !== null && _j !== void 0 ? _j : yAxisThickness,
30
- yAxisColor: (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisColor) !== null && _k !== void 0 ? _k : yAxisColor,
31
- yAxisLabelContainerStyle: (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelContainerStyle) !== null && _l !== void 0 ? _l : yAxisLabelContainerStyle,
29
+ yAxisThickness: (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisThickness) !== null && _g !== void 0 ? _g : yAxisThickness,
30
+ yAxisColor: (_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisColor) !== null && _h !== void 0 ? _h : yAxisColor,
31
+ yAxisLabelContainerStyle: (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelContainerStyle) !== null && _j !== void 0 ? _j : yAxisLabelContainerStyle,
32
32
  yAxisLabelTexts: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelTexts,
33
- yAxisTextStyle: (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextStyle) !== null && _m !== void 0 ? _m : yAxisTextStyle,
34
- yAxisTextNumberOfLines: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextNumberOfLines) !== null && _o !== void 0 ? _o : yAxisTextNumberOfLines,
35
- yAxisLabelWidth: (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelWidth) !== null && _p !== void 0 ? _p : yAxisLabelWidth,
36
- hideYAxisText: (_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideYAxisText) !== null && _q !== void 0 ? _q : hideYAxisText,
37
- yAxisLabelPrefix: (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelPrefix) !== null && _r !== void 0 ? _r : yAxisLabelPrefix,
38
- yAxisLabelSuffix: (_s = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelSuffix) !== null && _s !== void 0 ? _s : yAxisLabelSuffix,
39
- hideOrigin: (_t = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideOrigin) !== null && _t !== void 0 ? _t : hideOrigin,
33
+ yAxisTextStyle: (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextStyle) !== null && _k !== void 0 ? _k : yAxisTextStyle,
34
+ yAxisTextNumberOfLines: (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisTextNumberOfLines) !== null && _l !== void 0 ? _l : yAxisTextNumberOfLines,
35
+ yAxisLabelWidth: (_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelWidth) !== null && _m !== void 0 ? _m : yAxisLabelWidth,
36
+ hideYAxisText: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideYAxisText) !== null && _o !== void 0 ? _o : hideYAxisText,
37
+ yAxisLabelPrefix: (_p = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelPrefix) !== null && _p !== void 0 ? _p : yAxisLabelPrefix,
38
+ yAxisLabelSuffix: (_q = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.yAxisLabelSuffix) !== null && _q !== void 0 ? _q : yAxisLabelSuffix,
39
+ hideOrigin: (_r = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.hideOrigin) !== null && _r !== void 0 ? _r : hideOrigin,
40
40
  formatYLabel: secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.formatYLabel
41
41
  };
42
42
  secondaryYAxisConfig.maxValue =
43
- (_u = secondaryYAxisConfig.maxValue) !== null && _u !== void 0 ? _u : (secondaryMaxItem || maxValue);
43
+ (_s = secondaryYAxisConfig.maxValue) !== null && _s !== void 0 ? _s : (secondaryMaxItem || maxValue);
44
44
  secondaryYAxisConfig.mostNegativeValue =
45
- (_v = secondaryYAxisConfig.mostNegativeValue) !== null && _v !== void 0 ? _v : secondaryMinItem;
45
+ (_t = secondaryYAxisConfig.mostNegativeValue) !== null && _t !== void 0 ? _t : secondaryMinItem;
46
46
  secondaryYAxisConfig.stepHeight =
47
47
  secondaryYAxisConfig.stepHeight ||
48
- containerHeight / ((_w = secondaryYAxisConfig.noOfSections) !== null && _w !== void 0 ? _w : noOfSections);
48
+ containerHeight / ((_u = secondaryYAxisConfig.noOfSections) !== null && _u !== void 0 ? _u : noOfSections);
49
49
  var horizSections = [];
50
50
  for (var i = 0; i <= noOfSections; i++) {
51
51
  var value = maxValue - stepValue * i;
@@ -54,7 +54,7 @@ export var getHorizSectionVals = function (props) {
54
54
  }
55
55
  horizSections.push({
56
56
  value: (yAxisLabelTexts === null || yAxisLabelTexts === void 0 ? void 0 : yAxisLabelTexts.length)
57
- ? (_x = yAxisLabelTexts[noOfSections + noOfSectionsBelowXAxis - i]) !== null && _x !== void 0 ? _x : value.toString()
57
+ ? (_v = yAxisLabelTexts[noOfSections + noOfSectionsBelowXAxis - i]) !== null && _v !== void 0 ? _v : value.toString()
58
58
  : value.toString()
59
59
  });
60
60
  }
@@ -67,24 +67,24 @@ export var getHorizSectionVals = function (props) {
67
67
  }
68
68
  horizSectionsBelow.push({
69
69
  value: props.yAxisLabelTexts
70
- ? (_y = props.yAxisLabelTexts[noOfSectionsBelowXAxis - i]) !== null && _y !== void 0 ? _y : value.toString()
70
+ ? (_w = props.yAxisLabelTexts[noOfSectionsBelowXAxis - i]) !== null && _w !== void 0 ? _w : value.toString()
71
71
  : value.toString()
72
72
  });
73
73
  }
74
74
  }
75
75
  var secondaryHorizSections = [];
76
76
  if (secondaryYAxis) {
77
- for (var i = 0; i <= ((_z = secondaryYAxisConfig.noOfSections) !== null && _z !== void 0 ? _z : noOfSections); i++) {
77
+ for (var i = 0; i <= ((_x = secondaryYAxisConfig.noOfSections) !== null && _x !== void 0 ? _x : noOfSections); i++) {
78
78
  var value = secondaryYAxisConfig.stepValue * i;
79
79
  if (secondaryYAxisConfig.showFractionalValues ||
80
80
  secondaryYAxisConfig.roundToDigits) {
81
- value = parseFloat(value.toFixed((_0 = secondaryYAxisConfig.roundToDigits) !== null && _0 !== void 0 ? _0 : AxesAndRulesDefaults.roundToDigits));
81
+ value = parseFloat(value.toFixed((_y = secondaryYAxisConfig.roundToDigits) !== null && _y !== void 0 ? _y : AxesAndRulesDefaults.roundToDigits));
82
82
  }
83
83
  secondaryHorizSections.push({
84
- value: ((_1 = secondaryYAxisConfig.yAxisLabelTexts) === null || _1 === void 0 ? void 0 : _1.length)
85
- ? (_2 = secondaryYAxisConfig.yAxisLabelTexts[i + noOfSectionsBelowXAxis
84
+ value: ((_z = secondaryYAxisConfig.yAxisLabelTexts) === null || _z === void 0 ? void 0 : _z.length)
85
+ ? (_1 = secondaryYAxisConfig.yAxisLabelTexts[i + ((_0 = secondaryYAxisConfig.noOfSectionsBelowXAxis) !== null && _0 !== void 0 ? _0 : 0)
86
86
  // - noOfSectionsBelowXAxis - 1
87
- ]) !== null && _2 !== void 0 ? _2 : value.toString()
87
+ ]) !== null && _1 !== void 0 ? _1 : value.toString()
88
88
  : value.toString()
89
89
  });
90
90
  }
@@ -96,11 +96,11 @@ export var getHorizSectionVals = function (props) {
96
96
  (i - secondaryYAxisConfig.noOfSectionsBelowXAxis - 1);
97
97
  if (secondaryYAxisConfig.showFractionalValues ||
98
98
  secondaryYAxisConfig.roundToDigits) {
99
- value = parseFloat(value.toFixed((_3 = secondaryYAxisConfig.roundToDigits) !== null && _3 !== void 0 ? _3 : AxesAndRulesDefaults.roundToDigits));
99
+ value = parseFloat(value.toFixed((_2 = secondaryYAxisConfig.roundToDigits) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.roundToDigits));
100
100
  }
101
101
  secondaryHorizSectionsBelow.push({
102
- value: ((_4 = secondaryYAxisConfig.yAxisLabelTexts) === null || _4 === void 0 ? void 0 : _4.length)
103
- ? (_5 = secondaryYAxisConfig.yAxisLabelTexts[i - 1]) !== null && _5 !== void 0 ? _5 : value.toString()
102
+ value: ((_3 = secondaryYAxisConfig.yAxisLabelTexts) === null || _3 === void 0 ? void 0 : _3.length)
103
+ ? (_4 = secondaryYAxisConfig.yAxisLabelTexts[i - 1]) !== null && _4 !== void 0 ? _4 : value.toString()
104
104
  : value.toString()
105
105
  });
106
106
  }
@@ -121,12 +121,12 @@ export var getHorizSectionVals = function (props) {
121
121
  };
122
122
  showReferenceLine1 = referenceLinesConfig.showReferenceLine1 || false;
123
123
  referenceLine1Position =
124
- (_6 = referenceLinesConfig.referenceLine1Position) !== null && _6 !== void 0 ? _6 : (referenceLinesConfig.referenceLine1Position || containerHeight / 2);
124
+ (_5 = referenceLinesConfig.referenceLine1Position) !== null && _5 !== void 0 ? _5 : (referenceLinesConfig.referenceLine1Position || containerHeight / 2);
125
125
  referenceLine1Config = referenceLinesConfig.referenceLine1Config
126
126
  ? {
127
127
  thickness: referenceLinesConfig.referenceLine1Config.thickness ||
128
128
  defaultReferenceConfig.thickness,
129
- width: (_7 = referenceLinesConfig.referenceLine1Config.width) !== null && _7 !== void 0 ? _7 : defaultReferenceConfig.width,
129
+ width: (_6 = referenceLinesConfig.referenceLine1Config.width) !== null && _6 !== void 0 ? _6 : defaultReferenceConfig.width,
130
130
  color: referenceLinesConfig.referenceLine1Config.color ||
131
131
  defaultReferenceConfig.color,
132
132
  type: referenceLinesConfig.referenceLine1Config.type ||
@@ -139,17 +139,17 @@ export var getHorizSectionVals = function (props) {
139
139
  defaultReferenceConfig.labelText,
140
140
  labelTextStyle: referenceLinesConfig.referenceLine1Config.labelTextStyle ||
141
141
  defaultReferenceConfig.labelTextStyle,
142
- zIndex: (_8 = referenceLinesConfig.referenceLine1Config.zIndex) !== null && _8 !== void 0 ? _8 : defaultReferenceConfig.zIndex
142
+ zIndex: (_7 = referenceLinesConfig.referenceLine1Config.zIndex) !== null && _7 !== void 0 ? _7 : defaultReferenceConfig.zIndex
143
143
  }
144
144
  : defaultReferenceConfig;
145
145
  showReferenceLine2 = referenceLinesConfig.showReferenceLine2 || false;
146
146
  referenceLine2Position =
147
- (_9 = referenceLinesConfig.referenceLine2Position) !== null && _9 !== void 0 ? _9 : (referenceLinesConfig.referenceLine2Position || (3 * containerHeight) / 2);
147
+ (_8 = referenceLinesConfig.referenceLine2Position) !== null && _8 !== void 0 ? _8 : (referenceLinesConfig.referenceLine2Position || (3 * containerHeight) / 2);
148
148
  referenceLine2Config = referenceLinesConfig.referenceLine2Config
149
149
  ? {
150
150
  thickness: referenceLinesConfig.referenceLine2Config.thickness ||
151
151
  defaultReferenceConfig.thickness,
152
- width: (_10 = referenceLinesConfig.referenceLine2Config.width) !== null && _10 !== void 0 ? _10 : defaultReferenceConfig.width,
152
+ width: (_9 = referenceLinesConfig.referenceLine2Config.width) !== null && _9 !== void 0 ? _9 : defaultReferenceConfig.width,
153
153
  color: referenceLinesConfig.referenceLine2Config.color ||
154
154
  defaultReferenceConfig.color,
155
155
  type: referenceLinesConfig.referenceLine2Config.type ||
@@ -162,17 +162,17 @@ export var getHorizSectionVals = function (props) {
162
162
  defaultReferenceConfig.labelText,
163
163
  labelTextStyle: referenceLinesConfig.referenceLine2Config.labelTextStyle ||
164
164
  defaultReferenceConfig.labelTextStyle,
165
- zIndex: (_11 = referenceLinesConfig.referenceLine2Config.zIndex) !== null && _11 !== void 0 ? _11 : defaultReferenceConfig.zIndex
165
+ zIndex: (_10 = referenceLinesConfig.referenceLine2Config.zIndex) !== null && _10 !== void 0 ? _10 : defaultReferenceConfig.zIndex
166
166
  }
167
167
  : defaultReferenceConfig;
168
168
  showReferenceLine3 = referenceLinesConfig.showReferenceLine3 || false;
169
169
  referenceLine3Position =
170
- (_12 = referenceLinesConfig.referenceLine3Position) !== null && _12 !== void 0 ? _12 : (referenceLinesConfig.referenceLine3Position || containerHeight / 3);
170
+ (_11 = referenceLinesConfig.referenceLine3Position) !== null && _11 !== void 0 ? _11 : (referenceLinesConfig.referenceLine3Position || containerHeight / 3);
171
171
  referenceLine3Config = referenceLinesConfig.referenceLine3Config
172
172
  ? {
173
173
  thickness: referenceLinesConfig.referenceLine3Config.thickness ||
174
174
  defaultReferenceConfig.thickness,
175
- width: (_13 = referenceLinesConfig.referenceLine3Config.width) !== null && _13 !== void 0 ? _13 : defaultReferenceConfig.width,
175
+ width: (_12 = referenceLinesConfig.referenceLine3Config.width) !== null && _12 !== void 0 ? _12 : defaultReferenceConfig.width,
176
176
  color: referenceLinesConfig.referenceLine3Config.color ||
177
177
  defaultReferenceConfig.color,
178
178
  type: referenceLinesConfig.referenceLine3Config.type ||
@@ -185,7 +185,7 @@ export var getHorizSectionVals = function (props) {
185
185
  defaultReferenceConfig.labelText,
186
186
  labelTextStyle: referenceLinesConfig.referenceLine3Config.labelTextStyle ||
187
187
  defaultReferenceConfig.labelTextStyle,
188
- zIndex: (_14 = referenceLinesConfig.referenceLine3Config.zIndex) !== null && _14 !== void 0 ? _14 : defaultReferenceConfig.zIndex
188
+ zIndex: (_13 = referenceLinesConfig.referenceLine3Config.zIndex) !== null && _13 !== void 0 ? _13 : defaultReferenceConfig.zIndex
189
189
  }
190
190
  : defaultReferenceConfig;
191
191
  var getLabelTexts = function (val, index) {
@@ -38,7 +38,7 @@ import { useEffect, useState } from 'react';
38
38
  import { AxesAndRulesDefaults, BarDefaults } from '../../utils/constants';
39
39
  import { computeMaxAndMinItems } from '../../utils';
40
40
  export var useBarAndLineChartsWrapper = function (props) {
41
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
41
+ 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;
42
42
  var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex;
43
43
  var yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
44
44
  var hideOrigin = (_a = axesAndRulesProps.hideOrigin) !== null && _a !== void 0 ? _a : AxesAndRulesDefaults.hideOrigin;
@@ -104,17 +104,10 @@ export var useBarAndLineChartsWrapper = function (props) {
104
104
  var secondaryDataArrayWithMinValue = (secondaryData === null || secondaryData === void 0 ? void 0 : secondaryData.length)
105
105
  ? secondaryData
106
106
  : setWithMinValueInDataset === null || setWithMinValueInDataset === void 0 ? void 0 : setWithMinValueInDataset.data;
107
- var _25 = computeMaxAndMinItems(secondaryDataArrayWithMinValue, (_13 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _13 !== void 0 ? _13 : roundToDigits, (_14 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _14 !== void 0 ? _14 : showFractionalValues), secondaryMaxItem = _25.maxItem, secondaryMinItem = _25.minItem;
108
- var secondaryStepValue = (_15 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _15 !== void 0 ? _15 : ((_16 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _16 !== void 0 ? _16 : maxValue) /
109
- ((_17 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _17 !== void 0 ? _17 : noOfSections);
110
- var secondaryNegativeStepValue = (_18 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _18 !== void 0 ? _18 : secondaryStepValue;
111
- var secondaryNoOfSectionsBelowXAxis = (_19 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _19 !== void 0 ? _19 : (secondaryNegativeStepValue
112
- ? Math.ceil(((_20 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _20 !== void 0 ? _20 : secondaryMinItem) /
113
- -secondaryNegativeStepValue)
114
- : 0);
107
+ var _17 = computeMaxAndMinItems(secondaryDataArrayWithMinValue, (_13 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.roundToDigits) !== null && _13 !== void 0 ? _13 : roundToDigits, (_14 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.showFractionalValues) !== null && _14 !== void 0 ? _14 : showFractionalValues), secondaryMaxItem = _17.maxItem, secondaryMinItem = _17.minItem;
108
+ var _18 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepValue = _18.stepValue, secondaryNegativeStepValue = _18.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _18.noOfSectionsBelowXAxis, showSecondaryFractionalValues = _18.showFractionalValues, secondaryRoundToDigits = _18.roundToDigits, secondaryStepHeight = _18.stepHeight, secondaryNegativeStepHeight = _18.negativeStepHeight;
115
109
  var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
116
- var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis *
117
- ((_22 = (_21 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _21 !== void 0 ? _21 : secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _22 !== void 0 ? _22 : stepHeight);
110
+ var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
118
111
  var biggerNegativeYAxisHeight = Math.max(primaryYAxisHeightBelowOrigin, secondaryYAxisHeightBelowOrigin);
119
112
  var containerHeightIncludingBelowXAxis = extendedContainerHeight + biggerNegativeYAxisHeight;
120
113
  var horizSectionProps = {
@@ -181,7 +174,11 @@ export var useBarAndLineChartsWrapper = function (props) {
181
174
  secondaryMinItem: secondaryMinItem,
182
175
  secondaryStepValue: secondaryStepValue,
183
176
  secondaryNegativeStepValue: secondaryNegativeStepValue,
184
- secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
177
+ secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
178
+ showSecondaryFractionalValues: showSecondaryFractionalValues,
179
+ secondaryRoundToDigits: secondaryRoundToDigits,
180
+ secondaryStepHeight: secondaryStepHeight,
181
+ secondaryNegativeStepHeight: secondaryNegativeStepHeight
185
182
  };
186
183
  var lineInBarChartProps = {
187
184
  yAxisLabelWidth: yAxisLabelWidth,
@@ -190,7 +187,7 @@ export var useBarAndLineChartsWrapper = function (props) {
190
187
  containerHeight: containerHeight,
191
188
  containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
192
189
  lineConfig: lineConfig,
193
- maxValue: (_23 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _23 !== void 0 ? _23 : maxValue,
190
+ maxValue: (_15 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _15 !== void 0 ? _15 : maxValue,
194
191
  animatedWidth: animatedWidth,
195
192
  lineBehindBars: lineBehindBars,
196
193
  points: points,
@@ -207,7 +204,7 @@ export var useBarAndLineChartsWrapper = function (props) {
207
204
  var verticalLinesProps = {
208
205
  verticalLinesAr: verticalLinesAr,
209
206
  verticalLinesSpacing: verticalLinesSpacing,
210
- spacing: (_24 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _24 !== void 0 ? _24 : spacing,
207
+ spacing: (_16 = lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.spacing) !== null && _16 !== void 0 ? _16 : spacing,
211
208
  initialSpacing: initialSpacing,
212
209
  verticalLinesZIndex: verticalLinesZIndex,
213
210
  verticalLinesHeight: verticalLinesHeight,
@@ -262,7 +259,7 @@ export var useBarAndLineChartsWrapper = function (props) {
262
259
  : difBwWidthHeight - 40) /
263
260
  2 +
264
261
  (yAxisAtTop ? (rtl ? (props.width ? 12 : 40) : 12) : 52), ")");
265
- var _26 = __read(useState(false), 2), canMomentum = _26[0], setCanMomentum = _26[1];
262
+ var _19 = __read(useState(false), 2), canMomentum = _19[0], setCanMomentum = _19[1];
266
263
  var isCloseToEnd = function (_a) {
267
264
  var layoutMeasurement = _a.layoutMeasurement, contentOffset = _a.contentOffset, contentSize = _a.contentSize;
268
265
  return isRTL
@@ -1,6 +1,6 @@
1
1
  import { type ColorValue } from 'react-native';
2
2
  import { type IDataSanitisationProps, type lineDataItem } from '../LineChart/types';
3
- import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType } from './types';
3
+ import { type arrowConfigType, CurveType, type HighlightedRange, type LineProperties, type LineSegment, Framework, referenceConfigType, secondaryYAxisType } from './types';
4
4
  import { type lineConfigType, type BarChartPropsType, type FocusedBarConfig, type barDataItem } from '../BarChart/types';
5
5
  import { type extendedLineChartPropsType } from '../LineChart';
6
6
  import { type extendedBarChartPropsType } from '../BarChart';
@@ -31,8 +31,15 @@ interface ReferenceLinesConfig {
31
31
  interface IgetAxesAndRulesProps extends BarChartPropsType {
32
32
  verticalLinesUptoDataPoint?: boolean;
33
33
  referenceLinesConfig: ReferenceLinesConfig;
34
+ secondaryYAxisConfig: secondaryYAxisType & {
35
+ stepHeight: number;
36
+ stepValue: number;
37
+ negativeStepHeight: number;
38
+ negativeStepValue: number;
39
+ noOfSectionsBelowXAxis: number;
40
+ };
34
41
  }
35
- export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, negativeStepValue?: number, maxValue?: number) => IgetAxesAndRulesProps;
42
+ export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, containerHeight: number, stepHeight: number, stepValue: number, noOfSections: number, roundToDigits: number, negativeStepValue: number, secondaryMaxValue: number, secondaryMinItem: number, showSecondaryFractionalValues: boolean, secondaryRoundToDigits: number) => IgetAxesAndRulesProps;
36
43
  export declare const getExtendedContainerHeightWithPadding: (containerHeight: number, overflowTop?: number) => number;
37
44
  export declare const getSecondaryDataWithOffsetIncluded: (secondaryData?: barDataItem[] | lineDataItem[], secondaryYAxis?: any | undefined, showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => barDataItem[] | lineDataItem[] | undefined;
38
45
  export declare const getArrowProperty: (property: string, count: number, props: extendedLineChartPropsType, defaultArrowConfig: arrowConfigType) => any;
@@ -79,6 +86,7 @@ interface MaxAndMin {
79
86
  maxItem: number;
80
87
  minItem: number;
81
88
  }
89
+ export declare const indexOfFirstNonZeroDigit: (num: number) => number;
82
90
  export declare const maxAndMinUtil: (maxItem: number, minItem: number, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
83
91
  export declare const computeMaxAndMinItems: (data: any[] | undefined, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
84
92
  export declare const getLabelTextUtil: (val: string, index: number, showFractionalValues?: boolean, yAxisLabelTexts?: string[], yAxisOffset?: number, yAxisLabelPrefix?: string, yAxisLabelSuffix?: string, roundToDigits?: number, formatYLabel?: (label: string) => string) => string;
@@ -94,6 +102,7 @@ export declare const getBarSideColor: (isFocused?: boolean, focusedBarConfig?: F
94
102
  export declare const getBarTopColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemTopColor?: ColorValue, topColor?: ColorValue) => ColorValue | undefined;
95
103
  export declare const getBarWidth: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemBarWidth?: number, barWidth?: number) => number;
96
104
  export declare const getInterpolatedData: (dataParam: lineDataItem[], showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => lineDataItem[];
105
+ export declare const getLineSegmentsDueToNoExtrapolation: (data?: lineDataItem[]) => LineSegment[] | undefined;
97
106
  export declare const getLineSegmentsForMissingValues: (data?: lineDataItem[]) => LineSegment[] | undefined;
98
107
  export declare const getTextSizeForPieLabels: (textSize: number, radius: number) => number;
99
108
  export declare const adjustToOffset: (data: lineDataItem[], yAxisOffset?: number) => lineDataItem[];
@@ -486,11 +486,9 @@ export var getArrowPoints = function (arrowTipX, arrowTipY, x1, y1, arrowLength,
486
486
  arrowPoints += " L".concat(arrowTipX, " ").concat(arrowTipY);
487
487
  return arrowPoints;
488
488
  };
489
- export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue, maxValue) {
490
- var _a, _b, _c, _d, _e;
491
- var secondaryYAxis = !props.secondaryYAxis || props.secondaryYAxis === true
492
- ? {}
493
- : props.secondaryYAxis;
489
+ export var getAxesAndRulesProps = function (props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits) {
490
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
491
+ var secondaryYAxis = typeof props.secondaryYAxis === 'boolean' ? {} : props.secondaryYAxis;
494
492
  var axesAndRulesProps = {
495
493
  yAxisSide: props.yAxisSide,
496
494
  yAxisLabelContainerStyle: props.yAxisLabelContainerStyle,
@@ -551,19 +549,35 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
551
549
  verticalLinesStrokeLinecap: props.verticalLinesStrokeLinecap,
552
550
  // specific to Line charts-
553
551
  verticalLinesUptoDataPoint: props.verticalLinesUptoDataPoint,
554
- roundToDigits: props.roundToDigits,
552
+ roundToDigits: roundToDigits,
555
553
  stepValue: stepValue,
556
- negativeStepValue: negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue,
554
+ negativeStepValue: negativeStepValue,
557
555
  secondaryYAxis: props.secondaryYAxis,
558
556
  formatYLabel: props.formatYLabel,
559
- secondaryXAxis: props.secondaryXAxis
557
+ secondaryXAxis: props.secondaryXAxis,
558
+ secondaryYAxisConfig: {
559
+ stepHeight: 0,
560
+ stepValue: 0,
561
+ negativeStepHeight: 0,
562
+ negativeStepValue: 0,
563
+ noOfSectionsBelowXAxis: 0
564
+ }
560
565
  };
561
566
  if (((_d = props.secondaryYAxis) !== null && _d !== void 0 ? _d : (_e = props.lineConfig) === null || _e === void 0 ? void 0 : _e.isSecondary) &&
562
- maxValue !== undefined &&
567
+ secondaryMaxValue !== undefined &&
563
568
  secondaryYAxis &&
564
569
  secondaryYAxis.maxValue === undefined) {
565
- axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: maxValue });
570
+ axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: secondaryMaxValue });
566
571
  }
572
+ var secondaryNoOfSections = (_f = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _f !== void 0 ? _f : noOfSections;
573
+ var secondaryStepValue = (_g = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepValue) !== null && _g !== void 0 ? _g : ((_h = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.maxValue) !== null && _h !== void 0 ? _h : secondaryMaxValue) / secondaryNoOfSections;
574
+ var secondaryStepHeight = (_j = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.stepHeight) !== null && _j !== void 0 ? _j : containerHeight / secondaryNoOfSections;
575
+ var secondaryNegativeStepValue = (_k = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepValue) !== null && _k !== void 0 ? _k : secondaryStepValue;
576
+ var secondaryNoOfSectionsBelowXAxis = (_l = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSectionsBelowXAxis) !== null && _l !== void 0 ? _l : (secondaryNegativeStepValue
577
+ ? Math.ceil(((_m = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.mostNegativeValue) !== null && _m !== void 0 ? _m : secondaryMinItem) /
578
+ -secondaryNegativeStepValue)
579
+ : 0);
580
+ axesAndRulesProps.secondaryYAxisConfig = __assign(__assign({}, secondaryYAxis), { stepHeight: secondaryStepHeight, stepValue: secondaryStepValue, negativeStepHeight: (_o = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.negativeStepHeight) !== null && _o !== void 0 ? _o : secondaryStepHeight, negativeStepValue: secondaryNegativeStepValue, noOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis, showFractionalValues: showSecondaryFractionalValues, roundToDigits: secondaryRoundToDigits });
567
581
  return axesAndRulesProps;
568
582
  };
569
583
  export var getExtendedContainerHeightWithPadding = function (containerHeight, overflowTop) { return containerHeight + (overflowTop !== null && overflowTop !== void 0 ? overflowTop : 0) + 10; };
@@ -662,15 +676,29 @@ export var getAllArrowProperties = function (props, defaultArrowConfig) {
662
676
  showArrowBasesFromSet: showArrowBasesFromSet
663
677
  };
664
678
  };
679
+ export var indexOfFirstNonZeroDigit = function (num) {
680
+ var numString = num.toString();
681
+ var i = 0;
682
+ var d = numString[i];
683
+ while (i < numString.length - 2 && (isNaN(Number(d)) || d === '0')) {
684
+ d = numString[++i];
685
+ }
686
+ return i;
687
+ };
665
688
  export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFractionalValues) {
666
689
  if (showFractionalValues !== null && showFractionalValues !== void 0 ? showFractionalValues : roundToDigits) {
667
- maxItem *= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
668
- maxItem = maxItem + (10 - (maxItem % 10));
669
- maxItem /= 10 * (roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1);
670
- maxItem = parseFloat(maxItem.toFixed(roundToDigits !== null && roundToDigits !== void 0 ? roundToDigits : 1));
671
- if (minItem !== 0) {
672
- minItem += minItem / 10;
673
- }
690
+ var range = maxItem - minItem;
691
+ var stepValue = range / 10;
692
+ maxItem += stepValue;
693
+ minItem =
694
+ minItem !== 0 ? minItem + (minItem < 0 ? -stepValue : stepValue) : minItem;
695
+ // maxItem *= 10 * (roundToDigits ?? 1)
696
+ // maxItem = maxItem + (10 - (maxItem % 10))
697
+ // maxItem /= 10 * (roundToDigits ?? 1)
698
+ // maxItem = parseFloat(maxItem.toFixed(roundToDigits ?? 1))
699
+ // if (minItem !== 0) {
700
+ // minItem += minItem / 10
701
+ // }
674
702
  }
675
703
  else {
676
704
  maxItem = maxItem + (10 - (maxItem % 10));
@@ -835,6 +863,11 @@ export var getBarTopColor = function (isFocused, focusedBarConfig, itemTopColor,
835
863
  }
836
864
  return itemTopColor !== null && itemTopColor !== void 0 ? itemTopColor : topColor;
837
865
  };
866
+ var myFindLastIndex = function (arr, func) {
867
+ var tempLastIndex = arr.slice().reverse().findIndex(func);
868
+ var lastIndex = tempLastIndex >= 0 ? arr.length - 1 - tempLastIndex : tempLastIndex;
869
+ return lastIndex;
870
+ };
838
871
  export var getBarWidth = function (isFocused, focusedBarConfig, itemBarWidth, barWidth) {
839
872
  var _a, _b;
840
873
  var localBarWidth = (_a = itemBarWidth !== null && itemBarWidth !== void 0 ? itemBarWidth : barWidth) !== null && _a !== void 0 ? _a : BarDefaults.barWidth;
@@ -891,12 +924,7 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
891
924
  // 4. None has valid value -> this is already handled in preprocessing
892
925
  var pre = data.slice(0, index);
893
926
  var post = data.slice(index + 1, n);
894
- var preCount = pre.length - 1;
895
- var tempPreValidIndex = pre
896
- .slice()
897
- .reverse()
898
- .findIndex(function (item) { return typeof item.value === 'number'; });
899
- var preValidIndex = tempPreValidIndex >= 0 ? preCount - tempPreValidIndex : tempPreValidIndex;
927
+ var preValidIndex = myFindLastIndex(pre, function (item) { return typeof item.value === 'number'; });
900
928
  var postValidInd = post.findIndex(function (item) { return typeof item.value === 'number'; });
901
929
  var postValidIndex = postValidInd + index + 1;
902
930
  var count, step;
@@ -911,18 +939,12 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
911
939
  // 2. Only pre has valid value
912
940
  // Now there are 2 possibilities-
913
941
  // 1. There's only 1 valid value in the pre -> this is already handled in preprocessing
914
- // 2. There are more than valid values in pre
942
+ // 2. There are more than 1 valid values in pre
915
943
  var secondPre = data.slice(0, preValidIndex);
916
- var secondPreCount = pre.length - 1;
917
- var tempSecondPreIndex = secondPre
918
- .slice()
919
- .reverse()
920
- .findIndex(function (item) { return typeof item.value === 'number'; });
921
- var secondPreIndex = tempSecondPreIndex >= 0
922
- ? secondPreCount - tempSecondPreIndex
923
- : tempSecondPreIndex;
944
+ var secondPreIndex = myFindLastIndex(secondPre, function (item) { return typeof item.value === 'number'; });
924
945
  count = preValidIndex - secondPreIndex;
925
946
  step = (data[secondPreIndex].value - data[preValidIndex].value) / count;
947
+ var val = data[preValidIndex].value - step * (index - preValidIndex);
926
948
  data[index].value =
927
949
  data[preValidIndex].value - step * (index - preValidIndex);
928
950
  }
@@ -948,6 +970,28 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
948
970
  ? data.map(function (item) { return (__assign(__assign({}, item), { value: Math.max(item.value, 0) })); })
949
971
  : data;
950
972
  };
973
+ export var getLineSegmentsDueToNoExtrapolation = function (data) {
974
+ if (!(data === null || data === void 0 ? void 0 : data.length))
975
+ return undefined;
976
+ var segments = [];
977
+ var firstNumericIndex = data.findIndex(function (item) { return typeof item.value === 'number'; });
978
+ if (firstNumericIndex !== 0) {
979
+ segments.push({
980
+ startIndex: 0,
981
+ endIndex: firstNumericIndex,
982
+ color: 'transparent'
983
+ });
984
+ }
985
+ var lastNumericIndex = myFindLastIndex(data, function (item) { return typeof item.value === 'number'; });
986
+ if (lastNumericIndex !== data.length) {
987
+ segments.push({
988
+ startIndex: lastNumericIndex,
989
+ endIndex: data.length,
990
+ color: 'transparent'
991
+ });
992
+ }
993
+ return segments;
994
+ };
951
995
  export var getLineSegmentsForMissingValues = function (data) {
952
996
  if (!(data === null || data === void 0 ? void 0 : data.length))
953
997
  return undefined;
@@ -221,6 +221,10 @@ export interface horizSectionPropTypes {
221
221
  secondaryStepValue: number;
222
222
  secondaryNegativeStepValue: number;
223
223
  secondaryNoOfSectionsBelowXAxis: number;
224
+ showSecondaryFractionalValues: boolean;
225
+ secondaryRoundToDigits: number;
226
+ secondaryStepHeight: number;
227
+ secondaryNegativeStepHeight: number;
224
228
  }
225
229
  interface HorizSectionObject {
226
230
  value: string;
@@ -244,7 +248,7 @@ export interface BarAndLineChartsWrapperTypes {
244
248
  initialSpacing: number;
245
249
  data: any[];
246
250
  stackData: any[] | undefined;
247
- secondaryData: any[] | undefined;
251
+ secondaryData?: any[];
248
252
  barWidth: number | undefined;
249
253
  xAxisThickness: number;
250
254
  totalWidth: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "./dist/index.js",
6
6
  "files": [