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.
- package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
- package/dist/BarChart/Animated2DWithGradient.js +113 -1
- package/dist/BarChart/RenderBars.d.ts +3 -0
- package/dist/BarChart/RenderBars.js +264 -1
- package/dist/BarChart/RenderStackBars.d.ts +3 -0
- package/dist/BarChart/RenderStackBars.js +172 -1
- package/dist/BarChart/index.d.ts +2 -0
- package/dist/BarChart/index.js +233 -1
- package/dist/BarChart/styles.d.ts +45 -0
- package/dist/BarChart/styles.js +46 -1
- package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
- package/dist/Components/AnimatedThreeDBar/index.js +129 -1
- package/dist/Components/AnimatedThreeDBar/styles.d.ts +10 -0
- package/dist/Components/AnimatedThreeDBar/styles.js +13 -1
- package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/index.js +128 -1
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +322 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +76 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +50 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -1
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
- package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +94 -1
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -1
- package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
- package/dist/Components/BarSpecificComponents/cap.js +16 -1
- package/dist/Components/BarSpecificComponents/tooltip.d.ts +15 -0
- package/dist/Components/BarSpecificComponents/tooltip.js +40 -1
- package/dist/Components/common/LinearGradient.d.ts +16 -0
- package/dist/Components/common/LinearGradient.js +15 -1
- package/dist/Components/common/Pointer.d.ts +1 -0
- package/dist/Components/common/Pointer.js +16 -1
- package/dist/Components/common/StripAndLabel.d.ts +1 -0
- package/dist/Components/common/StripAndLabel.js +43 -1
- package/dist/Components/lineSvg.d.ts +14 -0
- package/dist/Components/lineSvg.js +22 -1
- package/dist/LineChart/LineChartBicolor.d.ts +2 -0
- package/dist/LineChart/LineChartBicolor.js +294 -1
- package/dist/LineChart/index.d.ts +2 -0
- package/dist/LineChart/index.js +1089 -1
- package/dist/LineChart/styles.d.ts +43 -0
- package/dist/LineChart/styles.js +46 -1
- package/dist/PieChart/index.d.ts +2 -0
- package/dist/PieChart/index.js +99 -1
- package/dist/PieChart/main.d.ts +2 -0
- package/dist/PieChart/main.js +182 -1
- package/dist/PieChartPro/index.d.ts +2 -0
- package/dist/PieChartPro/index.js +124 -1
- package/dist/PopulationPyramid/index.d.ts +2 -0
- package/dist/PopulationPyramid/index.js +130 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +12 -1
- package/package.json +3 -3
|
@@ -1 +1,322 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.renderHorizSections=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _lineSvg=_interopRequireDefault(require("../lineSvg"));var _styles=require("../../LineChart/styles");var _giftedChartsCore=require("gifted-charts-core");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/abhinandankushwaha/sites/projects/react-native-gifted-charts/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx";var renderHorizSections=exports.renderHorizSections=function renderHorizSections(props){var chartType=props.chartType,width=props.width,noOfSectionsBelowXAxis=props.noOfSectionsBelowXAxis,totalWidth=props.totalWidth,endSpacing=props.endSpacing,yAxisSide=props.yAxisSide,horizontalRulesStyle=props.horizontalRulesStyle,noOfSections=props.noOfSections,sectionColors=props.sectionColors,stepHeight=props.stepHeight,negativeStepHeight=props.negativeStepHeight,yAxisLabelWidth=props.yAxisLabelWidth,yAxisLabelContainerStyle=props.yAxisLabelContainerStyle,yAxisThickness=props.yAxisThickness,yAxisColor=props.yAxisColor,xAxisThickness=props.xAxisThickness,xAxisColor=props.xAxisColor,xAxisLength=props.xAxisLength,xAxisType=props.xAxisType,dashWidth=props.dashWidth,dashGap=props.dashGap,backgroundColor=props.backgroundColor,hideRules=props.hideRules,rulesLength=props.rulesLength,rulesType=props.rulesType,rulesThickness=props.rulesThickness,rulesColor=props.rulesColor,rulesConfigArray=props.rulesConfigArray,spacing=props.spacing,showYAxisIndices=props.showYAxisIndices,yAxisIndicesHeight=props.yAxisIndicesHeight,yAxisIndicesWidth=props.yAxisIndicesWidth,yAxisIndicesColor=props.yAxisIndicesColor,hideOrigin=props.hideOrigin,hideYAxisText=props.hideYAxisText,yAxisTextNumberOfLines=props.yAxisTextNumberOfLines,yAxisTextStyle=props.yAxisTextStyle,rotateYAxisTexts=props.rotateYAxisTexts,rtl=props.rtl,containerHeight=props.containerHeight,maxValue=props.maxValue,yAxisOffset=props.yAxisOffset,horizontal=props.horizontal,yAxisAtTop=props.yAxisAtTop,secondaryYAxis=props.secondaryYAxis,onlyReferenceLines=props.onlyReferenceLines,renderReferenceLines=props.renderReferenceLines,secondaryXAxis=props.secondaryXAxis;var _getHorizSectionVals=(0,_giftedChartsCore.getHorizSectionVals)(props),secondaryYAxisConfig=_getHorizSectionVals.secondaryYAxisConfig,horizSections=_getHorizSectionVals.horizSections,yAxisExtraHeightAtTop=_getHorizSectionVals.yAxisExtraHeightAtTop,secondaryHorizSections=_getHorizSectionVals.secondaryHorizSections,showReferenceLine1=_getHorizSectionVals.showReferenceLine1,referenceLine1Config=_getHorizSectionVals.referenceLine1Config,referenceLine1Position=_getHorizSectionVals.referenceLine1Position,showReferenceLine2=_getHorizSectionVals.showReferenceLine2,referenceLine2Config=_getHorizSectionVals.referenceLine2Config,referenceLine2Position=_getHorizSectionVals.referenceLine2Position,showReferenceLine3=_getHorizSectionVals.showReferenceLine3,referenceLine3Config=_getHorizSectionVals.referenceLine3Config,referenceLine3Position=_getHorizSectionVals.referenceLine3Position,horizSectionsBelow=_getHorizSectionVals.horizSectionsBelow,secondaryHorizSectionsBelow=_getHorizSectionVals.secondaryHorizSectionsBelow,getLabelTexts=_getHorizSectionVals.getLabelTexts,getLabelTextsForSecondaryYAxis=_getHorizSectionVals.getLabelTextsForSecondaryYAxis;var renderAxesAndRules=function renderAxesAndRules(index){var _sectionColors$invert,_rulesConfigArray$inv,_rulesConfigArray$inv2,_rulesConfigArray$inv3,_rulesConfigArray$inv4,_ref,_rulesConfigArray$inv5,_rulesConfigArray$inv6,_rulesConfigArray$inv7,_rulesConfigArray$inv8,_rulesConfigArray$inv9,_rulesConfigArray$inv10,_rulesConfigArray$inv11,_rulesConfigArray$inv12;var invertedIndex=horizSections.length-index-1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[index===noOfSections?_styles.styles.lastLeftPart:!index?{justifyContent:'flex-start'}:_styles.styles.leftPart,{borderColor:yAxisColor,backgroundColor:(_sectionColors$invert=sectionColors==null?void 0:sectionColors[invertedIndex])!=null?_sectionColors$invert:backgroundColor,width:(props.width||totalWidth-spacing)+endSpacing},!index?{height:stepHeight/2,marginTop:stepHeight/2}:null,yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?{borderRightWidth:yAxisThickness}:{borderLeftWidth:yAxisThickness}],children:[index===noOfSections?(0,_jsxRuntime.jsx)(_lineSvg.default,{config:{thickness:xAxisThickness,color:xAxisColor,width:xAxisLength||(props.width||totalWidth-spacing)+endSpacing,dashWidth:dashWidth,dashGap:dashGap,type:xAxisType}}):hideRules?null:(0,_jsxRuntime.jsx)(_lineSvg.default,{config:{thickness:(_rulesConfigArray$inv=(_rulesConfigArray$inv2=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv2.rulesThickness)!=null?_rulesConfigArray$inv:rulesThickness,color:(_rulesConfigArray$inv3=(_rulesConfigArray$inv4=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv4.rulesColor)!=null?_rulesConfigArray$inv3:rulesColor,width:(_ref=(_rulesConfigArray$inv5=(_rulesConfigArray$inv6=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv6.rulesLength)!=null?_rulesConfigArray$inv5:rulesLength)!=null?_ref:(props.width||totalWidth-spacing)+endSpacing,dashWidth:(_rulesConfigArray$inv7=(_rulesConfigArray$inv8=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv8.dashWidth)!=null?_rulesConfigArray$inv7:dashWidth,dashGap:(_rulesConfigArray$inv9=(_rulesConfigArray$inv10=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv10.dashGap)!=null?_rulesConfigArray$inv9:dashGap,type:(_rulesConfigArray$inv11=(_rulesConfigArray$inv12=rulesConfigArray[invertedIndex])==null?void 0:_rulesConfigArray$inv12.rulesType)!=null?_rulesConfigArray$inv11:rulesType}}),showYAxisIndices&&index!==noOfSections?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:'absolute',height:yAxisIndicesHeight,width:yAxisIndicesWidth,left:yAxisIndicesWidth/-2+(yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?(width!=null?width:totalWidth)+yAxisLabelWidth/2+yAxisIndicesWidth/4:0),backgroundColor:yAxisIndicesColor}}):null]});};var renderExtraHeightOfYAxisAtTop=function renderExtraHeightOfYAxisAtTop(){var _secondaryXAxis$color,_secondaryXAxis$thick;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_styles.styles.horizBar,{width:(width!=null?width:totalWidth)+endSpacing,top:stepHeight/2},horizontal&&!yAxisAtTop&&{transform:[{rotateY:'180deg'}]},horizontalRulesStyle],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.leftLabel,{height:yAxisExtraHeightAtTop,width:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth},yAxisLabelContainerStyle]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.leftPart,{borderLeftColor:yAxisColor,borderRightColor:yAxisColor,borderTopColor:(_secondaryXAxis$color=secondaryXAxis==null?void 0:secondaryXAxis.color)!=null?_secondaryXAxis$color:xAxisColor,borderTopWidth:secondaryXAxis?(_secondaryXAxis$thick=secondaryXAxis.thickness)!=null?_secondaryXAxis$thick:xAxisThickness:0,backgroundColor:backgroundColor,width:(props.width||totalWidth-spacing)+endSpacing},yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?{borderRightWidth:yAxisThickness}:{borderLeftWidth:yAxisThickness}]})]});};var renderSecondaryYaxisLabels=function renderSecondaryYaxisLabels(horizSections,isBelow){return horizSections.map(function(sectionItems,index){var _secondaryYAxisConfig,_secondaryYAxisConfig2,_secondaryYAxisConfig3;var label=getLabelTextsForSecondaryYAxis(sectionItems.value,index);if(secondaryYAxisConfig.hideOrigin&&index===0){label='';}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_styles.styles.horizBar,_styles.styles.leftLabel,{position:'absolute',zIndex:1,bottom:((_secondaryYAxisConfig=secondaryYAxisConfig.stepHeight)!=null?_secondaryYAxisConfig:0)*((isBelow?0:noOfSectionsBelowXAxis)+index-(noOfSectionsBelowXAxis?0:0.5)),width:secondaryYAxisConfig.yAxisLabelWidth,height:(_secondaryYAxisConfig2=secondaryYAxisConfig.stepHeight)!=null?_secondaryYAxisConfig2:0},yAxisLabelContainerStyle],children:[secondaryYAxisConfig.showYAxisIndices&&index!==0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:secondaryYAxisConfig.yAxisIndicesHeight,width:secondaryYAxisConfig.yAxisIndicesWidth,position:'absolute',left:((_secondaryYAxisConfig3=secondaryYAxisConfig.yAxisIndicesWidth)!=null?_secondaryYAxisConfig3:0)/-2,backgroundColor:secondaryYAxisConfig.yAxisIndicesColor}}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:secondaryYAxisConfig.yAxisTextNumberOfLines,ellipsizeMode:'clip',style:[secondaryYAxisConfig.yAxisTextStyle],children:label})]},index);});};var referenceLines=function referenceLines(){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[showReferenceLine1?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:'absolute',zIndex:referenceLine1Config.zIndex,bottom:(referenceLine1Position-(yAxisOffset!=null?yAxisOffset:0))*containerHeight/maxValue,left:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth+yAxisThickness},children:[(0,_jsxRuntime.jsx)(_lineSvg.default,{config:referenceLine1Config}),referenceLine1Config.labelText?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{position:'absolute'},referenceLine1Config.labelTextStyle],children:referenceLine1Config.labelText}):null]}):null,showReferenceLine2?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:'absolute',zIndex:referenceLine2Config.zIndex,bottom:(referenceLine2Position-(yAxisOffset!=null?yAxisOffset:0))*containerHeight/maxValue,left:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth+yAxisThickness},children:[(0,_jsxRuntime.jsx)(_lineSvg.default,{config:referenceLine2Config}),referenceLine2Config.labelText?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{position:'absolute'},referenceLine2Config.labelTextStyle],children:referenceLine2Config.labelText}):null]}):null,showReferenceLine3?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:'absolute',zIndex:referenceLine3Config.zIndex,bottom:(referenceLine3Position-(yAxisOffset!=null?yAxisOffset:0))*containerHeight/maxValue,left:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth+yAxisThickness},children:[(0,_jsxRuntime.jsx)(_lineSvg.default,{config:referenceLine3Config}),referenceLine3Config.labelText?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{position:'absolute'},referenceLine3Config.labelTextStyle],children:referenceLine3Config.labelText}):null]}):null]});};var leftShiftForRIghtYaxis=(width?width+20:totalWidth)+yAxisLabelWidth/2+endSpacing-(chartType===_giftedChartsCore.chartTypes.BAR?40:60);return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:onlyReferenceLines?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:'row',backgroundColor:'green'},children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:(width!=null?width:totalWidth)+endSpacing},children:referenceLines()})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:{flexDirection:'row',marginTop:stepHeight/-2},children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:(width!=null?width:totalWidth)+endSpacing},children:[yAxisExtraHeightAtTop?renderExtraHeightOfYAxisAtTop():null,horizSections.map(function(sectionItems,index){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_styles.styles.horizBar,{width:(width!=null?width:totalWidth)+endSpacing},horizontal&&!yAxisAtTop&&{transform:[{rotateY:'180deg'}]},horizontalRulesStyle],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.leftLabel,{height:index===noOfSections?stepHeight/2:stepHeight,width:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth},yAxisLabelContainerStyle]}),renderAxesAndRules(index)]},index);}),!hideYAxisText&&horizSections.map(function(sectionItems,index){var label=getLabelTexts(sectionItems.value,index);if(hideOrigin&&index===horizSections.length-1){label='';}return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.horizBar,_styles.styles.leftLabel,{position:'absolute',zIndex:1,top:stepHeight*index+yAxisExtraHeightAtTop,width:yAxisLabelWidth,height:index===noOfSections?stepHeight/2:stepHeight},yAxisSide===_giftedChartsCore.yAxisSides.RIGHT&&{left:leftShiftForRIghtYaxis},horizontal&&!yAxisAtTop&&{transform:[{translateX:(width!=null?width:totalWidth)-30+endSpacing}]},yAxisLabelContainerStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:yAxisTextNumberOfLines,ellipsizeMode:'clip',style:[yAxisTextStyle,horizontal&&{transform:[{rotate:`${rotateYAxisTexts!=null?rotateYAxisTexts:rtl?90:-90}deg`}]},index===noOfSections&&{marginBottom:stepHeight/-2}],children:label})},index);}),horizSectionsBelow.map(function(sectionItems,index){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[_styles.styles.horizBar,{width:(width!=null?width:totalWidth)+15},index===0&&{marginTop:negativeStepHeight/2}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.leftLabel,{borderRightWidth:yAxisThickness,borderColor:yAxisColor,marginLeft:yAxisThickness},{height:index===0?negativeStepHeight*1.5:negativeStepHeight,width:yAxisSide===_giftedChartsCore.yAxisSides.RIGHT?0:yAxisLabelWidth},index===0&&{marginTop:-negativeStepHeight/2}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.leftPart,{backgroundColor:backgroundColor}],children:hideRules?null:(0,_jsxRuntime.jsx)(_lineSvg.default,{config:{thickness:rulesThickness,color:rulesColor,width:rulesLength||(props.width||totalWidth-spacing)+endSpacing,dashWidth:dashWidth,dashGap:dashGap,type:rulesType}})})]},index);}),!hideYAxisText&&horizSectionsBelow.map(function(sectionItems,index){var label=getLabelTexts(horizSectionsBelow[horizSectionsBelow.length-1-index].value,index);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_styles.styles.horizBar,_styles.styles.leftLabel,{position:'absolute',zIndex:1,bottom:negativeStepHeight*index,width:yAxisLabelWidth,height:index===noOfSectionsBelowXAxis?negativeStepHeight/2:negativeStepHeight},yAxisSide===_giftedChartsCore.yAxisSides.RIGHT&&{left:(width!=null?width:totalWidth)+yAxisLabelWidth},yAxisLabelContainerStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:yAxisTextNumberOfLines,ellipsizeMode:'clip',style:[yAxisTextStyle,index===noOfSectionsBelowXAxis&&{marginBottom:negativeStepHeight/-2}],children:label})},index);}),renderReferenceLines?referenceLines():null]}),secondaryYAxis?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:secondaryYAxisConfig.yAxisLabelWidth,left:width?yAxisLabelWidth:yAxisLabelWidth-spacing,borderColor:secondaryYAxisConfig.yAxisColor,borderLeftWidth:secondaryYAxisConfig.yAxisThickness,height:containerHeight+yAxisExtraHeightAtTop,bottom:stepHeight/-2},children:[!secondaryYAxisConfig.hideYAxisText?renderSecondaryYaxisLabels(secondaryHorizSections,false):null,noOfSectionsBelowXAxis&&!secondaryYAxisConfig.hideYAxisText?renderSecondaryYaxisLabels(secondaryHorizSectionsBelow,true):null]}):null]})});};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import Rule from '../lineSvg';
|
|
4
|
+
import { styles } from '../../LineChart/styles';
|
|
5
|
+
import { getHorizSectionVals, yAxisSides, chartTypes, } from 'gifted-charts-core';
|
|
6
|
+
export var renderHorizSections = function (props) {
|
|
7
|
+
var chartType = props.chartType, width = props.width, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, totalWidth = props.totalWidth, endSpacing = props.endSpacing, yAxisSide = props.yAxisSide, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, yAxisLabelWidth = props.yAxisLabelWidth, yAxisLabelContainerStyle = props.yAxisLabelContainerStyle, yAxisThickness = props.yAxisThickness, yAxisColor = props.yAxisColor, xAxisThickness = props.xAxisThickness, xAxisColor = props.xAxisColor, xAxisLength = props.xAxisLength, xAxisType = props.xAxisType, dashWidth = props.dashWidth, dashGap = props.dashGap, backgroundColor = props.backgroundColor, hideRules = props.hideRules, rulesLength = props.rulesLength, rulesType = props.rulesType, rulesThickness = props.rulesThickness, rulesColor = props.rulesColor, rulesConfigArray = props.rulesConfigArray, spacing = props.spacing, showYAxisIndices = props.showYAxisIndices, yAxisIndicesHeight = props.yAxisIndicesHeight, yAxisIndicesWidth = props.yAxisIndicesWidth, yAxisIndicesColor = props.yAxisIndicesColor, hideOrigin = props.hideOrigin, hideYAxisText = props.hideYAxisText, yAxisTextNumberOfLines = props.yAxisTextNumberOfLines, yAxisTextStyle = props.yAxisTextStyle, rotateYAxisTexts = props.rotateYAxisTexts, rtl = props.rtl, containerHeight = props.containerHeight, maxValue = props.maxValue, yAxisOffset = props.yAxisOffset, horizontal = props.horizontal, yAxisAtTop = props.yAxisAtTop, secondaryYAxis = props.secondaryYAxis, onlyReferenceLines = props.onlyReferenceLines, renderReferenceLines = props.renderReferenceLines, secondaryXAxis = props.secondaryXAxis;
|
|
8
|
+
var _a = getHorizSectionVals(props), secondaryYAxisConfig = _a.secondaryYAxisConfig, horizSections = _a.horizSections, yAxisExtraHeightAtTop = _a.yAxisExtraHeightAtTop, secondaryHorizSections = _a.secondaryHorizSections, showReferenceLine1 = _a.showReferenceLine1, referenceLine1Config = _a.referenceLine1Config, referenceLine1Position = _a.referenceLine1Position, showReferenceLine2 = _a.showReferenceLine2, referenceLine2Config = _a.referenceLine2Config, referenceLine2Position = _a.referenceLine2Position, showReferenceLine3 = _a.showReferenceLine3, referenceLine3Config = _a.referenceLine3Config, referenceLine3Position = _a.referenceLine3Position, horizSectionsBelow = _a.horizSectionsBelow, secondaryHorizSectionsBelow = _a.secondaryHorizSectionsBelow, getLabelTexts = _a.getLabelTexts, getLabelTextsForSecondaryYAxis = _a.getLabelTextsForSecondaryYAxis;
|
|
9
|
+
var renderAxesAndRules = function (index) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
11
|
+
var invertedIndex = horizSections.length - index - 1;
|
|
12
|
+
return (_jsxs(View, { style: [
|
|
13
|
+
index === noOfSections
|
|
14
|
+
? styles.lastLeftPart
|
|
15
|
+
: !index
|
|
16
|
+
? { justifyContent: 'flex-start' }
|
|
17
|
+
: styles.leftPart,
|
|
18
|
+
{
|
|
19
|
+
borderColor: yAxisColor,
|
|
20
|
+
backgroundColor: (_a = sectionColors === null || sectionColors === void 0 ? void 0 : sectionColors[invertedIndex]) !== null && _a !== void 0 ? _a : backgroundColor,
|
|
21
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
22
|
+
},
|
|
23
|
+
!index ? { height: stepHeight / 2, marginTop: stepHeight / 2 } : null,
|
|
24
|
+
yAxisSide === yAxisSides.RIGHT
|
|
25
|
+
? { borderRightWidth: yAxisThickness }
|
|
26
|
+
: { borderLeftWidth: yAxisThickness },
|
|
27
|
+
], children: [index === noOfSections ? (_jsx(Rule, { config: {
|
|
28
|
+
thickness: xAxisThickness,
|
|
29
|
+
color: xAxisColor,
|
|
30
|
+
width: xAxisLength ||
|
|
31
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
32
|
+
dashWidth: dashWidth,
|
|
33
|
+
dashGap: dashGap,
|
|
34
|
+
type: xAxisType,
|
|
35
|
+
} })) : hideRules ? null : (_jsx(Rule, { config: {
|
|
36
|
+
thickness: (_c = (_b = rulesConfigArray[invertedIndex]) === null || _b === void 0 ? void 0 : _b.rulesThickness) !== null && _c !== void 0 ? _c : rulesThickness,
|
|
37
|
+
color: (_e = (_d = rulesConfigArray[invertedIndex]) === null || _d === void 0 ? void 0 : _d.rulesColor) !== null && _e !== void 0 ? _e : rulesColor,
|
|
38
|
+
width: (_h = (_g = (_f = rulesConfigArray[invertedIndex]) === null || _f === void 0 ? void 0 : _f.rulesLength) !== null && _g !== void 0 ? _g : rulesLength) !== null && _h !== void 0 ? _h : (props.width || totalWidth - spacing) + endSpacing,
|
|
39
|
+
dashWidth: (_k = (_j = rulesConfigArray[invertedIndex]) === null || _j === void 0 ? void 0 : _j.dashWidth) !== null && _k !== void 0 ? _k : dashWidth,
|
|
40
|
+
dashGap: (_m = (_l = rulesConfigArray[invertedIndex]) === null || _l === void 0 ? void 0 : _l.dashGap) !== null && _m !== void 0 ? _m : dashGap,
|
|
41
|
+
type: (_p = (_o = rulesConfigArray[invertedIndex]) === null || _o === void 0 ? void 0 : _o.rulesType) !== null && _p !== void 0 ? _p : rulesType,
|
|
42
|
+
} })), showYAxisIndices && index !== noOfSections ? (_jsx(View, { style: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
height: yAxisIndicesHeight,
|
|
45
|
+
width: yAxisIndicesWidth,
|
|
46
|
+
left: yAxisIndicesWidth / -2 +
|
|
47
|
+
(yAxisSide === yAxisSides.RIGHT
|
|
48
|
+
? (width !== null && width !== void 0 ? width : totalWidth) +
|
|
49
|
+
yAxisLabelWidth / 2 +
|
|
50
|
+
yAxisIndicesWidth / 4
|
|
51
|
+
: 0),
|
|
52
|
+
backgroundColor: yAxisIndicesColor,
|
|
53
|
+
} })) : null] }));
|
|
54
|
+
};
|
|
55
|
+
var renderExtraHeightOfYAxisAtTop = function () {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return (_jsxs(View, { style: [
|
|
58
|
+
styles.horizBar,
|
|
59
|
+
{
|
|
60
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
|
|
61
|
+
top: stepHeight / 2,
|
|
62
|
+
},
|
|
63
|
+
horizontal &&
|
|
64
|
+
!yAxisAtTop && {
|
|
65
|
+
transform: [{ rotateY: '180deg' }],
|
|
66
|
+
},
|
|
67
|
+
horizontalRulesStyle,
|
|
68
|
+
], children: [_jsx(View, { style: [
|
|
69
|
+
styles.leftLabel,
|
|
70
|
+
{
|
|
71
|
+
height: yAxisExtraHeightAtTop,
|
|
72
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
73
|
+
},
|
|
74
|
+
yAxisLabelContainerStyle,
|
|
75
|
+
] }), _jsx(View, { style: [
|
|
76
|
+
styles.leftPart,
|
|
77
|
+
{
|
|
78
|
+
borderLeftColor: yAxisColor,
|
|
79
|
+
borderRightColor: yAxisColor,
|
|
80
|
+
borderTopColor: (_a = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.color) !== null && _a !== void 0 ? _a : xAxisColor,
|
|
81
|
+
borderTopWidth: secondaryXAxis
|
|
82
|
+
? (_b = secondaryXAxis.thickness) !== null && _b !== void 0 ? _b : xAxisThickness
|
|
83
|
+
: 0,
|
|
84
|
+
backgroundColor: backgroundColor,
|
|
85
|
+
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
86
|
+
},
|
|
87
|
+
yAxisSide === yAxisSides.RIGHT
|
|
88
|
+
? { borderRightWidth: yAxisThickness }
|
|
89
|
+
: { borderLeftWidth: yAxisThickness },
|
|
90
|
+
] })] }));
|
|
91
|
+
};
|
|
92
|
+
var renderSecondaryYaxisLabels = function (horizSections, isBelow) {
|
|
93
|
+
return horizSections.map(function (sectionItems, index) {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
var label = getLabelTextsForSecondaryYAxis(sectionItems.value, index);
|
|
96
|
+
if (secondaryYAxisConfig.hideOrigin && index === 0) {
|
|
97
|
+
label = '';
|
|
98
|
+
}
|
|
99
|
+
return (_jsxs(View, { style: [
|
|
100
|
+
styles.horizBar,
|
|
101
|
+
styles.leftLabel,
|
|
102
|
+
{
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
zIndex: 1,
|
|
105
|
+
bottom: ((_a = secondaryYAxisConfig.stepHeight) !== null && _a !== void 0 ? _a : 0) *
|
|
106
|
+
((isBelow ? 0 : noOfSectionsBelowXAxis) +
|
|
107
|
+
index -
|
|
108
|
+
(noOfSectionsBelowXAxis ? 0 : 0.5)),
|
|
109
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
110
|
+
height: (_b = secondaryYAxisConfig.stepHeight) !== null && _b !== void 0 ? _b : 0,
|
|
111
|
+
},
|
|
112
|
+
yAxisLabelContainerStyle,
|
|
113
|
+
], children: [secondaryYAxisConfig.showYAxisIndices && index !== 0 ? (_jsx(View, { style: {
|
|
114
|
+
height: secondaryYAxisConfig.yAxisIndicesHeight,
|
|
115
|
+
width: secondaryYAxisConfig.yAxisIndicesWidth,
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
left: ((_c = secondaryYAxisConfig.yAxisIndicesWidth) !== null && _c !== void 0 ? _c : 0) / -2,
|
|
118
|
+
backgroundColor: secondaryYAxisConfig.yAxisIndicesColor,
|
|
119
|
+
} })) : null, _jsx(Text, { numberOfLines: secondaryYAxisConfig.yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [secondaryYAxisConfig.yAxisTextStyle], children: label })] }, index));
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
var referenceLines = function () {
|
|
123
|
+
return (_jsxs(_Fragment, { children: [showReferenceLine1 ? (_jsxs(View, { style: {
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
zIndex: referenceLine1Config.zIndex,
|
|
126
|
+
bottom: ((referenceLine1Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
127
|
+
containerHeight) /
|
|
128
|
+
maxValue,
|
|
129
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
130
|
+
? 0
|
|
131
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
132
|
+
}, children: [_jsx(Rule, { config: referenceLine1Config }), referenceLine1Config.labelText ? (_jsx(Text, { style: [
|
|
133
|
+
{ position: 'absolute' },
|
|
134
|
+
referenceLine1Config.labelTextStyle,
|
|
135
|
+
], children: referenceLine1Config.labelText })) : null] })) : null, showReferenceLine2 ? (_jsxs(View, { style: {
|
|
136
|
+
position: 'absolute',
|
|
137
|
+
zIndex: referenceLine2Config.zIndex,
|
|
138
|
+
bottom: ((referenceLine2Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
139
|
+
containerHeight) /
|
|
140
|
+
maxValue,
|
|
141
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
142
|
+
? 0
|
|
143
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
144
|
+
}, children: [_jsx(Rule, { config: referenceLine2Config }), referenceLine2Config.labelText ? (_jsx(Text, { style: [
|
|
145
|
+
{ position: 'absolute' },
|
|
146
|
+
referenceLine2Config.labelTextStyle,
|
|
147
|
+
], children: referenceLine2Config.labelText })) : null] })) : null, showReferenceLine3 ? (_jsxs(View, { style: {
|
|
148
|
+
position: 'absolute',
|
|
149
|
+
zIndex: referenceLine3Config.zIndex,
|
|
150
|
+
bottom: ((referenceLine3Position - (yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0)) *
|
|
151
|
+
containerHeight) /
|
|
152
|
+
maxValue,
|
|
153
|
+
left: yAxisSide === yAxisSides.RIGHT
|
|
154
|
+
? 0
|
|
155
|
+
: yAxisLabelWidth + yAxisThickness,
|
|
156
|
+
}, children: [_jsx(Rule, { config: referenceLine3Config }), referenceLine3Config.labelText ? (_jsx(Text, { style: [
|
|
157
|
+
{ position: 'absolute' },
|
|
158
|
+
referenceLine3Config.labelTextStyle,
|
|
159
|
+
], children: referenceLine3Config.labelText })) : null] })) : null] }));
|
|
160
|
+
};
|
|
161
|
+
var leftShiftForRIghtYaxis = (width ? width + 20 : totalWidth) +
|
|
162
|
+
yAxisLabelWidth / 2 +
|
|
163
|
+
endSpacing -
|
|
164
|
+
(chartType === chartTypes.BAR ? 40 : 60);
|
|
165
|
+
return (_jsx(_Fragment, { children: onlyReferenceLines ? (_jsx(View, { style: {
|
|
166
|
+
flexDirection: 'row',
|
|
167
|
+
backgroundColor: 'green',
|
|
168
|
+
}, children: _jsx(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: referenceLines() }) })) : (_jsxs(View, { pointerEvents: "none", style: {
|
|
169
|
+
flexDirection: 'row',
|
|
170
|
+
marginTop: stepHeight / -2,
|
|
171
|
+
}, children: [_jsxs(View, { style: { width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing }, children: [yAxisExtraHeightAtTop ? renderExtraHeightOfYAxisAtTop() : null, horizSections.map(function (sectionItems, index) {
|
|
172
|
+
return (_jsxs(View, { style: [
|
|
173
|
+
styles.horizBar,
|
|
174
|
+
{
|
|
175
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + endSpacing,
|
|
176
|
+
},
|
|
177
|
+
horizontal &&
|
|
178
|
+
!yAxisAtTop && {
|
|
179
|
+
transform: [{ rotateY: '180deg' }],
|
|
180
|
+
},
|
|
181
|
+
horizontalRulesStyle,
|
|
182
|
+
], children: [_jsx(View, { style: [
|
|
183
|
+
styles.leftLabel,
|
|
184
|
+
{
|
|
185
|
+
height: index === noOfSections ? stepHeight / 2 : stepHeight,
|
|
186
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
187
|
+
},
|
|
188
|
+
yAxisLabelContainerStyle,
|
|
189
|
+
] }), renderAxesAndRules(index)] }, index));
|
|
190
|
+
}),
|
|
191
|
+
/***********************************************************************************************/
|
|
192
|
+
/************************** Render the y axis labels separately **********************/
|
|
193
|
+
/***********************************************************************************************/
|
|
194
|
+
!hideYAxisText &&
|
|
195
|
+
horizSections.map(function (sectionItems, index) {
|
|
196
|
+
var label = getLabelTexts(sectionItems.value, index);
|
|
197
|
+
if (hideOrigin && index === horizSections.length - 1) {
|
|
198
|
+
label = '';
|
|
199
|
+
}
|
|
200
|
+
return (_jsx(View, { style: [
|
|
201
|
+
styles.horizBar,
|
|
202
|
+
styles.leftLabel,
|
|
203
|
+
{
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
zIndex: 1,
|
|
206
|
+
top: stepHeight * index + yAxisExtraHeightAtTop,
|
|
207
|
+
width: yAxisLabelWidth,
|
|
208
|
+
height: index === noOfSections
|
|
209
|
+
? stepHeight / 2
|
|
210
|
+
: stepHeight,
|
|
211
|
+
},
|
|
212
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
213
|
+
left: leftShiftForRIghtYaxis,
|
|
214
|
+
},
|
|
215
|
+
horizontal &&
|
|
216
|
+
!yAxisAtTop && {
|
|
217
|
+
transform: [
|
|
218
|
+
{
|
|
219
|
+
translateX: (width !== null && width !== void 0 ? width : totalWidth) - 30 + endSpacing,
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
yAxisLabelContainerStyle,
|
|
224
|
+
], children: _jsx(Text, { numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
|
|
225
|
+
yAxisTextStyle,
|
|
226
|
+
horizontal && {
|
|
227
|
+
transform: [
|
|
228
|
+
{
|
|
229
|
+
rotate: "".concat(rotateYAxisTexts !== null && rotateYAxisTexts !== void 0 ? rotateYAxisTexts : (rtl ? 90 : -90), "deg"),
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
index === noOfSections && {
|
|
234
|
+
marginBottom: stepHeight / -2,
|
|
235
|
+
},
|
|
236
|
+
], children: label }) }, index));
|
|
237
|
+
})
|
|
238
|
+
/***********************************************************************************************/
|
|
239
|
+
/***********************************************************************************************/
|
|
240
|
+
, horizSectionsBelow.map(function (sectionItems, index) {
|
|
241
|
+
return (_jsxs(View, { style: [
|
|
242
|
+
styles.horizBar,
|
|
243
|
+
{
|
|
244
|
+
width: (width !== null && width !== void 0 ? width : totalWidth) + 15,
|
|
245
|
+
},
|
|
246
|
+
index === 0 && { marginTop: negativeStepHeight / 2 },
|
|
247
|
+
], children: [_jsx(View, { style: [
|
|
248
|
+
styles.leftLabel,
|
|
249
|
+
{
|
|
250
|
+
borderRightWidth: yAxisThickness,
|
|
251
|
+
borderColor: yAxisColor,
|
|
252
|
+
marginLeft: yAxisThickness,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
height: index === 0
|
|
256
|
+
? negativeStepHeight * 1.5
|
|
257
|
+
: negativeStepHeight,
|
|
258
|
+
width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
259
|
+
},
|
|
260
|
+
index === 0 && { marginTop: -negativeStepHeight / 2 },
|
|
261
|
+
] }), _jsx(View, { style: [
|
|
262
|
+
styles.leftPart,
|
|
263
|
+
{ backgroundColor: backgroundColor },
|
|
264
|
+
], children: hideRules ? null : (_jsx(Rule, { config: {
|
|
265
|
+
thickness: rulesThickness,
|
|
266
|
+
color: rulesColor,
|
|
267
|
+
width: rulesLength ||
|
|
268
|
+
(props.width || totalWidth - spacing) + endSpacing,
|
|
269
|
+
dashWidth: dashWidth,
|
|
270
|
+
dashGap: dashGap,
|
|
271
|
+
type: rulesType,
|
|
272
|
+
} })) })] }, index));
|
|
273
|
+
}),
|
|
274
|
+
/***********************************************************************************************/
|
|
275
|
+
/************************* Render the y axis labels below origin *********************/
|
|
276
|
+
/***********************************************************************************************/
|
|
277
|
+
!hideYAxisText &&
|
|
278
|
+
horizSectionsBelow.map(function (sectionItems, index) {
|
|
279
|
+
var label = getLabelTexts(horizSectionsBelow[horizSectionsBelow.length - 1 - index]
|
|
280
|
+
.value, index);
|
|
281
|
+
return (_jsx(View, { style: [
|
|
282
|
+
styles.horizBar,
|
|
283
|
+
styles.leftLabel,
|
|
284
|
+
{
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
zIndex: 1,
|
|
287
|
+
bottom: negativeStepHeight * index,
|
|
288
|
+
width: yAxisLabelWidth,
|
|
289
|
+
height: index === noOfSectionsBelowXAxis
|
|
290
|
+
? negativeStepHeight / 2
|
|
291
|
+
: negativeStepHeight,
|
|
292
|
+
},
|
|
293
|
+
yAxisSide === yAxisSides.RIGHT && {
|
|
294
|
+
left: (width !== null && width !== void 0 ? width : totalWidth) + yAxisLabelWidth,
|
|
295
|
+
},
|
|
296
|
+
yAxisLabelContainerStyle,
|
|
297
|
+
], children: _jsx(Text, { numberOfLines: yAxisTextNumberOfLines, ellipsizeMode: 'clip', style: [
|
|
298
|
+
yAxisTextStyle,
|
|
299
|
+
index === noOfSectionsBelowXAxis && {
|
|
300
|
+
marginBottom: negativeStepHeight / -2,
|
|
301
|
+
},
|
|
302
|
+
], children: label }) }, index));
|
|
303
|
+
})
|
|
304
|
+
/***********************************************************************************************/
|
|
305
|
+
/***********************************************************************************************/
|
|
306
|
+
, renderReferenceLines ? referenceLines() : null] }),
|
|
307
|
+
/***********************************************************************************************/
|
|
308
|
+
/************************* Render the secondary Y Axis *********************/
|
|
309
|
+
/***********************************************************************************************/
|
|
310
|
+
secondaryYAxis ? (_jsxs(View, { style: {
|
|
311
|
+
width: secondaryYAxisConfig.yAxisLabelWidth,
|
|
312
|
+
left: width ? yAxisLabelWidth : yAxisLabelWidth - spacing,
|
|
313
|
+
borderColor: secondaryYAxisConfig.yAxisColor,
|
|
314
|
+
borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
|
|
315
|
+
height: containerHeight + yAxisExtraHeightAtTop,
|
|
316
|
+
bottom: stepHeight / -2,
|
|
317
|
+
}, children: [!secondaryYAxisConfig.hideYAxisText
|
|
318
|
+
? renderSecondaryYaxisLabels(secondaryHorizSections, false)
|
|
319
|
+
: null, noOfSectionsBelowXAxis && !secondaryYAxisConfig.hideYAxisText
|
|
320
|
+
? renderSecondaryYaxisLabels(secondaryHorizSectionsBelow, true)
|
|
321
|
+
: null] })) : null] })) }));
|
|
322
|
+
};
|
|
@@ -1 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View, Animated } from 'react-native';
|
|
3
|
+
import Svg, { Path } from 'react-native-svg';
|
|
4
|
+
import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
|
|
5
|
+
import { renderDataPoints } from './renderDataPoints';
|
|
6
|
+
import { renderSpecificDataPoints } from './renderSpecificDataPoints';
|
|
7
|
+
var RenderLineInBarChart = function (props) {
|
|
8
|
+
var _a;
|
|
9
|
+
var yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, arrowPoints = props.arrowPoints, data = props.data, totalWidth = props.totalWidth, barWidth = props.barWidth, labelsExtraHeight = props.labelsExtraHeight, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, selectedIndex = props.selectedIndex;
|
|
10
|
+
var firstBarWidth = (_a = data[0].barWidth) !== null && _a !== void 0 ? _a : barWidth;
|
|
11
|
+
var dataPointsProps = {
|
|
12
|
+
data: data,
|
|
13
|
+
lineConfig: lineConfig,
|
|
14
|
+
barWidth: barWidth,
|
|
15
|
+
containerHeight: containerHeight,
|
|
16
|
+
maxValue: maxValue,
|
|
17
|
+
firstBarWidth: firstBarWidth,
|
|
18
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
19
|
+
spacing: spacing,
|
|
20
|
+
selectedIndex: selectedIndex,
|
|
21
|
+
};
|
|
22
|
+
var specificVerticalLinesProps = {
|
|
23
|
+
data: data,
|
|
24
|
+
barWidth: barWidth,
|
|
25
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
26
|
+
initialSpacing: initialSpacing,
|
|
27
|
+
spacing: spacing,
|
|
28
|
+
containerHeight: containerHeight,
|
|
29
|
+
lineConfig: lineConfig,
|
|
30
|
+
maxValue: maxValue,
|
|
31
|
+
};
|
|
32
|
+
var specificDataPointsProps = {
|
|
33
|
+
data: data,
|
|
34
|
+
barWidth: barWidth,
|
|
35
|
+
firstBarWidth: firstBarWidth,
|
|
36
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
37
|
+
lineConfig: lineConfig,
|
|
38
|
+
spacing: spacing,
|
|
39
|
+
containerHeight: containerHeight,
|
|
40
|
+
maxValue: maxValue,
|
|
41
|
+
};
|
|
42
|
+
var renderAnimatedLine = function () {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
// console.log('animatedWidth is-------->', animatedWidth);
|
|
45
|
+
return (_jsx(Animated.View, { pointerEvents: "none", style: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
height: containerHeight + 10,
|
|
48
|
+
left: 6 - yAxisLabelWidth,
|
|
49
|
+
bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
50
|
+
width: animatedWidth,
|
|
51
|
+
zIndex: lineBehindBars ? -1 : 100000,
|
|
52
|
+
// backgroundColor: 'wheat',
|
|
53
|
+
}, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", stroke: lineConfig.color, strokeWidth: lineConfig.thickness }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
54
|
+
? renderDataPoints(dataPointsProps)
|
|
55
|
+
: renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
|
|
56
|
+
};
|
|
57
|
+
var renderLine = function () {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
return (_jsx(View, { pointerEvents: "none", style: {
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
height: containerHeight + 10 + labelsExtraHeight,
|
|
62
|
+
left: 6 - yAxisLabelWidth,
|
|
63
|
+
bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
|
|
64
|
+
width: totalWidth,
|
|
65
|
+
zIndex: lineBehindBars ? -1 : 100000,
|
|
66
|
+
// backgroundColor: 'rgba(200,150,150,0.1)'
|
|
67
|
+
}, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", stroke: lineConfig.color, strokeWidth: lineConfig.thickness }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
|
|
68
|
+
? renderDataPoints(dataPointsProps)
|
|
69
|
+
: renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
|
|
70
|
+
};
|
|
71
|
+
if (lineConfig.isAnimated) {
|
|
72
|
+
return renderAnimatedLine();
|
|
73
|
+
}
|
|
74
|
+
return renderLine();
|
|
75
|
+
};
|
|
76
|
+
export default RenderLineInBarChart;
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { styles } from '../../../BarChart/styles';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
|
|
6
|
+
import { Rect, Text as CanvasText, Circle } from 'react-native-svg';
|
|
7
|
+
export var renderDataPoints = function (props) {
|
|
8
|
+
var data = props.data, lineConfig = props.lineConfig, barWidth = props.barWidth, containerHeight = props.containerHeight, maxValue = props.maxValue, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, spacing = props.spacing, selectedIndex = props.selectedIndex;
|
|
9
|
+
return data.map(function (item, index) {
|
|
10
|
+
var _a, _b, _c, _d, _e;
|
|
11
|
+
if (index < lineConfig.startIndex ||
|
|
12
|
+
index > lineConfig.endIndex ||
|
|
13
|
+
item.hideDataPoint) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
17
|
+
var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
|
|
18
|
+
var dataPointColor = lineConfig.focusEnabled &&
|
|
19
|
+
index === ((_a = lineConfig.focusedDataPointIndex) !== null && _a !== void 0 ? _a : selectedIndex)
|
|
20
|
+
? lineConfig.focusedDataPointColor
|
|
21
|
+
: lineConfig.dataPointsColor;
|
|
22
|
+
var dataPointRadius = lineConfig.focusEnabled &&
|
|
23
|
+
index === ((_b = lineConfig.focusedDataPointIndex) !== null && _b !== void 0 ? _b : selectedIndex)
|
|
24
|
+
? lineConfig.focusedDataPointRadius
|
|
25
|
+
: lineConfig.dataPointsRadius;
|
|
26
|
+
var value = (_c = item.value) !== null && _c !== void 0 ? _c : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
|
|
27
|
+
if (customDataPoint) {
|
|
28
|
+
return (_jsx(View, { style: [
|
|
29
|
+
styles.customDataPointContainer,
|
|
30
|
+
{
|
|
31
|
+
height: lineConfig.dataPointsHeight,
|
|
32
|
+
width: lineConfig.dataPointsWidth,
|
|
33
|
+
top: containerHeight -
|
|
34
|
+
(value * containerHeight) / maxValue -
|
|
35
|
+
((_e = (_d = item.shiftY) !== null && _d !== void 0 ? _d : lineConfig.shiftY) !== null && _e !== void 0 ? _e : 0),
|
|
36
|
+
left: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing),
|
|
37
|
+
},
|
|
38
|
+
], children: customDataPoint(item, index) }));
|
|
39
|
+
}
|
|
40
|
+
if (lineConfig.dataPointsShape === 'rectangular') {
|
|
41
|
+
return (_jsxs(Fragment, { children: [_jsx(Rect, { x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
42
|
+
lineConfig.dataPointsHeight / 2, width: lineConfig.dataPointsWidth, height: lineConfig.dataPointsHeight, fill: dataPointColor }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
43
|
+
lineConfig.dataPointsHeight / 2 +
|
|
44
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
45
|
+
}
|
|
46
|
+
return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), cy: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue), r: dataPointRadius, fill: dataPointColor }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue) -
|
|
47
|
+
lineConfig.dataPointsHeight / 2 +
|
|
48
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
49
|
+
});
|
|
50
|
+
};
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderSpecificDataPoints: (props: any) => any;
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
|
|
4
|
+
import { Circle, Rect, Text as CanvasText } from 'react-native-svg';
|
|
5
|
+
export var renderSpecificDataPoints = function (props) {
|
|
6
|
+
var data = props.data, barWidth = props.barWidth, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, lineConfig = props.lineConfig, spacing = props.spacing, containerHeight = props.containerHeight, maxValue = props.maxValue;
|
|
7
|
+
return data.map(function (item, index) {
|
|
8
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
9
|
+
var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
|
|
10
|
+
var y = getYForLineInBar(item.value, lineConfig.shiftY, containerHeight, maxValue);
|
|
11
|
+
if (item.showDataPoint) {
|
|
12
|
+
if (item.dataPointShape === 'rectangular') {
|
|
13
|
+
return (_jsxs(Fragment, { children: [_jsx(Rect, { x: x, y: y - item.dataPointsHeight / 2, width: item.dataPointWidth || lineConfig.dataPointsWidth, height: item.dataPointHeight || 2, fill: item.dataPointColor || 'black' }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || 'black', fontSize: item.textFontSize || 10, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
|
|
14
|
+
(item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
|
|
15
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: x, cy: y, r: item.dataPointRadius || 3, fill: item.dataPointColor || 'black' }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || 'black', fontSize: item.textFontSize || 10, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
|
|
19
|
+
(item.dataPointHeight || lineConfig.dataPointsHeight) / 2 +
|
|
20
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderSpecificVerticalLines: (props: any) => any;
|
package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Rect } from 'react-native-svg';
|
|
3
|
+
export var renderSpecificVerticalLines = function (props) {
|
|
4
|
+
var data = props.data, barWidth = props.barWidth, yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue;
|
|
5
|
+
return data.map(function (item, index) {
|
|
6
|
+
if (item.showVerticalLine) {
|
|
7
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
8
|
+
return (_jsx(Rect, { x: yAxisLabelWidth +
|
|
9
|
+
6 -
|
|
10
|
+
(item.verticalLineThickness || 1) / 2 -
|
|
11
|
+
1 -
|
|
12
|
+
(initialSpacing - currentBarWidth / 2) +
|
|
13
|
+
(currentBarWidth + spacing) * index, y: containerHeight -
|
|
14
|
+
lineConfig.shiftY -
|
|
15
|
+
(item.value * containerHeight) / maxValue +
|
|
16
|
+
9, width: item.verticalLineThickness || 1, height: (item.value * containerHeight) / maxValue + lineConfig.shiftY, fill: item.verticalLineColor || 'lightgray' }));
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
});
|
|
20
|
+
};
|