react-native-gifted-charts 1.4.20 → 1.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +4 -3
  2. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  3. package/dist/BarChart/Animated2DWithGradient.js +113 -0
  4. package/dist/BarChart/RenderBars.d.ts +3 -0
  5. package/dist/BarChart/RenderBars.js +264 -0
  6. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  7. package/dist/BarChart/RenderStackBars.js +172 -0
  8. package/dist/BarChart/index.d.ts +2 -0
  9. package/dist/BarChart/index.js +233 -0
  10. package/dist/BarChart/styles.d.ts +45 -0
  11. package/dist/BarChart/styles.js +46 -0
  12. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  13. package/dist/Components/AnimatedThreeDBar/index.js +129 -0
  14. package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.js +13 -0
  16. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.js +128 -0
  18. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -0
  30. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  31. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  32. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  33. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  34. package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
  35. package/dist/Components/BarSpecificComponents/tooltip.js +40 -0
  36. package/dist/Components/common/LinearGradient.d.ts +16 -0
  37. package/dist/Components/common/LinearGradient.js +15 -0
  38. package/dist/Components/common/Pointer.d.ts +1 -0
  39. package/dist/Components/common/Pointer.js +16 -0
  40. package/dist/Components/common/StripAndLabel.d.ts +1 -0
  41. package/dist/Components/common/StripAndLabel.js +43 -0
  42. package/dist/Components/lineSvg.d.ts +14 -0
  43. package/dist/Components/lineSvg.js +22 -0
  44. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  45. package/dist/LineChart/LineChartBicolor.js +294 -0
  46. package/dist/LineChart/index.d.ts +2 -0
  47. package/dist/LineChart/index.js +1089 -0
  48. package/dist/LineChart/styles.d.ts +43 -0
  49. package/dist/LineChart/styles.js +46 -0
  50. package/dist/PieChart/index.d.ts +2 -0
  51. package/dist/PieChart/index.js +99 -0
  52. package/dist/PieChart/main.d.ts +2 -0
  53. package/dist/PieChart/main.js +182 -0
  54. package/dist/PieChartPro/index.d.ts +2 -0
  55. package/dist/PieChartPro/index.js +124 -0
  56. package/dist/PopulationPyramid/index.d.ts +2 -0
  57. package/dist/PopulationPyramid/index.js +130 -0
  58. package/dist/index.d.ts +7 -0
  59. package/dist/index.js +7 -0
  60. package/dist/utils/index.d.ts +2 -0
  61. package/dist/utils/index.js +12 -0
  62. package/package.json +21 -20
  63. package/src/BarChart/Animated2DWithGradient.tsx +0 -197
  64. package/src/BarChart/RenderBars.tsx +0 -527
  65. package/src/BarChart/RenderStackBars.tsx +0 -359
  66. package/src/BarChart/index.tsx +0 -391
  67. package/src/BarChart/styles.tsx +0 -47
  68. package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
  69. package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
  70. package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
  71. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
  72. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
  73. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
  74. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
  75. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
  76. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
  77. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
  78. package/src/Components/BarSpecificComponents/cap.tsx +0 -34
  79. package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
  80. package/src/Components/common/LinearGradient.tsx +0 -27
  81. package/src/Components/common/Pointer.tsx +0 -37
  82. package/src/Components/common/StripAndLabel.tsx +0 -98
  83. package/src/Components/lineSvg.tsx +0 -42
  84. package/src/LineChart/LineChartBicolor.tsx +0 -740
  85. package/src/LineChart/index.tsx +0 -2231
  86. package/src/LineChart/styles.tsx +0 -47
  87. package/src/PieChart/index.tsx +0 -168
  88. package/src/PieChart/main.tsx +0 -363
  89. package/src/PieChartPro/index.tsx +0 -267
  90. package/src/PopulationPyramid/index.tsx +0 -603
  91. package/src/index.tsx +0 -26
  92. package/src/todos.md +0 -24
  93. package/src/utils/index.ts +0 -16
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { BarDefaults } from 'gifted-charts-core';
4
+ var Cap = function (props) {
5
+ var _a, _b, _c, _d;
6
+ var capThicknessFromItem = props.capThicknessFromItem, capThicknessFromProps = props.capThicknessFromProps, capColorFromItem = props.capColorFromItem, capColorFromProps = props.capColorFromProps, capRadiusFromItem = props.capRadiusFromItem, capRadiusFromProps = props.capRadiusFromProps;
7
+ return (_jsx(View, { style: {
8
+ position: 'absolute',
9
+ width: '100%',
10
+ height: (_a = capThicknessFromItem !== null && capThicknessFromItem !== void 0 ? capThicknessFromItem : capThicknessFromProps) !== null && _a !== void 0 ? _a : BarDefaults.capThickness,
11
+ backgroundColor: (_b = capColorFromItem !== null && capColorFromItem !== void 0 ? capColorFromItem : capColorFromProps) !== null && _b !== void 0 ? _b : BarDefaults.capColor,
12
+ borderTopLeftRadius: (_c = capRadiusFromItem !== null && capRadiusFromItem !== void 0 ? capRadiusFromItem : capRadiusFromProps) !== null && _c !== void 0 ? _c : BarDefaults.capRadius,
13
+ borderTopRightRadius: (_d = capRadiusFromItem !== null && capRadiusFromItem !== void 0 ? capRadiusFromItem : capRadiusFromProps) !== null && _d !== void 0 ? _d : BarDefaults.capRadius,
14
+ } }));
15
+ };
16
+ export default Cap;
@@ -0,0 +1,15 @@
1
+ interface TooltipProps {
2
+ barHeight: number;
3
+ barWidth: number;
4
+ item: any;
5
+ index: number;
6
+ isLast: boolean;
7
+ leftSpacing: number;
8
+ leftShiftForLastIndexTooltip: number;
9
+ leftShiftForTooltip: number;
10
+ renderTooltip?: Function;
11
+ autoCenterTooltip?: boolean;
12
+ horizontal?: boolean;
13
+ }
14
+ declare const Tooltip: (props: TooltipProps) => import("react/jsx-runtime").JSX.Element;
15
+ export default Tooltip;
@@ -0,0 +1,40 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { useState } from 'react';
19
+ import { View } from 'react-native';
20
+ var Tooltip = function (props) {
21
+ var barHeight = props.barHeight, barWidth = props.barWidth, item = props.item, index = props.index, isLast = props.isLast, leftSpacing = props.leftSpacing, leftShiftForLastIndexTooltip = props.leftShiftForLastIndexTooltip, leftShiftForTooltip = props.leftShiftForTooltip, renderTooltip = props.renderTooltip, autoCenterTooltip = props.autoCenterTooltip, horizontal = props.horizontal;
22
+ var _a = __read(useState(0), 2), leftShiftTooltipForCentering = _a[0], setLeftShiftTooltipForCentering = _a[1];
23
+ return (_jsx(View, { style: {
24
+ position: 'absolute',
25
+ bottom: barHeight + 60,
26
+ left: leftSpacing -
27
+ (isLast ? leftShiftForLastIndexTooltip : leftShiftForTooltip) -
28
+ leftShiftTooltipForCentering,
29
+ zIndex: 1000,
30
+ transform: [{ rotate: horizontal ? '-90deg' : '0deg' }],
31
+ }, onLayout: function (event) {
32
+ if (!autoCenterTooltip)
33
+ return;
34
+ var width = event.nativeEvent.layout.width;
35
+ var shift = (width - barWidth) / 2;
36
+ if (shift > 0)
37
+ setLeftShiftTooltipForCentering(shift);
38
+ }, children: renderTooltip === null || renderTooltip === void 0 ? void 0 : renderTooltip(item, index) }));
39
+ };
40
+ export default Tooltip;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ type LinearGradientProps = {
3
+ style?: any;
4
+ start?: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ end?: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ colors: string[];
13
+ children?: any;
14
+ };
15
+ declare let LinearGradient: React.FC<LinearGradientProps>;
16
+ export default LinearGradient;
@@ -0,0 +1,15 @@
1
+ var LinearGradient;
2
+ try {
3
+ // for bare react-native projects
4
+ LinearGradient = require('react-native-linear-gradient').LinearGradient;
5
+ }
6
+ catch (e) {
7
+ try {
8
+ // for expo-based projects
9
+ LinearGradient = require('expo-linear-gradient').LinearGradient;
10
+ }
11
+ catch (e) {
12
+ throw new Error('Gradient package was not found. Make sure "react-native-linear-gradient" or "expo-linear-gradient" is installed');
13
+ }
14
+ }
15
+ export default LinearGradient;
@@ -0,0 +1 @@
1
+ export declare const Pointer: (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ export var Pointer = function (props) {
4
+ var pointerX = props.pointerX, pointerYLocal = props.pointerYLocal, pointerComponent = props.pointerComponent, pointerHeight = props.pointerHeight, pointerRadius = props.pointerRadius, pointerWidth = props.pointerWidth, pointerItemLocal = props.pointerItemLocal, pointerColorLocal = props.pointerColorLocal;
5
+ return (_jsx(View, { style: {
6
+ position: 'absolute',
7
+ left: pointerX + (pointerX.pointerShiftX || 0),
8
+ top: pointerYLocal - 2,
9
+ }, children: pointerComponent ? (pointerComponent()) : (_jsx(View, { style: {
10
+ height: pointerHeight || pointerRadius * 2,
11
+ width: pointerWidth || pointerRadius * 2,
12
+ marginTop: (pointerItemLocal === null || pointerItemLocal === void 0 ? void 0 : pointerItemLocal.pointerShiftY) || 0,
13
+ backgroundColor: pointerColorLocal,
14
+ borderRadius: pointerRadius || 0,
15
+ } })) }));
16
+ };
@@ -0,0 +1 @@
1
+ export declare const StripAndLabel: (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import Svg, { Line } from 'react-native-svg';
4
+ import { getTopAndLeftForStripAndLabel } from 'gifted-charts-core';
5
+ export var StripAndLabel = function (props) {
6
+ var _a;
7
+ var pointerX = props.pointerX, pointerLabelWidth = props.pointerLabelWidth, pointerRadius = props.pointerRadius, pointerWidth = props.pointerWidth, pointerYLocal = props.pointerYLocal, pointerStripUptoDataPoint = props.pointerStripUptoDataPoint, pointerStripHeight = props.pointerStripHeight, pointerItemLocal = props.pointerItemLocal, showPointerStrip = props.showPointerStrip, pointerStripWidth = props.pointerStripWidth, containerHeight = props.containerHeight, xAxisThickness = props.xAxisThickness, pointerStripColor = props.pointerStripColor, pointerConfig = props.pointerConfig, pointerLabelComponent = props.pointerLabelComponent, secondaryPointerItem = props.secondaryPointerItem, pointerEvents = props.pointerEvents, isBarChart = props.isBarChart;
8
+ var _b = getTopAndLeftForStripAndLabel(props), top = _b.top, left = _b.left;
9
+ return (_jsxs(View, { style: {
10
+ position: 'absolute',
11
+ left: pointerX + (((_a = pointerItemLocal[0]) === null || _a === void 0 ? void 0 : _a.pointerShiftX) || 0),
12
+ top: pointerYLocal,
13
+ }, children: [(isBarChart
14
+ ? showPointerStrip && !pointerLabelComponent
15
+ : showPointerStrip) ? (_jsx(View, { style: {
16
+ position: 'absolute',
17
+ left: (pointerRadius || pointerWidth) - pointerStripWidth / 4,
18
+ top: pointerStripUptoDataPoint
19
+ ? pointerRadius || pointerStripHeight / 2
20
+ : -pointerYLocal + 8,
21
+ width: pointerStripWidth,
22
+ height: pointerStripUptoDataPoint
23
+ ? containerHeight - pointerYLocal + 5 - xAxisThickness
24
+ : pointerStripHeight,
25
+ marginTop: pointerStripUptoDataPoint
26
+ ? 0
27
+ : containerHeight - pointerStripHeight,
28
+ }, children: _jsx(Svg, { children: _jsx(Line, { stroke: pointerStripColor, strokeWidth: pointerStripWidth, strokeDasharray: (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.strokeDashArray)
29
+ ? pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.strokeDashArray
30
+ : '', x1: 0, y1: 0, x2: 0, y2: pointerStripUptoDataPoint
31
+ ? containerHeight - pointerYLocal + 5 - xAxisThickness
32
+ : pointerStripHeight }) }) })) : null, pointerLabelComponent ? (_jsx(View, { pointerEvents: pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : 'none', style: [
33
+ {
34
+ position: 'absolute',
35
+ left: left,
36
+ top: top,
37
+ marginTop: pointerStripUptoDataPoint
38
+ ? 0
39
+ : containerHeight - pointerStripHeight,
40
+ width: pointerLabelWidth,
41
+ },
42
+ ], children: pointerLabelComponent === null || pointerLabelComponent === void 0 ? void 0 : pointerLabelComponent(pointerItemLocal, secondaryPointerItem) })) : null] }));
43
+ };
@@ -0,0 +1,14 @@
1
+ import { ColorValue } from 'react-native';
2
+ type ruleProps = {
3
+ thickness: number;
4
+ width: number;
5
+ color: ColorValue | string | any;
6
+ type: string;
7
+ dashWidth: number;
8
+ dashGap: number;
9
+ };
10
+ type configType = {
11
+ config: ruleProps;
12
+ };
13
+ declare function Rule(props: configType): import("react/jsx-runtime").JSX.Element;
14
+ export default Rule;
@@ -0,0 +1,22 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import Svg, { G, Path } from 'react-native-svg';
14
+ import { ruleTypes } from 'gifted-charts-core';
15
+ function Rule(props) {
16
+ var _a = props.config, thickness = _a.thickness, width = _a.width, color = _a.color, type = _a.type, dashWidth = _a.dashWidth, dashGap = _a.dashGap;
17
+ if (type === ruleTypes.SOLID) {
18
+ return (_jsx(Svg, __assign({ height: thickness, width: width }, props, { children: _jsx(G, { fill: "lightgray", stroke: color, strokeWidth: thickness, children: _jsx(Path, { d: "M0 ".concat(thickness / 2, "h").concat(width) }) }) })));
19
+ }
20
+ return (_jsx(Svg, __assign({ height: thickness, width: width }, props, { children: _jsx(G, { fill: "lightgray", stroke: color, strokeWidth: thickness, children: _jsx(Path, { strokeDasharray: "".concat(dashWidth, ",").concat(dashGap), d: "M0 ".concat(thickness / 2, "h").concat(width) }) }) })));
21
+ }
22
+ export default Rule;
@@ -0,0 +1,2 @@
1
+ import { LineChartBicolorPropsType } from 'gifted-charts-core';
2
+ export declare const LineChartBicolor: (props: LineChartBicolorPropsType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,294 @@
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
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
14
+ import { View, Animated, Easing, Text } from 'react-native';
15
+ import { styles } from './styles';
16
+ import Svg, { Path, LinearGradient, Stop, Circle, Rect, Text as CanvasText, } from 'react-native-svg';
17
+ import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
18
+ import { useLineChartBiColor, } from 'gifted-charts-core';
19
+ import { screenWidth } from '../utils';
20
+ export var LineChartBicolor = function (props) {
21
+ var _a;
22
+ var scrollRef = useRef();
23
+ // const heightValue = useMemo(() => new Animated.Value(0), []);
24
+ var widthValue = useMemo(function () { return new Animated.Value(0); }, []);
25
+ var opacValue = useMemo(function () { return new Animated.Value(0); }, []);
26
+ var _b = useLineChartBiColor(__assign(__assign({}, props), { parentWidth: (_a = props.parentWidth) !== null && _a !== void 0 ? _a : screenWidth })), pointsArray = _b.pointsArray, fillPointsArray = _b.fillPointsArray, selectedIndex = _b.selectedIndex, setSelectedIndex = _b.setSelectedIndex, containerHeight = _b.containerHeight, data = _b.data, labelsExtraHeight = _b.labelsExtraHeight, animationDuration = _b.animationDuration, startIndex1 = _b.startIndex1, endIndex1 = _b.endIndex1, initialSpacing = _b.initialSpacing, thickness = _b.thickness, spacing = _b.spacing, xAxisThickness = _b.xAxisThickness, dataPointsHeight1 = _b.dataPointsHeight1, dataPointsWidth1 = _b.dataPointsWidth1, dataPointsRadius1 = _b.dataPointsRadius1, dataPointsColor1 = _b.dataPointsColor1, dataPointsShape1 = _b.dataPointsShape1, areaChart = _b.areaChart, textFontSize1 = _b.textFontSize1, textColor1 = _b.textColor1, totalWidth = _b.totalWidth, maxValue = _b.maxValue, extendedContainerHeight = _b.extendedContainerHeight, getX = _b.getX, getY = _b.getY, stepHeight = _b.stepHeight, noOfSectionsBelowXAxis = _b.noOfSectionsBelowXAxis, thickness1 = _b.thickness1, zIndex = _b.zIndex, strokeDashArray1 = _b.strokeDashArray1, rotateLabel = _b.rotateLabel, isAnimated = _b.isAnimated, hideDataPoints1 = _b.hideDataPoints1, color = _b.color, colorNegative = _b.colorNegative, startFillColor = _b.startFillColor, endFillColor = _b.endFillColor, startOpacity = _b.startOpacity, endOpacity = _b.endOpacity, startFillColorNegative = _b.startFillColorNegative, endFillColorNegative = _b.endFillColorNegative, startOpacityNegative = _b.startOpacityNegative, endOpacityNegative = _b.endOpacityNegative, gradientDirection = _b.gradientDirection, xAxisTextNumberOfLines = _b.xAxisTextNumberOfLines, focusEnabled = _b.focusEnabled, showDataPointOnFocus = _b.showDataPointOnFocus, showStripOnFocus = _b.showStripOnFocus, showTextOnFocus = _b.showTextOnFocus, stripHeight = _b.stripHeight, stripWidth = _b.stripWidth, stripColor = _b.stripColor, stripOpacity = _b.stripOpacity, unFocusOnPressOut = _b.unFocusOnPressOut, delayBeforeUnFocus = _b.delayBeforeUnFocus, barAndLineChartsWrapperProps = _b.barAndLineChartsWrapperProps;
27
+ var labelsAppear = useCallback(function () {
28
+ opacValue.setValue(0);
29
+ Animated.timing(opacValue, {
30
+ toValue: 1,
31
+ duration: 500,
32
+ easing: Easing.ease,
33
+ useNativeDriver: false,
34
+ }).start();
35
+ }, [opacValue]);
36
+ var appearingOpacity = opacValue.interpolate({
37
+ inputRange: [0, 1],
38
+ outputRange: [0, 1],
39
+ });
40
+ var decreaseWidth = useCallback(function () {
41
+ widthValue.setValue(0);
42
+ Animated.timing(widthValue, {
43
+ toValue: 1,
44
+ duration: animationDuration,
45
+ easing: Easing.linear,
46
+ useNativeDriver: false,
47
+ }).start();
48
+ }, [animationDuration, widthValue]);
49
+ useEffect(function () {
50
+ decreaseWidth();
51
+ labelsAppear();
52
+ }, [animationDuration, decreaseWidth, labelsAppear]);
53
+ var renderLabel = function (index, label, labelTextStyle, labelComponent) {
54
+ return (_jsx(View, { style: [
55
+ {
56
+ position: 'absolute',
57
+ bottom: 30,
58
+ zIndex: 10,
59
+ width: spacing + labelsExtraHeight,
60
+ left: index === 0 && initialSpacing < 10
61
+ ? getX(index) - spacing / 2 + 8
62
+ : getX(index) - spacing / 2,
63
+ justifyContent: 'center',
64
+ },
65
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
66
+ ], children: labelComponent ? (labelComponent()) : (_jsx(Text, { style: labelTextStyle || { textAlign: 'center' }, numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
67
+ };
68
+ var renderAnimatedLabel = function (index, label, labelTextStyle, labelComponent) {
69
+ return (_jsx(Animated.View, { style: [
70
+ {
71
+ height: rotateLabel ? 40 : 20,
72
+ // backgroundColor: 'yellow',
73
+ position: 'absolute',
74
+ bottom: rotateLabel ? 10 : 30,
75
+ zIndex: 10,
76
+ width: spacing,
77
+ left: index === 0 && initialSpacing < 10
78
+ ? getX(index) - spacing / 2 + 8
79
+ : getX(index) - spacing / 2,
80
+ opacity: appearingOpacity,
81
+ },
82
+ rotateLabel && { transform: [{ rotate: '60deg' }] },
83
+ ], children: labelComponent ? (labelComponent()) : (_jsx(Text, { style: labelTextStyle || { textAlign: 'center' }, numberOfLines: xAxisTextNumberOfLines, children: label || '' })) }));
84
+ };
85
+ var animatedWidth = widthValue.interpolate({
86
+ inputRange: [0, 1],
87
+ outputRange: [0, totalWidth],
88
+ });
89
+ var onStripPress = function (item, index) {
90
+ setSelectedIndex(index);
91
+ if (props.onFocus) {
92
+ props.onFocus(item, index);
93
+ }
94
+ };
95
+ var renderDataPoints = function (dataForRender, dataPtsShape, dataPtsWidth, dataPtsHeight, dataPtsColor, dataPtsRadius, textColor, textFontSize, startIndex, endIndex) {
96
+ return dataForRender.map(function (item, index) {
97
+ var _a, _b, _c;
98
+ if (index < startIndex || index > endIndex)
99
+ return null;
100
+ if (item.hideDataPoint) {
101
+ return null;
102
+ }
103
+ var dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, text, customDataPoint, dataPointLabelComponent;
104
+ if (index === selectedIndex) {
105
+ dataPointsShape =
106
+ item.focusedDataPointShape ||
107
+ props.focusedDataPointShape ||
108
+ item.dataPointShape ||
109
+ dataPtsShape;
110
+ dataPointsWidth =
111
+ item.focusedDataPointWidth ||
112
+ props.focusedDataPointWidth ||
113
+ item.dataPointWidth ||
114
+ dataPtsWidth;
115
+ dataPointsHeight =
116
+ item.focusedDataPointHeight ||
117
+ props.focusedDataPointHeight ||
118
+ item.dataPointHeight ||
119
+ dataPtsHeight;
120
+ dataPointsColor =
121
+ item.focusedDataPointColor || props.focusedDataPointColor || 'orange';
122
+ dataPointsRadius =
123
+ item.focusedDataPointRadius ||
124
+ props.focusedDataPointRadius ||
125
+ item.dataPointRadius ||
126
+ dataPtsRadius;
127
+ if (showTextOnFocus) {
128
+ text = item.dataPointText;
129
+ }
130
+ customDataPoint =
131
+ item.focusedCustomDataPoint ||
132
+ props.focusedCustomDataPoint ||
133
+ item.customDataPoint ||
134
+ props.customDataPoint;
135
+ dataPointLabelComponent =
136
+ item.focusedDataPointLabelComponent || item.dataPointLabelComponent;
137
+ }
138
+ else {
139
+ dataPointsShape = item.dataPointShape || dataPtsShape;
140
+ dataPointsWidth = item.dataPointWidth || dataPtsWidth;
141
+ dataPointsHeight = item.dataPointHeight || dataPtsHeight;
142
+ dataPointsColor = item.dataPointColor || dataPtsColor;
143
+ dataPointsRadius = item.dataPointRadius || dataPtsRadius;
144
+ if (showTextOnFocus) {
145
+ text = '';
146
+ }
147
+ customDataPoint = item.customDataPoint || props.customDataPoint;
148
+ dataPointLabelComponent = item.dataPointLabelComponent;
149
+ }
150
+ var currentStripHeight = (_a = item.stripHeight) !== null && _a !== void 0 ? _a : stripHeight;
151
+ var currentStripWidth = (_b = item.stripWidth) !== null && _b !== void 0 ? _b : stripWidth;
152
+ var currentStripOpacity = (_c = item.stripOpacity) !== null && _c !== void 0 ? _c : stripOpacity;
153
+ var currentStripColor = item.stripColor || stripColor;
154
+ return (_jsxs(Fragment, { children: [focusEnabled ? (_jsx(_Fragment, { children: unFocusOnPressOut ? (_jsx(Rect, { onPressIn: function () { return onStripPress(item, index); }, onPressOut: function () {
155
+ return setTimeout(function () { return setSelectedIndex(-1); }, delayBeforeUnFocus);
156
+ }, x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight, fill: 'none' })) : (_jsx(Rect, { onPress: function () { return onStripPress(item, index); }, x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight, fill: 'none' })) })) : null, item.showStrip ||
157
+ (focusEnabled && index === selectedIndex && showStripOnFocus) ? (_jsx(Rect, { x: initialSpacing + (spacing * index - dataPointsWidth / 2), y: currentStripHeight
158
+ ? containerHeight - currentStripHeight + 8
159
+ : containerHeight -
160
+ dataPointsHeight / 2 +
161
+ 20 -
162
+ (item.value * containerHeight) / maxValue, width: currentStripWidth, height: currentStripHeight ||
163
+ containerHeight - dataPointsHeight / 2 + 20, opacity: currentStripOpacity, fill: currentStripColor })) : null, customDataPoint ? (_jsx(View, { style: [
164
+ styles.customDataPointContainer,
165
+ {
166
+ height: dataPointsHeight,
167
+ width: dataPointsWidth,
168
+ top: containerHeight - (item.value * containerHeight) / maxValue,
169
+ left: getX(index) - dataPointsWidth,
170
+ },
171
+ ], children: customDataPoint() })) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Rect, { x: getX(index) - dataPointsWidth, y: extendedContainerHeight +
172
+ dataPointsHeight / 2 -
173
+ (item.value * containerHeight) / maxValue, width: dataPointsWidth, height: dataPointsHeight, fill: showDataPointOnFocus
174
+ ? index === selectedIndex
175
+ ? dataPointsColor
176
+ : 'none'
177
+ : dataPointsColor, onPress: function () {
178
+ item.onPress
179
+ ? item.onPress(item, index)
180
+ : props.onPress
181
+ ? props.onPress(item, index)
182
+ : null;
183
+ } })) }, index)) : (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Circle, { cx: getX(index), cy: getY(index), r: dataPointsRadius, fill: showDataPointOnFocus
184
+ ? index === selectedIndex
185
+ ? dataPointsColor
186
+ : 'none'
187
+ : dataPointsColor, onPress: function () {
188
+ item.onPress
189
+ ? item.onPress(item, index)
190
+ : props.onPress
191
+ ? props.onPress(item, index)
192
+ : null;
193
+ } })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (_jsx(View, { style: [
194
+ styles.customDataPointContainer,
195
+ {
196
+ top: containerHeight +
197
+ (item.dataPointLabelShiftY ||
198
+ props.dataPointLabelShiftY ||
199
+ 0) -
200
+ (item.value * containerHeight) / maxValue,
201
+ left: initialSpacing +
202
+ (item.dataPointLabelShiftX ||
203
+ props.dataPointLabelShiftX ||
204
+ 0) -
205
+ (item.dataPointLabelWidth
206
+ ? item.dataPointLabelWidth + 20
207
+ : props.dataPointLabelWidth
208
+ ? props.dataPointLabelWidth + 20
209
+ : 50) /
210
+ 2 +
211
+ spacing * index,
212
+ },
213
+ ], children: dataPointLabelComponent() })) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: initialSpacing -
214
+ dataPointsWidth +
215
+ spacing * index +
216
+ (item.textShiftX || props.textShiftX || 0), y: extendedContainerHeight -
217
+ dataPointsHeight / 2 -
218
+ (item.value * containerHeight) / maxValue +
219
+ (item.textShiftY || props.textShiftY || 0), children: !showTextOnFocus ? item.dataPointText : text })) : null) : null] }, index));
220
+ });
221
+ };
222
+ var renderSpecificVerticalLines = function (dataForRender) {
223
+ return dataForRender.map(function (item, index) {
224
+ if (item.showVerticalLine) {
225
+ return (_jsx(Rect, { x: initialSpacing -
226
+ (item.verticalLineThickness || 1) / 2 -
227
+ 1 +
228
+ spacing * index, y: item.verticalLineUptoDataPoint
229
+ ? containerHeight -
230
+ (item.value * containerHeight) / maxValue +
231
+ 10
232
+ : -xAxisThickness, width: item.verticalLineThickness || 1, height: item.verticalLineUptoDataPoint
233
+ ? (item.value * containerHeight) / maxValue - xAxisThickness
234
+ : containerHeight + 10 - xAxisThickness, fill: item.verticalLineColor || 'lightgray' }, index));
235
+ }
236
+ return null;
237
+ });
238
+ };
239
+ var lineSvgComponent = function (pointsArray, currentLineThickness, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray) {
240
+ return (_jsxs(Svg, { children: [strokeDashArray &&
241
+ strokeDashArray.length === 2 &&
242
+ typeof strokeDashArray[0] === 'number' &&
243
+ typeof strokeDashArray[1] === 'number'
244
+ ? pointsArray.map(function (points, index) { return (_jsx(Path, { d: points.points, fill: "none", stroke: points.color === 'green' ? color : colorNegative, strokeWidth: currentLineThickness || thickness, strokeDasharray: strokeDashArray }, index)); })
245
+ : pointsArray.map(function (points, index) {
246
+ return (_jsx(Path, { d: points.points, fill: "none", stroke: points.color === 'green' ? color : colorNegative, strokeWidth: currentLineThickness || thickness }, index));
247
+ }), areaChart && (_jsxs(_Fragment, { children: [_jsxs(LinearGradient, { id: "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() })] }), _jsxs(LinearGradient, { id: "GradientNegative", x1: "0", y1: "0", x2: gradientDirection === 'horizontal' ? '1' : '0', y2: gradientDirection === 'vertical' ? '1' : '0', children: [_jsx(Stop, { offset: "1", stopColor: startFillColorNegative, stopOpacity: startOpacityNegative.toString() }), _jsx(Stop, { offset: "0", stopColor: endFillColorNegative, stopOpacity: endOpacityNegative.toString() })] })] })), areaChart
248
+ ? fillPointsArray.map(function (item, index) {
249
+ return (_jsx(Path, { d: item.points, fill: item.color === 'green'
250
+ ? 'url(#Gradient)'
251
+ : 'url(#GradientNegative)', stroke: 'transparent', strokeWidth: currentLineThickness || thickness }, index));
252
+ })
253
+ : null, renderSpecificVerticalLines(data), !hideDataPoints1
254
+ ? renderDataPoints(data, dataPointsShape1, dataPointsWidth1, dataPointsHeight1, dataPointsColor1, dataPointsRadius1, textColor1, textFontSize1, startIndex1, endIndex1)
255
+ : null] }));
256
+ };
257
+ var renderLine = function (zIndex, pointsArray, currentLineThickness, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray) {
258
+ return (_jsx(View, { style: {
259
+ position: 'absolute',
260
+ height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
261
+ bottom: 60 + labelsExtraHeight,
262
+ width: totalWidth,
263
+ zIndex: zIndex,
264
+ }, children: pointsArray.length
265
+ ? lineSvgComponent(pointsArray, currentLineThickness, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray)
266
+ : null }));
267
+ };
268
+ var renderAnimatedLine = function (zIndex, points, animatedWidth, currentLineThickness, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray) {
269
+ return (_jsx(Animated.View, { style: {
270
+ position: 'absolute',
271
+ height: extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
272
+ bottom: 60, //stepHeight * -0.5 + xAxisThickness,
273
+ width: animatedWidth,
274
+ zIndex: zIndex,
275
+ // backgroundColor: 'wheat',
276
+ }, children: lineSvgComponent(points, currentLineThickness, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray) }));
277
+ };
278
+ var renderChartContent = function () {
279
+ return (_jsxs(_Fragment, { children: [isAnimated
280
+ ? renderAnimatedLine(zIndex, pointsArray, animatedWidth, thickness1, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray1)
281
+ : renderLine(zIndex, pointsArray, thickness1, color, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray1), data.map(function (item, index) {
282
+ return (_jsx(View, { children: isAnimated
283
+ ? renderAnimatedLabel(index, item.label ||
284
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
285
+ ? props.xAxisLabelTexts[index]
286
+ : ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent)
287
+ : renderLabel(index, item.label ||
288
+ (props.xAxisLabelTexts && props.xAxisLabelTexts[index]
289
+ ? props.xAxisLabelTexts[index]
290
+ : ''), item.labelTextStyle || props.xAxisLabelTextStyle, item.labelComponent) }, index));
291
+ })] }));
292
+ };
293
+ return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { scrollRef: scrollRef, animatedWidth: animatedWidth, renderChartContent: renderChartContent, remainingScrollViewProps: { onScroll: function (ev) { var _a; return (_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, ev); } } })));
294
+ };
@@ -0,0 +1,2 @@
1
+ import { LineChartPropsType } from 'gifted-charts-core';
2
+ export declare const LineChart: (props: LineChartPropsType) => import("react/jsx-runtime").JSX.Element;