gifted-charts-core 0.0.20 → 0.0.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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  AxesAndRulesDefaults,
3
3
  populationDefaults,
4
- ruleTypes,
5
- } from "../utils/constants";
6
- import { PopulationPyramidPropsType, RulesProps } from "./types";
4
+ ruleTypes
5
+ } from '../utils/constants'
6
+ import { type PopulationPyramidPropsType, type RulesProps } from './types'
7
7
 
8
8
  export const usePopulationPyramid = (props: PopulationPyramidPropsType) => {
9
9
  const {
@@ -122,41 +122,41 @@ export const usePopulationPyramid = (props: PopulationPyramidPropsType) => {
122
122
  rightSurplusColor = populationDefaults.rightSurplusColor,
123
123
  rightSurplusBorderColor = populationDefaults.rightSurplusBorderColor,
124
124
  leftSurplusBorderWidth = populationDefaults.leftSurplusBorderWidth,
125
- rightSurplusBorderWidth = populationDefaults.rightSurplusBorderWidth,
126
- } = props;
125
+ rightSurplusBorderWidth = populationDefaults.rightSurplusBorderWidth
126
+ } = props
127
127
 
128
128
  const yAxisLabelWidth = hideYAxisText
129
129
  ? yAxisThickness
130
- : props.yAxisLabelWidth ?? AxesAndRulesDefaults.yAxisLabelWidth;
130
+ : props.yAxisLabelWidth ?? AxesAndRulesDefaults.yAxisLabelWidth
131
131
 
132
- const noOfSections = props.noOfSections ?? data.length;
132
+ const noOfSections = props.noOfSections ?? data.length
133
133
  const containerHeight = props.stepHeight
134
134
  ? props.stepHeight * noOfSections
135
- : height;
136
- const stepHeight = props.stepHeight ?? containerHeight / noOfSections;
135
+ : height
136
+ const stepHeight = props.stepHeight ?? containerHeight / noOfSections
137
137
 
138
- const xAxisLabelsHeight = 80;
139
- const containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight;
138
+ const xAxisLabelsHeight = 80
139
+ const containerHeightWithXaxisLabels = containerHeight + xAxisLabelsHeight
140
140
 
141
- const mid = (width + yAxisLabelWidth) / 2;
141
+ const mid = (width + yAxisLabelWidth) / 2
142
142
 
143
- const leftMax = Math.max(...data.map((item) => item.left));
144
- const rightMax = Math.max(...data.map((item) => item.right));
143
+ const leftMax = Math.max(...data.map((item) => item.left))
144
+ const rightMax = Math.max(...data.map((item) => item.right))
145
145
 
146
- const max = Math.max(leftMax, rightMax);
146
+ const max = Math.max(leftMax, rightMax)
147
147
 
148
148
  const xAxisRoundToDigits =
149
149
  props.xAxisRoundToDigits ??
150
- (max < 0.1 ? 3 : max < 1 ? 2 : max < 10 ? 1 : 0);
150
+ (max < 0.1 ? 3 : max < 1 ? 2 : max < 10 ? 1 : 0)
151
151
 
152
152
  const midAxisAndLabelWidth =
153
153
  (showMidAxis ? midAxisLabelWidth : 0) / 2 +
154
- Math.max(leftBarLabelWidth, rightBarLabelWidth);
154
+ Math.max(leftBarLabelWidth, rightBarLabelWidth)
155
155
  const barWidthFactor =
156
- ((width - yAxisLabelWidth) / 2 - midAxisAndLabelWidth) / max;
156
+ ((width - yAxisLabelWidth) / 2 - midAxisAndLabelWidth) / max
157
157
 
158
- const leftXAfterMid = mid - (showMidAxis ? midAxisLabelWidth / 2 : 0);
159
- const rightXAfterMid = mid + (showMidAxis ? midAxisLabelWidth / 2 : 0);
158
+ const leftXAfterMid = mid - (showMidAxis ? midAxisLabelWidth / 2 : 0)
159
+ const rightXAfterMid = mid + (showMidAxis ? midAxisLabelWidth / 2 : 0)
160
160
 
161
161
  const yAxisLineProps: RulesProps = {
162
162
  x1: yAxisLabelWidth,
@@ -164,37 +164,37 @@ export const usePopulationPyramid = (props: PopulationPyramidPropsType) => {
164
164
  x2: yAxisLabelWidth,
165
165
  y2: containerHeight,
166
166
  stroke: yAxisColor,
167
- strokeWidth: yAxisThickness,
168
- };
167
+ strokeWidth: yAxisThickness
168
+ }
169
169
  if (props.yAxisStrokeDashArray?.length === 2) {
170
- yAxisLineProps.strokeDasharray = props.yAxisStrokeDashArray;
170
+ yAxisLineProps.strokeDasharray = props.yAxisStrokeDashArray
171
171
  }
172
172
 
173
173
  const midAxisLineCommonProps: RulesProps = {
174
174
  y1: 0,
175
175
  y2: containerHeight,
176
- strokeWidth: props.midAxisThickness ?? yAxisThickness,
177
- };
176
+ strokeWidth: props.midAxisThickness ?? yAxisThickness
177
+ }
178
178
  if (props.midAxisStrokeDashArray?.length === 2) {
179
- midAxisLineCommonProps.strokeDasharray = props.midAxisStrokeDashArray;
179
+ midAxisLineCommonProps.strokeDasharray = props.midAxisStrokeDashArray
180
180
  }
