@harveylx/react-native-gifted-charts 1.4.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/dist/BarChart/Animated2DWithGradient.d.ts +3 -0
  4. package/dist/BarChart/Animated2DWithGradient.js +78 -0
  5. package/dist/BarChart/RenderBars.d.ts +3 -0
  6. package/dist/BarChart/RenderBars.js +222 -0
  7. package/dist/BarChart/RenderStackBars.d.ts +3 -0
  8. package/dist/BarChart/RenderStackBars.js +214 -0
  9. package/dist/BarChart/index.d.ts +2 -0
  10. package/dist/BarChart/index.js +256 -0
  11. package/dist/BarChart/styles.d.ts +45 -0
  12. package/dist/BarChart/styles.js +46 -0
  13. package/dist/Components/AnimatedThreeDBar/index.d.ts +3 -0
  14. package/dist/Components/AnimatedThreeDBar/index.js +103 -0
  15. package/dist/Components/AnimatedThreeDBar/styles.d.ts +11 -0
  16. package/dist/Components/AnimatedThreeDBar/styles.js +12 -0
  17. package/dist/Components/BarAndLineChartsWrapper/index.d.ts +3 -0
  18. package/dist/Components/BarAndLineChartsWrapper/index.js +161 -0
  19. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.d.ts +7 -0
  20. package/dist/Components/BarAndLineChartsWrapper/renderBackgroundSlices.js +30 -0
  21. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.d.ts +2 -0
  22. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +468 -0
  23. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.d.ts +3 -0
  24. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +87 -0
  25. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +2 -0
  26. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +102 -0
  27. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.d.ts +1 -0
  28. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +25 -0
  29. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.d.ts +1 -0
  30. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +20 -0
  31. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.d.ts +2 -0
  32. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +133 -0
  33. package/dist/Components/BarSpecificComponents/barBackgroundPattern.d.ts +2 -0
  34. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +9 -0
  35. package/dist/Components/BarSpecificComponents/cap.d.ts +2 -0
  36. package/dist/Components/BarSpecificComponents/cap.js +16 -0
  37. package/dist/Components/BarSpecificComponents/tooltip.d.ts +3 -0
  38. package/dist/Components/BarSpecificComponents/tooltip.js +38 -0
  39. package/dist/Components/common/LinearGradient.d.ts +16 -0
  40. package/dist/Components/common/LinearGradient.js +15 -0
  41. package/dist/Components/common/Pointer.d.ts +1 -0
  42. package/dist/Components/common/Pointer.js +18 -0
  43. package/dist/Components/common/StripAndLabel.d.ts +2 -0
  44. package/dist/Components/common/StripAndLabel.js +60 -0
  45. package/dist/Components/lineSvg.d.ts +14 -0
  46. package/dist/Components/lineSvg.js +22 -0
  47. package/dist/LineChart/LineChartBicolor.d.ts +2 -0
  48. package/dist/LineChart/LineChartBicolor.js +298 -0
  49. package/dist/LineChart/index.d.ts +2 -0
  50. package/dist/LineChart/index.js +1137 -0
  51. package/dist/LineChart/styles.d.ts +43 -0
  52. package/dist/LineChart/styles.js +46 -0
  53. package/dist/PieChart/index.d.ts +2 -0
  54. package/dist/PieChart/index.js +146 -0
  55. package/dist/PieChart/main.d.ts +2 -0
  56. package/dist/PieChart/main.js +178 -0
  57. package/dist/PieChartPro/index.d.ts +2 -0
  58. package/dist/PieChartPro/index.js +124 -0
  59. package/dist/PopulationPyramid/index.d.ts +2 -0
  60. package/dist/PopulationPyramid/index.js +132 -0
  61. package/dist/RadarChart/index.d.ts +2 -0
  62. package/dist/RadarChart/index.js +113 -0
  63. package/dist/index.d.ts +8 -0
  64. package/dist/index.js +8 -0
  65. package/dist/utils/index.d.ts +5 -0
  66. package/dist/utils/index.js +22 -0
  67. package/package.json +89 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Abhinandan Kushwaha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # react-native-gifted-charts
