react-native-gifted-charts 1.4.21 → 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 (61) hide show
  1. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  2. package/dist/BarChart/Animated2DWithGradient.js +113 -1
  3. package/dist/BarChart/RenderBars.d.ts +3 -0
  4. package/dist/BarChart/RenderBars.js +264 -1
  5. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  6. package/dist/BarChart/RenderStackBars.js +172 -1
  7. package/dist/BarChart/index.d.ts +2 -0
  8. package/dist/BarChart/index.js +233 -1
  9. package/dist/BarChart/styles.d.ts +45 -0
  10. package/dist/BarChart/styles.js +46 -1
  11. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  12. package/dist/Components/AnimatedThreeDBar/index.js +129 -1
  13. package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
  14. package/dist/Components/AnimatedThreeDBar/styles.js +13 -1
  15. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  16. package/dist/Components/BarAndLineChartsWrapper/index.js +128 -1
  17. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  18. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -1
  19. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -1
  21. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -1
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -1
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -1
  27. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -1
  29. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  30. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -1
  31. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  32. package/dist/Components/BarSpecificComponents/cap.js +16 -1
  33. package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
  34. package/dist/Components/BarSpecificComponents/tooltip.js +40 -1
  35. package/dist/Components/common/LinearGradient.d.ts +16 -0
  36. package/dist/Components/common/LinearGradient.js +15 -1
  37. package/dist/Components/common/Pointer.d.ts +1 -0
  38. package/dist/Components/common/Pointer.js +16 -1
  39. package/dist/Components/common/StripAndLabel.d.ts +1 -0
  40. package/dist/Components/common/StripAndLabel.js +43 -1
  41. package/dist/Components/lineSvg.d.ts +14 -0
  42. package/dist/Components/lineSvg.js +22 -1
  43. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  44. package/dist/LineChart/LineChartBicolor.js +294 -1
  45. package/dist/LineChart/index.d.ts +2 -0
  46. package/dist/LineChart/index.js +1089 -1
  47. package/dist/LineChart/styles.d.ts +43 -0
  48. package/dist/LineChart/styles.js +46 -1
  49. package/dist/PieChart/index.d.ts +2 -0
  50. package/dist/PieChart/index.js +99 -1
  51. package/dist/PieChart/main.d.ts +2 -0
  52. package/dist/PieChart/main.js +182 -1
  53. package/dist/PieChartPro/index.d.ts +2 -0
  54. package/dist/PieChartPro/index.js +124 -1
  55. package/dist/PopulationPyramid/index.d.ts +2 -0
  56. package/dist/PopulationPyramid/index.js +130 -1
  57. package/dist/index.d.ts +7 -0
  58. package/dist/index.js +7 -1
  59. package/dist/utils/index.d.ts +2 -0
  60. package/dist/utils/index.js +12 -1
  61. package/package.json +3 -3