181
181
 
182
182
  const xAxisLabelY =
183
- containerHeight + xAxisLabelFontSize + 6 + xAxisLabelShiftY;
183
+ containerHeight + xAxisLabelFontSize + 6 + xAxisLabelShiftY
184
184
  const xAxisIndicesCommonProps = {
185
185
  y1: containerHeight - xAxisIndicesHeight / 2 + xAxisIndicesShiftY,
186
186
  y2: containerHeight + xAxisIndicesHeight / 2 + xAxisIndicesShiftY,
187
187
  stroke: xAxisIndicesColor,
188
- strokeWidth: xAxisIndicesWidth,
189
- };
188
+ strokeWidth: xAxisIndicesWidth
189
+ }
190
190
  const verticalLinesCommonProps: RulesProps = {
191
191
  y1: 0,
192
192
  y2: containerHeight,
193
193
  stroke: verticalLinesColor,
194
- strokeWidth: verticalLinesThickness,
195
- };
194
+ strokeWidth: verticalLinesThickness
195
+ }
196
196
  if (verticalLinesType !== ruleTypes.SOLID) {
197
- verticalLinesCommonProps.strokeDasharray = verticalLinesStrokeDashArray;
197
+ verticalLinesCommonProps.strokeDasharray = verticalLinesStrokeDashArray
198
198
  }
199
199
  const xAxisLabelsCommonProps = {
200
200
  y: xAxisLabelY + xAxisLabelShiftY,
@@ -202,13 +202,13 @@ export const usePopulationPyramid = (props: PopulationPyramidPropsType) => {
202
202
  fontSize: xAxisLabelFontSize,
203
203
  fontStyle: xAxisLabelFontStyle,
204
204
  fontWeight: xAxisLabelFontWeight,
205
- fontFamily: xAxisLabelFontFamily,
206
- };
205
+ fontFamily: xAxisLabelFontFamily
206
+ }
207
207
 
208
- const getXLabel = (index: number) =>
208
+ const getXLabel = (index: number): string =>
209
209
  ((leftXAfterMid * index) / xAxisNoOfSections / barWidthFactor)
210
210
  .toFixed(xAxisRoundToDigits)
211
- .toString();
211
+ .toString()
212
212
 