2
+
3
+ <p align="center">
4
+ <a href="https://gifted-charts.web.app">
5
+ <img src="/demos/favicon.png" height="auto" width="26" height="26" />
6
+ </a> &nbsp; &nbsp; &nbsp;
7
+ <a href="https://www.npmjs.com/package/react-native-gifted-charts">
8
+ <img src="/demos/npmIcon.png" height="auto" width="28" height="28" />
9
+ </a> &nbsp; &nbsp; &nbsp;
10
+ <a href="https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts">
11
+ <img src="/demos/gitLogo.png" height="auto" width="28" height="28" />
12
+ </a> &nbsp; &nbsp; &nbsp;
13
+ <a href="https://stackoverflow.com/questions/tagged/react-native-gifted-charts?tab=Newest">
14
+ <img src="/demos/stackOverflow.png" height="auto" width="28" height="28" />
15
+ </a> &nbsp; &nbsp; &nbsp;
16
+ <a href="https://discord.gg/FBbu9duJxs">
17
+ <img src="/demos/discord.png" height="auto" width="30" height="30" />
18
+ </a> &nbsp; &nbsp; &nbsp;
19
+ <a href="https://www.reddit.com/r/gifted_charts/">
20
+ <img src="/demos/redditLogo.png" height="auto" width="32" height="32" />
21
+ </a>
22
+ </p>
23
+ The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar, Population Pyramid and Radar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.
24
+
25
+ ### Yet another chart library? Why?
26
+
27
+ **_To bring Life to your data_**
28
+
29
+ - Plenty of features with minimal code
30
+ - Apply animations to your charts on load and on value change, just by adding a prop
31
+ - Smooth animations implemented using the `Animated` API (no external library used for animations)
32
+ - Clickable and scrollable
33
+ - Three-D and gradient effects
34
+ - Fully customizable (see the [props](docs/docs.md))
35
+ - Detailed [documentation](https://gifted-charts.web.app/) with examples
36
+ - Support for **_combined_** Bar and Line charts
37
+ - Tested to be pixel perfect using [react-native-screenshot-test](https://www.npmjs.com/package/react-native-screenshot-test). See [the screenshot tests here](https://abhinandan-kushwaha.github.io/TestingCharts/ss-test/test.html)
38
+ - Detailed and illustrated [dev docs](docs/dev/index.md) that explain the architecture and working of the library
39
+
40
+ The web counterpart of this library is public now. Try out our new reactJS library- [react-gifted-charts](https://www.npmjs.com/package/react-gifted-charts) <br />
41
+ The exact same piece of code that you write to render charts in react-native, can be used to render charts in reactJS using this library!
42
+
43
+ ## [Release notes (Changelog) 🎉](release-notes/release-notes.md)
44
+
45
+ See the **[release changes by version here.](release-notes/release-notes.md)**
46
+
47
+ <img src='/demos/bars.png' alt=''/>
48
+ <img src='/demos/lineArea.png' alt=''/>
49
+ <img src='/demos/blues.png' alt=''/>
50
+ <table>
51
+ <tr>
52
+ <td><img src='/demos/scrollLine.gif' alt='' width=320 height=280/></td>
53
+ <td><img src='/demos/animatedDataLine.gif' alt='' width=320 height=260/></td>
54
+ </tr>
55
+
56
+ <tr>
57
+ <td><img src='/demos/crossHair.gif' alt='' height=280 /></td>
58
+ <td><img src='/demos/movingBars.gif' alt='' width=270 height=300/></td>
59
+ <tr>
60
+ <td><img src='/demos/radar.png' alt='' height=280 width=320/></td>
61
+ <td><img src='/demos/ppnLabelled.png' alt='' height=280 width=300/></td>
62
+ </tr>
63
+ </table>
64
+ <img src='/demos/pieExt.png' alt='' height=280 />
65
+
66
+ ---
67
+
68
+ ## Installation
69
+
70
+ ### React Native CLI
71
+
72
+ ```sh
73
+ npm install react-native-gifted-charts react-native-linear-gradient react-native-svg
74
+ ```
75
+
76
+ ### Expo
77
+
78
+ ```sh
79
+ npx expo install react-native-gifted-charts expo-linear-gradient react-native-svg
80
+ ```
81
+
82
+ Please note that `react-native-svg` and `react-native-linear-gradient`/`expo-linear-gradient` are needed for the library to work, so make sure they are installed in your project. <br />
83
+ **[gifted-charts-core](https://www.npmjs.com/package/gifted-charts-core)** contains the mathematical and logical utilities used by this library.
84
+
85
+ # 📚 Docs & Demos 🎦
86
+
87
+ - [Documentation and gallery](https://gifted-charts.web.app/) <br />
88
+ - [Architecture and working (dev docs)](docs/dev/index.md)
89
+ - [Demo repo and snacks list](https://github.com/Abhinandan-Kushwaha/GiftedChartsDemo?tab=readme-ov-file#gifted-charts-demo)
90
+ - [Demo app on Play Store](https://play.google.com/store/apps/details?id=com.giftedcharts.demo)
91
+
92
+ ## Usage
93
+
94
+ The simplest usage of various types of charts can be done as below-
95
+
96
+ ```js
97
+ import { BarChart, LineChart, PieChart, PopulationPyramid, RadarChart } from "react-native-gifted-charts";
98
+
99
+ // ...
100
+ const data=[ {value:50}, {value:80}, {value:90}, {value:70} ]
101
+
102
+ <BarChart data = {data} />
103
+ <LineChart data = {data} />
104
+ <PieChart data = {data} />
105
+ <PopulationPyramid data = {[{left:10,right:12}, {left:9,right:8}]} />
106
+ <RadarChart data = {[50, 80, 90, 70]} />
107
+
108
+ // For Horizontal Bar chart, just add the prop horizontal to the <BarChart/> component
109
+
110
+ <BarChart data = {data} horizontal />
111
+
112
+ // For Area chart, just add the prop areaChart to the <LineChart/> component
113
+
114
+ <LineChart data = {data} areaChart />
115
+
116
+ // For Donut chart, just add the prop donut to the <PieChart/> component
117
+
118
+ <PieChart data = {data} donut />
119
+ ```
120
+
121
+ ## Props tables
122
+
123
+ **1. [BarChart, Horizontal BarChart and Stacked Bar Chart props](docs/BarChart/BarChartProps.md)** \
124
+ **2. [LineChart and AreaChart props](docs/LineChart/LineChartProps.md)** \
125
+ **3. [PieChart and DonutChart props](docs/PieChart/PieChartProps.md)** \
126
+ **4. [Population Pyramid props](docs/PopulationPyramid/PopulationPyramid.md)** \
127
+ **5. [RadarChart props](docs/RadarChart/RadarChartProps.md)**
128
+
129
+ ## 🤝 Contributing
130
+
131
+ This project exists thanks to all the people who contribute.
132
+
133
+ <a href="https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/graphs/contributors">
134
+ <img src="https://contrib.rocks/image?repo=Abhinandan-Kushwaha/react-native-gifted-charts" />
135
+ </a>
136
+ <br/><br/>
137
+
138
+ _Dear developers_! Your small contribution can make someone's day 😊
139
+
140
+ One of the ways you can contribute is to address an [open issue](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues).
141
+
142
+ Sometimes people report issues which don't exist, or request for features which are already present. Such issues can be addressed without pushing any code to the repo. Just show them in the comments how to do it.
143
+
144
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
145
+
146
+ 📝 [To do list](./src/todos.md)
147
+
148
+ ## 🧐 Test cases
149
+
150
+ - Test strategy and cases are discussed here- [TESTS.md](./TESTS.md) <br />
151
+ - Pixel perfection is assured using [react-native-screenshot-test](https://www.npmjs.com/package/react-native-screenshot-test). <br/>
152
+ - 290+ screenshot tests have been written. See the [Reports here](https://abhinandan-kushwaha.github.io/TestingCharts/ss-test/test.html).
153
+ - Screenshot tests are written in a separate repo named [TestingCharts](https://github.com/Abhinandan-Kushwaha/TestingCharts)
154
+
155
+ ## 🏆 Showcase
156
+
157
+ Showcase your dashing charts on [Expo snack](https://snack.expo.dev/) and list them on the [Demo app repo](https://github.com/Abhinandan-Kushwaha/GiftedChartsDemo?tab=readme-ov-file#gifted-charts-demo).<br />
158
+ Your snack might get published in the [Demo app on Play Store!](https://play.google.com/store/apps/details?id=com.giftedcharts.demo)
159
+
160
+ ## License
161
+
162
+ MIT
@@ -0,0 +1,3 @@
1
+ import { Animated2DWithGradientPropsType } from '@harveylx/gifted-charts-core';
2
+ declare const Animated2DWithGradient: (props: Animated2DWithGradientPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default Animated2DWithGradient;
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ import { View, Text, Animated } from 'react-native';
4
+ import Svg, { Defs, Rect } from 'react-native-svg';
5
+ import Cap from '../Components/BarSpecificComponents/cap';
6
+ import LinearGradient from '../Components/common/LinearGradient';
7
+ var Animated2DWithGradient = function (props) {
8
+ var _a, _b;
9
+ var barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, bWidth = props.barWidth, barStyle = props.barStyle, item = props.item, index = props.index, opacity = props.opacity, animationDuration = props.animationDuration, noGradient = props.noGradient, noAnimation = props.noAnimation, barInnerComponent = props.barInnerComponent, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, commonStyleForBar = props.commonStyleForBar, barStyleWithBackground = props.barStyleWithBackground, yAxisOffset = props.yAxisOffset, height = props.height;
10
+ var barWidth = (_a = item.barWidth) !== null && _a !== void 0 ? _a : bWidth; // setting width in state for animation purpose
11
+ var topLabelPosition = (item.barWidth || barWidth || 30) * -1;
12
+ var animatedHeight = useRef(new Animated.Value(0)).current; // initial height = 0
13
+ var animatedLabelHeight = useRef(new Animated.Value(height + topLabelPosition)).current;
14
+ var elevate = function () {
15
+ Animated.parallel([
16
+ Animated.timing(animatedHeight, {
17
+ toValue: height,
18
+ duration: animationDuration,
19
+ useNativeDriver: false,
20
+ }),
21
+ Animated.timing(animatedLabelHeight, {
22
+ toValue: topLabelPosition,
23
+ duration: animationDuration,
24
+ useNativeDriver: false,
25
+ }),
26
+ ]).start();
27
+ };
28
+ useEffect(function () {
29
+ if (!noAnimation) {
30
+ elevate();
31
+ }
32
+ }, []);
33
+ return (_jsxs(_Fragment, { children: [_jsxs(Animated.View, { style: [
34
+ {
35
+ position: 'absolute',
36
+ bottom: 0,
37
+ width: barWidth,
38
+ overflow: 'hidden',
39
+ height: noAnimation ? height : animatedHeight,
40
+ },
41
+ item.barStyle || barStyle,
42
+ ], children: [noGradient ? (_jsx(View, { style: barStyleWithBackground, children: props.cappedBars && item.value ? (_jsx(Cap, { capThicknessFromItem: item.capThickness, capThicknessFromProps: props.capThickness, capColorFromItem: item.capColor, capColorFromProps: props.capColor, capRadiusFromItem: item.capRadius, capRadiusFromProps: props.capRadius })) : null })) : (_jsx(LinearGradient, { style: commonStyleForBar, start: { x: 0, y: 0 }, end: { x: 1, y: 1 }, colors: [
43
+ item.gradientColor || props.gradientColor || 'white',
44
+ item.frontColor || props.frontColor || 'black',
45
+ ], children: props.cappedBars && (_jsx(View, { style: {
46
+ position: 'absolute',
47
+ width: '100%',
48
+ height: item.capThickness === 0
49
+ ? 0
50
+ : item.capThickness || props.capThickness || 6,
51
+ backgroundColor: item.capColor || props.capColor || 'black',
52
+ borderTopLeftRadius: item.capRadius === 0
53
+ ? 0
54
+ : item.capRadius || props.capRadius || 0,
55
+ borderTopRightRadius: item.capRadius === 0
56
+ ? 0
57
+ : item.capRadius || props.capRadius || 0,
58
+ } })) })), (item.barBackgroundPattern || barBackgroundPattern) && (_jsxs(Svg, { children: [_jsx(Defs, { children: item.barBackgroundPattern
59
+ ? item.barBackgroundPattern()
60
+ : barBackgroundPattern === null || barBackgroundPattern === void 0 ? void 0 : barBackgroundPattern() }), _jsx(Rect, { stroke: "none", x: "1", y: "1", width: item.barWidth || barWidth || 30, height: noAnimation ? Math.abs(height) : height, fill: "url(#".concat(item.patternId || patternId, ")") })] })), barInnerComponent ? (_jsx(View, { style: { height: '100%', width: '100%' }, children: barInnerComponent(item, index) })) : null] }), item.topLabelComponent || showValuesAsTopLabel ? (_jsx(Animated.View, { style: [
61
+ {
62
+ position: 'absolute',
63
+ top: noAnimation ? topLabelPosition : animatedLabelHeight,
64
+ height: item.barWidth || barWidth || 30,
65
+ width: item.barWidth || barWidth || 30,
66
+ justifyContent: (props.horizontal && !intactTopLabel) || item.value < 0
67
+ ? 'center'
68
+ : 'flex-end',
69
+ alignItems: 'center',
70
+ opacity: opacity,
71
+ },
72
+ item.value < 0 && { transform: [{ rotate: '180deg' }] },
73
+ props.horizontal &&
74
+ !intactTopLabel && { transform: [{ rotate: '270deg' }] },
75
+ topLabelContainerStyle !== null && topLabelContainerStyle !== void 0 ? topLabelContainerStyle : item.topLabelContainerStyle,
76
+ ], children: showValuesAsTopLabel ? (_jsx(Text, { style: topLabelTextStyle, children: item.value + yAxisOffset })) : ((_b = item.topLabelComponent) === null || _b === void 0 ? void 0 : _b.call(item)) })) : null] }));
77
+ };
78
+ export default Animated2DWithGradient;
@@ -0,0 +1,3 @@
1
+ import { RenderBarsPropsType } from '@harveylx/gifted-charts-core';
2
+ declare const RenderBars: (props: RenderBarsPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default RenderBars;
@@ -0,0 +1,222 @@
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 { View, TouchableOpacity, Animated, Text } from 'react-native';
14
+ import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
15
+ import Animated2DWithGradient from './Animated2DWithGradient';
16
+ import { getPropsForAnimated2DWithGradient, useRenderBars, } from '@harveylx/gifted-charts-core';
17
+ import Tooltip from '../Components/BarSpecificComponents/tooltip';
18
+ var isIndexSelected = function (values, idx) {
19
+ if (Array.isArray(values))
20
+ return values.includes(idx);
21
+ return values === idx;
22
+ };
23
+ var RenderBars = function (props) {
24
+ var _a, _b, _c;
25
+ var item = props.item, index = props.index, containerHeight = props.containerHeight, maxValue = props.maxValue, minHeight = props.minHeight, spacing = props.spacing, side = props.side, data = props.data, barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, isThreeD = props.isThreeD, isAnimated = props.isAnimated, rotateLabel = props.rotateLabel, appearingOpacity = props.appearingOpacity, animationDuration = props.animationDuration, autoShiftLabels = props.autoShiftLabels, label = props.label, secondaryLabel = props.secondaryLabel, labelTextStyle = props.labelTextStyle, secondaryLabelTextStyle = props.secondaryLabelTextStyle, xAxisTextNumberOfLines = props.xAxisTextNumberOfLines, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, renderTooltip = props.renderTooltip, selectedIndex = props.selectedIndex, setSelectedIndex = props.setSelectedIndex, horizontal = props.horizontal, rtl = props.rtl, pointerConfig = props.pointerConfig, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, barWidth = props.barWidth, _d = props.labelsDistanceFromXaxis, labelsDistanceFromXaxis = _d === void 0 ? 0 : _d, secondaryXAxis = props.secondaryXAxis, secondaryNoOfSectionsBelowXAxis = props.secondaryNoOfSectionsBelowXAxis, _e = props.barMarginBottom, barMarginBottom = _e === void 0 ? 0 : _e, highlightEnabled = props.highlightEnabled, highlightedBarIndex = props.highlightedBarIndex, lowlightOpacity = props.lowlightOpacity;
26
+ var _f = useRenderBars(props), heightFactor = _f.heightFactor, barHeight = _f.barHeight, tooltipProps = _f.tooltipProps;
27
+ var _g = getPropsForAnimated2DWithGradient(__assign(__assign({}, props), { barHeight: barHeight })), commonStyleForBar = _g.commonStyleForBar, barStyleWithBackground = _g.barStyleWithBackground, commonPropsFor2dAnd3dBars = _g.commonPropsFor2dAnd3dBars, isFocused = _g.isFocused, focusedBarConfig = _g.focusedBarConfig, localFrontColor = _g.localFrontColor;
28
+ var itemOrPropsBarInnerComponent = (_a = item.barInnerComponent) !== null && _a !== void 0 ? _a : props.barInnerComponent;
29
+ var localBarInnerComponent = isFocused
30
+ ? ((_b = focusedBarConfig === null || focusedBarConfig === void 0 ? void 0 : focusedBarConfig.barInnerComponent) !== null && _b !== void 0 ? _b : itemOrPropsBarInnerComponent)
31
+ : itemOrPropsBarInnerComponent;
32
+ var renderLabel = function (top, label, labelTextStyle, value) {
33
+ var _a, _b;
34
+ return (_jsx(View, { style: [
35
+ {
36
+ width: (item.labelWidth ||
37
+ props.labelWidth ||
38
+ item.barWidth ||
39
+ barWidth) + spacing,
40
+ left: spacing / -2,
41
+ position: 'absolute',
42
+ height: (_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18,
43
+ bottom: top
44
+ ? (containerHeight || 200) +
45
+ ((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
46
+ : (rotateLabel
47
+ ? -40
48
+ : -6 -
49
+ xAxisTextNumberOfLines * 18 -
50
+ (value < 0
51
+ ? -xAxisLabelsVerticalShift
52
+ : xAxisLabelsVerticalShift)) -
53
+ barMarginBottom -
54
+ (value < 0 && !autoShiftLabels
55
+ ? -labelsDistanceFromXaxis
56
+ : labelsDistanceFromXaxis),
57
+ },
58
+ rotateLabel
59
+ ? horizontal
60
+ ? { transform: [{ rotate: '330deg' }] }
61
+ : {
62
+ transform: [
63
+ { rotate: value < 0 ? '240deg' : '60deg' },
64
+ { translateX: value < 0 ? 56 : 0 },
65
+ { translateY: value < 0 ? 32 : 0 },
66
+ ],
67
+ }
68
+ : horizontal
69
+ ? { transform: [{ rotate: '-90deg' }] }
70
+ : value < 0
71
+ ? {
72
+ transform: [
73
+ { rotate: '180deg' },
74
+ {
75
+ translateY: autoShiftLabels
76
+ ? 0
77
+ : 16.5 * xAxisTextNumberOfLines + 12,
78
+ },
79
+ ],
80
+ }
81
+ : {},
82
+ ], children: top ? (item.secondaryLabelComponent ? (item.secondaryLabelComponent()) : (_jsx(Text, { style: [
83
+ { textAlign: 'center' },
84
+ rtl && horizontal && { transform: [{ rotate: '180deg' }] },
85
+ labelTextStyle,
86
+ ], numberOfLines: xAxisTextNumberOfLines, children: label }))) : item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
87
+ { textAlign: 'center' },
88
+ rtl && horizontal && { transform: [{ rotate: '180deg' }] },
89
+ labelTextStyle,
90
+ ], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
91
+ };
92
+ var renderAnimatedLabel = function (top, label, labelTextStyle, value) {
93
+ var _a, _b;
94
+ return (_jsx(Animated.View, { style: [
95
+ {
96
+ width: (item.labelWidth ||
97
+ props.labelWidth ||
98
+ item.barWidth ||
99
+ barWidth) + spacing,
100
+ left: spacing / -2,
101
+ position: 'absolute',
102
+ height: (_a = props.xAxisLabelsHeight) !== null && _a !== void 0 ? _a : xAxisTextNumberOfLines * 18 -
103
+ (value < 0
104
+ ? -xAxisLabelsVerticalShift
105
+ : xAxisLabelsVerticalShift),
106
+ bottom: top
107
+ ? (containerHeight || 200) +
108
+ ((_b = secondaryXAxis === null || secondaryXAxis === void 0 ? void 0 : secondaryXAxis.labelsDistanceFromXaxis) !== null && _b !== void 0 ? _b : 15)
109
+ : (rotateLabel
110
+ ? -40
111
+ : -6 -
112
+ xAxisTextNumberOfLines * 18 -
113
+ xAxisLabelsVerticalShift) - barMarginBottom,
114
+ opacity: appearingOpacity,
115
+ },
116
+ value < 0 && { transform: [{ rotate: '180deg' }] },
117
+ rotateLabel
118
+ ? horizontal
119
+ ? { transform: [{ rotate: '330deg' }] }
120
+ : { transform: [{ rotate: '60deg' }] }
121
+ : horizontal
122
+ ? { transform: [{ rotate: '-90deg' }] }
123
+ : value < 0
124
+ ? {
125
+ transform: [
126
+ { rotate: '180deg' },
127
+ {
128
+ translateY: autoShiftLabels
129
+ ? 0
130
+ : 16.5 * xAxisTextNumberOfLines + 12,
131
+ },
132
+ ],
133
+ }
134
+ : {},
135
+ ], children: top ? (item.secondaryLabelComponent ? (item.secondaryLabelComponent()) : (_jsx(Text, { style: [
136
+ { textAlign: 'center' },
137
+ rtl && horizontal && { transform: [{ rotate: '180deg' }] },
138
+ labelTextStyle,
139
+ ], numberOfLines: xAxisTextNumberOfLines, children: label }))) : item.labelComponent ? (item.labelComponent()) : (_jsx(Text, { style: [
140
+ { textAlign: 'center' },
141
+ rtl && horizontal && { transform: [{ rotate: '180deg' }] },
142
+ labelTextStyle,
143
+ ], numberOfLines: xAxisTextNumberOfLines, children: label })) }));
144
+ };
145
+ var barWrapperStyle = [
146
+ {
147
+ // overflow: 'visible',
148
+ opacity: highlightEnabled
149
+ ? isIndexSelected(highlightedBarIndex, -1)
150
+ ? 1
151
+ : isIndexSelected(highlightedBarIndex, index)
152
+ ? 1
153
+ : lowlightOpacity
154
+ : 1,
155
+ marginBottom: 60 + barMarginBottom + xAxisLabelsVerticalShift - 0.5,
156
+ width: commonPropsFor2dAnd3dBars.barWidth,
157
+ height: barHeight,
158
+ marginRight: spacing,
159
+ transform: [
160
+ {
161
+ translateY: (containerHeight || 200) -
162
+ (barHeight - 10 + xAxisLabelsVerticalShift) +
163
+ (item.value < 0
164
+ ? Math.max(minHeight, Math.abs(item.value) * heightFactor)
165
+ : 0),
166
+ },
167
+ { rotateZ: item.value < 0 ? '180deg' : '0deg' },
168
+ ],
169
+ },
170
+ side !== 'right' && { zIndex: data.length - index },
171
+ ];
172
+ var pressDisabled = item.disablePress ||
173
+ props.disablePress ||
174
+ (pointerConfig && pointerConfig.barTouchable !== true);
175
+ var barContent = function () {
176
+ var isBarBelowXaxisAndInvisible = item.value < 0 &&
177
+ !(noOfSectionsBelowXAxis || secondaryNoOfSectionsBelowXAxis);
178
+ var animated2DWithGradient = function (noGradient, noAnimation) { return (_jsx(Animated2DWithGradient, __assign({}, commonPropsFor2dAnd3dBars, { animationDuration: animationDuration || 800, roundedBottom: props.roundedBottom || false, roundedTop: props.roundedTop || false, noGradient: noGradient, noAnimation: noAnimation, containerHeight: containerHeight, maxValue: maxValue, minHeight: minHeight !== null && minHeight !== void 0 ? minHeight : 0, barMarginBottom: barMarginBottom, cappedBars: props.cappedBars, capThickness: props.capThickness, capColor: props.capColor, capRadius: props.capRadius, horizontal: horizontal, barBorderWidth: barBorderWidth, barBorderColor: barBorderColor, commonStyleForBar: commonStyleForBar, barStyleWithBackground: barStyleWithBackground }))); };
179
+ return (_jsxs(_Fragment, { children: [(props.showXAxisIndices || item.showXAxisIndex) && (_jsx(View, { style: {
180
+ zIndex: 2,
181
+ position: 'absolute',
182
+ height: props.xAxisIndicesHeight,
183
+ width: props.xAxisIndicesWidth,
184
+ bottom: props.xAxisIndicesHeight / -2,
185
+ left: ((item.barWidth || barWidth) - props.xAxisIndicesWidth) / 2,
186
+ backgroundColor: props.xAxisIndicesColor,
187
+ } })), isBarBelowXaxisAndInvisible ? null : isThreeD ? (_jsx(AnimatedThreeDBar, __assign({}, commonPropsFor2dAnd3dBars, { sideWidth: item.sideWidth ||
188
+ props.sideWidth ||
189
+ (item.barWidth || barWidth) / 2, side: side || 'left', sideColor: item.sideColor || props.sideColor || '', topColor: item.topColor || props.topColor || '', horizontal: horizontal, isAnimated: isAnimated, animationDuration: animationDuration || 800, selectedIndex: selectedIndex, containerHeight: containerHeight || 200 }))) : item.showGradient || props.showGradient ? (isAnimated ? (animated2DWithGradient(false, false)) : (animated2DWithGradient(false, true))) : isAnimated ? (animated2DWithGradient(true, false)) : (animated2DWithGradient(true, true)), isAnimated
190
+ ? renderAnimatedLabel(false, label, labelTextStyle, item.value)
191
+ : renderLabel(false, label, labelTextStyle, item.value), secondaryXAxis
192
+ ? isAnimated
193
+ ? renderAnimatedLabel(true, secondaryLabel, secondaryLabelTextStyle, item.value)
194
+ : renderLabel(true, secondaryLabel, secondaryLabelTextStyle, item.value)
195
+ : null] }));
196
+ };
197
+ return (_jsxs(_Fragment, { children: [pressDisabled ? (_jsx(View, { pointerEvents: "none", style: barWrapperStyle, children: barContent() })) : (_jsx(TouchableOpacity, { activeOpacity: props.activeOpacity || 0.2, onPress: function () {
198
+ if (renderTooltip || props.focusBarOnPress || highlightEnabled) {
199
+ if (props.focusedBarIndex === undefined || !props.onPress) {
200
+ setSelectedIndex([index]);
201
+ }
202
+ }
203
+ item.onPress
204
+ ? item.onPress()
205
+ : props.onPress
206
+ ? props.onPress(item, index)
207
+ : null;
208
+ }, onLongPress: function () {
209
+ item.onLongPress
210
+ ? item.onLongPress()
211
+ : props.onLongPress
212
+ ? props.onLongPress(item, index)
213
+ : null;
214
+ }, onPressOut: function () {
215
+ item.onPressOut
216
+ ? item.onPressOut()
217
+ : props.onPressOut
218
+ ? props.onPressOut(item, index)
219
+ : null;
220
+ }, style: barWrapperStyle, children: barContent() })), renderTooltip && ((_c = selectedIndex.includes) === null || _c === void 0 ? void 0 : _c.call(selectedIndex, index)) && (_jsx(Tooltip, __assign({}, tooltipProps)))] }));
221
+ };
222
+ export default RenderBars;
@@ -0,0 +1,3 @@
1
+ import { StackedBarChartPropsType } from '@harveylx/gifted-charts-core';
2
+ declare const RenderStackBars: (props: StackedBarChartPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default RenderStackBars;