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.
- package/index.ts +6 -1
- package/package.json +12 -4
- package/src/BarChart/Animated2DWithGradient.ts +80 -46
- package/src/BarChart/RenderStackBars.ts +41 -41
- package/src/BarChart/index.ts +293 -275
- package/src/BarChart/types.ts +574 -572
- package/src/LineChart/LineChartBiColor.ts +272 -265
- package/src/LineChart/index.ts +750 -766
- package/src/LineChart/types.ts +592 -584
- package/src/PieChart/index.ts +82 -51
- package/src/PieChart/main.ts +71 -71
- package/src/PieChart/types.ts +83 -83
- package/src/PopulationPyramid/index.ts +39 -39
- package/src/PopulationPyramid/types.ts +195 -196
- package/src/components/AnimatedThreeDBar/{index.tsx → index.ts} +18 -18
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.ts +97 -93
- package/src/components/BarAndLineChartsWrapper/index.ts +94 -90
- package/src/components/common/StripAndLabel.ts +28 -20
- package/src/components/common/types.ts +31 -0
- package/src/utils/constants.ts +90 -90
- package/src/utils/{index.tsx → index.ts} +720 -640
- package/src/utils/types.ts +352 -351
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AxesAndRulesDefaults,
|
|
3
3
|
populationDefaults,
|
|
4
|
-
ruleTypes
|
|
5
|
-
} from
|
|
6
|
-
import { PopulationPyramidPropsType, RulesProps } from
|
|
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
|
|
2
|
-
import { RuleTypes } from
|
|
3
|
-
import { FontStyle, FontWeight } from
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
2
|
-
import { animatedBarPropTypes } from
|
|
3
|
-
import { BarDefaults } from
|
|
4
|
-
import { getBarSideColor, getBarTopColor } from
|
|
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
|
-
|
|
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
|
+
}
|