213
213
  return {
214
214
  height,
@@ -325,6 +325,6 @@ export const usePopulationPyramid = (props: PopulationPyramidPropsType) => {
325
325
  xAxisIndicesCommonProps,
326
326
  verticalLinesCommonProps,
327
327
  xAxisLabelsCommonProps,
328
- getXLabel,
329
- };
330
- };
328
+ getXLabel
329
+ }
330
+ }
@@ -1,200 +1,199 @@
1
- import { ColorValue } from "react-native";
2
- import { RuleTypes } from "../utils/types";
3
- import { FontStyle, FontWeight } from "react-native-svg";
4
-
5
- export type popnPyramidDataItem = {
6
- left: number;
7
- right: number;
8
- leftBarColor?: ColorValue;
9
- rightBarColor?: ColorValue;
10
- leftBarBorderColor?: ColorValue;
11
- rightBarBorderColor?: ColorValue;
12
- barBorderWidth?: number;
13
- leftBarBorderWidth?: number;
14
- rightBarBorderWidth?: number;
15
- barBorderRadius?: number;
16
- leftBarBorderRadius?: number;
17
- rightBarBorderRadius?: number;
18
-
19
- barLabelWidth?: number;
20
- barLabelFontSize?: number;
21
- barLabelColor?: ColorValue;
22
- barLabelFontStyle?: FontStyle;
23
- barLabelFontWeight?: FontWeight;
24
- barLabelFontFamily?: string;
25
-
26
- leftBarLabel?: string;
27
- leftBarLabelWidth?: number;
28
- leftBarLabelFontSize?: number;
29
- leftBarLabelColor?: ColorValue;
30
- leftBarLabelFontStyle?: FontStyle;
31
- leftBarLabelFontWeight?: FontWeight;
32
- leftBarLabelFontFamily?: string;
33
- leftBarLabelShift?: number;
34
-
35
- rightBarLabel?: string;
36
- rightBarLabelWidth?: number;
37
- rightBarLabelFontSize?: number;
38
- rightBarLabelColor?: ColorValue;
39
- rightBarLabelFontStyle?: FontStyle;
40
- rightBarLabelFontWeight?: FontWeight;
41
- rightBarLabelFontFamily?: string;
42
- rightBarLabelShift?: number;
43
-
44
- yAxisLabel?: string;
45
- midAxisLabel?: string;
46
- midAxisLabelFontSize?: number;
47
- midAxisLabelColor?: ColorValue;
48
- midAxisLabelFontStyle?: FontStyle;
49
- midAxisLabelFontWeight?: FontWeight;
50
- midAxisLabelFontFamily?: string;
51
-
52
- showSurplus?: boolean;
53
- showSurplusLeft?: boolean;
54
- showSurplusRight?: boolean;
55
- leftSurplusColor?: ColorValue;
56
- leftSurplusBorderColor?: ColorValue;
57
- rightSurplusColor?: ColorValue;
58
- rightSurplusBorderColor?: ColorValue;
59
- leftSurplusBorderWidth?: number;
60
- rightSurplusBorderWidth?: number;
1
+ import { type ColorValue } from 'react-native'
2
+ import { type RuleTypes } from '../utils/types'
3
+ import { type FontStyle, type FontWeight } from 'react-native-svg'
4
+
5
+ export interface popnPyramidDataItem {
6
+ left: number
7
+ right: number
8
+ leftBarColor?: ColorValue
9
+ rightBarColor?: ColorValue
10
+ leftBarBorderColor?: ColorValue
11
+ rightBarBorderColor?: ColorValue
12
+ barBorderWidth?: number
13
+ leftBarBorderWidth?: number
14
+ rightBarBorderWidth?: number
15
+ barBorderRadius?: number
16
+ leftBarBorderRadius?: number
17
+ rightBarBorderRadius?: number
18
+
19
+ barLabelWidth?: number
20
+ barLabelFontSize?: number
21
+ barLabelColor?: ColorValue
22
+ barLabelFontStyle?: FontStyle
23
+ barLabelFontWeight?: FontWeight
24
+ barLabelFontFamily?: string
25
+
26
+ leftBarLabel?: string
27
+ leftBarLabelWidth?: number
28
+ leftBarLabelFontSize?: number
29
+ leftBarLabelColor?: ColorValue
30
+ leftBarLabelFontStyle?: FontStyle
31
+ leftBarLabelFontWeight?: FontWeight
32
+ leftBarLabelFontFamily?: string
33
+ leftBarLabelShift?: number
34
+
35
+ rightBarLabel?: string
36
+ rightBarLabelWidth?: number
37
+ rightBarLabelFontSize?: number
38
+ rightBarLabelColor?: ColorValue
39
+ rightBarLabelFontStyle?: FontStyle
40
+ rightBarLabelFontWeight?: FontWeight
41
+ rightBarLabelFontFamily?: string
42
+ rightBarLabelShift?: number
43
+
44
+ yAxisLabel?: string
45
+ midAxisLabel?: string
46
+ midAxisLabelFontSize?: number
47
+ midAxisLabelColor?: ColorValue
48
+ midAxisLabelFontStyle?: FontStyle
49
+ midAxisLabelFontWeight?: FontWeight
50
+ midAxisLabelFontFamily?: string
51
+
52
+ showSurplus?: boolean
53
+ showSurplusLeft?: boolean
54
+ showSurplusRight?: boolean
55
+ leftSurplusColor?: ColorValue
56
+ leftSurplusBorderColor?: ColorValue
57
+ rightSurplusColor?: ColorValue
58
+ rightSurplusBorderColor?: ColorValue
59
+ leftSurplusBorderWidth?: number
60
+ rightSurplusBorderWidth?: number
61
61
  }
62
62
 
63
- export type RulesProps = {
64
- x1?: number;
65
- y1?: number;
66
- x2?: number;
67
- y2?: number;
68
- stroke?: ColorValue;
69
- strokeWidth?: number;
70
- strokeDasharray?: Array<number>;
63
+ export interface RulesProps {
64
+ x1?: number
65
+ y1?: number
66
+ x2?: number
67
+ y2?: number
68
+ stroke?: ColorValue
69
+ strokeWidth?: number
70
+ strokeDasharray?: number[]
71
71
  }
72
72
 
73
- export type PopulationPyramidPropsType = {
74
- height?: number;
75
- width?: number;
76
- data: Array<popnPyramidDataItem>;
77
- hideRules?: boolean;
78
- stepHeight?: number;
79
- verticalMarginBetweenBars?: number;
80
- hideYAxisText?: boolean;
81
- yAxisLabelWidth?: number;
82
- yAxisColor?: ColorValue;
83
- yAxisThickness?: number;
84
- yAxisStrokeDashArray?: Array<number>;
85
- xAxisColor?: ColorValue;
86
- xAxisThickness?: number;
87
- xAxisType?: RuleTypes;
88
- xAxisNoOfSections?: number;
89
- showXAxisIndices?: boolean;
90
- xAxisIndicesWidth?: number;
91
- xAxisIndicesHeight?: number;
92
- xAxisIndicesColor?: ColorValue;
93
- xAxisIndicesShiftY?: number;
94
- showXAxisLabelTexts?: boolean;
95
- xAxisLabelFontSize?: number;
96
- xAxisLabelColor?: ColorValue;
97
- xAxisLabelFontStyle?: FontStyle;
98
- xAxisLabelFontWeight?: FontWeight;
99
- xAxisLabelFontFamily?: string;
100
- xAxisLabelShiftX?: number;
101
- xAxisLabelShiftY?: number;
102
- xAxisRoundToDigits?: number;
103
- xAxisLabelPrefix?: string;
104
- xAxisLabelSuffix?: string;
105
- formatXAxisLabels?: (label: string) => string;
106
-
107
- showVerticalLines?: boolean;
108
- verticalLinesColor?: ColorValue;
109
- verticalLinesThickness?: number;
110
- verticalLinesType?: RuleTypes;
111
- verticalLinesStrokeDashArray?: Array<number>;
112
-
113
- noOfSections?: number;
114
- barsMapToYAxisSections?: boolean;
115
-
116
- showYAxisIndices?: boolean;
117
- yAxisIndicesWidth?: number;
118
- yAxisIndicesHeight?: number;
119
- yAxisIndicesColor?: ColorValue;
120
- yAxisLabelColor?: ColorValue;
121
- yAxisLabelFontSize?: number;
122
- yAxisLabelTextMarginRight?: number;
123
- yAxisLabelTexts?: Array<string>;
124
- yAxisLabelFontStyle?: FontStyle;
125
- yAxisLabelFontWeight?: FontWeight;
126
- yAxisLabelFontFamily?: string;
127
-
128
- showValuesAsBarLabels?: boolean;
129
-
130
-
131
- rulesThickness?: number;
132
- rulesColor?: ColorValue;
133
- rulesType?: RuleTypes;
134
- dashWidth?: number;
135
- dashGap?: number;
136
-
137
- showMidAxis?: boolean;
138
- midAxisThickness?: number;
139
- midAxisLabelWidth?: number;
140
- midAxisColor?: ColorValue;
141
- midAxisLeftColor?: ColorValue;
142
- midAxisRightColor?: ColorValue;
143
- midAxisStrokeDashArray?: Array<number>;
144
- midAxisLabelFontSize?: number;
145
- midAxisLabelColor?: ColorValue;
146
- midAxisLabelFontStyle?: FontStyle;
147
- midAxisLabelFontWeight?: FontWeight;
148
- midAxisLabelFontFamily?: string;
149
-
150
- barLabelWidth?: number;
151
- barLabelFontSize?: number;
152
- barLabelColor?: ColorValue;
153
- barLabelFontStyle?: FontStyle;
154
- barLabelFontWeight?: FontWeight;
155
- barLabelFontFamily?: string;
156
-
157
- leftBarLabelWidth?: number;
158
- leftBarLabelFontSize?: number;
159
- leftBarLabelColor?: ColorValue;
160
- leftBarLabelFontStyle?: FontStyle;
161
- leftBarLabelFontWeight?: FontWeight;
162
- leftBarLabelFontFamily?: string;
163
- leftBarLabelShift?: number;
164
- leftBarLabelPrefix?: string;
165
- leftBarLabelSuffix?: string;
166
-
167
- rightBarLabelWidth?: number;
168
- rightBarLabelFontSize?: number;
169
- rightBarLabelColor?: ColorValue;
170
- rightBarLabelFontStyle?: FontStyle;
171
- rightBarLabelFontWeight?: FontWeight;
172
- rightBarLabelFontFamily?: string;
173
- rightBarLabelShift?: number;
174
- rightBarLabelPrefix?: string;
175
- rightBarLabelSuffix?: string;
176
- formatBarLabels?: (label: string) => string;
177
-
178
- leftBarColor?: ColorValue;
179
- rightBarColor?: ColorValue;
180
- leftBarBorderColor?: ColorValue;
181
- rightBarBorderColor?: ColorValue;
182
- barBorderWidth?: number;
183
- leftBarBorderWidth?: number;
184
- rightBarBorderWidth?: number;
185
- barBorderRadius?: number;
186
- leftBarBorderRadius?: number;
187
- rightBarBorderRadius?: number;
188
- allCornersRounded?: boolean;
189
-
190
- showSurplus?: boolean;
191
- showSurplusLeft?: boolean;
192
- showSurplusRight?: boolean;
193
- leftSurplusColor?: ColorValue;
194
- leftSurplusBorderColor?: ColorValue;
195
- rightSurplusColor?: ColorValue;
196
- rightSurplusBorderColor?: ColorValue;
197
- leftSurplusBorderWidth?: number;
198
- rightSurplusBorderWidth?: number;
199
-
200
- }
73
+ export interface PopulationPyramidPropsType {
74
+ height?: number
75
+ width?: number
76
+ data: popnPyramidDataItem[]
77
+ hideRules?: boolean
78
+ stepHeight?: number
79
+ verticalMarginBetweenBars?: number
80
+ hideYAxisText?: boolean
81
+ yAxisLabelWidth?: number
82
+ yAxisColor?: ColorValue
83
+ yAxisThickness?: number
84
+ yAxisStrokeDashArray?: number[]
85
+ xAxisColor?: ColorValue
86
+ xAxisThickness?: number
87
+ xAxisType?: RuleTypes
88
+ xAxisNoOfSections?: number
89
+ showXAxisIndices?: boolean
90
+ xAxisIndicesWidth?: number
91
+ xAxisIndicesHeight?: number
92
+ xAxisIndicesColor?: ColorValue
93
+ xAxisIndicesShiftY?: number
94
+ showXAxisLabelTexts?: boolean
95
+ xAxisLabelFontSize?: number
96
+ xAxisLabelColor?: ColorValue
97
+ xAxisLabelFontStyle?: FontStyle
98
+ xAxisLabelFontWeight?: FontWeight
99
+ xAxisLabelFontFamily?: string
100
+ xAxisLabelShiftX?: number
101
+ xAxisLabelShiftY?: number
102
+ xAxisRoundToDigits?: number
103
+ xAxisLabelPrefix?: string
104
+ xAxisLabelSuffix?: string
105
+ formatXAxisLabels?: (label: string) => string
106
+
107
+ showVerticalLines?: boolean
108
+ verticalLinesColor?: ColorValue
109
+ verticalLinesThickness?: number
110
+ verticalLinesType?: RuleTypes
111
+ verticalLinesStrokeDashArray?: number[]
112
+
113
+ noOfSections?: number
114
+ barsMapToYAxisSections?: boolean
115
+
116
+ showYAxisIndices?: boolean
117
+ yAxisIndicesWidth?: number
118
+ yAxisIndicesHeight?: number
119
+ yAxisIndicesColor?: ColorValue
120
+ yAxisLabelColor?: ColorValue
121
+ yAxisLabelFontSize?: number
122
+ yAxisLabelTextMarginRight?: number
123
+ yAxisLabelTexts?: string[]
124
+ yAxisLabelFontStyle?: FontStyle
125
+ yAxisLabelFontWeight?: FontWeight
126
+ yAxisLabelFontFamily?: string
127
+
128
+ showValuesAsBarLabels?: boolean
129
+
130
+ rulesThickness?: number
131
+ rulesColor?: ColorValue
132
+ rulesType?: RuleTypes
133
+ dashWidth?: number
134
+ dashGap?: number
135
+
136
+ showMidAxis?: boolean
137
+ midAxisThickness?: number
138
+ midAxisLabelWidth?: number
139
+ midAxisColor?: ColorValue
140
+ midAxisLeftColor?: ColorValue
141
+ midAxisRightColor?: ColorValue
142
+ midAxisStrokeDashArray?: number[]
143
+ midAxisLabelFontSize?: number
144
+ midAxisLabelColor?: ColorValue
145
+ midAxisLabelFontStyle?: FontStyle
146
+ midAxisLabelFontWeight?: FontWeight
147
+ midAxisLabelFontFamily?: string
148
+
149
+ barLabelWidth?: number
150
+ barLabelFontSize?: number
151
+ barLabelColor?: ColorValue
152
+ barLabelFontStyle?: FontStyle
153
+ barLabelFontWeight?: FontWeight
154
+ barLabelFontFamily?: string
155
+
156
+ leftBarLabelWidth?: number
157
+ leftBarLabelFontSize?: number
158
+ leftBarLabelColor?: ColorValue
159
+ leftBarLabelFontStyle?: FontStyle
160
+ leftBarLabelFontWeight?: FontWeight
161
+ leftBarLabelFontFamily?: string
162
+ leftBarLabelShift?: number
163
+ leftBarLabelPrefix?: string
164
+ leftBarLabelSuffix?: string
165
+
166
+ rightBarLabelWidth?: number
167
+ rightBarLabelFontSize?: number
168
+ rightBarLabelColor?: ColorValue
169
+ rightBarLabelFontStyle?: FontStyle
170
+ rightBarLabelFontWeight?: FontWeight
171
+ rightBarLabelFontFamily?: string
172
+ rightBarLabelShift?: number
173
+ rightBarLabelPrefix?: string
174
+ rightBarLabelSuffix?: string
175
+ formatBarLabels?: (label: string) => string
176
+
177
+ leftBarColor?: ColorValue
178
+ rightBarColor?: ColorValue
179
+ leftBarBorderColor?: ColorValue
180
+ rightBarBorderColor?: ColorValue
181
+ barBorderWidth?: number
182
+ leftBarBorderWidth?: number
183
+ rightBarBorderWidth?: number
184
+ barBorderRadius?: number
185
+ leftBarBorderRadius?: number
186
+ rightBarBorderRadius?: number
187
+ allCornersRounded?: boolean
188
+
189
+ showSurplus?: boolean
190
+ showSurplusLeft?: boolean
191
+ showSurplusRight?: boolean
192
+ leftSurplusColor?: ColorValue
193
+ leftSurplusBorderColor?: ColorValue
194
+ rightSurplusColor?: ColorValue
195
+ rightSurplusBorderColor?: ColorValue
196
+ leftSurplusBorderWidth?: number
197
+ rightSurplusBorderWidth?: number
198
+
199
+ }
@@ -1,18 +1,18 @@
1
- import { useState } from "react";
2
- import { animatedBarPropTypes } from "../../BarChart/types";
3
- import { BarDefaults } from "../../utils/constants";
4
- import { getBarSideColor, getBarTopColor } from "../../utils";
1
+ import { useState } from 'react'
2
+ import { type animatedBarPropTypes } from '../../BarChart/types'
3
+ import { BarDefaults } from '../../utils/constants'
4
+ import { getBarSideColor, getBarTopColor } from '../../utils'
5
5
 
6
6
  export const useAnimatedThreeDBar = (props: animatedBarPropTypes) => {
7
7
  const { focusBarOnPress, index, selectedIndex, focusedBarConfig, item } =
8
- props;
9
- const isFocused = focusBarOnPress && index === selectedIndex;
10
- const localFrontColor = props.frontColor || BarDefaults.threeDBarFrontColor;
8
+ props
9
+ const isFocused = focusBarOnPress && index === selectedIndex
10
+ const localFrontColor = props.frontColor || BarDefaults.threeDBarFrontColor
11
11
  const localGradientColor =
12
- props.gradientColor || BarDefaults.threeDBarGradientColor;
13
- const localSideColor = props.sideColor || BarDefaults.threeDBarSideColor;
14
- const localTopColor = props.topColor || BarDefaults.threeDBarTopColor;
15
- const localOpacity = props.opacity || 1;
12
+ props.gradientColor || BarDefaults.threeDBarGradientColor
13
+ const localSideColor = props.sideColor || BarDefaults.threeDBarSideColor
14
+ const localTopColor = props.topColor || BarDefaults.threeDBarTopColor
15
+ const localOpacity = props.opacity || 1
16
16
  const {
17
17
  isAnimated,
18
18
  showGradient = props.showGradient || false,
@@ -30,16 +30,16 @@ export const useAnimatedThreeDBar = (props: animatedBarPropTypes) => {
30
30
  ),
31
31
  topColor = getBarTopColor(
32
32
  isFocused,
33
- focusBarOnPress,
33
+ focusedBarConfig,
34
34
  item.topColor,
35
35
  localTopColor
36
36
  ),
37
37
  opacity = isFocused
38
38
  ? focusedBarConfig?.opacity ?? localOpacity
39
- : localOpacity,
40
- } = props;
39
+ : localOpacity
40
+ } = props
41
41
 
42
- const [initialRender, setInitialRender] = useState(isAnimated);
42
+ const [initialRender, setInitialRender] = useState(isAnimated)
43
43
 
44
44
  return {
45
45
  showGradient,
@@ -55,6 +55,6 @@ export const useAnimatedThreeDBar = (props: animatedBarPropTypes) => {
55
55
  : BarDefaults.threeDBarTopColor,
56
56
  opacity,
57
57
  initialRender,
58
- setInitialRender,
59
- };
60
- };
58
+ setInitialRender
59
+ }
60
+ }