@@ -1 +1,294 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.LineChartBicolor=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _styles=require("./styles");var _reactNativeSvg=_interopRequireWildcard(require("react-native-svg"));var _BarAndLineChartsWrapper=_interopRequireDefault(require("../Components/BarAndLineChartsWrapper"));var _giftedChartsCore=require("gifted-charts-core");var _utils=require("../utils");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/abhinandankushwaha/sites/projects/react-native-gifted-charts/src/LineChart/LineChartBicolor.tsx";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}var LineChartBicolor=exports.LineChartBicolor=function LineChartBicolor(props){var _props$parentWidth;var scrollRef=(0,_react.useRef)();var widthValue=(0,_react.useMemo)(function(){return new _reactNative.Animated.Value(0);},[]);var opacValue=(0,_react.useMemo)(function(){return new _reactNative.Animated.Value(0);},[]);var _useLineChartBiColor=(0,_giftedChartsCore.useLineChartBiColor)(Object.assign({},props,{parentWidth:(_props$parentWidth=props.parentWidth)!=null?_props$parentWidth:_utils.screenWidth})),pointsArray=_useLineChartBiColor.pointsArray,fillPointsArray=_useLineChartBiColor.fillPointsArray,selectedIndex=_useLineChartBiColor.selectedIndex,setSelectedIndex=_useLineChartBiColor.setSelectedIndex,containerHeight=_useLineChartBiColor.containerHeight,data=_useLineChartBiColor.data,labelsExtraHeight=_useLineChartBiColor.labelsExtraHeight,animationDuration=_useLineChartBiColor.animationDuration,startIndex1=_useLineChartBiColor.startIndex1,endIndex1=_useLineChartBiColor.endIndex1,initialSpacing=_useLineChartBiColor.initialSpacing,thickness=_useLineChartBiColor.thickness,spacing=_useLineChartBiColor.spacing,xAxisThickness=_useLineChartBiColor.xAxisThickness,dataPointsHeight1=_useLineChartBiColor.dataPointsHeight1,dataPointsWidth1=_useLineChartBiColor.dataPointsWidth1,dataPointsRadius1=_useLineChartBiColor.dataPointsRadius1,dataPointsColor1=_useLineChartBiColor.dataPointsColor1,dataPointsShape1=_useLineChartBiColor.dataPointsShape1,areaChart=_useLineChartBiColor.areaChart,textFontSize1=_useLineChartBiColor.textFontSize1,textColor1=_useLineChartBiColor.textColor1,totalWidth=_useLineChartBiColor.totalWidth,maxValue=_useLineChartBiColor.maxValue,extendedContainerHeight=_useLineChartBiColor.extendedContainerHeight,getX=_useLineChartBiColor.getX,getY=_useLineChartBiColor.getY,stepHeight=_useLineChartBiColor.stepHeight,noOfSectionsBelowXAxis=_useLineChartBiColor.noOfSectionsBelowXAxis,thickness1=_useLineChartBiColor.thickness1,zIndex=_useLineChartBiColor.zIndex,strokeDashArray1=_useLineChartBiColor.strokeDashArray1,rotateLabel=_useLineChartBiColor.rotateLabel,isAnimated=_useLineChartBiColor.isAnimated,hideDataPoints1=_useLineChartBiColor.hideDataPoints1,color=_useLineChartBiColor.color,colorNegative=_useLineChartBiColor.colorNegative,startFillColor=_useLineChartBiColor.startFillColor,endFillColor=_useLineChartBiColor.endFillColor,startOpacity=_useLineChartBiColor.startOpacity,endOpacity=_useLineChartBiColor.endOpacity,startFillColorNegative=_useLineChartBiColor.startFillColorNegative,endFillColorNegative=_useLineChartBiColor.endFillColorNegative,startOpacityNegative=_useLineChartBiColor.startOpacityNegative,endOpacityNegative=_useLineChartBiColor.endOpacityNegative,gradientDirection=_useLineChartBiColor.gradientDirection,xAxisTextNumberOfLines=_useLineChartBiColor.xAxisTextNumberOfLines,focusEnabled=_useLineChartBiColor.focusEnabled,showDataPointOnFocus=_useLineChartBiColor.showDataPointOnFocus,showStripOnFocus=_useLineChartBiColor.showStripOnFocus,showTextOnFocus=_useLineChartBiColor.showTextOnFocus,stripHeight=_useLineChartBiColor.stripHeight,stripWidth=_useLineChartBiColor.stripWidth,stripColor=_useLineChartBiColor.stripColor,stripOpacity=_useLineChartBiColor.stripOpacity,unFocusOnPressOut=_useLineChartBiColor.unFocusOnPressOut,delayBeforeUnFocus=_useLineChartBiColor.delayBeforeUnFocus,barAndLineChartsWrapperProps=_useLineChartBiColor.barAndLineChartsWrapperProps;var labelsAppear=(0,_react.useCallback)(function(){opacValue.setValue(0);_reactNative.Animated.timing(opacValue,{toValue:1,duration:500,easing:_reactNative.Easing.ease,useNativeDriver:false}).start();},[opacValue]);var appearingOpacity=opacValue.interpolate({inputRange:[0,1],outputRange:[0,1]});var decreaseWidth=(0,_react.useCallback)(function(){widthValue.setValue(0);_reactNative.Animated.timing(widthValue,{toValue:1,duration:animationDuration,easing:_reactNative.Easing.linear,useNativeDriver:false}).start();},[animationDuration,widthValue]);(0,_react.useEffect)(function(){decreaseWidth();labelsAppear();},[animationDuration,decreaseWidth,labelsAppear]);var renderLabel=function renderLabel(index,label,labelTextStyle,labelComponent){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:'absolute',bottom:30,zIndex:10,width:spacing+labelsExtraHeight,left:index===0&&initialSpacing<10?getX(index)-spacing/2+8:getX(index)-spacing/2,justifyContent:'center'},rotateLabel&&{transform:[{rotate:'60deg'}]}],children:labelComponent?labelComponent():(0,_jsxRuntime.jsx)(_reactNative.Text,{style:labelTextStyle||{textAlign:'center'},numberOfLines:xAxisTextNumberOfLines,children:label||''})});};var renderAnimatedLabel=function renderAnimatedLabel(index,label,labelTextStyle,labelComponent){return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[{height:rotateLabel?40:20,position:'absolute',bottom:rotateLabel?10:30,zIndex:10,width:spacing,left:index===0&&initialSpacing<10?getX(index)-spacing/2+8:getX(index)-spacing/2,opacity:appearingOpacity},rotateLabel&&{transform:[{rotate:'60deg'}]}],children:labelComponent?labelComponent():(0,_jsxRuntime.jsx)(_reactNative.Text,{style:labelTextStyle||{textAlign:'center'},numberOfLines:xAxisTextNumberOfLines,children:label||''})});};var animatedWidth=widthValue.interpolate({inputRange:[0,1],outputRange:[0,totalWidth]});var onStripPress=function onStripPress(item,index){setSelectedIndex(index);if(props.onFocus){props.onFocus(item,index);}};var renderDataPoints=function renderDataPoints(dataForRender,dataPtsShape,dataPtsWidth,dataPtsHeight,dataPtsColor,dataPtsRadius,textColor,textFontSize,startIndex,endIndex){return dataForRender.map(function(item,index){var _item$stripHeight,_item$stripWidth,_item$stripOpacity;if(index<startIndex||index>endIndex)return null;if(item.hideDataPoint){return null;}var dataPointsShape,dataPointsWidth,dataPointsHeight,dataPointsColor,dataPointsRadius,text,customDataPoint,dataPointLabelComponent;if(index===selectedIndex){dataPointsShape=item.focusedDataPointShape||props.focusedDataPointShape||item.dataPointShape||dataPtsShape;dataPointsWidth=item.focusedDataPointWidth||props.focusedDataPointWidth||item.dataPointWidth||dataPtsWidth;dataPointsHeight=item.focusedDataPointHeight||props.focusedDataPointHeight||item.dataPointHeight||dataPtsHeight;dataPointsColor=item.focusedDataPointColor||props.focusedDataPointColor||'orange';dataPointsRadius=item.focusedDataPointRadius||props.focusedDataPointRadius||item.dataPointRadius||dataPtsRadius;if(showTextOnFocus){text=item.dataPointText;}customDataPoint=item.focusedCustomDataPoint||props.focusedCustomDataPoint||item.customDataPoint||props.customDataPoint;dataPointLabelComponent=item.focusedDataPointLabelComponent||item.dataPointLabelComponent;}else{dataPointsShape=item.dataPointShape||dataPtsShape;dataPointsWidth=item.dataPointWidth||dataPtsWidth;dataPointsHeight=item.dataPointHeight||dataPtsHeight;dataPointsColor=item.dataPointColor||dataPtsColor;dataPointsRadius=item.dataPointRadius||dataPtsRadius;if(showTextOnFocus){text='';}customDataPoint=item.customDataPoint||props.customDataPoint;dataPointLabelComponent=item.dataPointLabelComponent;}var currentStripHeight=(_item$stripHeight=item.stripHeight)!=null?_item$stripHeight:stripHeight;var currentStripWidth=(_item$stripWidth=item.stripWidth)!=null?_item$stripWidth:stripWidth;var currentStripOpacity=(_item$stripOpacity=item.stripOpacity)!=null?_item$stripOpacity:stripOpacity;var currentStripColor=item.stripColor||stripColor;return(0,_jsxRuntime.jsxs)(_react.Fragment,{children:[focusEnabled?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:unFocusOnPressOut?(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{onPressIn:function onPressIn(){return onStripPress(item,index);},onPressOut:function onPressOut(){return setTimeout(function(){return setSelectedIndex(-1);},delayBeforeUnFocus);},x:initialSpacing+(spacing*index-spacing/2),y:8,width:spacing,height:containerHeight,fill:'none'}):(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{onPress:function onPress(){return onStripPress(item,index);},x:initialSpacing+(spacing*index-spacing/2),y:8,width:spacing,height:containerHeight,fill:'none'})}):null,item.showStrip||focusEnabled&&index===selectedIndex&&showStripOnFocus?(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:initialSpacing+(spacing*index-dataPointsWidth/2),y:currentStripHeight?containerHeight-currentStripHeight+8:containerHeight-dataPointsHeight/2+20-item.value*containerHeight/maxValue,width:currentStripWidth,height:currentStripHeight||containerHeight-dataPointsHeight/2+20,opacity:currentStripOpacity,fill:currentStripColor}):null,customDataPoint?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.customDataPointContainer,{height:dataPointsHeight,width:dataPointsWidth,top:containerHeight-item.value*containerHeight/maxValue,left:getX(index)-dataPointsWidth}],children:customDataPoint()}):null,dataPointsShape==='rectangular'?(0,_jsxRuntime.jsx)(_react.Fragment,{children:customDataPoint?null:(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:getX(index)-dataPointsWidth,y:extendedContainerHeight+dataPointsHeight/2-item.value*containerHeight/maxValue,width:dataPointsWidth,height:dataPointsHeight,fill:showDataPointOnFocus?index===selectedIndex?dataPointsColor:'none':dataPointsColor,onPress:function onPress(){item.onPress?item.onPress(item,index):props.onPress?props.onPress(item,index):null;}})},index):(0,_jsxRuntime.jsx)(_react.Fragment,{children:customDataPoint?null:(0,_jsxRuntime.jsx)(_reactNativeSvg.Circle,{cx:getX(index),cy:getY(index),r:dataPointsRadius,fill:showDataPointOnFocus?index===selectedIndex?dataPointsColor:'none':dataPointsColor,onPress:function onPress(){item.onPress?item.onPress(item,index):props.onPress?props.onPress(item,index):null;}})},index),dataPointLabelComponent?!showTextOnFocus||index===selectedIndex?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.customDataPointContainer,{top:containerHeight+(item.dataPointLabelShiftY||props.dataPointLabelShiftY||0)-item.value*containerHeight/maxValue,left:initialSpacing+(item.dataPointLabelShiftX||props.dataPointLabelShiftX||0)-(item.dataPointLabelWidth?item.dataPointLabelWidth+20:props.dataPointLabelWidth?props.dataPointLabelWidth+20:50)/2+spacing*index}],children:dataPointLabelComponent()}):null:text||item.dataPointText?!showTextOnFocus||index===selectedIndex?(0,_jsxRuntime.jsx)(_reactNativeSvg.Text,{fill:item.textColor||textColor,fontSize:item.textFontSize||textFontSize,x:initialSpacing-dataPointsWidth+spacing*index+(item.textShiftX||props.textShiftX||0),y:extendedContainerHeight-dataPointsHeight/2-item.value*containerHeight/maxValue+(item.textShiftY||props.textShiftY||0),children:!showTextOnFocus?item.dataPointText:text}):null:null]},index);});};var renderSpecificVerticalLines=function renderSpecificVerticalLines(dataForRender){return dataForRender.map(function(item,index){if(item.showVerticalLine){return(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:initialSpacing-(item.verticalLineThickness||1)/2-1+spacing*index,y:item.verticalLineUptoDataPoint?containerHeight-item.value*containerHeight/maxValue+10:-xAxisThickness,width:item.verticalLineThickness||1,height:item.verticalLineUptoDataPoint?item.value*containerHeight/maxValue-xAxisThickness:containerHeight+10-xAxisThickness,fill:item.verticalLineColor||'lightgray'},index);}return null;});};var lineSvgComponent=function lineSvgComponent(pointsArray,currentLineThickness,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray){return(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{children:[strokeDashArray&&strokeDashArray.length===2&&typeof strokeDashArray[0]==='number'&&typeof strokeDashArray[1]==='number'?pointsArray.map(function(points,index){return(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:points.points,fill:"none",stroke:points.color==='green'?color:colorNegative,strokeWidth:currentLineThickness||thickness,strokeDasharray:strokeDashArray},index);}):pointsArray.map(function(points,index){return(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:points.points,fill:"none",stroke:points.color==='green'?color:colorNegative,strokeWidth:currentLineThickness||thickness},index);}),areaChart&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNativeSvg.LinearGradient,{id:"Gradient",x1:"0",y1:"0",x2:gradientDirection==='horizontal'?'1':'0',y2:gradientDirection==='vertical'?'1':'0',children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"0",stopColor:startFillColor,stopOpacity:startOpacity.toString()}),(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"1",stopColor:endFillColor,stopOpacity:endOpacity.toString()})]}),(0,_jsxRuntime.jsxs)(_reactNativeSvg.LinearGradient,{id:"GradientNegative",x1:"0",y1:"0",x2:gradientDirection==='horizontal'?'1':'0',y2:gradientDirection==='vertical'?'1':'0',children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"1",stopColor:startFillColorNegative,stopOpacity:startOpacityNegative.toString()}),(0,_jsxRuntime.jsx)(_reactNativeSvg.Stop,{offset:"0",stopColor:endFillColorNegative,stopOpacity:endOpacityNegative.toString()})]})]}),areaChart?fillPointsArray.map(function(item,index){return(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:item.points,fill:item.color==='green'?'url(#Gradient)':'url(#GradientNegative)',stroke:'transparent',strokeWidth:currentLineThickness||thickness},index);}):null,renderSpecificVerticalLines(data),!hideDataPoints1?renderDataPoints(data,dataPointsShape1,dataPointsWidth1,dataPointsHeight1,dataPointsColor1,dataPointsRadius1,textColor1,textFontSize1,startIndex1,endIndex1):null]});};var renderLine=function renderLine(zIndex,pointsArray,currentLineThickness,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:'absolute',height:extendedContainerHeight+noOfSectionsBelowXAxis*stepHeight,bottom:60+labelsExtraHeight,width:totalWidth,zIndex:zIndex},children:pointsArray.length?lineSvgComponent(pointsArray,currentLineThickness,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray):null});};var renderAnimatedLine=function renderAnimatedLine(zIndex,points,animatedWidth,currentLineThickness,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray){return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{position:'absolute',height:extendedContainerHeight+noOfSectionsBelowXAxis*stepHeight,bottom:60,width:animatedWidth,zIndex:zIndex},children:lineSvgComponent(points,currentLineThickness,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray)});};var renderChartContent=function renderChartContent(){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[isAnimated?renderAnimatedLine(zIndex,pointsArray,animatedWidth,thickness1,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray1):renderLine(zIndex,pointsArray,thickness1,color,startFillColor,endFillColor,startOpacity,endOpacity,strokeDashArray1),data.map(function(item,index){return(0,_jsxRuntime.jsx)(_reactNative.View,{children:isAnimated?renderAnimatedLabel(index,item.label||(props.xAxisLabelTexts&&props.xAxisLabelTexts[index]?props.xAxisLabelTexts[index]:''),item.labelTextStyle||props.xAxisLabelTextStyle,item.labelComponent):renderLabel(index,item.label||(props.xAxisLabelTexts&&props.xAxisLabelTexts[index]?props.xAxisLabelTexts[index]:''),item.labelTextStyle||props.xAxisLabelTextStyle,item.labelComponent)},index);})]});};return(0,_jsxRuntime.jsx)(_BarAndLineChartsWrapper.default,Object.assign({},barAndLineChartsWrapperProps,{scrollRef:scrollRef,animatedWidth:animatedWidth,renderChartContent:renderChartContent,remainingScrollViewProps:{onScroll:function onScroll(ev){return props.onScroll==null?void 0:props.onScroll(ev);}}}));};
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;