@harveylx/react-native-gifted-charts 1.4.70
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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +78 -0
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +222 -0
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +214 -0
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +256 -0
- package/dist/BarChart/styles.d.ts +45 -0
- package/dist/BarChart/styles.js +46 -0
- package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
- package/dist/Components/AnimatedThreeDBar/index.js +103 -0
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
- package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
- package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
- package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/cap.js +16 -0
- package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
- package/dist/Components/common/LinearGradient.d.ts +16 -0
- package/dist/Components/common/LinearGradient.js +15 -0
- package/dist/Components/common/Pointer.d.ts +1 -0
- package/dist/Components/common/Pointer.js +18 -0
- package/dist/Components/common/StripAndLabel.d.ts +2 -0
- package/dist/Components/common/StripAndLabel.js +60 -0
- package/dist/Components/lineSvg.d.ts +14 -0
- package/dist/Components/lineSvg.js +22 -0
- package/dist/LineChart/LineChartBicolor.d.ts +2 -0
- package/dist/LineChart/LineChartBicolor.js +298 -0
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1137 -0
- package/dist/LineChart/styles.d.ts +43 -0
- package/dist/LineChart/styles.js +46 -0
- package/dist/PieChart/index.d.ts +2 -0
- package/dist/PieChart/index.js +146 -0
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +178 -0
- package/dist/PieChartPro/index.d.ts +2 -0
- package/dist/PieChartPro/index.js +124 -0
- package/dist/PopulationPyramid/index.d.ts +2 -0
- package/dist/PopulationPyramid/index.js +132 -0
- package/dist/RadarChart/index.d.ts +2 -0
- package/dist/RadarChart/index.js +113 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +22 -0
- package/package.json +89 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
37
|
+
import { createElement as _createElement } from "react";
|
|
38
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
39
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
40
|
+
import { View, Animated, Easing, Text, Dimensions, I18nManager, } from 'react-native';
|
|
41
|
+
import { isWebApp, screenWidth, usePrevious } from '../utils';
|
|
42
|
+
import Svg, { Path, LinearGradient, Stop, Circle, Rect, Text as CanvasText, Line, ClipPath, Use, ForeignObject, Defs, Mask, } from 'react-native-svg';
|
|
43
|
+
import { getSegmentedPathObjects, getRegionPathObjects, RANGE_ENTER, RANGE_EXIT, SEGMENT_END, SEGMENT_START, STOP, svgPath, useLineChart, adjustToOffset, LineDefaults, pointsWithPaddedRepititions, } from '@harveylx/gifted-charts-core';
|
|
44
|
+
import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
|
|
45
|
+
import { StripAndLabel } from '../Components/common/StripAndLabel';
|
|
46
|
+
import { Pointer } from '../Components/common/Pointer';
|
|
47
|
+
var AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
48
|
+
var AnimatedRect = Animated.createAnimatedComponent(Rect);
|
|
49
|
+
export var LineChart = function (props) {
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
|
+
var scrollRef = (_a = props.scrollRef) !== null && _a !== void 0 ? _a : useRef(null);
|
|
52
|
+
var opacityValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
53
|
+
// const heightValue = useMemo(() => new Animated.Value(0), []);
|
|
54
|
+
var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
|
|
55
|
+
var widthValue2 = useMemo(function () { return new Animated.Value(0); }, []);
|
|
56
|
+
var widthValue3 = useMemo(function () { return new Animated.Value(0); }, []);
|
|
57
|
+
var widthValue4 = useMemo(function () { return new Animated.Value(0); }, []);
|
|
58
|
+
var widthValue5 = useMemo(function () { return new Animated.Value(0); }, []);
|
|
59
|
+
var _e = useLineChart(__assign(__assign({}, props), { parentWidth: (_b = props.parentWidth) !== null && _b !== void 0 ? _b : screenWidth })), curveType = _e.curveType, scrollX = _e.scrollX, setScrollX = _e.setScrollX, arrow1Points = _e.arrow1Points, arrow2Points = _e.arrow2Points, arrow3Points = _e.arrow3Points, arrow4Points = _e.arrow4Points, arrow5Points = _e.arrow5Points, secondaryArrowPoints = _e.secondaryArrowPoints, pointerIndex = _e.pointerIndex, setPointerIndex = _e.setPointerIndex, pointerX = _e.pointerX, setPointerX = _e.setPointerX, pointerY = _e.pointerY, setPointerY = _e.setPointerY, pointerItem = _e.pointerItem, setPointerItem = _e.setPointerItem, pointerY2 = _e.pointerY2, setPointerY2 = _e.setPointerY2, pointerItem2 = _e.pointerItem2, setPointerItem2 = _e.setPointerItem2, pointerY3 = _e.pointerY3, setPointerY3 = _e.setPointerY3, pointerItem3 = _e.pointerItem3, setPointerItem3 = _e.setPointerItem3, pointerY4 = _e.pointerY4, setPointerY4 = _e.setPointerY4, pointerItem4 = _e.pointerItem4, setPointerItem4 = _e.setPointerItem4, pointerY5 = _e.pointerY5, setPointerY5 = _e.setPointerY5, pointerYsForDataSet = _e.pointerYsForDataSet, setPointerYsForDataSet = _e.setPointerYsForDataSet, pointerItem5 = _e.pointerItem5, setPointerItem5 = _e.setPointerItem5, secondaryPointerY = _e.secondaryPointerY, setSecondaryPointerY = _e.setSecondaryPointerY, secondaryPointerItem = _e.secondaryPointerItem, setSecondaryPointerItem = _e.setSecondaryPointerItem, pointerItemsForSet = _e.pointerItemsForSet, setPointerItemsForSet = _e.setPointerItemsForSet, secondaryPointerItemsForSet = _e.secondaryPointerItemsForSet, setSecondaryPointerItemsForSet = _e.setSecondaryPointerItemsForSet, responderStartTime = _e.responderStartTime, setResponderStartTime = _e.setResponderStartTime, setResponderActive = _e.setResponderActive, points = _e.points, points2 = _e.points2, points3 = _e.points3, points4 = _e.points4, points5 = _e.points5, secondaryPoints = _e.secondaryPoints, fillPoints = _e.fillPoints, fillPoints2 = _e.fillPoints2, fillPoints3 = _e.fillPoints3, fillPoints4 = _e.fillPoints4, fillPoints5 = _e.fillPoints5, secondaryFillPoints = _e.secondaryFillPoints, pointsFromSet = _e.pointsFromSet, fillPointsFromSet = _e.fillPointsFromSet, arrowPointsFromSet = _e.arrowPointsFromSet, selectedIndex = _e.selectedIndex, setSelectedIndex = _e.setSelectedIndex, containerHeight = _e.containerHeight, data = _e.data, data2 = _e.data2, data3 = _e.data3, data4 = _e.data4, data5 = _e.data5, secondaryData = _e.secondaryData, dataSet = _e.dataSet, data0 = _e.data0, labelsExtraHeight = _e.labelsExtraHeight, animationDuration = _e.animationDuration, onDataChangeAnimationDuration = _e.onDataChangeAnimationDuration, animateTogether = _e.animateTogether, renderDataPointsAfterAnimationEnds = _e.renderDataPointsAfterAnimationEnds, animateOnDataChange = _e.animateOnDataChange, startIndex1 = _e.startIndex1, startIndex2 = _e.startIndex2, endIndex1 = _e.endIndex1, endIndex2 = _e.endIndex2, startIndex3 = _e.startIndex3, endIndex3 = _e.endIndex3, startIndex4 = _e.startIndex4, endIndex4 = _e.endIndex4, startIndex5 = _e.startIndex5, endIndex5 = _e.endIndex5, initialSpacing = _e.initialSpacing, thickness = _e.thickness, yAxisLabelWidth = _e.yAxisLabelWidth, spacing = _e.spacing, xAxisThickness = _e.xAxisThickness, dataPointsHeight1 = _e.dataPointsHeight1, dataPointsWidth1 = _e.dataPointsWidth1, dataPointsRadius1 = _e.dataPointsRadius1, dataPointsColor1 = _e.dataPointsColor1, dataPointsShape1 = _e.dataPointsShape1, dataPointsHeight2 = _e.dataPointsHeight2, dataPointsWidth2 = _e.dataPointsWidth2, dataPointsRadius2 = _e.dataPointsRadius2, dataPointsColor2 = _e.dataPointsColor2, dataPointsShape2 = _e.dataPointsShape2, dataPointsHeight3 = _e.dataPointsHeight3, dataPointsWidth3 = _e.dataPointsWidth3, dataPointsRadius3 = _e.dataPointsRadius3, dataPointsColor3 = _e.dataPointsColor3, dataPointsShape3 = _e.dataPointsShape3, dataPointsHeight4 = _e.dataPointsHeight4, dataPointsWidth4 = _e.dataPointsWidth4, dataPointsRadius4 = _e.dataPointsRadius4, dataPointsColor4 = _e.dataPointsColor4, dataPointsShape4 = _e.dataPointsShape4, dataPointsHeight5 = _e.dataPointsHeight5, dataPointsWidth5 = _e.dataPointsWidth5, dataPointsRadius5 = _e.dataPointsRadius5, dataPointsColor5 = _e.dataPointsColor5, dataPointsShape5 = _e.dataPointsShape5, getIsNthAreaChart = _e.getIsNthAreaChart, textFontSize1 = _e.textFontSize1, textFontSize2 = _e.textFontSize2, textFontSize3 = _e.textFontSize3, textFontSize4 = _e.textFontSize4, textFontSize5 = _e.textFontSize5, textColor1 = _e.textColor1, textColor2 = _e.textColor2, textColor3 = _e.textColor3, textColor4 = _e.textColor4, textColor5 = _e.textColor5, totalWidth = _e.totalWidth, maxValue = _e.maxValue, overflowTop = _e.overflowTop, extendedContainerHeight = _e.extendedContainerHeight, getX = _e.getX, getY = _e.getY, getSecondaryY = _e.getSecondaryY, secondaryMaxValue = _e.secondaryMaxValue, showValuesAsDataPointsText = _e.showValuesAsDataPointsText, thickness1 = _e.thickness1, thickness2 = _e.thickness2, thickness3 = _e.thickness3, thickness4 = _e.thickness4, thickness5 = _e.thickness5, zIndex1 = _e.zIndex1, zIndex2 = _e.zIndex2, zIndex3 = _e.zIndex3, zIndex4 = _e.zIndex4, zIndex5 = _e.zIndex5, strokeDashArray1 = _e.strokeDashArray1, strokeDashArray2 = _e.strokeDashArray2, strokeDashArray3 = _e.strokeDashArray3, strokeDashArray4 = _e.strokeDashArray4, strokeDashArray5 = _e.strokeDashArray5, strokeLinecap1 = _e.strokeLinecap1, strokeLinecap2 = _e.strokeLinecap2, strokeLinecap3 = _e.strokeLinecap3, strokeLinecap4 = _e.strokeLinecap4, strokeLinecap5 = _e.strokeLinecap5, rotateLabel = _e.rotateLabel, isAnimated = _e.isAnimated, hideDataPoints1 = _e.hideDataPoints1, hideDataPoints2 = _e.hideDataPoints2, hideDataPoints3 = _e.hideDataPoints3, hideDataPoints4 = _e.hideDataPoints4, hideDataPoints5 = _e.hideDataPoints5, color1 = _e.color1, color2 = _e.color2, color3 = _e.color3, color4 = _e.color4, color5 = _e.color5, startFillColor1 = _e.startFillColor1, endFillColor1 = _e.endFillColor1, startOpacity1 = _e.startOpacity1, endOpacity1 = _e.endOpacity1, startFillColor2 = _e.startFillColor2, endFillColor2 = _e.endFillColor2, startOpacity2 = _e.startOpacity2, endOpacity2 = _e.endOpacity2, startFillColor3 = _e.startFillColor3, endFillColor3 = _e.endFillColor3, startOpacity3 = _e.startOpacity3, endOpacity3 = _e.endOpacity3, startFillColor4 = _e.startFillColor4, endFillColor4 = _e.endFillColor4, startOpacity4 = _e.startOpacity4, endOpacity4 = _e.endOpacity4, startFillColor5 = _e.startFillColor5, endFillColor5 = _e.endFillColor5, startOpacity5 = _e.startOpacity5, endOpacity5 = _e.endOpacity5, arrowStrokeWidth1 = _e.arrowStrokeWidth1, arrowStrokeColor1 = _e.arrowStrokeColor1, arrowFillColor1 = _e.arrowFillColor1, arrowStrokeWidth2 = _e.arrowStrokeWidth2, arrowStrokeColor2 = _e.arrowStrokeColor2, arrowFillColor2 = _e.arrowFillColor2, arrowStrokeWidth3 = _e.arrowStrokeWidth3, arrowStrokeColor3 = _e.arrowStrokeColor3, arrowFillColor3 = _e.arrowFillColor3, arrowStrokeWidth4 = _e.arrowStrokeWidth4, arrowStrokeColor4 = _e.arrowStrokeColor4, arrowFillColor4 = _e.arrowFillColor4, arrowStrokeWidth5 = _e.arrowStrokeWidth5, arrowStrokeColor5 = _e.arrowStrokeColor5, arrowFillColor5 = _e.arrowFillColor5, arrowStrokeWidthsFromSet = _e.arrowStrokeWidthsFromSet, arrowStrokeColorsFromSet = _e.arrowStrokeColorsFromSet, arrowFillColorsFromSet = _e.arrowFillColorsFromSet, secondaryLineConfig = _e.secondaryLineConfig, gradientDirection = _e.gradientDirection, stepHeight = _e.stepHeight, noOfSectionsBelowXAxis = _e.noOfSectionsBelowXAxis, xAxisTextNumberOfLines = _e.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = _e.xAxisLabelsVerticalShift, pointerConfig = _e.pointerConfig, pointerHeight = _e.pointerHeight, pointerWidth = _e.pointerWidth, pointerRadius = _e.pointerRadius, pointerColor = _e.pointerColor, pointerComponent = _e.pointerComponent, showPointerStrip = _e.showPointerStrip, pointerStripHeight = _e.pointerStripHeight, pointerStripWidth = _e.pointerStripWidth, pointerStripColor = _e.pointerStripColor, pointerStripUptoDataPoint = _e.pointerStripUptoDataPoint, pointerLabelComponent = _e.pointerLabelComponent, stripOverPointer = _e.stripOverPointer, shiftPointerLabelX = _e.shiftPointerLabelX, shiftPointerLabelY = _e.shiftPointerLabelY, pointerLabelWidth = _e.pointerLabelWidth, pointerLabelHeight = _e.pointerLabelHeight, autoAdjustPointerLabelPosition = _e.autoAdjustPointerLabelPosition, pointerVanishDelay = _e.pointerVanishDelay, activatePointersOnLongPress = _e.activatePointersOnLongPress, activatePointersInstantlyOnTouch = _e.activatePointersInstantlyOnTouch, activatePointersDelay = _e.activatePointersDelay, persistPointer = _e.persistPointer, resetPointerIndexOnRelease = _e.resetPointerIndexOnRelease, hidePointers = _e.hidePointers, hidePointer1 = _e.hidePointer1, hidePointer2 = _e.hidePointer2, hidePointer3 = _e.hidePointer3, hidePointer4 = _e.hidePointer4, hidePointer5 = _e.hidePointer5, cumulativeSpacing1 = _e.cumulativeSpacing1, cumulativeSpacing2 = _e.cumulativeSpacing2, cumulativeSpacing3 = _e.cumulativeSpacing3, cumulativeSpacing4 = _e.cumulativeSpacing4, cumulativeSpacing5 = _e.cumulativeSpacing5, cumulativeSpacingSecondary = _e.cumulativeSpacingSecondary, cumulativeSpacingForSet = _e.cumulativeSpacingForSet, hideSecondaryPointer = _e.hideSecondaryPointer, hidePointerDataPointForMissingValues = _e.hidePointerDataPointForMissingValues, pointerEvents = _e.pointerEvents, focusEnabled = _e.focusEnabled, showDataPointOnFocus = _e.showDataPointOnFocus, showStripOnFocus = _e.showStripOnFocus, stripOverDataPoints = _e.stripOverDataPoints, showTextOnFocus = _e.showTextOnFocus, showDataPointLabelOnFocus = _e.showDataPointLabelOnFocus, stripHeight = _e.stripHeight, stripWidth = _e.stripWidth, stripColor = _e.stripColor, stripOpacity = _e.stripOpacity, stripStrokeDashArray = _e.stripStrokeDashArray, _f = _e.containerHeightIncludingBelowXAxis, containerHeightIncludingBelowXAxis = _f === void 0 ? 0 : _f, lineGradient = _e.lineGradient, lineGradientDirection = _e.lineGradientDirection, lineGradientStartColor = _e.lineGradientStartColor, lineGradientEndColor = _e.lineGradientEndColor, barAndLineChartsWrapperProps = _e.barAndLineChartsWrapperProps, areaChart = _e.areaChart, mostNegativeValue = _e.mostNegativeValue, strips = _e.strips, lastLineNumber = _e.lastLineNumber, focusTogether = _e.focusTogether, selectedLineNumber = _e.selectedLineNumber, handleFocus = _e.handleFocus, handleUnFocus = _e.handleUnFocus, stepValue = _e.stepValue, pointerItemLocal = _e.pointerItemLocal, allowFontScaling = _e.allowFontScaling, colors = _e.colors;
|
|
60
|
+
var svgHeight = containerHeightIncludingBelowXAxis +
|
|
61
|
+
((_c = props.overflowBottom) !== null && _c !== void 0 ? _c : dataPointsRadius1);
|
|
62
|
+
var secondaryXAxis = props.secondaryXAxis, intersectionAreaConfig = props.intersectionAreaConfig;
|
|
63
|
+
var widthValuesFromSet = useMemo(function () { return dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set) { return new Animated.Value(0); }); }, []);
|
|
64
|
+
var animatedPoints = new Animated.Value(0);
|
|
65
|
+
var animatedFillPoints = new Animated.Value(0);
|
|
66
|
+
var oldPoints = usePrevious(points);
|
|
67
|
+
var oldFillPoints = usePrevious(fillPoints);
|
|
68
|
+
var animatedPath = animateOnDataChange && points && oldPoints && points !== oldPoints
|
|
69
|
+
? animatedPoints.interpolate({
|
|
70
|
+
inputRange: [0, 1],
|
|
71
|
+
outputRange: pointsWithPaddedRepititions(oldPoints, points),
|
|
72
|
+
})
|
|
73
|
+
: '';
|
|
74
|
+
var animatedFillPath = animateOnDataChange &&
|
|
75
|
+
fillPoints &&
|
|
76
|
+
oldFillPoints &&
|
|
77
|
+
fillPoints !== oldFillPoints
|
|
78
|
+
? animatedFillPoints.interpolate({
|
|
79
|
+
inputRange: [0, 1],
|
|
80
|
+
outputRange: pointsWithPaddedRepititions(oldFillPoints, fillPoints),
|
|
81
|
+
})
|
|
82
|
+
: '';
|
|
83
|
+
useEffect(function () {
|
|
84
|
+
if (animateOnDataChange) {
|
|
85
|
+
Animated.timing(animatedPoints, {
|
|
86
|
+
toValue: 1,
|
|
87
|
+
duration: onDataChangeAnimationDuration,
|
|
88
|
+
useNativeDriver: true,
|
|
89
|
+
easing: Easing.ease,
|
|
90
|
+
}).start();
|
|
91
|
+
if (props.areaChart || props.areaChart1) {
|
|
92
|
+
Animated.timing(animatedFillPoints, {
|
|
93
|
+
toValue: 1,
|
|
94
|
+
duration: onDataChangeAnimationDuration,
|
|
95
|
+
useNativeDriver: true,
|
|
96
|
+
easing: Easing.ease,
|
|
97
|
+
}).start();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, [animatedPoints]);
|
|
101
|
+
var labelsAppear = useCallback(function () {
|
|
102
|
+
opacityValue.setValue(0);
|
|
103
|
+
Animated.timing(opacityValue, {
|
|
104
|
+
toValue: 1,
|
|
105
|
+
duration: 500,
|
|
106
|
+
easing: Easing.ease,
|
|
107
|
+
useNativeDriver: false,
|
|
108
|
+
}).start();
|
|
109
|
+
}, [opacityValue]);
|
|
110
|
+
var appearingOpacity = opacityValue.interpolate({
|
|
111
|
+
inputRange: [0, 1],
|
|
112
|
+
outputRange: [0, 1],
|
|
113
|
+
});
|
|
114
|
+
var decreaseWidth = useCallback(function () {
|
|
115
|
+
widthValue.setValue(0);
|
|
116
|
+
Animated.timing(widthValue, {
|
|
117
|
+
toValue: totalWidth,
|
|
118
|
+
duration: animationDuration,
|
|
119
|
+
easing: Easing.linear,
|
|
120
|
+
useNativeDriver: false,
|
|
121
|
+
}).start();
|
|
122
|
+
}, [animationDuration, widthValue]);
|
|
123
|
+
var decreaseWidth2 = useCallback(function () {
|
|
124
|
+
widthValue2.setValue(0);
|
|
125
|
+
Animated.timing(widthValue2, {
|
|
126
|
+
toValue: totalWidth,
|
|
127
|
+
duration: animationDuration,
|
|
128
|
+
easing: Easing.linear,
|
|
129
|
+
useNativeDriver: false,
|
|
130
|
+
}).start();
|
|
131
|
+
}, [animationDuration, widthValue2]);
|
|
132
|
+
var decreaseWidth3 = useCallback(function () {
|
|
133
|
+
widthValue3.setValue(0);
|
|
134
|
+
Animated.timing(widthValue3, {
|
|
135
|
+
toValue: totalWidth,
|
|
136
|
+
duration: animationDuration,
|
|
137
|
+
easing: Easing.linear,
|
|
138
|
+
useNativeDriver: false,
|
|
139
|
+
}).start();
|
|
140
|
+
}, [animationDuration, widthValue3]);
|
|
141
|
+
var decreaseWidth4 = useCallback(function () {
|
|
142
|
+
widthValue4.setValue(0);
|
|
143
|
+
Animated.timing(widthValue4, {
|
|
144
|
+
toValue: totalWidth,
|
|
145
|
+
duration: animationDuration,
|
|
146
|
+
easing: Easing.linear,
|
|
147
|
+
useNativeDriver: false,
|
|
148
|
+
}).start();
|
|
149
|
+
}, [animationDuration, widthValue4]);
|
|
150
|
+
var decreaseWidth5 = useCallback(function () {
|
|
151
|
+
widthValue5.setValue(0);
|
|
152
|
+
Animated.timing(widthValue5, {
|
|
153
|
+
toValue: totalWidth,
|
|
154
|
+
duration: animationDuration,
|
|
155
|
+
easing: Easing.linear,
|
|
156
|
+
useNativeDriver: false,
|
|
157
|
+
}).start();
|
|
158
|
+
}, [animationDuration, widthValue5]);
|
|
159
|
+
var decreaseWidthsFromSet = useCallback(function () {
|
|
160
|
+
dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set, index) {
|
|
161
|
+
var _a;
|
|
162
|
+
(_a = widthValuesFromSet === null || widthValuesFromSet === void 0 ? void 0 : widthValuesFromSet[index]) === null || _a === void 0 ? void 0 : _a.setValue(0);
|
|
163
|
+
if (widthValuesFromSet === null || widthValuesFromSet === void 0 ? void 0 : widthValuesFromSet[index]) {
|
|
164
|
+
Animated.timing(widthValuesFromSet === null || widthValuesFromSet === void 0 ? void 0 : widthValuesFromSet[index], {
|
|
165
|
+
toValue: totalWidth,
|
|
166
|
+
duration: animationDuration,
|
|
167
|
+
easing: Easing.linear,
|
|
168
|
+
useNativeDriver: false,
|
|
169
|
+
}).start();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}, [animationDuration, widthValuesFromSet]);
|
|
173
|
+
useEffect(function () {
|
|
174
|
+
decreaseWidth();
|
|
175
|
+
labelsAppear();
|
|
176
|
+
widthValuesFromSet === null || widthValuesFromSet === void 0 ? void 0 : widthValuesFromSet.forEach(function (item, index) {
|
|
177
|
+
setTimeout(function () {
|
|
178
|
+
decreaseWidthsFromSet();
|
|
179
|
+
}, animateTogether ? 0 : animationDuration * index);
|
|
180
|
+
});
|
|
181
|
+
setTimeout(function () {
|
|
182
|
+
decreaseWidth2();
|
|
183
|
+
}, animateTogether ? 0 : animationDuration);
|
|
184
|
+
setTimeout(function () {
|
|
185
|
+
decreaseWidth3();
|
|
186
|
+
}, animateTogether ? 0 : animationDuration * 2);
|
|
187
|
+
setTimeout(function () {
|
|
188
|
+
decreaseWidth4();
|
|
189
|
+
}, animateTogether ? 0 : animationDuration * 3);
|
|
190
|
+
setTimeout(function () {
|
|
191
|
+
decreaseWidth5();
|
|
192
|
+
}, animateTogether ? 0 : animationDuration * 4);
|
|
193
|
+
}, [
|
|
194
|
+
animateTogether,
|
|
195
|
+
animationDuration,
|
|
196
|
+
decreaseWidth,
|
|
197
|
+
decreaseWidth2,
|
|
198
|
+
decreaseWidth3,
|
|
199
|
+
decreaseWidth4,
|
|
200
|
+
decreaseWidth5,
|
|
201
|
+
labelsAppear,
|
|
202
|
+
]);
|
|
203
|
+
var svgWrapperViewStyle = {
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
bottom: 61 + xAxisLabelsVerticalShift + labelsExtraHeight - xAxisThickness,
|
|
206
|
+
left: 0,
|
|
207
|
+
zIndex: 1,
|
|
208
|
+
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
|
|
209
|
+
};
|
|
210
|
+
var renderLabel = function (top, index, label, labelTextStyle, labelComponent) {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
return (_jsx(View, { style: [
|
|
213
|
+
{
|
|
214
|
+
position: 'absolute',
|
|
215
|
+
bottom: top
|
|
216
|
+
? containerHeight +
|
|
217
|
+
60 +
|
|
218
|
+
((_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _a !== void 0 ? _a : 15)
|
|
219
|
+
: 54 - xAxisTextNumberOfLines * 18,
|
|
220
|
+
zIndex: 10,
|
|
221
|
+
width: spacing + labelsExtraHeight,
|
|
222
|
+
left: spacing * index - spacing / 2,
|
|
223
|
+
height: (_b = props.xAxisLabelsHeight) !== null && _b !== void 0 ? _b : xAxisTextNumberOfLines * 18,
|
|
224
|
+
},
|
|
225
|
+
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
226
|
+
], children: labelComponent ? (labelComponent()) : (_jsx(Text, { style: [{ textAlign: 'center' }, labelTextStyle], allowFontScaling: allowFontScaling, numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
227
|
+
};
|
|
228
|
+
var renderAnimatedLabel = function (top, index, label, labelTextStyle, labelComponent) {
|
|
229
|
+
var _a, _b;
|
|
230
|
+
return (_jsx(Animated.View, { style: [
|
|
231
|
+
{
|
|
232
|
+
height: rotateLabel
|
|
233
|
+
? 40
|
|
234
|
+
: ((_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18),
|
|
235
|
+
position: 'absolute',
|
|
236
|
+
bottom: top
|
|
237
|
+
? containerHeight +
|
|
238
|
+
60 +
|
|
239
|
+
((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
|
|
240
|
+
: rotateLabel
|
|
241
|
+
? 10
|
|
242
|
+
: 54 - xAxisTextNumberOfLines * 18,
|
|
243
|
+
zIndex: 10,
|
|
244
|
+
width: spacing,
|
|
245
|
+
left: spacing * index - spacing / 2,
|
|
246
|
+
opacity: appearingOpacity,
|
|
247
|
+
},
|
|
248
|
+
rotateLabel && { transform: [{ rotate: '60deg' }] },
|
|
249
|
+
], children: labelComponent ? (labelComponent()) : (_jsx(Text, { allowFontScaling: allowFontScaling, style: [{ textAlign: 'center' }, labelTextStyle], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
|
|
250
|
+
};
|
|
251
|
+
var onStripPress = function (item, index) {
|
|
252
|
+
if (props.focusedDataPointIndex === undefined || !props.onFocus) {
|
|
253
|
+
setSelectedIndex(index);
|
|
254
|
+
}
|
|
255
|
+
if (props.onFocus) {
|
|
256
|
+
props.onFocus(item, index);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
// const [selectedLineNumber, setSelectedLineNumber] = useState(-1);
|
|
260
|
+
var renderDataPoints = function (hideDataPoints, dataForRender, originalDataFromProps, dataPtsShape, dataPtsWidth, dataPtsHeight, dataPtsColor, dataPtsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
261
|
+
var getYOrSecondaryY = isSecondary ? getSecondaryY : getY;
|
|
262
|
+
return dataForRender.map(function (item, index) {
|
|
263
|
+
var _a, _b, _c, _d, _e, _f;
|
|
264
|
+
if (index < startIndex || index > endIndex)
|
|
265
|
+
return null;
|
|
266
|
+
if (item.hideDataPoint) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
var dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, text, customDataPoint, dataPointLabelComponent;
|
|
270
|
+
if (index === selectedIndex &&
|
|
271
|
+
(focusTogether || key === selectedLineNumber)) {
|
|
272
|
+
dataPointsShape =
|
|
273
|
+
item.focusedDataPointShape ||
|
|
274
|
+
props.focusedDataPointShape ||
|
|
275
|
+
item.dataPointShape ||
|
|
276
|
+
dataPtsShape;
|
|
277
|
+
dataPointsWidth =
|
|
278
|
+
item.focusedDataPointWidth ||
|
|
279
|
+
props.focusedDataPointWidth ||
|
|
280
|
+
item.dataPointWidth ||
|
|
281
|
+
dataPtsWidth;
|
|
282
|
+
dataPointsHeight =
|
|
283
|
+
item.focusedDataPointHeight ||
|
|
284
|
+
props.focusedDataPointHeight ||
|
|
285
|
+
item.dataPointHeight ||
|
|
286
|
+
dataPtsHeight;
|
|
287
|
+
dataPointsColor =
|
|
288
|
+
item.focusedDataPointColor ||
|
|
289
|
+
props.focusedDataPointColor ||
|
|
290
|
+
LineDefaults.focusedDataPointColor;
|
|
291
|
+
dataPointsRadius =
|
|
292
|
+
(_c = (_b = (_a = item.focusedDataPointRadius) !== null && _a !== void 0 ? _a : props.focusedDataPointRadius) !== null && _b !== void 0 ? _b : item.dataPointRadius) !== null && _c !== void 0 ? _c : dataPtsRadius;
|
|
293
|
+
if (showTextOnFocus) {
|
|
294
|
+
text = item.dataPointText;
|
|
295
|
+
}
|
|
296
|
+
customDataPoint =
|
|
297
|
+
item.focusedCustomDataPoint ||
|
|
298
|
+
props.focusedCustomDataPoint ||
|
|
299
|
+
item.customDataPoint ||
|
|
300
|
+
props.customDataPoint;
|
|
301
|
+
dataPointLabelComponent =
|
|
302
|
+
item.focusedDataPointLabelComponent ||
|
|
303
|
+
item.dataPointLabelComponent ||
|
|
304
|
+
props.focusedDataPointLabelComponent ||
|
|
305
|
+
props.dataPointLabelComponent;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
dataPointsShape = item.dataPointShape || dataPtsShape;
|
|
309
|
+
dataPointsWidth = item.dataPointWidth || dataPtsWidth;
|
|
310
|
+
dataPointsHeight = item.dataPointHeight || dataPtsHeight;
|
|
311
|
+
dataPointsColor = item.dataPointColor || dataPtsColor;
|
|
312
|
+
dataPointsRadius = (_d = item.dataPointRadius) !== null && _d !== void 0 ? _d : dataPtsRadius;
|
|
313
|
+
if (showTextOnFocus) {
|
|
314
|
+
text = '';
|
|
315
|
+
}
|
|
316
|
+
customDataPoint = item.customDataPoint || props.customDataPoint;
|
|
317
|
+
dataPointLabelComponent =
|
|
318
|
+
item.dataPointLabelComponent || props.dataPointLabelComponent;
|
|
319
|
+
}
|
|
320
|
+
if (showValuesAsDataPointsText) {
|
|
321
|
+
text = originalDataFromProps[index].value;
|
|
322
|
+
}
|
|
323
|
+
var dataPointLabelWidth = item.dataPointLabelWidth
|
|
324
|
+
? item.dataPointLabelWidth
|
|
325
|
+
: props.dataPointLabelWidth
|
|
326
|
+
? props.dataPointLabelWidth
|
|
327
|
+
: 30;
|
|
328
|
+
return (_jsxs(Fragment, { children: [focusEnabled ? (_jsx(_Fragment, { children: key === lastLineNumber - 1 ? (_jsx(Rect, { x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight - 0, fill: 'none', onPressIn: function (evt) {
|
|
329
|
+
var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
|
|
330
|
+
handleFocus(index, item, locationY, onStripPress);
|
|
331
|
+
}, onPressOut: handleUnFocus })) : null })) : null, hideDataPoints ? null : (_jsxs(_Fragment, { children: [customDataPoint ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: initialSpacing -
|
|
332
|
+
dataPointsWidth / 2 +
|
|
333
|
+
((_e = spacingArray[index - 1]) !== null && _e !== void 0 ? _e : 0), y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, children: customDataPoint(item, index) })) : (_jsx(Animated.View, { style: {
|
|
334
|
+
position: 'absolute',
|
|
335
|
+
// height: svgHeight,
|
|
336
|
+
// width: totalWidth,
|
|
337
|
+
left: initialSpacing -
|
|
338
|
+
dataPointsWidth / 2 +
|
|
339
|
+
((_f = spacingArray[index - 1]) !== null && _f !== void 0 ? _f : 0),
|
|
340
|
+
top: getYOrSecondaryY(item.value) - dataPointsHeight / 2,
|
|
341
|
+
opacity: isAnimated ? appearingOpacity : 1,
|
|
342
|
+
}, children: customDataPoint(item, index) }))) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Rect, { x: getX(spacingArray, index) - dataPointsWidth / 2, y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, width: dataPointsWidth, height: dataPointsHeight, fill: showDataPointOnFocus
|
|
343
|
+
? index === selectedIndex
|
|
344
|
+
? dataPointsColor
|
|
345
|
+
: 'none'
|
|
346
|
+
: dataPointsColor, onPress: function () {
|
|
347
|
+
item.onPress
|
|
348
|
+
? item.onPress(item, index)
|
|
349
|
+
: props.onPress
|
|
350
|
+
? props.onPress(item, index)
|
|
351
|
+
: focusEnabled
|
|
352
|
+
? handleFocus(index, item, 0, onStripPress)
|
|
353
|
+
: null;
|
|
354
|
+
}, onPressOut: function () {
|
|
355
|
+
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
356
|
+
handleUnFocus();
|
|
357
|
+
}
|
|
358
|
+
} })) }, index)) : (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Circle, { cx: getX(spacingArray, index), cy: getYOrSecondaryY(item.value), r: dataPointsRadius, fill: showDataPointOnFocus
|
|
359
|
+
? index === selectedIndex
|
|
360
|
+
? dataPointsColor
|
|
361
|
+
: 'none'
|
|
362
|
+
: dataPointsColor, onPress: function () {
|
|
363
|
+
item.onPress
|
|
364
|
+
? item.onPress(item, index)
|
|
365
|
+
: props.onPress
|
|
366
|
+
? props.onPress(item, index)
|
|
367
|
+
: focusEnabled
|
|
368
|
+
? handleFocus(index, item, 0, onStripPress)
|
|
369
|
+
: null;
|
|
370
|
+
}, onPressOut: function () {
|
|
371
|
+
if (!item.onPress && !props.onPress && focusEnabled) {
|
|
372
|
+
handleUnFocus();
|
|
373
|
+
}
|
|
374
|
+
} })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: dataPointLabelWidth, x: initialSpacing +
|
|
375
|
+
(item.dataPointLabelShiftX ||
|
|
376
|
+
props.dataPointLabelShiftX ||
|
|
377
|
+
0) -
|
|
378
|
+
dataPointLabelWidth / 2 +
|
|
379
|
+
spacing * index, y: containerHeight +
|
|
380
|
+
(item.dataPointLabelShiftY ||
|
|
381
|
+
props.dataPointLabelShiftY ||
|
|
382
|
+
0) -
|
|
383
|
+
(item.value * containerHeight) / maxValue, children: showDataPointLabelOnFocus
|
|
384
|
+
? index === selectedIndex &&
|
|
385
|
+
(focusTogether || key == selectedLineNumber)
|
|
386
|
+
? dataPointLabelComponent(item, index) // not pushed in latest release
|
|
387
|
+
: null
|
|
388
|
+
: dataPointLabelComponent(item, index) })) : (_jsx(View, { style: {
|
|
389
|
+
position: 'absolute',
|
|
390
|
+
height: svgHeight,
|
|
391
|
+
width: dataPointLabelWidth,
|
|
392
|
+
left: initialSpacing +
|
|
393
|
+
(item.dataPointLabelShiftX ||
|
|
394
|
+
props.dataPointLabelShiftX ||
|
|
395
|
+
0) -
|
|
396
|
+
dataPointLabelWidth / 2 +
|
|
397
|
+
spacing * index,
|
|
398
|
+
top: containerHeight +
|
|
399
|
+
(item.dataPointLabelShiftY ||
|
|
400
|
+
props.dataPointLabelShiftY ||
|
|
401
|
+
0) -
|
|
402
|
+
(item.value * containerHeight) / maxValue,
|
|
403
|
+
}, children: showDataPointLabelOnFocus
|
|
404
|
+
? index === selectedIndex &&
|
|
405
|
+
(focusTogether || key == selectedLineNumber)
|
|
406
|
+
? dataPointLabelComponent(item, index) // not pushed in latest release
|
|
407
|
+
: null
|
|
408
|
+
: dataPointLabelComponent(item, index) }))) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: getX(spacingArray, index) -
|
|
409
|
+
dataPointsWidth +
|
|
410
|
+
(item.textShiftX || props.textShiftX || 0), y: getYOrSecondaryY(item.value) -
|
|
411
|
+
dataPointsHeight / 2 +
|
|
412
|
+
(item.textShiftY || props.textShiftY || 0), children: !showTextOnFocus && !showValuesAsDataPointsText
|
|
413
|
+
? item.dataPointText
|
|
414
|
+
: text })) : null) : null, index === selectedIndex ? _jsx(Text, { children: '' }) : null] }))] }, index));
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
var renderSpecificVerticalLines = function (dataForRender, spacingArray) {
|
|
418
|
+
return dataForRender.map(function (item, index) {
|
|
419
|
+
var _a, _b, _c;
|
|
420
|
+
if (item.showVerticalLine) {
|
|
421
|
+
var x = getX(spacingArray, index);
|
|
422
|
+
return (_jsx(Line, { x1: x, y1: extendedContainerHeight, x2: x, y2: item.verticalLineHeight
|
|
423
|
+
? extendedContainerHeight - item.verticalLineHeight
|
|
424
|
+
: props.verticalLinesHeight
|
|
425
|
+
? extendedContainerHeight - props.verticalLinesHeight
|
|
426
|
+
: ((_a = item.verticalLineUptoDataPoint) !== null && _a !== void 0 ? _a : props.verticalLinesUptoDataPoint)
|
|
427
|
+
? getY(item.value)
|
|
428
|
+
: -xAxisThickness, stroke: item.verticalLineColor || props.verticalLinesColor || 'lightgray', strokeWidth: item.verticalLineThickness || props.verticalLinesThickness || 2, strokeDasharray: (_c = (_b = item.verticalLineStrokeDashArray) !== null && _b !== void 0 ? _b : props.verticalLinesStrokeDashArray) !== null && _c !== void 0 ? _c : '' }, index));
|
|
429
|
+
}
|
|
430
|
+
return null;
|
|
431
|
+
});
|
|
432
|
+
};
|
|
433
|
+
var renderPointer = function (lineNumber, isDataSet) {
|
|
434
|
+
var _a, _b;
|
|
435
|
+
if (hidePointers)
|
|
436
|
+
return;
|
|
437
|
+
if (isDataSet) {
|
|
438
|
+
var pointerItemLocal_1, pointerYLocal_1, pointerColorLocal_1;
|
|
439
|
+
return dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set, index) {
|
|
440
|
+
var _a, _b;
|
|
441
|
+
var pIndex = barAndLineChartsWrapperProps.pointerIndex;
|
|
442
|
+
pointerItemLocal_1 = set.data[pIndex];
|
|
443
|
+
if (set.hidePointers || (pointerItemLocal_1 === null || pointerItemLocal_1 === void 0 ? void 0 : pointerItemLocal_1.hidePointer))
|
|
444
|
+
return null;
|
|
445
|
+
if (hidePointerDataPointForMissingValues &&
|
|
446
|
+
typeof pointerItemLocal_1.value !== 'number')
|
|
447
|
+
return null;
|
|
448
|
+
pointerYLocal_1 = pointerYsForDataSet[index];
|
|
449
|
+
pointerColorLocal_1 =
|
|
450
|
+
(_b = (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColorsForDataSet) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : pointerColor;
|
|
451
|
+
return (_jsx(Fragment, { children: Pointer({
|
|
452
|
+
pointerX: pointerX,
|
|
453
|
+
pointerYLocal: pointerYLocal_1 + xAxisThickness,
|
|
454
|
+
pointerComponent: pointerComponent,
|
|
455
|
+
pointerHeight: pointerHeight,
|
|
456
|
+
pointerRadius: pointerRadius,
|
|
457
|
+
pointerWidth: pointerWidth,
|
|
458
|
+
pointerItemLocal: pointerItemLocal_1,
|
|
459
|
+
pointerColorLocal: pointerColorLocal_1,
|
|
460
|
+
pointerIndex: pIndex,
|
|
461
|
+
}) }, 'dSetPts' + index));
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
if (lineNumber === 1 && hidePointer1)
|
|
465
|
+
return;
|
|
466
|
+
if (lineNumber === 2 && hidePointer2)
|
|
467
|
+
return;
|
|
468
|
+
if (lineNumber === 3 && hidePointer3)
|
|
469
|
+
return;
|
|
470
|
+
if (lineNumber === 4 && hidePointer4)
|
|
471
|
+
return;
|
|
472
|
+
if (lineNumber === 5 && hidePointer5)
|
|
473
|
+
return;
|
|
474
|
+
// 6666 is for secondaryData
|
|
475
|
+
if (lineNumber === 6666 && hideSecondaryPointer)
|
|
476
|
+
return;
|
|
477
|
+
var pointerItemLocal, pointerYLocal, pointerColorLocal;
|
|
478
|
+
switch (lineNumber) {
|
|
479
|
+
case 1:
|
|
480
|
+
pointerItemLocal = pointerItem;
|
|
481
|
+
pointerYLocal = pointerY;
|
|
482
|
+
pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer1Color) || pointerColor;
|
|
483
|
+
break;
|
|
484
|
+
case 2:
|
|
485
|
+
pointerItemLocal = pointerItem2;
|
|
486
|
+
pointerYLocal = pointerY2;
|
|
487
|
+
pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer2Color) || pointerColor;
|
|
488
|
+
break;
|
|
489
|
+
case 3:
|
|
490
|
+
pointerItemLocal = pointerItem3;
|
|
491
|
+
pointerYLocal = pointerY3;
|
|
492
|
+
pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer3Color) || pointerColor;
|
|
493
|
+
break;
|
|
494
|
+
case 4:
|
|
495
|
+
pointerItemLocal = pointerItem4;
|
|
496
|
+
pointerYLocal = pointerY4;
|
|
497
|
+
pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer4Color) || pointerColor;
|
|
498
|
+
break;
|
|
499
|
+
case 5:
|
|
500
|
+
pointerItemLocal = pointerItem5;
|
|
501
|
+
pointerYLocal = pointerY5;
|
|
502
|
+
pointerColorLocal = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointer5Color) || pointerColor;
|
|
503
|
+
break;
|
|
504
|
+
case 6666:
|
|
505
|
+
pointerItemLocal = secondaryPointerItem;
|
|
506
|
+
pointerYLocal = secondaryPointerY;
|
|
507
|
+
pointerColorLocal =
|
|
508
|
+
(pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.secondaryPointerColor) || pointerColor;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
if (!pointerYLocal)
|
|
512
|
+
return;
|
|
513
|
+
if (hidePointerDataPointForMissingValues &&
|
|
514
|
+
typeof ((_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[pointerIndex]) === null || _b === void 0 ? void 0 : _b.value) !== 'number')
|
|
515
|
+
return null;
|
|
516
|
+
return Pointer({
|
|
517
|
+
pointerX: pointerX,
|
|
518
|
+
pointerYLocal: pointerYLocal + xAxisThickness,
|
|
519
|
+
pointerComponent: pointerComponent,
|
|
520
|
+
pointerHeight: pointerHeight,
|
|
521
|
+
pointerRadius: pointerRadius,
|
|
522
|
+
pointerWidth: pointerWidth,
|
|
523
|
+
pointerItemLocal: pointerItemLocal,
|
|
524
|
+
pointerColorLocal: pointerColorLocal,
|
|
525
|
+
pointerIndex: pointerIndex,
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
var renderStripAndLabel = function () {
|
|
529
|
+
var _a, _b;
|
|
530
|
+
var pointerYLocal;
|
|
531
|
+
var arr = [pointerY];
|
|
532
|
+
if (pointerY2 !== 0) {
|
|
533
|
+
arr.push(pointerY2);
|
|
534
|
+
}
|
|
535
|
+
if (pointerY3 !== 0) {
|
|
536
|
+
arr.push(pointerY3);
|
|
537
|
+
}
|
|
538
|
+
if (pointerY4 !== 0) {
|
|
539
|
+
arr.push(pointerY4);
|
|
540
|
+
}
|
|
541
|
+
if (pointerY5 !== 0) {
|
|
542
|
+
arr.push(pointerY5);
|
|
543
|
+
}
|
|
544
|
+
pointerYLocal = Math.min.apply(Math, __spreadArray([], __read(arr), false));
|
|
545
|
+
if ((pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointerForMissingValues) &&
|
|
546
|
+
typeof pointerItemLocal[0].value !== 'number')
|
|
547
|
+
return null;
|
|
548
|
+
return StripAndLabel({
|
|
549
|
+
autoAdjustPointerLabelPosition: autoAdjustPointerLabelPosition,
|
|
550
|
+
pointerX: pointerX,
|
|
551
|
+
pointerLabelWidth: pointerLabelWidth,
|
|
552
|
+
activatePointersOnLongPress: activatePointersOnLongPress,
|
|
553
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
554
|
+
pointerRadius: pointerRadius,
|
|
555
|
+
pointerWidth: pointerWidth,
|
|
556
|
+
shiftPointerLabelX: shiftPointerLabelX,
|
|
557
|
+
pointerLabelHeight: pointerLabelHeight,
|
|
558
|
+
pointerYLocal: pointerYLocal,
|
|
559
|
+
pointerStripUptoDataPoint: pointerStripUptoDataPoint,
|
|
560
|
+
pointerStripHeight: pointerStripHeight,
|
|
561
|
+
shiftPointerLabelY: shiftPointerLabelY,
|
|
562
|
+
pointerItemLocal: pointerItemLocal,
|
|
563
|
+
secondaryPointerItem: secondaryPointerItem,
|
|
564
|
+
pointerItemsForSet: pointerItemsForSet,
|
|
565
|
+
secondaryPointerItemsForSet: secondaryPointerItemsForSet,
|
|
566
|
+
showPointerStrip: showPointerStrip,
|
|
567
|
+
pointerStripWidth: pointerStripWidth,
|
|
568
|
+
containerHeight: containerHeight,
|
|
569
|
+
xAxisThickness: xAxisThickness,
|
|
570
|
+
pointerStripColor: pointerStripColor,
|
|
571
|
+
pointerConfig: pointerConfig,
|
|
572
|
+
pointerLabelComponent: pointerLabelComponent,
|
|
573
|
+
scrollX: scrollX,
|
|
574
|
+
pointerEvents: pointerEvents,
|
|
575
|
+
isBarChart: false,
|
|
576
|
+
pointerIndex: pointerIndex,
|
|
577
|
+
width: totalWidth,
|
|
578
|
+
screenWidth: (_a = props.width) !== null && _a !== void 0 ? _a : Math.min(totalWidth, (_b = props.parentWidth) !== null && _b !== void 0 ? _b : screenWidth) -
|
|
579
|
+
yAxisLabelWidth,
|
|
580
|
+
hasDataSet: !!dataSet,
|
|
581
|
+
containsNegative: mostNegativeValue < 0,
|
|
582
|
+
horizontalStripConfig: pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.horizontalStripConfig,
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
var getLineGradientComponent = function () {
|
|
586
|
+
return props.lineGradientComponent ? (props.lineGradientComponent()) : (_jsxs(LinearGradient, { id: "lineGradient", x1: "0", y1: "0", x2: lineGradientDirection === 'horizontal' ? '1' : '0', y2: lineGradientDirection === 'vertical' ? '1' : '0', children: [_jsx(Stop, { offset: "0", stopColor: lineGradientStartColor }), _jsx(Stop, { offset: "1", stopColor: lineGradientEndColor })] }));
|
|
587
|
+
};
|
|
588
|
+
var getAreaGradientComponent = function (startFillColor, endFillColor, startOpacity, endOpacity, gradientId) {
|
|
589
|
+
return props.areaGradientComponent ? (props.areaGradientComponent()) : (_jsxs(LinearGradient, { id: gradientId || 'Gradient', x1: "0", y1: "0", x2: gradientDirection === 'horizontal' ? '1' : '0', y2: gradientDirection === 'vertical' ? '1' : '0', children: [_jsx(Stop, { offset: "0", stopColor: startFillColor, stopOpacity: startOpacity.toString() }), _jsx(Stop, { offset: "1", stopColor: endFillColor, stopOpacity: endOpacity.toString() })] }));
|
|
590
|
+
};
|
|
591
|
+
var getSpreadAreaPath = function (spreadAreaData, getX, getY, spacingArray, curvature, curveType) {
|
|
592
|
+
if (!spreadAreaData || spreadAreaData.length === 0)
|
|
593
|
+
return '';
|
|
594
|
+
// Generate points arrays for upper and lower bounds
|
|
595
|
+
var upperPoints = spreadAreaData.map(function (point, index) { return [
|
|
596
|
+
getX(spacingArray, index),
|
|
597
|
+
getY(point.upper),
|
|
598
|
+
]; });
|
|
599
|
+
var lowerPoints = spreadAreaData.map(function (point, index) { return [
|
|
600
|
+
getX(spacingArray, index),
|
|
601
|
+
getY(point.lower),
|
|
602
|
+
]; });
|
|
603
|
+
// Use curve interpolation if curveType is specified
|
|
604
|
+
if (curveType !== undefined && curveType !== 0) {
|
|
605
|
+
var topPath = svgPath(upperPoints, curveType, props.curvature);
|
|
606
|
+
// Reverse the lower points for the path and create curved path
|
|
607
|
+
var reversedLowerPoints = lowerPoints.slice().reverse();
|
|
608
|
+
var bottomPath = svgPath(reversedLowerPoints, curveType, props.curvature);
|
|
609
|
+
// Remove the initial 'M' from bottomPath and prepend 'L' to connect it
|
|
610
|
+
var bottomPathConnected = bottomPath.replace(/^M/, 'L');
|
|
611
|
+
return "".concat(topPath, " ").concat(bottomPathConnected, " Z");
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
// Fallback to straight lines for compatibility
|
|
615
|
+
var topPath = spreadAreaData
|
|
616
|
+
.map(function (point, index) {
|
|
617
|
+
return "L ".concat(getX(spacingArray, index), " ").concat(getY(point.upper));
|
|
618
|
+
})
|
|
619
|
+
.join(' ')
|
|
620
|
+
.replace(/^L/, 'M');
|
|
621
|
+
var bottomPath = spreadAreaData
|
|
622
|
+
.slice()
|
|
623
|
+
.reverse()
|
|
624
|
+
.map(function (point, index) {
|
|
625
|
+
return "L ".concat(getX(spacingArray, spreadAreaData.length - 1 - index), " ").concat(getY(point.lower));
|
|
626
|
+
})
|
|
627
|
+
.join(' ');
|
|
628
|
+
return "".concat(topPath, " ").concat(bottomPath, " Z");
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
var getClipRange = function (startIndex, endIndex, clipRangeId) {
|
|
632
|
+
var startX = startIndex * spacing + initialSpacing;
|
|
633
|
+
var endX = endIndex * spacing + initialSpacing;
|
|
634
|
+
var clipWidth = endX - startX;
|
|
635
|
+
return (_jsx(Defs, { children: _jsx(ClipPath, { id: clipRangeId, children: _jsx(Rect, { x: startX, y: 0, width: clipWidth, height: "100%" }) }) }));
|
|
636
|
+
};
|
|
637
|
+
var getColorBackRects = function () {
|
|
638
|
+
return colors === null || colors === void 0 ? void 0 : colors.map(function (colorItem) {
|
|
639
|
+
var key = JSON.stringify(colorItem);
|
|
640
|
+
var from = colorItem.from, to = colorItem.to, color = colorItem.color;
|
|
641
|
+
var y = getY(from);
|
|
642
|
+
var height = getY(to) - getY(from);
|
|
643
|
+
var rectProps = {
|
|
644
|
+
x: 0,
|
|
645
|
+
y: y,
|
|
646
|
+
height: height,
|
|
647
|
+
fill: color,
|
|
648
|
+
mask: 'url(#pathMask)',
|
|
649
|
+
};
|
|
650
|
+
return isAnimated ? (_createElement(AnimatedRect, __assign({}, rectProps, { key: key, width: widthValue }))) : (_createElement(Rect, __assign({}, rectProps, { key: key, width: '100%' })));
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
var renderIntersection = function () {
|
|
654
|
+
var _a;
|
|
655
|
+
return (_jsx(View, { style: [svgWrapperViewStyle, { width: totalWidth }], children: _jsxs(Svg, { children: [_jsx(Path, { id: "path1", d: fillPoints, fill: "none", stroke: 'none' }), _jsx(Path, { id: "path2", d: fillPoints2, fill: "none", stroke: 'none' }), _jsx(ClipPath, { id: "clip", children: _jsx(Use, { href: "#path1" }) }), _jsx(Path, { d: fillPoints2, clipPath: "url(#clip)", fill: (_a = intersectionAreaConfig === null || intersectionAreaConfig === void 0 ? void 0 : intersectionAreaConfig.fillColor) !== null && _a !== void 0 ? _a : 'white' }), _jsx(Path, { d: points, stroke: color1, strokeWidth: thickness1 !== null && thickness1 !== void 0 ? thickness1 : thickness, fill: 'none' })] }) }));
|
|
656
|
+
};
|
|
657
|
+
var renderDataPointsForEachLine = function () {
|
|
658
|
+
if (dataSet && pointsFromSet.length) {
|
|
659
|
+
return (_jsx(_Fragment, { children: dataSet.map(function (set, index) {
|
|
660
|
+
var _a;
|
|
661
|
+
var hideDataPoints = set.hideDataPoints, data = set.data, dataPointsShape = set.dataPointsShape, dataPointsWidth = set.dataPointsWidth, dataPointsHeight = set.dataPointsHeight, dataPointsColor = set.dataPointsColor, dataPointsRadius = set.dataPointsRadius, textColor = set.textColor, textFontSize = set.textFontSize, startIndex = set.startIndex, endIndex = set.endIndex, isSecondary = set.isSecondary;
|
|
662
|
+
return renderDataPoints(hideDataPoints !== null && hideDataPoints !== void 0 ? hideDataPoints : hideDataPoints1, data, adjustToOffset(data, -((_a = props.yAxisOffset) !== null && _a !== void 0 ? _a : 0)), dataPointsShape !== null && dataPointsShape !== void 0 ? dataPointsShape : dataPointsShape1, dataPointsWidth !== null && dataPointsWidth !== void 0 ? dataPointsWidth : dataPointsWidth1, dataPointsHeight !== null && dataPointsHeight !== void 0 ? dataPointsHeight : dataPointsHeight1, dataPointsColor !== null && dataPointsColor !== void 0 ? dataPointsColor : dataPointsColor1, dataPointsRadius !== null && dataPointsRadius !== void 0 ? dataPointsRadius : dataPointsRadius1, textColor !== null && textColor !== void 0 ? textColor : textColor1, textFontSize !== null && textFontSize !== void 0 ? textFontSize : textFontSize1, startIndex !== null && startIndex !== void 0 ? startIndex : 0, endIndex !== null && endIndex !== void 0 ? endIndex : set.data.length - 1, isSecondary, showValuesAsDataPointsText, cumulativeSpacingForSet[index], index);
|
|
663
|
+
}) }));
|
|
664
|
+
}
|
|
665
|
+
return (_jsxs(_Fragment, { children: [renderDataPoints(hideDataPoints1, data, props.data, dataPointsShape1, dataPointsWidth1, dataPointsHeight1, dataPointsColor1, dataPointsRadius1, textColor1, textFontSize1, startIndex1, endIndex1, false, showValuesAsDataPointsText, cumulativeSpacing1, 0), points2
|
|
666
|
+
? renderDataPoints(hideDataPoints2, data2, props.data2, dataPointsShape2, dataPointsWidth2, dataPointsHeight2, dataPointsColor2, dataPointsRadius2, textColor2, textFontSize2, startIndex2, endIndex2, false, showValuesAsDataPointsText, cumulativeSpacing2, 1)
|
|
667
|
+
: null, points3
|
|
668
|
+
? renderDataPoints(hideDataPoints3, data3, props.data3, dataPointsShape3, dataPointsWidth3, dataPointsHeight3, dataPointsColor3, dataPointsRadius3, textColor3, textFontSize3, startIndex3, endIndex3, false, showValuesAsDataPointsText, cumulativeSpacing3, 2)
|
|
669
|
+
: null, points4
|
|
670
|
+
? renderDataPoints(hideDataPoints4, data4, props.data4, dataPointsShape4, dataPointsWidth4, dataPointsHeight4, dataPointsColor4, dataPointsRadius4, textColor4, textFontSize4, startIndex4, endIndex4, false, showValuesAsDataPointsText, cumulativeSpacing4, 3)
|
|
671
|
+
: null, points5
|
|
672
|
+
? renderDataPoints(hideDataPoints5, data5, props.data5, dataPointsShape5, dataPointsWidth5, dataPointsHeight5, dataPointsColor5, dataPointsRadius5, textColor5, textFontSize5, startIndex5, endIndex5, false, showValuesAsDataPointsText, cumulativeSpacing5, 4)
|
|
673
|
+
: null, secondaryPoints
|
|
674
|
+
? renderDataPoints(secondaryLineConfig.hideDataPoints, secondaryData, props.secondaryData, secondaryLineConfig.dataPointsShape, secondaryLineConfig.dataPointsWidth, secondaryLineConfig.dataPointsHeight, secondaryLineConfig.dataPointsColor, secondaryLineConfig.dataPointsRadius, secondaryLineConfig.textColor, secondaryLineConfig.textFontSize, secondaryLineConfig.startIndex, secondaryLineConfig.endIndex, true, secondaryLineConfig.showValuesAsDataPointsText, cumulativeSpacingSecondary, 6666)
|
|
675
|
+
: null] }));
|
|
676
|
+
};
|
|
677
|
+
var lineSvgComponent = function (points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, key, hideDataPoints, data, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray) {
|
|
678
|
+
var _a, _b;
|
|
679
|
+
if (!points)
|
|
680
|
+
return null;
|
|
681
|
+
var isCurved = points.includes('C') || points.includes('Q');
|
|
682
|
+
var clipRangeId = "Clip-range-".concat(key);
|
|
683
|
+
var uniqueId = "Gradient-line-".concat(key);
|
|
684
|
+
var isNthAreaChart = !!dataSet
|
|
685
|
+
? ((_a = dataSet[Number(key)].areaChart) !== null && _a !== void 0 ? _a : areaChart)
|
|
686
|
+
: getIsNthAreaChart(key !== null && key !== void 0 ? key : 0);
|
|
687
|
+
// Add support for spread area data from props
|
|
688
|
+
var spreadAreaData = props.spreadAreaData;
|
|
689
|
+
var spreadAreaColor = props.spreadAreaColor;
|
|
690
|
+
var spreadAreaOpacity = props.spreadAreaOpacity;
|
|
691
|
+
var ar = [{ d: '', color: '', strokeWidth: 0 }];
|
|
692
|
+
if (points.includes(RANGE_ENTER)) {
|
|
693
|
+
ar = getRegionPathObjects(points, color, currentLineThickness !== null && currentLineThickness !== void 0 ? currentLineThickness : 0, thickness, strokeDashArray !== null && strokeDashArray !== void 0 ? strokeDashArray : [], isCurved, RANGE_ENTER, STOP, RANGE_EXIT, curveType);
|
|
694
|
+
}
|
|
695
|
+
else if (points.includes(SEGMENT_START)) {
|
|
696
|
+
ar = getSegmentedPathObjects(points, color, currentLineThickness !== null && currentLineThickness !== void 0 ? currentLineThickness : 0, thickness, strokeDashArray !== null && strokeDashArray !== void 0 ? strokeDashArray : [], isCurved, SEGMENT_START, SEGMENT_END, curveType);
|
|
697
|
+
}
|
|
698
|
+
var lineSvgPropsOuter = {
|
|
699
|
+
d: animateOnDataChange && animatedPath ? animatedPath : points,
|
|
700
|
+
fill: 'none',
|
|
701
|
+
stroke: lineGradient
|
|
702
|
+
? props.lineGradientId
|
|
703
|
+
? "url(#".concat(props.lineGradientId, ")")
|
|
704
|
+
: "url(#lineGradient)"
|
|
705
|
+
: color,
|
|
706
|
+
strokeWidth: currentLineThickness || thickness,
|
|
707
|
+
strokeLinecap: strokeLinecap,
|
|
708
|
+
};
|
|
709
|
+
if (strokeDashArray &&
|
|
710
|
+
strokeDashArray.length === 2 &&
|
|
711
|
+
typeof strokeDashArray[0] === 'number' &&
|
|
712
|
+
typeof strokeDashArray[1] === 'number') {
|
|
713
|
+
lineSvgPropsOuter.strokeDasharray = strokeDashArray;
|
|
714
|
+
}
|
|
715
|
+
return (_jsxs(Svg, { height: svgHeight,
|
|
716
|
+
// width={widthValue}
|
|
717
|
+
onPress: props.onBackgroundPress, children: [lineGradient && getLineGradientComponent(), points.includes(SEGMENT_START) || points.includes(RANGE_ENTER) ? (ar.map(function (item, index) {
|
|
718
|
+
var lineSvgProps = {
|
|
719
|
+
d: item.d,
|
|
720
|
+
fill: 'none',
|
|
721
|
+
stroke: lineGradient
|
|
722
|
+
? props.lineGradientId
|
|
723
|
+
? "url(#".concat(props.lineGradientId, ")")
|
|
724
|
+
: "url(#lineGradient)"
|
|
725
|
+
: item.color,
|
|
726
|
+
strokeWidth: item.strokeWidth,
|
|
727
|
+
strokeLinecap: strokeLinecap,
|
|
728
|
+
};
|
|
729
|
+
if (item.strokeDashArray &&
|
|
730
|
+
item.strokeDashArray.length === 2 &&
|
|
731
|
+
typeof item.strokeDashArray[0] === 'number' &&
|
|
732
|
+
typeof item.strokeDashArray[1] === 'number') {
|
|
733
|
+
lineSvgProps.strokeDasharray = item.strokeDashArray;
|
|
734
|
+
}
|
|
735
|
+
return _jsx(Path, __assign({}, lineSvgProps), index);
|
|
736
|
+
})) : animateOnDataChange && animatedPath ? (_jsx(AnimatedPath, __assign({}, lineSvgPropsOuter))) : colors ? (_jsx(Defs, { children: _jsx(Mask, { id: "pathMask", children: _jsx(Path, __assign({}, lineSvgPropsOuter, { stroke: colors ? 'white' : color })) }) })) : (_jsx(Path, __assign({}, lineSvgPropsOuter))), colors && getColorBackRects(), isNthAreaChart &&
|
|
737
|
+
getAreaGradientComponent(startFillColor, endFillColor, startOpacity, endOpacity, uniqueId), isNthAreaChart &&
|
|
738
|
+
(startIndex !== 0 || endIndex !== data.length - 1) &&
|
|
739
|
+
getClipRange(startIndex, endIndex, clipRangeId), isNthAreaChart ? (props.interpolateMissingValues === false &&
|
|
740
|
+
propsData.some(function (item) { return isNaN(item.value); }) ? null : animateOnDataChange && animatedFillPath ? (_jsx(AnimatedPath, { onPress: props.onChartAreaPress, d: animatedFillPath, fill: props.areaGradientId
|
|
741
|
+
? "url(#".concat(props.areaGradientId, ")")
|
|
742
|
+
: "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness })) : (_jsx(Path, { onPress: props.onChartAreaPress, d: fillPoints, fill: props.areaGradientId
|
|
743
|
+
? "url(#".concat(props.areaGradientId, ")")
|
|
744
|
+
: "url(#".concat(uniqueId, ")"), clipPath: "url(#".concat(clipRangeId, ")"), stroke: 'none', strokeWidth: currentLineThickness || thickness }))) : null, spreadAreaData && (_jsx(Path, { d: getSpreadAreaPath(spreadAreaData, getX, getY, spacingArray, props.curvature, curveType), fill: spreadAreaColor || 'rgba(0,0,255,0.2)', stroke: "none", opacity: spreadAreaOpacity !== null && spreadAreaOpacity !== void 0 ? spreadAreaOpacity : 0.3 })), renderSpecificVerticalLines(data, cumulativeSpacing1), renderSpecificVerticalLines(data2, cumulativeSpacing2), renderSpecificVerticalLines(data3, cumulativeSpacing3), renderSpecificVerticalLines(data4, cumulativeSpacing4), renderSpecificVerticalLines(data5, cumulativeSpacing5), (_b = dataSet === null || dataSet === void 0 ? void 0 : dataSet.map(function (set, index) {
|
|
745
|
+
return renderSpecificVerticalLines(set === null || set === void 0 ? void 0 : set.data, cumulativeSpacingForSet[index]);
|
|
746
|
+
})) !== null && _b !== void 0 ? _b : null, isAnimated && !renderDataPointsAfterAnimationEnds // in this condition onPress won't work properly in case of multi-line, so it's suggested to use either renderDataPointsAfterAnimationEnds prop if you want to use onPress for data points
|
|
747
|
+
? renderDataPoints(hideDataPoints, data, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key)
|
|
748
|
+
: key === lastLineNumber - 1
|
|
749
|
+
? renderDataPointsForEachLine()
|
|
750
|
+
: null, showArrow && (_jsx(Path, { d: arrowPoints, fill: arrowFillColor, stroke: arrowStrokeColor, strokeWidth: arrowStrokeWidth }))] }));
|
|
751
|
+
};
|
|
752
|
+
// const getClosestValueFromSpacingArray = (spacingArray:number[],x:number):number => {
|
|
753
|
+
// let dif=0,prevDif=0,i;
|
|
754
|
+
// for(i=0;i<spacingArray.length;i++){
|
|
755
|
+
// dif = Math.abs(spacingArray[i]-x)
|
|
756
|
+
// if(prevDif!=0 && prevDif<dif){
|
|
757
|
+
// break;
|
|
758
|
+
// }
|
|
759
|
+
// prevDif = dif;
|
|
760
|
+
// }
|
|
761
|
+
// return i-1;
|
|
762
|
+
// }
|
|
763
|
+
var activatePointers = function (x) {
|
|
764
|
+
var _a;
|
|
765
|
+
var factor = (x - initialSpacing) / ((_a = props.spacing1) !== null && _a !== void 0 ? _a : spacing); // getClosestValueFromSpacingArray(cumulativeSpacing1,x-initialSpacing)
|
|
766
|
+
factor = Math.round(factor);
|
|
767
|
+
factor = Math.min(factor, (data0 !== null && data0 !== void 0 ? data0 : data).length - 1);
|
|
768
|
+
factor = Math.max(factor, 0);
|
|
769
|
+
var item, y;
|
|
770
|
+
item = (data0 !== null && data0 !== void 0 ? data0 : data)[factor];
|
|
771
|
+
if (!item.hidePointer) {
|
|
772
|
+
var z = getX((dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) ? cumulativeSpacingForSet[0] : cumulativeSpacing1, factor) -
|
|
773
|
+
(pointerRadius || pointerWidth / 2) -
|
|
774
|
+
1;
|
|
775
|
+
setPointerX(Math.max(0.1, z)); // 0.1 is to avoid pointer going out of the chart, See https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/925
|
|
776
|
+
setPointerIndex(factor);
|
|
777
|
+
y =
|
|
778
|
+
containerHeight -
|
|
779
|
+
(item.value * containerHeight) / maxValue -
|
|
780
|
+
(pointerRadius || pointerHeight / 2) +
|
|
781
|
+
10;
|
|
782
|
+
setPointerY(y);
|
|
783
|
+
setPointerItem(item);
|
|
784
|
+
}
|
|
785
|
+
if (data2 && data2.length) {
|
|
786
|
+
item = data2[factor];
|
|
787
|
+
if (item && !item.hidePointer) {
|
|
788
|
+
y =
|
|
789
|
+
containerHeight -
|
|
790
|
+
(item.value * containerHeight) / maxValue -
|
|
791
|
+
(pointerRadius || pointerHeight / 2) +
|
|
792
|
+
10;
|
|
793
|
+
setPointerY2(y);
|
|
794
|
+
setPointerItem2(item);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
if (data3 && data3.length) {
|
|
798
|
+
item = data3[factor];
|
|
799
|
+
if (item && !item.hidePointer) {
|
|
800
|
+
y =
|
|
801
|
+
containerHeight -
|
|
802
|
+
(item.value * containerHeight) / maxValue -
|
|
803
|
+
(pointerRadius || pointerHeight / 2) +
|
|
804
|
+
10;
|
|
805
|
+
setPointerY3(y);
|
|
806
|
+
setPointerItem3(item);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
if (data4 && data4.length) {
|
|
810
|
+
item = data4[factor];
|
|
811
|
+
if (item && !item.hidePointer) {
|
|
812
|
+
y =
|
|
813
|
+
containerHeight -
|
|
814
|
+
(item.value * containerHeight) / maxValue -
|
|
815
|
+
(pointerRadius || pointerHeight / 2) +
|
|
816
|
+
10;
|
|
817
|
+
setPointerY4(y);
|
|
818
|
+
setPointerItem4(item);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (data5 && data5.length) {
|
|
822
|
+
item = data5[factor];
|
|
823
|
+
if (item && !item.hidePointer) {
|
|
824
|
+
y =
|
|
825
|
+
containerHeight -
|
|
826
|
+
(item.value * containerHeight) / maxValue -
|
|
827
|
+
(pointerRadius || pointerHeight / 2) +
|
|
828
|
+
10;
|
|
829
|
+
setPointerY5(y);
|
|
830
|
+
setPointerItem5(item);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
if (secondaryData === null || secondaryData === void 0 ? void 0 : secondaryData.length) {
|
|
834
|
+
item = secondaryData[factor];
|
|
835
|
+
if (item) {
|
|
836
|
+
y =
|
|
837
|
+
containerHeight -
|
|
838
|
+
(item.value * containerHeight) / secondaryMaxValue -
|
|
839
|
+
(pointerRadius || pointerHeight / 2) +
|
|
840
|
+
10;
|
|
841
|
+
setSecondaryPointerY(y);
|
|
842
|
+
// @ts-ignore
|
|
843
|
+
setSecondaryPointerItem(item);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (dataSet === null || dataSet === void 0 ? void 0 : dataSet.length) {
|
|
847
|
+
var pointerItemsForSetLocal_1 = [];
|
|
848
|
+
var secondaryPointerItemsForSetLocal_1 = [];
|
|
849
|
+
var ysForDataSet = dataSet.map(function (set) {
|
|
850
|
+
var item = set.data[factor];
|
|
851
|
+
if (set.isSecondary) {
|
|
852
|
+
secondaryPointerItemsForSetLocal_1.push(item);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
pointerItemsForSetLocal_1.push(item);
|
|
856
|
+
}
|
|
857
|
+
var y = item
|
|
858
|
+
? containerHeight -
|
|
859
|
+
(item.value * containerHeight) /
|
|
860
|
+
(set.isSecondary ? secondaryMaxValue : maxValue) -
|
|
861
|
+
(pointerRadius || pointerHeight / 2) +
|
|
862
|
+
10
|
|
863
|
+
: 0;
|
|
864
|
+
return y;
|
|
865
|
+
});
|
|
866
|
+
setPointerItemsForSet(pointerItemsForSetLocal_1);
|
|
867
|
+
setSecondaryPointerItemsForSet(secondaryPointerItemsForSetLocal_1);
|
|
868
|
+
setPointerYsForDataSet(ysForDataSet);
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
var renderLine = function (containerHeightIncludingBelowXAxis, zIndex, points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, hideDataPoints, paramData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
872
|
+
return (_jsx(View, { onPointerEnter: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerEnter) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onPointerLeave: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerLeave) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchStart: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchStart) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchEnd: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onMoveShouldSetResponder: function (evt) { return (pointerConfig ? true : false); }, onStartShouldSetResponder: function (evt) {
|
|
873
|
+
return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
|
|
874
|
+
}, onResponderGrant: function (evt) {
|
|
875
|
+
var _a;
|
|
876
|
+
if (!pointerConfig)
|
|
877
|
+
return;
|
|
878
|
+
setResponderStartTime(evt.timeStamp);
|
|
879
|
+
if (activatePointersOnLongPress) {
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
var x = evt.nativeEvent.locationX;
|
|
883
|
+
activatePointers(x);
|
|
884
|
+
(_a = pointerConfig.onResponderGrant) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
885
|
+
}, onResponderMove: function (evt) {
|
|
886
|
+
var _a;
|
|
887
|
+
if (!pointerConfig)
|
|
888
|
+
return;
|
|
889
|
+
if (activatePointersOnLongPress &&
|
|
890
|
+
evt.timeStamp - responderStartTime < activatePointersDelay) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
setResponderActive(true);
|
|
895
|
+
}
|
|
896
|
+
var x = evt.nativeEvent.locationX;
|
|
897
|
+
var px = evt.nativeEvent.pageX;
|
|
898
|
+
if (yAxisLabelWidth != -1 && x == px)
|
|
899
|
+
return; // if locationX and pageX are equal, it means pointer has gone out of the chart, but this is not the case when yAxisLabelWidth is -1
|
|
900
|
+
if (!activatePointersOnLongPress &&
|
|
901
|
+
x > (props.width || Dimensions.get('window').width))
|
|
902
|
+
return;
|
|
903
|
+
activatePointers(x);
|
|
904
|
+
(_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderMove) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
905
|
+
},
|
|
906
|
+
// onResponderReject={evt => {
|
|
907
|
+
// console.log('evt...reject.......',evt);
|
|
908
|
+
// }}
|
|
909
|
+
onResponderEnd: function (evt) {
|
|
910
|
+
var _a;
|
|
911
|
+
setResponderStartTime(0);
|
|
912
|
+
if (resetPointerIndexOnRelease)
|
|
913
|
+
setPointerIndex(-1);
|
|
914
|
+
setResponderActive(false);
|
|
915
|
+
if (!persistPointer)
|
|
916
|
+
setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
|
|
917
|
+
(_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
918
|
+
}, onResponderTerminationRequest: function (evt) { return false; },
|
|
919
|
+
// onResponderTerminate={evt => {
|
|
920
|
+
// console.log('evt...terminate.......',evt);
|
|
921
|
+
// }}
|
|
922
|
+
// onResponderRelease={evt => {
|
|
923
|
+
// setResponderStartTime(0);
|
|
924
|
+
// setResponderActive(false);
|
|
925
|
+
// setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
926
|
+
// }}
|
|
927
|
+
style: [
|
|
928
|
+
svgWrapperViewStyle,
|
|
929
|
+
{
|
|
930
|
+
width: totalWidth,
|
|
931
|
+
height: containerHeightIncludingBelowXAxis,
|
|
932
|
+
zIndex: zIndex,
|
|
933
|
+
},
|
|
934
|
+
], children: lineSvgComponent(points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, key, hideDataPoints, paramData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray) }, key !== null && key !== void 0 ? key : 0));
|
|
935
|
+
};
|
|
936
|
+
var renderAnimatedLine = function (containerHeightIncludingBelowXAxis, zIndex, points, animatedWidth, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, hideDataPoints, paramsData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
937
|
+
return (_jsx(Animated.View, { onPointerEnter: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerEnter) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onPointerLeave: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerLeave) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onMoveShouldSetResponder: function (evt) { return (pointerConfig ? true : false); }, onStartShouldSetResponder: function (evt) {
|
|
938
|
+
return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
|
|
939
|
+
}, onResponderGrant: function (evt) {
|
|
940
|
+
var _a;
|
|
941
|
+
if (!pointerConfig)
|
|
942
|
+
return;
|
|
943
|
+
setResponderStartTime(evt.timeStamp);
|
|
944
|
+
if (activatePointersOnLongPress) {
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
var x = evt.nativeEvent.locationX;
|
|
948
|
+
activatePointers(x);
|
|
949
|
+
(_a = pointerConfig.onResponderGrant) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
950
|
+
}, onResponderMove: function (evt) {
|
|
951
|
+
var _a;
|
|
952
|
+
if (!pointerConfig)
|
|
953
|
+
return;
|
|
954
|
+
if (activatePointersOnLongPress &&
|
|
955
|
+
evt.timeStamp - responderStartTime < activatePointersDelay) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
setResponderActive(true);
|
|
960
|
+
}
|
|
961
|
+
var x = evt.nativeEvent.locationX;
|
|
962
|
+
if (!activatePointersOnLongPress &&
|
|
963
|
+
x > (props.width || Dimensions.get('window').width))
|
|
964
|
+
return;
|
|
965
|
+
activatePointers(x);
|
|
966
|
+
(_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderMove) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
967
|
+
},
|
|
968
|
+
// onResponderReject={evt => {
|
|
969
|
+
// console.log('evt...reject.......',evt);
|
|
970
|
+
// }}
|
|
971
|
+
onResponderEnd: function (evt) {
|
|
972
|
+
var _a;
|
|
973
|
+
// console.log('evt...end.......',evt);
|
|
974
|
+
setResponderStartTime(0);
|
|
975
|
+
if (resetPointerIndexOnRelease)
|
|
976
|
+
setPointerIndex(-1);
|
|
977
|
+
setResponderActive(false);
|
|
978
|
+
if (!persistPointer)
|
|
979
|
+
setTimeout(function () { return setPointerX(0); }, pointerVanishDelay);
|
|
980
|
+
(_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onResponderEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig);
|
|
981
|
+
}, onResponderTerminationRequest: function (evt) { return false; },
|
|
982
|
+
// onResponderTerminate={evt => {
|
|
983
|
+
// console.log('evt...terminate.......',evt);
|
|
984
|
+
// }}
|
|
985
|
+
// onResponderRelease={evt => {
|
|
986
|
+
// setResponderStartTime(0);
|
|
987
|
+
// setResponderActive(false);
|
|
988
|
+
// setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
989
|
+
// }}
|
|
990
|
+
style: [
|
|
991
|
+
svgWrapperViewStyle,
|
|
992
|
+
{
|
|
993
|
+
width: animatedWidth,
|
|
994
|
+
height: containerHeightIncludingBelowXAxis,
|
|
995
|
+
zIndex: zIndex,
|
|
996
|
+
},
|
|
997
|
+
], children: lineSvgComponent(points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, key, hideDataPoints, paramsData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray) }, key !== null && key !== void 0 ? key : 0));
|
|
998
|
+
};
|
|
999
|
+
var remainingScrollViewProps = {
|
|
1000
|
+
onScroll: function (ev) {
|
|
1001
|
+
var _a;
|
|
1002
|
+
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev);
|
|
1003
|
+
if (pointerConfig &&
|
|
1004
|
+
pointerConfig.activatePointersOnLongPress &&
|
|
1005
|
+
pointerConfig.autoAdjustPointerLabelPosition) {
|
|
1006
|
+
setScrollX(ev.nativeEvent.contentOffset.x);
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
bounces: props.bounces,
|
|
1010
|
+
overScrollMode: (_d = props.overScrollMode) !== null && _d !== void 0 ? _d : 'auto',
|
|
1011
|
+
};
|
|
1012
|
+
var renderStrips = function (item, index, ind) {
|
|
1013
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1014
|
+
if (item.showStrip || index === selectedIndex) {
|
|
1015
|
+
var currentStripHeight = (_a = item.stripHeight) !== null && _a !== void 0 ? _a : stripHeight;
|
|
1016
|
+
var currentStripWidth = (_b = item.stripWidth) !== null && _b !== void 0 ? _b : stripWidth;
|
|
1017
|
+
var currentStripOpacity = (_c = item.stripOpacity) !== null && _c !== void 0 ? _c : stripOpacity;
|
|
1018
|
+
var currentStripStrokeDashArray = (_e = (_d = item.stripStrokeDashArray) !== null && _d !== void 0 ? _d : stripStrokeDashArray) !== null && _e !== void 0 ? _e : '';
|
|
1019
|
+
var currentStripColor = item.stripColor || stripColor;
|
|
1020
|
+
var y1 = currentStripHeight
|
|
1021
|
+
? containerHeight - currentStripHeight + 8
|
|
1022
|
+
: containerHeight -
|
|
1023
|
+
((_f = item.dataPointHeight) !== null && _f !== void 0 ? _f : dataPointsHeight1) / 2 +
|
|
1024
|
+
14 -
|
|
1025
|
+
(((_g = item.value) !== null && _g !== void 0 ? _g : 0) * containerHeight) / maxValue;
|
|
1026
|
+
var actualStripHeight = currentStripHeight ||
|
|
1027
|
+
(((_h = item.value) !== null && _h !== void 0 ? _h : 0) * containerHeight) / maxValue - 2 + overflowTop;
|
|
1028
|
+
return (_jsx(Line, { x1: initialSpacing + spacing * index, y1: y1, x2: initialSpacing + spacing * index, y2: y1 + actualStripHeight + 2, strokeWidth: currentStripWidth, stroke: currentStripColor, strokeDasharray: currentStripStrokeDashArray, opacity: currentStripOpacity }, 'strip' + (ind * 10000 + index)));
|
|
1029
|
+
}
|
|
1030
|
+
return null;
|
|
1031
|
+
};
|
|
1032
|
+
var renderChartContent = function (containerHeightIncludingBelowXAxis) {
|
|
1033
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1034
|
+
return (_jsxs(_Fragment, { children: [Object.keys(strips).length > 0 ||
|
|
1035
|
+
(focusEnabled && showStripOnFocus && selectedIndex !== -1) ? ( // render focus strips separately (so that it's rendered below the data points unless specified otherwise)
|
|
1036
|
+
_jsx(View, { pointerEvents: "none", style: [
|
|
1037
|
+
svgWrapperViewStyle,
|
|
1038
|
+
{
|
|
1039
|
+
width: totalWidth,
|
|
1040
|
+
height: containerHeightIncludingBelowXAxis,
|
|
1041
|
+
zIndex: stripOverDataPoints ? 10000 : -1,
|
|
1042
|
+
},
|
|
1043
|
+
], children: _jsxs(Svg, { height: containerHeightIncludingBelowXAxis +
|
|
1044
|
+
((_a = props.overflowBottom) !== null && _a !== void 0 ? _a : dataPointsRadius1), children: [Object.keys(strips).map(function (stripKey) {
|
|
1045
|
+
return Object.keys(strips[stripKey]).map(function (ind) {
|
|
1046
|
+
var _a = strips[stripKey][ind], item = _a.item, index = _a.index, key = _a.key;
|
|
1047
|
+
return renderStrips(item, index, key);
|
|
1048
|
+
});
|
|
1049
|
+
}), focusEnabled && showStripOnFocus && selectedIndex !== -1 ? (_jsxs(_Fragment, { children: [dataSet && pointsFromSet.length
|
|
1050
|
+
? dataSet.map(function (set, ind) {
|
|
1051
|
+
return set.data.map(function (item, index) {
|
|
1052
|
+
return renderStrips(item, index, ind);
|
|
1053
|
+
});
|
|
1054
|
+
})
|
|
1055
|
+
: (_b = props.data) === null || _b === void 0 ? void 0 : _b.map(function (item, index) {
|
|
1056
|
+
return renderStrips(item, index, 0);
|
|
1057
|
+
}), (_c = props.data2) === null || _c === void 0 ? void 0 : _c.map(function (item, index) {
|
|
1058
|
+
return renderStrips(item, index, 1);
|
|
1059
|
+
}), (_d = props.data3) === null || _d === void 0 ? void 0 : _d.map(function (item, index) {
|
|
1060
|
+
return renderStrips(item, index, 2);
|
|
1061
|
+
}), (_e = props.data4) === null || _e === void 0 ? void 0 : _e.map(function (item, index) {
|
|
1062
|
+
return renderStrips(item, index, 3);
|
|
1063
|
+
}), (_f = props.data5) === null || _f === void 0 ? void 0 : _f.map(function (item, index) {
|
|
1064
|
+
return renderStrips(item, index, 4);
|
|
1065
|
+
}), (_g = props.secondaryData) === null || _g === void 0 ? void 0 : _g.map(function (item, index) {
|
|
1066
|
+
return renderStrips(item, index, 5);
|
|
1067
|
+
})] })) : null] }) })) : null, dataSet
|
|
1068
|
+
? pointsFromSet.length
|
|
1069
|
+
? dataSet.map(function (set, index) {
|
|
1070
|
+
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;
|
|
1071
|
+
if (isAnimated) {
|
|
1072
|
+
return renderAnimatedLine(containerHeightIncludingBelowXAxis, (_a = set.zIndex) !== null && _a !== void 0 ? _a : zIndex1, pointsFromSet[index], widthValue, (_b = set.thickness) !== null && _b !== void 0 ? _b : thickness1, (_c = set.color) !== null && _c !== void 0 ? _c : color1, fillPointsFromSet[index], (_d = set.startFillColor) !== null && _d !== void 0 ? _d : startFillColor1, (_e = set.endFillColor) !== null && _e !== void 0 ? _e : endFillColor1, (_f = set.startOpacity) !== null && _f !== void 0 ? _f : startOpacity1, (_g = set.endOpacity) !== null && _g !== void 0 ? _g : endOpacity1, (_h = set.strokeDashArray) !== null && _h !== void 0 ? _h : strokeDashArray1, (_j = set.strokeLinecap) !== null && _j !== void 0 ? _j : strokeLinecap1, set.showArrow || props.showArrows, arrowPointsFromSet[index], arrowStrokeWidthsFromSet === null || arrowStrokeWidthsFromSet === void 0 ? void 0 : arrowStrokeWidthsFromSet[index], arrowStrokeColorsFromSet === null || arrowStrokeColorsFromSet === void 0 ? void 0 : arrowStrokeColorsFromSet[index], arrowFillColorsFromSet === null || arrowFillColorsFromSet === void 0 ? void 0 : arrowFillColorsFromSet[index], (_k = set.hideDataPoints) !== null && _k !== void 0 ? _k : hideDataPoints1, set.data, adjustToOffset(set.data, -((_l = props.yAxisOffset) !== null && _l !== void 0 ? _l : 0)), // need the actual values passed by user
|
|
1073
|
+
(_m = set.dataPointsShape) !== null && _m !== void 0 ? _m : dataPointsShape1, (_o = set.dataPointsWidth) !== null && _o !== void 0 ? _o : dataPointsWidth1, (_p = set.dataPointsHeight) !== null && _p !== void 0 ? _p : dataPointsHeight1, (_q = set.dataPointsColor) !== null && _q !== void 0 ? _q : dataPointsColor1, (_r = set.dataPointsRadius) !== null && _r !== void 0 ? _r : dataPointsRadius1, (_s = set.textColor) !== null && _s !== void 0 ? _s : textColor1, (_t = set.textFontSize) !== null && _t !== void 0 ? _t : textFontSize1, (_u = set.startIndex) !== null && _u !== void 0 ? _u : 0, (_v = set.endIndex) !== null && _v !== void 0 ? _v : set.data.length - 1, set.isSecondary, showValuesAsDataPointsText, cumulativeSpacingForSet[index], index);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
return renderLine(containerHeightIncludingBelowXAxis, (_w = set.zIndex) !== null && _w !== void 0 ? _w : zIndex1, pointsFromSet[index], (_x = set.thickness) !== null && _x !== void 0 ? _x : thickness1, (_y = set.color) !== null && _y !== void 0 ? _y : color1, fillPointsFromSet[index], (_z = set.startFillColor) !== null && _z !== void 0 ? _z : startFillColor1, (_0 = set.endFillColor) !== null && _0 !== void 0 ? _0 : endFillColor1, (_1 = set.startOpacity) !== null && _1 !== void 0 ? _1 : startOpacity1, (_2 = set.endOpacity) !== null && _2 !== void 0 ? _2 : endOpacity1, (_3 = set.strokeDashArray) !== null && _3 !== void 0 ? _3 : strokeDashArray1, (_4 = set.strokeLinecap) !== null && _4 !== void 0 ? _4 : strokeLinecap1, set.showArrow || props.showArrows, arrowPointsFromSet[index], arrowStrokeWidthsFromSet === null || arrowStrokeWidthsFromSet === void 0 ? void 0 : arrowStrokeWidthsFromSet[index], arrowStrokeColorsFromSet === null || arrowStrokeColorsFromSet === void 0 ? void 0 : arrowStrokeColorsFromSet[index], arrowFillColorsFromSet === null || arrowFillColorsFromSet === void 0 ? void 0 : arrowFillColorsFromSet[index], (_5 = set.hideDataPoints) !== null && _5 !== void 0 ? _5 : hideDataPoints1, set.data, adjustToOffset(set.data, -((_6 = props.yAxisOffset) !== null && _6 !== void 0 ? _6 : 0)), // need the actual values passed by user
|
|
1077
|
+
(_7 = set.dataPointsShape) !== null && _7 !== void 0 ? _7 : dataPointsShape1, (_8 = set.dataPointsWidth) !== null && _8 !== void 0 ? _8 : dataPointsWidth1, (_9 = set.dataPointsHeight) !== null && _9 !== void 0 ? _9 : dataPointsHeight1, (_10 = set.dataPointsColor) !== null && _10 !== void 0 ? _10 : dataPointsColor1, (_11 = set.dataPointsRadius) !== null && _11 !== void 0 ? _11 : dataPointsRadius1, (_12 = set.textColor) !== null && _12 !== void 0 ? _12 : textColor1, (_13 = set.textFontSize) !== null && _13 !== void 0 ? _13 : textFontSize1, (_14 = set.startIndex) !== null && _14 !== void 0 ? _14 : 0, (_15 = set.endIndex) !== null && _15 !== void 0 ? _15 : set.data.length - 1, set.isSecondary, showValuesAsDataPointsText, cumulativeSpacingForSet[index], index);
|
|
1078
|
+
}
|
|
1079
|
+
})
|
|
1080
|
+
: null
|
|
1081
|
+
: isAnimated
|
|
1082
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, zIndex1, points, widthValue, thickness1, color1, fillPoints, startFillColor1, endFillColor1, startOpacity1, endOpacity1, strokeDashArray1, strokeLinecap1, props.showArrow1 || props.showArrows, arrow1Points, arrowStrokeWidth1, arrowStrokeColor1, arrowFillColor1, hideDataPoints1, data, props.data, dataPointsShape1, dataPointsWidth1, dataPointsHeight1, dataPointsColor1, dataPointsRadius1, textColor1, textFontSize1, startIndex1, endIndex1, false, showValuesAsDataPointsText, cumulativeSpacing1, 0)
|
|
1083
|
+
: renderLine(containerHeightIncludingBelowXAxis, zIndex1, points, thickness1, color1, fillPoints, startFillColor1, endFillColor1, startOpacity1, endOpacity1, strokeDashArray1, strokeLinecap1, props.showArrow1 || props.showArrows, arrow1Points, arrowStrokeWidth1, arrowStrokeColor1, arrowFillColor1, hideDataPoints1, data, props.data, dataPointsShape1, dataPointsWidth1, dataPointsHeight1, dataPointsColor1, dataPointsRadius1, textColor1, textFontSize1, startIndex1, endIndex1, false, showValuesAsDataPointsText, cumulativeSpacing1, 0), secondaryPoints
|
|
1084
|
+
? isAnimated
|
|
1085
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, secondaryLineConfig.zIndex, secondaryPoints, widthValue, secondaryLineConfig.thickness, secondaryLineConfig.color, secondaryFillPoints, secondaryLineConfig.startFillColor, secondaryLineConfig.endFillColor, secondaryLineConfig.startOpacity, secondaryLineConfig.endOpacity, secondaryLineConfig.strokeDashArray, secondaryLineConfig.strokeLinecap, secondaryLineConfig.showArrow, secondaryArrowPoints, (_h = secondaryLineConfig.arrowConfig) === null || _h === void 0 ? void 0 : _h.strokeWidth, (_j = secondaryLineConfig.arrowConfig) === null || _j === void 0 ? void 0 : _j.strokeColor, (_k = secondaryLineConfig.arrowConfig) === null || _k === void 0 ? void 0 : _k.fillColor, secondaryLineConfig.hideDataPoints, secondaryData, props.secondaryData, secondaryLineConfig.dataPointsShape, secondaryLineConfig.dataPointsWidth, secondaryLineConfig.dataPointsHeight, secondaryLineConfig.dataPointsColor, secondaryLineConfig.dataPointsRadius, secondaryLineConfig.textColor, secondaryLineConfig.textFontSize, secondaryLineConfig.startIndex, secondaryLineConfig.endIndex, true, secondaryLineConfig.showValuesAsDataPointsText, cumulativeSpacingSecondary, 6666)
|
|
1086
|
+
: renderLine(containerHeightIncludingBelowXAxis, secondaryLineConfig.zIndex, secondaryPoints, secondaryLineConfig.thickness, secondaryLineConfig.color, secondaryFillPoints, secondaryLineConfig.startFillColor, secondaryLineConfig.endFillColor, secondaryLineConfig.startOpacity, secondaryLineConfig.endOpacity, secondaryLineConfig.strokeDashArray, secondaryLineConfig.strokeLinecap, secondaryLineConfig.showArrow, secondaryArrowPoints, (_l = secondaryLineConfig.arrowConfig) === null || _l === void 0 ? void 0 : _l.strokeWidth, (_m = secondaryLineConfig.arrowConfig) === null || _m === void 0 ? void 0 : _m.strokeColor, (_o = secondaryLineConfig.arrowConfig) === null || _o === void 0 ? void 0 : _o.fillColor, secondaryLineConfig.hideDataPoints, secondaryData, props.secondaryData, secondaryLineConfig.dataPointsShape, secondaryLineConfig.dataPointsWidth, secondaryLineConfig.dataPointsHeight, secondaryLineConfig.dataPointsColor, secondaryLineConfig.dataPointsRadius, secondaryLineConfig.textColor, secondaryLineConfig.textFontSize, secondaryLineConfig.startIndex, secondaryLineConfig.endIndex, true, secondaryLineConfig.showValuesAsDataPointsText, cumulativeSpacingSecondary, 6666)
|
|
1087
|
+
: null, points2
|
|
1088
|
+
? isAnimated
|
|
1089
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, zIndex2, points2, widthValue2, thickness2, color2, fillPoints2, startFillColor2, endFillColor2, startOpacity2, endOpacity2, strokeDashArray2, strokeLinecap2, props.showArrow2 || props.showArrows, arrow2Points, arrowStrokeWidth2, arrowStrokeColor2, arrowFillColor2, hideDataPoints2, data2, props.data2, dataPointsShape2, dataPointsWidth2, dataPointsHeight2, dataPointsColor2, dataPointsRadius2, textColor2, textFontSize2, startIndex2, endIndex2, false, showValuesAsDataPointsText, cumulativeSpacing2, 1)
|
|
1090
|
+
: renderLine(containerHeightIncludingBelowXAxis, zIndex2, points2, thickness2, color2, fillPoints2, startFillColor2, endFillColor2, startOpacity2, endOpacity2, strokeDashArray2, strokeLinecap2, props.showArrow2 || props.showArrows, arrow2Points, arrowStrokeWidth2, arrowStrokeColor2, arrowFillColor2, hideDataPoints2, data2, props.data2, dataPointsShape2, dataPointsWidth2, dataPointsHeight2, dataPointsColor2, dataPointsRadius2, textColor2, textFontSize2, startIndex2, endIndex2, false, showValuesAsDataPointsText, cumulativeSpacing2, 1)
|
|
1091
|
+
: null, points3
|
|
1092
|
+
? isAnimated
|
|
1093
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, zIndex3, points3, widthValue3, thickness3, color3, fillPoints3, startFillColor3, endFillColor3, startOpacity3, endOpacity3, strokeDashArray3, strokeLinecap3, props.showArrow3 || props.showArrows, arrow3Points, arrowStrokeWidth3, arrowStrokeColor3, arrowFillColor3, hideDataPoints3, data3, props.data3, dataPointsShape3, dataPointsWidth3, dataPointsHeight3, dataPointsColor3, dataPointsRadius3, textColor3, textFontSize3, startIndex3, endIndex3, false, showValuesAsDataPointsText, cumulativeSpacing3, 2)
|
|
1094
|
+
: renderLine(containerHeightIncludingBelowXAxis, zIndex3, points3, thickness3, color3, fillPoints3, startFillColor3, endFillColor3, startOpacity3, endOpacity3, strokeDashArray3, strokeLinecap3, props.showArrow3 || props.showArrows, arrow3Points, arrowStrokeWidth3, arrowStrokeColor3, arrowFillColor3, hideDataPoints3, data3, props.data3, dataPointsShape3, dataPointsWidth3, dataPointsHeight3, dataPointsColor3, dataPointsRadius3, textColor3, textFontSize3, startIndex3, endIndex3, false, showValuesAsDataPointsText, cumulativeSpacing3, 2)
|
|
1095
|
+
: null, points4
|
|
1096
|
+
? isAnimated
|
|
1097
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, zIndex4, points4, widthValue4, thickness4, color4, fillPoints4, startFillColor4, endFillColor4, startOpacity4, endOpacity4, strokeDashArray4, strokeLinecap4, props.showArrow4 || props.showArrows, arrow4Points, arrowStrokeWidth4, arrowStrokeColor4, arrowFillColor4, hideDataPoints4, data4, props.data4, dataPointsShape4, dataPointsWidth4, dataPointsHeight4, dataPointsColor4, dataPointsRadius4, textColor4, textFontSize4, startIndex4, endIndex4, false, showValuesAsDataPointsText, cumulativeSpacing4, 3)
|
|
1098
|
+
: renderLine(containerHeightIncludingBelowXAxis, zIndex4, points4, thickness4, color4, fillPoints4, startFillColor4, endFillColor4, startOpacity4, endOpacity4, strokeDashArray4, strokeLinecap4, props.showArrow4 || props.showArrows, arrow4Points, arrowStrokeWidth4, arrowStrokeColor4, arrowFillColor4, hideDataPoints4, data4, props.data4, dataPointsShape4, dataPointsWidth4, dataPointsHeight4, dataPointsColor4, dataPointsRadius4, textColor4, textFontSize4, startIndex4, endIndex4, false, showValuesAsDataPointsText, cumulativeSpacing4, 3)
|
|
1099
|
+
: null, points5
|
|
1100
|
+
? isAnimated
|
|
1101
|
+
? renderAnimatedLine(containerHeightIncludingBelowXAxis, zIndex5, points5, widthValue5, thickness5, color5, fillPoints5, startFillColor5, endFillColor5, startOpacity5, endOpacity5, strokeDashArray5, strokeLinecap5, props.showArrow5 || props.showArrows, arrow5Points, arrowStrokeWidth5, arrowStrokeColor5, arrowFillColor5, hideDataPoints5, data5, props.data5, dataPointsShape5, dataPointsWidth5, dataPointsHeight5, dataPointsColor5, dataPointsRadius5, textColor5, textFontSize5, startIndex5, endIndex5, false, showValuesAsDataPointsText, cumulativeSpacing5, 4)
|
|
1102
|
+
: renderLine(containerHeightIncludingBelowXAxis, zIndex5, points5, thickness5, color5, fillPoints5, startFillColor5, endFillColor5, startOpacity5, endOpacity5, strokeDashArray5, strokeLinecap5, props.showArrow5 || props.showArrows, arrow5Points, arrowStrokeWidth5, arrowStrokeColor5, arrowFillColor5, hideDataPoints5, data5, props.data5, dataPointsShape5, dataPointsWidth5, dataPointsHeight5, dataPointsColor5, dataPointsRadius5, textColor5, textFontSize5, startIndex5, endIndex5, false, showValuesAsDataPointsText, cumulativeSpacing5, 4)
|
|
1103
|
+
: null, intersectionAreaConfig &&
|
|
1104
|
+
(props.areaChart || (props.areaChart1 && props.areaChart2))
|
|
1105
|
+
? renderIntersection()
|
|
1106
|
+
: null, pointerX > 0 ? (_jsxs(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: {
|
|
1107
|
+
position: 'absolute',
|
|
1108
|
+
height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
|
|
1109
|
+
bottom: 58 + labelsExtraHeight + xAxisLabelsVerticalShift - overflowTop,
|
|
1110
|
+
// width: totalWidth,
|
|
1111
|
+
zIndex: 20,
|
|
1112
|
+
}, children: [!stripOverPointer && renderStripAndLabel(), dataSet ? (renderPointer(0, true)) : (
|
|
1113
|
+
// dataSet.map((set, index) => renderPointer(index))
|
|
1114
|
+
_jsxs(_Fragment, { children: [renderPointer(1), points2 ? renderPointer(2) : null, points3 ? renderPointer(3) : null, points4 ? renderPointer(4) : null, points5 ? renderPointer(5) : null, secondaryPoints ? renderPointer(6666) : null, stripOverPointer && renderStripAndLabel()] }))] })) : null, (data0 !== null && data0 !== void 0 ? data0 : data).map(function (item, index) {
|
|
1115
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1116
|
+
var secondaryLabel = (_c = (_a = item.secondaryLabel) !== null && _a !== void 0 ? _a : (_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelTexts) === null || _b === void 0 ? void 0 : _b[index]) !== null && _c !== void 0 ? _c : '';
|
|
1117
|
+
var secondaryLabelTextStyle = (_f = (_e = (_d = item.secondaryLabelTextStyle) !== null && _d !== void 0 ? _d : secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsTextStyle) !== null && _e !== void 0 ? _e : item.labelTextStyle) !== null && _f !== void 0 ? _f : props.xAxisLabelTextStyle;
|
|
1118
|
+
return (_jsxs(View, { children: [isAnimated
|
|
1119
|
+
? renderAnimatedLabel(false, index, item.label ||
|
|
1120
|
+
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
1121
|
+
? props.xAxisLabelTexts[index]
|
|
1122
|
+
: ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent)
|
|
1123
|
+
: renderLabel(false, index, item.label ||
|
|
1124
|
+
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
|
1125
|
+
? props.xAxisLabelTexts[index]
|
|
1126
|
+
: ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent), secondaryXAxis
|
|
1127
|
+
? isAnimated
|
|
1128
|
+
? renderAnimatedLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
|
|
1129
|
+
: renderLabel(true, index, secondaryLabel, secondaryLabelTextStyle, item.secondaryLabelComponent)
|
|
1130
|
+
: null] }, index));
|
|
1131
|
+
}), (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.dynamicLegendComponent) && pointerX > 0 ? (_jsx(View, { style: [
|
|
1132
|
+
{ position: 'absolute' },
|
|
1133
|
+
pointerConfig.dynamicLegendContainerStyle,
|
|
1134
|
+
], children: pointerConfig.dynamicLegendComponent(pointerItemLocal, pointerIndex) })) : null] }));
|
|
1135
|
+
};
|
|
1136
|
+
return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { dataSet: dataSet, scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled, showBackgroundSlices: props.showBackgroundSlices })));
|
|
1137
|
+
};
|