gifted-charts-core 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BarChart/index.d.ts +5 -2
- package/dist/BarChart/index.js +86 -81
- package/dist/BarChart/types.d.ts +17 -0
- package/dist/LineChart/LineChartBiColor.js +7 -7
- package/dist/LineChart/index.d.ts +1 -0
- package/dist/LineChart/index.js +288 -272
- package/dist/LineChart/types.d.ts +1 -0
- package/dist/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +16 -14
- package/dist/components/BarAndLineChartsWrapper/index.js +5 -3
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +53 -24
- package/package.json +1 -1
|
@@ -298,6 +298,7 @@ export interface LineChartPropsType {
|
|
|
298
298
|
onMomentumScrollEnd?: Function;
|
|
299
299
|
showDataPointsForMissingValues?: boolean;
|
|
300
300
|
interpolateMissingValues?: boolean;
|
|
301
|
+
extrapolateMissingValues?: boolean;
|
|
301
302
|
onlyPositive?: boolean;
|
|
302
303
|
parentWidth?: number;
|
|
303
304
|
onChartAreaPress?: (event: GestureResponderEvent) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
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;
|
|
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, _15;
|
|
5
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;
|
|
6
6
|
var yAxisExtraHeightAtTop = trimYAxisAtTop ? 0 : yAxisExtraHeight;
|
|
7
7
|
/***********************************************************************************************************************************
|
|
@@ -82,7 +82,9 @@ export var getHorizSectionVals = function (props) {
|
|
|
82
82
|
}
|
|
83
83
|
secondaryHorizSections.push({
|
|
84
84
|
value: ((_1 = secondaryYAxisConfig.yAxisLabelTexts) === null || _1 === void 0 ? void 0 : _1.length)
|
|
85
|
-
? (
|
|
85
|
+
? (_3 = secondaryYAxisConfig.yAxisLabelTexts[i + ((_2 = secondaryYAxisConfig.noOfSectionsBelowXAxis) !== null && _2 !== void 0 ? _2 : 0)
|
|
86
|
+
// - noOfSectionsBelowXAxis - 1
|
|
87
|
+
]) !== null && _3 !== void 0 ? _3 : value.toString()
|
|
86
88
|
: value.toString()
|
|
87
89
|
});
|
|
88
90
|
}
|
|
@@ -94,11 +96,11 @@ export var getHorizSectionVals = function (props) {
|
|
|
94
96
|
(i - secondaryYAxisConfig.noOfSectionsBelowXAxis - 1);
|
|
95
97
|
if (secondaryYAxisConfig.showFractionalValues ||
|
|
96
98
|
secondaryYAxisConfig.roundToDigits) {
|
|
97
|
-
value = parseFloat(value.toFixed((
|
|
99
|
+
value = parseFloat(value.toFixed((_4 = secondaryYAxisConfig.roundToDigits) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.roundToDigits));
|
|
98
100
|
}
|
|
99
101
|
secondaryHorizSectionsBelow.push({
|
|
100
|
-
value: ((
|
|
101
|
-
? (
|
|
102
|
+
value: ((_5 = secondaryYAxisConfig.yAxisLabelTexts) === null || _5 === void 0 ? void 0 : _5.length)
|
|
103
|
+
? (_6 = secondaryYAxisConfig.yAxisLabelTexts[i - 1]) !== null && _6 !== void 0 ? _6 : value.toString()
|
|
102
104
|
: value.toString()
|
|
103
105
|
});
|
|
104
106
|
}
|
|
@@ -119,12 +121,12 @@ export var getHorizSectionVals = function (props) {
|
|
|
119
121
|
};
|
|
120
122
|
showReferenceLine1 = referenceLinesConfig.showReferenceLine1 || false;
|
|
121
123
|
referenceLine1Position =
|
|
122
|
-
(
|
|
124
|
+
(_7 = referenceLinesConfig.referenceLine1Position) !== null && _7 !== void 0 ? _7 : (referenceLinesConfig.referenceLine1Position || containerHeight / 2);
|
|
123
125
|
referenceLine1Config = referenceLinesConfig.referenceLine1Config
|
|
124
126
|
? {
|
|
125
127
|
thickness: referenceLinesConfig.referenceLine1Config.thickness ||
|
|
126
128
|
defaultReferenceConfig.thickness,
|
|
127
|
-
width: (
|
|
129
|
+
width: (_8 = referenceLinesConfig.referenceLine1Config.width) !== null && _8 !== void 0 ? _8 : defaultReferenceConfig.width,
|
|
128
130
|
color: referenceLinesConfig.referenceLine1Config.color ||
|
|
129
131
|
defaultReferenceConfig.color,
|
|
130
132
|
type: referenceLinesConfig.referenceLine1Config.type ||
|
|
@@ -137,17 +139,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
137
139
|
defaultReferenceConfig.labelText,
|
|
138
140
|
labelTextStyle: referenceLinesConfig.referenceLine1Config.labelTextStyle ||
|
|
139
141
|
defaultReferenceConfig.labelTextStyle,
|
|
140
|
-
zIndex: (
|
|
142
|
+
zIndex: (_9 = referenceLinesConfig.referenceLine1Config.zIndex) !== null && _9 !== void 0 ? _9 : defaultReferenceConfig.zIndex
|
|
141
143
|
}
|
|
142
144
|
: defaultReferenceConfig;
|
|
143
145
|
showReferenceLine2 = referenceLinesConfig.showReferenceLine2 || false;
|
|
144
146
|
referenceLine2Position =
|
|
145
|
-
(
|
|
147
|
+
(_10 = referenceLinesConfig.referenceLine2Position) !== null && _10 !== void 0 ? _10 : (referenceLinesConfig.referenceLine2Position || (3 * containerHeight) / 2);
|
|
146
148
|
referenceLine2Config = referenceLinesConfig.referenceLine2Config
|
|
147
149
|
? {
|
|
148
150
|
thickness: referenceLinesConfig.referenceLine2Config.thickness ||
|
|
149
151
|
defaultReferenceConfig.thickness,
|
|
150
|
-
width: (
|
|
152
|
+
width: (_11 = referenceLinesConfig.referenceLine2Config.width) !== null && _11 !== void 0 ? _11 : defaultReferenceConfig.width,
|
|
151
153
|
color: referenceLinesConfig.referenceLine2Config.color ||
|
|
152
154
|
defaultReferenceConfig.color,
|
|
153
155
|
type: referenceLinesConfig.referenceLine2Config.type ||
|
|
@@ -160,17 +162,17 @@ export var getHorizSectionVals = function (props) {
|
|
|
160
162
|
defaultReferenceConfig.labelText,
|
|
161
163
|
labelTextStyle: referenceLinesConfig.referenceLine2Config.labelTextStyle ||
|
|
162
164
|
defaultReferenceConfig.labelTextStyle,
|
|
163
|
-
zIndex: (
|
|
165
|
+
zIndex: (_12 = referenceLinesConfig.referenceLine2Config.zIndex) !== null && _12 !== void 0 ? _12 : defaultReferenceConfig.zIndex
|
|
164
166
|
}
|
|
165
167
|
: defaultReferenceConfig;
|
|
166
168
|
showReferenceLine3 = referenceLinesConfig.showReferenceLine3 || false;
|
|
167
169
|
referenceLine3Position =
|
|
168
|
-
(
|
|
170
|
+
(_13 = referenceLinesConfig.referenceLine3Position) !== null && _13 !== void 0 ? _13 : (referenceLinesConfig.referenceLine3Position || containerHeight / 3);
|
|
169
171
|
referenceLine3Config = referenceLinesConfig.referenceLine3Config
|
|
170
172
|
? {
|
|
171
173
|
thickness: referenceLinesConfig.referenceLine3Config.thickness ||
|
|
172
174
|
defaultReferenceConfig.thickness,
|
|
173
|
-
width: (
|
|
175
|
+
width: (_14 = referenceLinesConfig.referenceLine3Config.width) !== null && _14 !== void 0 ? _14 : defaultReferenceConfig.width,
|
|
174
176
|
color: referenceLinesConfig.referenceLine3Config.color ||
|
|
175
177
|
defaultReferenceConfig.color,
|
|
176
178
|
type: referenceLinesConfig.referenceLine3Config.type ||
|
|
@@ -183,7 +185,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
183
185
|
defaultReferenceConfig.labelText,
|
|
184
186
|
labelTextStyle: referenceLinesConfig.referenceLine3Config.labelTextStyle ||
|
|
185
187
|
defaultReferenceConfig.labelTextStyle,
|
|
186
|
-
zIndex: (
|
|
188
|
+
zIndex: (_15 = referenceLinesConfig.referenceLine3Config.zIndex) !== null && _15 !== void 0 ? _15 : defaultReferenceConfig.zIndex
|
|
187
189
|
}
|
|
188
190
|
: defaultReferenceConfig;
|
|
189
191
|
var getLabelTexts = function (val, index) {
|
|
@@ -105,11 +105,13 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
105
105
|
? secondaryData
|
|
106
106
|
: setWithMinValueInDataset === null || setWithMinValueInDataset === void 0 ? void 0 : setWithMinValueInDataset.data;
|
|
107
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 :
|
|
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
109
|
((_17 = secondaryYAxis === null || secondaryYAxis === void 0 ? void 0 : secondaryYAxis.noOfSections) !== null && _17 !== void 0 ? _17 : noOfSections);
|
|
110
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
|
-
|
|
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);
|
|
113
115
|
var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
|
|
114
116
|
var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis *
|
|
115
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);
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ interface IgetAxesAndRulesProps extends BarChartPropsType {
|
|
|
32
32
|
verticalLinesUptoDataPoint?: boolean;
|
|
33
33
|
referenceLinesConfig: ReferenceLinesConfig;
|
|
34
34
|
}
|
|
35
|
-
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, negativeStepValue?: number, maxValue?: number) => IgetAxesAndRulesProps;
|
|
35
|
+
export declare const getAxesAndRulesProps: (props: extendedBarChartPropsType, stepValue: number, roundToDigits: number, negativeStepValue?: number, maxValue?: number) => IgetAxesAndRulesProps;
|
|
36
36
|
export declare const getExtendedContainerHeightWithPadding: (containerHeight: number, overflowTop?: number) => number;
|
|
37
37
|
export declare const getSecondaryDataWithOffsetIncluded: (secondaryData?: barDataItem[] | lineDataItem[], secondaryYAxis?: any | undefined, showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => barDataItem[] | lineDataItem[] | undefined;
|
|
38
38
|
export declare const getArrowProperty: (property: string, count: number, props: extendedLineChartPropsType, defaultArrowConfig: arrowConfigType) => any;
|
|
@@ -79,6 +79,7 @@ interface MaxAndMin {
|
|
|
79
79
|
maxItem: number;
|
|
80
80
|
minItem: number;
|
|
81
81
|
}
|
|
82
|
+
export declare const indexOfFirstNonZeroDigit: (num: number) => number;
|
|
82
83
|
export declare const maxAndMinUtil: (maxItem: number, minItem: number, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
|
|
83
84
|
export declare const computeMaxAndMinItems: (data: any[] | undefined, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
|
|
84
85
|
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 +95,7 @@ export declare const getBarSideColor: (isFocused?: boolean, focusedBarConfig?: F
|
|
|
94
95
|
export declare const getBarTopColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemTopColor?: ColorValue, topColor?: ColorValue) => ColorValue | undefined;
|
|
95
96
|
export declare const getBarWidth: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemBarWidth?: number, barWidth?: number) => number;
|
|
96
97
|
export declare const getInterpolatedData: (dataParam: lineDataItem[], showDataPointsForMissingValues?: boolean, interpolateMissingValues?: boolean, onlyPositive?: boolean) => lineDataItem[];
|
|
98
|
+
export declare const getLineSegmentsDueToNoExtrapolation: (data?: lineDataItem[]) => LineSegment[] | undefined;
|
|
97
99
|
export declare const getLineSegmentsForMissingValues: (data?: lineDataItem[]) => LineSegment[] | undefined;
|
|
98
100
|
export declare const getTextSizeForPieLabels: (textSize: number, radius: number) => number;
|
|
99
101
|
export declare const adjustToOffset: (data: lineDataItem[], yAxisOffset?: number) => lineDataItem[];
|
package/dist/utils/index.js
CHANGED
|
@@ -486,7 +486,7 @@ 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) {
|
|
489
|
+
export var getAxesAndRulesProps = function (props, stepValue, roundToDigits, negativeStepValue, maxValue) {
|
|
490
490
|
var _a, _b, _c, _d, _e;
|
|
491
491
|
var secondaryYAxis = !props.secondaryYAxis || props.secondaryYAxis === true
|
|
492
492
|
? {}
|
|
@@ -551,7 +551,7 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
|
|
|
551
551
|
verticalLinesStrokeLinecap: props.verticalLinesStrokeLinecap,
|
|
552
552
|
// specific to Line charts-
|
|
553
553
|
verticalLinesUptoDataPoint: props.verticalLinesUptoDataPoint,
|
|
554
|
-
roundToDigits:
|
|
554
|
+
roundToDigits: roundToDigits,
|
|
555
555
|
stepValue: stepValue,
|
|
556
556
|
negativeStepValue: negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue,
|
|
557
557
|
secondaryYAxis: props.secondaryYAxis,
|
|
@@ -662,15 +662,28 @@ export var getAllArrowProperties = function (props, defaultArrowConfig) {
|
|
|
662
662
|
showArrowBasesFromSet: showArrowBasesFromSet
|
|
663
663
|
};
|
|
664
664
|
};
|
|
665
|
+
export var indexOfFirstNonZeroDigit = function (num) {
|
|
666
|
+
var numString = num.toString();
|
|
667
|
+
var i = 0;
|
|
668
|
+
var d = numString[i];
|
|
669
|
+
while (i < numString.length - 2 && (isNaN(Number(d)) || d === '0')) {
|
|
670
|
+
d = numString[++i];
|
|
671
|
+
}
|
|
672
|
+
return i;
|
|
673
|
+
};
|
|
665
674
|
export var maxAndMinUtil = function (maxItem, minItem, roundToDigits, showFractionalValues) {
|
|
666
675
|
if (showFractionalValues !== null && showFractionalValues !== void 0 ? showFractionalValues : roundToDigits) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
maxItem
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
676
|
+
var range = maxItem - minItem;
|
|
677
|
+
var stepValue = range / 10;
|
|
678
|
+
maxItem += stepValue;
|
|
679
|
+
minItem = minItem !== 0 ? minItem + stepValue : minItem;
|
|
680
|
+
// maxItem *= 10 * (roundToDigits ?? 1)
|
|
681
|
+
// maxItem = maxItem + (10 - (maxItem % 10))
|
|
682
|
+
// maxItem /= 10 * (roundToDigits ?? 1)
|
|
683
|
+
// maxItem = parseFloat(maxItem.toFixed(roundToDigits ?? 1))
|
|
684
|
+
// if (minItem !== 0) {
|
|
685
|
+
// minItem += minItem / 10
|
|
686
|
+
// }
|
|
674
687
|
}
|
|
675
688
|
else {
|
|
676
689
|
maxItem = maxItem + (10 - (maxItem % 10));
|
|
@@ -835,6 +848,11 @@ export var getBarTopColor = function (isFocused, focusedBarConfig, itemTopColor,
|
|
|
835
848
|
}
|
|
836
849
|
return itemTopColor !== null && itemTopColor !== void 0 ? itemTopColor : topColor;
|
|
837
850
|
};
|
|
851
|
+
var myFindLastIndex = function (arr, func) {
|
|
852
|
+
var tempLastIndex = arr.slice().reverse().findIndex(func);
|
|
853
|
+
var lastIndex = tempLastIndex >= 0 ? arr.length - 1 - tempLastIndex : tempLastIndex;
|
|
854
|
+
return lastIndex;
|
|
855
|
+
};
|
|
838
856
|
export var getBarWidth = function (isFocused, focusedBarConfig, itemBarWidth, barWidth) {
|
|
839
857
|
var _a, _b;
|
|
840
858
|
var localBarWidth = (_a = itemBarWidth !== null && itemBarWidth !== void 0 ? itemBarWidth : barWidth) !== null && _a !== void 0 ? _a : BarDefaults.barWidth;
|
|
@@ -891,12 +909,7 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
|
|
|
891
909
|
// 4. None has valid value -> this is already handled in preprocessing
|
|
892
910
|
var pre = data.slice(0, index);
|
|
893
911
|
var post = data.slice(index + 1, n);
|
|
894
|
-
var
|
|
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;
|
|
912
|
+
var preValidIndex = myFindLastIndex(pre, function (item) { return typeof item.value === 'number'; });
|
|
900
913
|
var postValidInd = post.findIndex(function (item) { return typeof item.value === 'number'; });
|
|
901
914
|
var postValidIndex = postValidInd + index + 1;
|
|
902
915
|
var count, step;
|
|
@@ -911,18 +924,12 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
|
|
|
911
924
|
// 2. Only pre has valid value
|
|
912
925
|
// Now there are 2 possibilities-
|
|
913
926
|
// 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
|
|
927
|
+
// 2. There are more than 1 valid values in pre
|
|
915
928
|
var secondPre = data.slice(0, preValidIndex);
|
|
916
|
-
var
|
|
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;
|
|
929
|
+
var secondPreIndex = myFindLastIndex(secondPre, function (item) { return typeof item.value === 'number'; });
|
|
924
930
|
count = preValidIndex - secondPreIndex;
|
|
925
931
|
step = (data[secondPreIndex].value - data[preValidIndex].value) / count;
|
|
932
|
+
var val = data[preValidIndex].value - step * (index - preValidIndex);
|
|
926
933
|
data[index].value =
|
|
927
934
|
data[preValidIndex].value - step * (index - preValidIndex);
|
|
928
935
|
}
|
|
@@ -948,6 +955,28 @@ export var getInterpolatedData = function (dataParam, showDataPointsForMissingVa
|
|
|
948
955
|
? data.map(function (item) { return (__assign(__assign({}, item), { value: Math.max(item.value, 0) })); })
|
|
949
956
|
: data;
|
|
950
957
|
};
|
|
958
|
+
export var getLineSegmentsDueToNoExtrapolation = function (data) {
|
|
959
|
+
if (!(data === null || data === void 0 ? void 0 : data.length))
|
|
960
|
+
return undefined;
|
|
961
|
+
var segments = [];
|
|
962
|
+
var firstNumericIndex = data.findIndex(function (item) { return typeof item.value === 'number'; });
|
|
963
|
+
if (firstNumericIndex !== 0) {
|
|
964
|
+
segments.push({
|
|
965
|
+
startIndex: 0,
|
|
966
|
+
endIndex: firstNumericIndex,
|
|
967
|
+
color: 'transparent'
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
var lastNumericIndex = myFindLastIndex(data, function (item) { return typeof item.value === 'number'; });
|
|
971
|
+
if (lastNumericIndex !== data.length) {
|
|
972
|
+
segments.push({
|
|
973
|
+
startIndex: lastNumericIndex,
|
|
974
|
+
endIndex: data.length,
|
|
975
|
+
color: 'transparent'
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
return segments;
|
|
979
|
+
};
|
|
951
980
|
export var getLineSegmentsForMissingValues = function (data) {
|
|
952
981
|
if (!(data === null || data === void 0 ? void 0 : data.length))
|
|
953
982
|
return undefined;
|