gifted-charts-core 0.0.21 → 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/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 -637
- package/src/utils/types.ts +352 -351
package/src/BarChart/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
type lineConfigType,
|
|
4
|
+
type BarChartPropsType,
|
|
5
|
+
type barDataItem,
|
|
6
|
+
type stackDataItem
|
|
7
|
+
} from './types'
|
|
3
8
|
import {
|
|
4
9
|
getArrowPoints,
|
|
5
10
|
getAxesAndRulesProps,
|
|
@@ -11,164 +16,170 @@ import {
|
|
|
11
16
|
getXForLineInBar,
|
|
12
17
|
getYForLineInBar,
|
|
13
18
|
maxAndMinUtil,
|
|
14
|
-
svgPath
|
|
15
|
-
} from
|
|
19
|
+
svgPath
|
|
20
|
+
} from '../utils'
|
|
16
21
|
import {
|
|
17
22
|
AxesAndRulesDefaults,
|
|
18
23
|
BarDefaults,
|
|
19
24
|
chartTypes,
|
|
20
25
|
defaultLineConfig,
|
|
21
|
-
defaultPointerConfig
|
|
22
|
-
} from
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
defaultPointerConfig
|
|
27
|
+
} from '../utils/constants'
|
|
28
|
+
import {
|
|
29
|
+
type BarAndLineChartsWrapperTypes,
|
|
30
|
+
type secondaryYAxisType
|
|
31
|
+
} from '../utils/types'
|
|
32
|
+
import { type Animated } from 'react-native'
|
|
33
|
+
|
|
34
|
+
export interface extendedBarChartPropsType extends BarChartPropsType {
|
|
35
|
+
heightValue: Animated.Value
|
|
36
|
+
widthValue: Animated.Value
|
|
37
|
+
opacValue: Animated.Value
|
|
38
|
+
verticalLinesUptoDataPoint?: boolean
|
|
39
|
+
secondaryYAxis?: secondaryYAxisType
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
32
|
-
const { heightValue, widthValue, opacValue } = props
|
|
33
|
-
const [points, setPoints] = useState(
|
|
34
|
-
const [points2, setPoints2] = useState(
|
|
35
|
-
const [arrowPoints, setArrowPoints] = useState(
|
|
36
|
-
const [selectedIndex, setSelectedIndex] = useState(-1)
|
|
37
|
-
const showLine = props.showLine
|
|
38
|
-
const spacing = props.spacing ?? BarDefaults.spacing
|
|
39
|
-
const initialSpacing = props.initialSpacing ?? spacing
|
|
40
|
-
const endSpacing = props.endSpacing ?? spacing
|
|
43
|
+
const { heightValue, widthValue, opacValue } = props
|
|
44
|
+
const [points, setPoints] = useState('')
|
|
45
|
+
const [points2, setPoints2] = useState('')
|
|
46
|
+
const [arrowPoints, setArrowPoints] = useState('')
|
|
47
|
+
const [selectedIndex, setSelectedIndex] = useState(-1)
|
|
48
|
+
const showLine = props.showLine ?? BarDefaults.showLine
|
|
49
|
+
const spacing = props.spacing ?? BarDefaults.spacing
|
|
50
|
+
const initialSpacing = props.initialSpacing ?? spacing
|
|
51
|
+
const endSpacing = props.endSpacing ?? spacing
|
|
41
52
|
const showFractionalValues =
|
|
42
|
-
props.showFractionalValues
|
|
53
|
+
props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues
|
|
43
54
|
|
|
44
|
-
const horizontal = props.horizontal ?? BarDefaults.horizontal
|
|
45
|
-
const rtl = props.rtl ?? BarDefaults.rtl
|
|
46
|
-
const yAxisAtTop = props.yAxisAtTop ?? BarDefaults.yAxisAtTop
|
|
47
|
-
const intactTopLabel = props.intactTopLabel ?? BarDefaults.intactTopLabel
|
|
55
|
+
const horizontal = props.horizontal ?? BarDefaults.horizontal
|
|
56
|
+
const rtl = props.rtl ?? BarDefaults.rtl
|
|
57
|
+
const yAxisAtTop = props.yAxisAtTop ?? BarDefaults.yAxisAtTop
|
|
58
|
+
const intactTopLabel = props.intactTopLabel ?? BarDefaults.intactTopLabel
|
|
48
59
|
|
|
49
|
-
const heightFromProps = horizontal ? props.width : props.height
|
|
50
|
-
const widthFromProps = horizontal ? props.height : props.width
|
|
60
|
+
const heightFromProps = horizontal ? props.width : props.height
|
|
61
|
+
const widthFromProps = horizontal ? props.height : props.width
|
|
51
62
|
|
|
52
|
-
const isAnimated = props.isAnimated ?? BarDefaults.isAnimated
|
|
63
|
+
const isAnimated = props.isAnimated ?? BarDefaults.isAnimated
|
|
53
64
|
const animationDuration =
|
|
54
|
-
props.animationDuration ?? BarDefaults.animationDuration
|
|
65
|
+
props.animationDuration ?? BarDefaults.animationDuration
|
|
55
66
|
|
|
56
67
|
const data = useMemo(() => {
|
|
57
68
|
if (!props.data) {
|
|
58
|
-
return []
|
|
69
|
+
return []
|
|
59
70
|
}
|
|
60
71
|
if (props.yAxisOffset) {
|
|
61
72
|
return props.data.map((item) => {
|
|
62
|
-
item.value = item.value - (props.yAxisOffset ?? 0)
|
|
63
|
-
return item
|
|
64
|
-
})
|
|
73
|
+
item.value = (item.value ?? 0) - (props.yAxisOffset ?? 0)
|
|
74
|
+
return item
|
|
75
|
+
})
|
|
65
76
|
}
|
|
66
|
-
return props.data
|
|
67
|
-
}, [props.yAxisOffset, props.data])
|
|
77
|
+
return props.data
|
|
78
|
+
}, [props.yAxisOffset, props.data])
|
|
68
79
|
|
|
69
80
|
const secondaryData = getSecondaryDataWithOffsetIncluded(
|
|
70
81
|
props.secondaryData,
|
|
71
82
|
props.secondaryYAxis
|
|
72
|
-
)
|
|
83
|
+
)
|
|
73
84
|
|
|
74
85
|
const lineData = useMemo(() => {
|
|
75
86
|
if (!props.lineData) {
|
|
76
|
-
return props.stackData ?? data
|
|
87
|
+
return props.stackData ?? data
|
|
77
88
|
}
|
|
78
89
|
if (props.yAxisOffset) {
|
|
79
|
-
return props.lineData.map((item) => {
|
|
80
|
-
item
|
|
81
|
-
|
|
82
|
-
})
|
|
90
|
+
return props.lineData.map((item) => ({
|
|
91
|
+
...item,
|
|
92
|
+
value: (item.value ?? 0) - (props.yAxisOffset ?? 0)
|
|
93
|
+
}))
|
|
83
94
|
}
|
|
84
|
-
return props.lineData
|
|
85
|
-
}, [props.yAxisOffset, props.lineData, data, props.stackData])
|
|
95
|
+
return props.lineData
|
|
96
|
+
}, [props.yAxisOffset, props.lineData, data, props.stackData])
|
|
86
97
|
|
|
87
|
-
const lineData2 = props.lineData2
|
|
98
|
+
const lineData2 = props.lineData2
|
|
88
99
|
|
|
89
|
-
const lineBehindBars = props.lineBehindBars
|
|
100
|
+
const lineBehindBars = props.lineBehindBars ?? BarDefaults.lineBehindBars
|
|
90
101
|
|
|
91
|
-
defaultLineConfig.initialSpacing = initialSpacing
|
|
92
|
-
defaultLineConfig.endIndex = lineData.length - 1
|
|
93
|
-
defaultLineConfig.animationDuration = animationDuration
|
|
102
|
+
defaultLineConfig.initialSpacing = initialSpacing
|
|
103
|
+
defaultLineConfig.endIndex = lineData.length - 1
|
|
104
|
+
defaultLineConfig.animationDuration = animationDuration
|
|
94
105
|
|
|
95
|
-
const lineConfig = props.lineConfig
|
|
106
|
+
const lineConfig: lineConfigType = props.lineConfig
|
|
96
107
|
? getLineConfigForBarChart(props.lineConfig, initialSpacing)
|
|
97
|
-
: defaultLineConfig
|
|
98
|
-
const lineConfig2 = props.lineConfig2
|
|
108
|
+
: defaultLineConfig
|
|
109
|
+
const lineConfig2: lineConfigType = props.lineConfig2
|
|
99
110
|
? getLineConfigForBarChart(props.lineConfig2, initialSpacing)
|
|
100
|
-
: defaultLineConfig
|
|
111
|
+
: defaultLineConfig
|
|
101
112
|
const noOfSections = getNoOfSections(
|
|
102
113
|
props.noOfSections,
|
|
103
114
|
props.maxValue,
|
|
104
115
|
props.stepValue
|
|
105
|
-
)
|
|
116
|
+
)
|
|
106
117
|
const containerHeight =
|
|
107
118
|
heightFromProps ??
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
const horizSections = [{ value:
|
|
111
|
-
const stepHeight = props.stepHeight ?? containerHeight / noOfSections
|
|
112
|
-
const labelWidth = props.labelWidth ?? AxesAndRulesDefaults.labelWidth
|
|
113
|
-
const scrollToEnd = props.scrollToEnd ?? BarDefaults.scrollToEnd
|
|
114
|
-
const scrollAnimation = props.scrollAnimation ?? BarDefaults.scrollAnimation
|
|
119
|
+
(props.stepHeight ?? 0) * noOfSections ??
|
|
120
|
+
AxesAndRulesDefaults.containerHeight
|
|
121
|
+
const horizSections = [{ value: '0' }]
|
|
122
|
+
const stepHeight = props.stepHeight ?? containerHeight / noOfSections
|
|
123
|
+
const labelWidth = props.labelWidth ?? AxesAndRulesDefaults.labelWidth
|
|
124
|
+
const scrollToEnd = props.scrollToEnd ?? BarDefaults.scrollToEnd
|
|
125
|
+
const scrollAnimation = props.scrollAnimation ?? BarDefaults.scrollAnimation
|
|
115
126
|
const scrollEventThrottle =
|
|
116
|
-
props.scrollEventThrottle ?? BarDefaults.scrollEventThrottle
|
|
127
|
+
props.scrollEventThrottle ?? BarDefaults.scrollEventThrottle
|
|
117
128
|
const labelsExtraHeight =
|
|
118
|
-
props.labelsExtraHeight ?? AxesAndRulesDefaults.labelsExtraHeight
|
|
129
|
+
props.labelsExtraHeight ?? AxesAndRulesDefaults.labelsExtraHeight
|
|
119
130
|
|
|
120
|
-
let totalWidth = initialSpacing
|
|
121
|
-
let maxItem = 0
|
|
122
|
-
|
|
131
|
+
let totalWidth = initialSpacing
|
|
132
|
+
let maxItem = 0
|
|
133
|
+
let minItem = 0
|
|
123
134
|
if (props.stackData) {
|
|
124
135
|
props.stackData.forEach((stackItem) => {
|
|
125
136
|
const stackSumMax = stackItem.stacks.reduce(
|
|
126
137
|
(acc, stack) => acc + (stack.value >= 0 ? stack.value : 0),
|
|
127
138
|
0
|
|
128
|
-
)
|
|
139
|
+
)
|
|
129
140
|
const stackSumMin = stackItem.stacks.reduce(
|
|
130
141
|
(acc, stack) => acc + (stack.value < 0 ? stack.value : 0),
|
|
131
142
|
0
|
|
132
|
-
)
|
|
143
|
+
)
|
|
133
144
|
|
|
134
145
|
if (stackSumMax > maxItem) {
|
|
135
|
-
maxItem = stackSumMax
|
|
146
|
+
maxItem = stackSumMax
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
if (stackSumMin < minItem) {
|
|
139
|
-
minItem = stackSumMin
|
|
150
|
+
minItem = stackSumMin
|
|
140
151
|
}
|
|
141
152
|
totalWidth +=
|
|
142
153
|
(stackItem.stacks[0].barWidth ??
|
|
143
154
|
props.barWidth ??
|
|
144
|
-
BarDefaults.barWidth) + spacing
|
|
145
|
-
})
|
|
155
|
+
BarDefaults.barWidth) + spacing
|
|
156
|
+
})
|
|
146
157
|
} else {
|
|
147
158
|
data.forEach((item: barDataItem) => {
|
|
148
159
|
if (item.value > maxItem) {
|
|
149
|
-
maxItem = item.value
|
|
160
|
+
maxItem = item.value
|
|
150
161
|
}
|
|
151
162
|
if (item.value < minItem) {
|
|
152
|
-
minItem = item.value
|
|
163
|
+
minItem = item.value
|
|
153
164
|
}
|
|
154
165
|
totalWidth +=
|
|
155
166
|
(item.barWidth ?? props.barWidth ?? BarDefaults.barWidth) +
|
|
156
|
-
(item.spacing ?? spacing)
|
|
157
|
-
})
|
|
167
|
+
(item.spacing ?? spacing)
|
|
168
|
+
})
|
|
158
169
|
}
|
|
159
170
|
|
|
160
|
-
let secondaryMaxItem = 0
|
|
161
|
-
|
|
171
|
+
let secondaryMaxItem = 0
|
|
172
|
+
let secondaryMinItem = 0
|
|
162
173
|
|
|
163
174
|
if (lineConfig.isSecondary) {
|
|
164
|
-
lineData.forEach((item
|
|
165
|
-
if (item.value > secondaryMaxItem) {
|
|
166
|
-
secondaryMaxItem = item.value
|
|
175
|
+
lineData.forEach((item) => {
|
|
176
|
+
if ((item.value ?? 0) > secondaryMaxItem) {
|
|
177
|
+
secondaryMaxItem = item.value ?? 0
|
|
167
178
|
}
|
|
168
|
-
if (item.value < secondaryMinItem) {
|
|
169
|
-
secondaryMinItem = item.value
|
|
179
|
+
if ((item.value ?? 0) < secondaryMinItem) {
|
|
180
|
+
secondaryMinItem = item.value ?? 0
|
|
170
181
|
}
|
|
171
|
-
})
|
|
182
|
+
})
|
|
172
183
|
}
|
|
173
184
|
|
|
174
185
|
const maxAndMin = maxAndMinUtil(
|
|
@@ -176,184 +187,179 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
176
187
|
minItem,
|
|
177
188
|
props.roundToDigits,
|
|
178
189
|
props.showFractionalValues
|
|
179
|
-
)
|
|
190
|
+
)
|
|
180
191
|
|
|
181
192
|
const secondaryMaxAndMin = maxAndMinUtil(
|
|
182
193
|
secondaryMaxItem,
|
|
183
194
|
secondaryMinItem,
|
|
184
195
|
props.roundToDigits,
|
|
185
196
|
props.showFractionalValues
|
|
186
|
-
)
|
|
197
|
+
)
|
|
187
198
|
|
|
188
199
|
const maxValue = getMaxValue(
|
|
189
200
|
props.maxValue,
|
|
190
201
|
props.stepValue,
|
|
191
202
|
noOfSections,
|
|
192
203
|
maxAndMin.maxItem
|
|
193
|
-
)
|
|
204
|
+
)
|
|
194
205
|
const secondaryMaxValue = lineConfig.isSecondary
|
|
195
206
|
? secondaryMaxAndMin.maxItem
|
|
196
|
-
: maxValue
|
|
197
|
-
const mostNegativeValue = props.mostNegativeValue ?? maxAndMin.minItem
|
|
207
|
+
: maxValue
|
|
208
|
+
const mostNegativeValue = props.mostNegativeValue ?? maxAndMin.minItem
|
|
198
209
|
|
|
199
|
-
const stepValue = props.stepValue ?? maxValue / noOfSections
|
|
210
|
+
const stepValue = props.stepValue ?? maxValue / noOfSections
|
|
200
211
|
const noOfSectionsBelowXAxis =
|
|
201
|
-
props.noOfSectionsBelowXAxis ?? -mostNegativeValue / stepValue
|
|
212
|
+
props.noOfSectionsBelowXAxis ?? -mostNegativeValue / stepValue
|
|
202
213
|
const showScrollIndicator =
|
|
203
|
-
props.showScrollIndicator ?? BarDefaults.showScrollIndicator
|
|
204
|
-
const side = props.side ?? BarDefaults.side
|
|
205
|
-
const rotateLabel = props.rotateLabel ?? AxesAndRulesDefaults.rotateLabel
|
|
206
|
-
const opacity = props.opacity ?? BarDefaults.opacity
|
|
207
|
-
const isThreeD = props.isThreeD ?? BarDefaults.isThreeD
|
|
214
|
+
props.showScrollIndicator ?? BarDefaults.showScrollIndicator
|
|
215
|
+
const side = props.side ?? BarDefaults.side
|
|
216
|
+
const rotateLabel = props.rotateLabel ?? AxesAndRulesDefaults.rotateLabel
|
|
217
|
+
const opacity = props.opacity ?? BarDefaults.opacity
|
|
218
|
+
const isThreeD = props.isThreeD ?? BarDefaults.isThreeD
|
|
208
219
|
|
|
209
220
|
const showXAxisIndices =
|
|
210
|
-
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
|
|
221
|
+
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
|
|
211
222
|
const xAxisIndicesHeight =
|
|
212
|
-
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
|
|
223
|
+
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
|
|
213
224
|
const xAxisIndicesWidth =
|
|
214
|
-
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
|
|
225
|
+
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
|
|
215
226
|
const xAxisIndicesColor =
|
|
216
|
-
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
|
|
227
|
+
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
|
|
217
228
|
|
|
218
229
|
const xAxisThickness =
|
|
219
|
-
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
|
|
230
|
+
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
|
|
220
231
|
|
|
221
232
|
const xAxisTextNumberOfLines =
|
|
222
|
-
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
|
|
233
|
+
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
|
|
223
234
|
const xAxisLabelsVerticalShift =
|
|
224
235
|
props.xAxisLabelsVerticalShift ??
|
|
225
|
-
AxesAndRulesDefaults.xAxisLabelsVerticalShift
|
|
226
|
-
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
236
|
+
AxesAndRulesDefaults.xAxisLabelsVerticalShift
|
|
237
|
+
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
227
238
|
const yAxisLabelWidth =
|
|
228
239
|
props.yAxisLabelWidth ??
|
|
229
240
|
(props.hideYAxisText
|
|
230
241
|
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
231
|
-
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
242
|
+
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
232
243
|
|
|
233
|
-
const autoShiftLabels = props.autoShiftLabels ?? false
|
|
244
|
+
const autoShiftLabels = props.autoShiftLabels ?? false
|
|
234
245
|
|
|
235
|
-
const barWidth = props.barWidth
|
|
236
|
-
const barBorderColor = props.barBorderColor ?? BarDefaults.barBorderColor
|
|
246
|
+
const barWidth = props.barWidth ?? BarDefaults.barWidth
|
|
247
|
+
const barBorderColor = props.barBorderColor ?? BarDefaults.barBorderColor
|
|
237
248
|
|
|
238
249
|
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
239
250
|
containerHeight,
|
|
240
251
|
0
|
|
241
|
-
)
|
|
252
|
+
)
|
|
242
253
|
|
|
243
254
|
const containerHeightIncludingBelowXAxis =
|
|
244
|
-
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight
|
|
245
|
-
|
|
246
|
-
const [pointerIndex, setPointerIndex] = useState(-1)
|
|
247
|
-
const [pointerX, setPointerX] = useState(0)
|
|
248
|
-
const [pointerY, setPointerY] = useState(0)
|
|
249
|
-
const [pointerItem, setPointerItem] = useState(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height;
|
|
259
|
-
const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width;
|
|
260
|
-
const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius;
|
|
255
|
+
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight
|
|
256
|
+
|
|
257
|
+
const [pointerIndex, setPointerIndex] = useState(-1)
|
|
258
|
+
const [pointerX, setPointerX] = useState(0)
|
|
259
|
+
const [pointerY, setPointerY] = useState(0)
|
|
260
|
+
const [pointerItem, setPointerItem] = useState<barDataItem | stackDataItem>()
|
|
261
|
+
const [responderStartTime, setResponderStartTime] = useState(0)
|
|
262
|
+
const [responderActive, setResponderActive] = useState(false)
|
|
263
|
+
|
|
264
|
+
const pointerConfig = props.pointerConfig
|
|
265
|
+
const getPointerProps = props.getPointerProps ?? null
|
|
266
|
+
const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height
|
|
267
|
+
const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width
|
|
268
|
+
const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius
|
|
261
269
|
const pointerColor =
|
|
262
|
-
pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor
|
|
270
|
+
pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor
|
|
263
271
|
const pointerComponent =
|
|
264
|
-
pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent
|
|
272
|
+
pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent
|
|
265
273
|
|
|
266
274
|
const showPointerStrip =
|
|
267
275
|
pointerConfig?.showPointerStrip === false
|
|
268
276
|
? false
|
|
269
|
-
: defaultPointerConfig.showPointerStrip
|
|
277
|
+
: defaultPointerConfig.showPointerStrip
|
|
270
278
|
const pointerStripHeight =
|
|
271
279
|
pointerConfig?.pointerStripHeight ??
|
|
272
|
-
defaultPointerConfig.pointerStripHeight
|
|
280
|
+
defaultPointerConfig.pointerStripHeight
|
|
273
281
|
const pointerStripWidth =
|
|
274
|
-
pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth
|
|
282
|
+
pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth
|
|
275
283
|
const pointerStripColor =
|
|
276
|
-
pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor
|
|
284
|
+
pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor
|
|
277
285
|
const pointerStripUptoDataPoint =
|
|
278
286
|
pointerConfig?.pointerStripUptoDataPoint ??
|
|
279
|
-
defaultPointerConfig.pointerStripUptoDataPoint
|
|
287
|
+
defaultPointerConfig.pointerStripUptoDataPoint
|
|
280
288
|
const pointerLabelComponent =
|
|
281
289
|
pointerConfig?.pointerLabelComponent ??
|
|
282
|
-
defaultPointerConfig.pointerLabelComponent
|
|
290
|
+
defaultPointerConfig.pointerLabelComponent
|
|
283
291
|
const stripOverPointer =
|
|
284
|
-
pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer
|
|
292
|
+
pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer
|
|
285
293
|
const shiftPointerLabelX =
|
|
286
294
|
pointerConfig?.shiftPointerLabelX ??
|
|
287
|
-
defaultPointerConfig.shiftPointerLabelX
|
|
295
|
+
defaultPointerConfig.shiftPointerLabelX
|
|
288
296
|
const shiftPointerLabelY =
|
|
289
297
|
pointerConfig?.shiftPointerLabelY ??
|
|
290
|
-
defaultPointerConfig.shiftPointerLabelY
|
|
298
|
+
defaultPointerConfig.shiftPointerLabelY
|
|
291
299
|
const pointerLabelWidth =
|
|
292
|
-
pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth
|
|
300
|
+
pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth
|
|
293
301
|
const pointerLabelHeight =
|
|
294
302
|
pointerConfig?.pointerLabelHeight ??
|
|
295
|
-
defaultPointerConfig.pointerLabelHeight
|
|
303
|
+
defaultPointerConfig.pointerLabelHeight
|
|
296
304
|
const autoAdjustPointerLabelPosition =
|
|
297
305
|
pointerConfig?.autoAdjustPointerLabelPosition ??
|
|
298
|
-
defaultPointerConfig.autoAdjustPointerLabelPosition
|
|
306
|
+
defaultPointerConfig.autoAdjustPointerLabelPosition
|
|
299
307
|
const pointerVanishDelay =
|
|
300
308
|
pointerConfig?.pointerVanishDelay ??
|
|
301
|
-
defaultPointerConfig.pointerVanishDelay
|
|
309
|
+
defaultPointerConfig.pointerVanishDelay
|
|
302
310
|
const activatePointersOnLongPress =
|
|
303
311
|
pointerConfig?.activatePointersOnLongPress ??
|
|
304
|
-
defaultPointerConfig.activatePointersOnLongPress
|
|
312
|
+
defaultPointerConfig.activatePointersOnLongPress
|
|
305
313
|
const activatePointersDelay =
|
|
306
314
|
pointerConfig?.activatePointersDelay ??
|
|
307
|
-
defaultPointerConfig.activatePointersDelay
|
|
315
|
+
defaultPointerConfig.activatePointersDelay
|
|
308
316
|
const initialPointerIndex =
|
|
309
317
|
pointerConfig?.initialPointerIndex ??
|
|
310
|
-
defaultPointerConfig.initialPointerIndex
|
|
318
|
+
defaultPointerConfig.initialPointerIndex
|
|
311
319
|
const initialPointerAppearDelay =
|
|
312
320
|
pointerConfig?.initialPointerAppearDelay ??
|
|
313
321
|
(isAnimated
|
|
314
322
|
? animationDuration
|
|
315
|
-
: defaultPointerConfig.initialPointerAppearDelay)
|
|
323
|
+
: defaultPointerConfig.initialPointerAppearDelay)
|
|
316
324
|
const persistPointer =
|
|
317
|
-
pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer
|
|
325
|
+
pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer
|
|
318
326
|
const hidePointer1 =
|
|
319
|
-
pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1
|
|
320
|
-
const pointerEvents = pointerConfig?.pointerEvents
|
|
327
|
+
pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1
|
|
328
|
+
const pointerEvents = pointerConfig?.pointerEvents
|
|
321
329
|
const stripBehindBars =
|
|
322
|
-
pointerConfig?.stripBehindBars ?? defaultPointerConfig.stripBehindBars
|
|
330
|
+
pointerConfig?.stripBehindBars ?? defaultPointerConfig.stripBehindBars
|
|
323
331
|
|
|
324
332
|
const disableScroll =
|
|
325
|
-
props.disableScroll
|
|
333
|
+
props.disableScroll ??
|
|
326
334
|
(pointerConfig
|
|
327
335
|
? activatePointersOnLongPress
|
|
328
|
-
? responderActive
|
|
329
|
-
? true
|
|
330
|
-
: false
|
|
336
|
+
? !!responderActive
|
|
331
337
|
: true
|
|
332
|
-
: false)
|
|
338
|
+
: false)
|
|
333
339
|
|
|
334
|
-
const barInnerComponent = props.barInnerComponent
|
|
340
|
+
const barInnerComponent = props.barInnerComponent
|
|
335
341
|
|
|
336
342
|
useEffect(() => {
|
|
337
343
|
if (showLine) {
|
|
338
|
-
let pp =
|
|
339
|
-
|
|
344
|
+
let pp = ''
|
|
345
|
+
let pp2 = ''
|
|
340
346
|
const firstBarWidth =
|
|
341
|
-
(props.stackData ?? data)?.[0].barWidth ?? props.barWidth ?? 30
|
|
347
|
+
(props.stackData ?? data)?.[0].barWidth ?? props.barWidth ?? 30
|
|
342
348
|
if (!lineConfig.curved) {
|
|
343
349
|
for (let i = 0; i < lineData.length; i++) {
|
|
344
|
-
if (i < lineConfig.startIndex || i > lineConfig.endIndex) continue
|
|
350
|
+
if (i < (lineConfig.startIndex ?? 0) || i > (lineConfig.endIndex ?? 0)) continue
|
|
345
351
|
const currentBarWidth =
|
|
346
|
-
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
352
|
+
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
347
353
|
const currentValue = props.lineData
|
|
348
354
|
? props.lineData[i].value
|
|
349
355
|
: props.stackData
|
|
350
|
-
|
|
356
|
+
? props.stackData[i].stacks.reduce(
|
|
351
357
|
(total, item) => total + item.value,
|
|
352
358
|
0
|
|
353
359
|
)
|
|
354
|
-
|
|
360
|
+
: data[i].value
|
|
355
361
|
pp +=
|
|
356
|
-
|
|
362
|
+
'L' +
|
|
357
363
|
getXForLineInBar(
|
|
358
364
|
i,
|
|
359
365
|
firstBarWidth,
|
|
@@ -362,51 +368,51 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
362
368
|
lineConfig,
|
|
363
369
|
spacing
|
|
364
370
|
) +
|
|
365
|
-
|
|
371
|
+
' ' +
|
|
366
372
|
getYForLineInBar(
|
|
367
373
|
currentValue,
|
|
368
374
|
lineConfig.shiftY,
|
|
369
375
|
containerHeight,
|
|
370
376
|
lineConfig.isSecondary ? secondaryMaxValue : maxValue
|
|
371
377
|
) +
|
|
372
|
-
|
|
378
|
+
' '
|
|
373
379
|
}
|
|
374
|
-
setPoints(pp.replace(
|
|
380
|
+
setPoints(pp.replace('L', 'M'))
|
|
375
381
|
if (lineData.length > 1 && lineConfig.showArrow) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
ppArray[ppArray.length - 2].replace(
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
const ppArray = pp.trim().split(' ')
|
|
383
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
384
|
+
const arrowTipX = parseInt(
|
|
385
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
386
|
+
)
|
|
387
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
388
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
389
|
+
|
|
390
|
+
const arrowPoints = getArrowPoints(
|
|
385
391
|
arrowTipX,
|
|
386
392
|
arrowTipY,
|
|
387
393
|
x1,
|
|
388
394
|
y1,
|
|
389
|
-
lineConfig.arrowConfig
|
|
390
|
-
lineConfig.arrowConfig
|
|
391
|
-
lineConfig.arrowConfig
|
|
392
|
-
)
|
|
395
|
+
lineConfig.arrowConfig?.length,
|
|
396
|
+
lineConfig.arrowConfig?.width,
|
|
397
|
+
lineConfig.arrowConfig?.showArrowBase
|
|
398
|
+
)
|
|
393
399
|
|
|
394
|
-
setArrowPoints(arrowPoints)
|
|
400
|
+
setArrowPoints(arrowPoints)
|
|
395
401
|
}
|
|
396
402
|
} else {
|
|
397
|
-
|
|
403
|
+
const p1Array: number[][] = []
|
|
398
404
|
for (let i = 0; i < lineData.length; i++) {
|
|
399
|
-
if (i < lineConfig.startIndex || i > lineConfig.endIndex) continue
|
|
405
|
+
if (i < (lineConfig.startIndex ?? 0) || i > (lineConfig.endIndex ?? 0)) continue
|
|
400
406
|
const currentBarWidth =
|
|
401
|
-
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
407
|
+
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
402
408
|
const currentValue = props.lineData
|
|
403
409
|
? props.lineData[i].value
|
|
404
410
|
: props.stackData
|
|
405
|
-
|
|
411
|
+
? props.stackData[i].stacks.reduce(
|
|
406
412
|
(total, item) => total + item.value,
|
|
407
413
|
0
|
|
408
414
|
)
|
|
409
|
-
|
|
415
|
+
: data[i].value
|
|
410
416
|
p1Array.push([
|
|
411
417
|
getXForLineInBar(
|
|
412
418
|
i,
|
|
@@ -421,22 +427,27 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
421
427
|
lineConfig.shiftY,
|
|
422
428
|
containerHeight,
|
|
423
429
|
lineConfig.isSecondary ? secondaryMaxValue : maxValue
|
|
424
|
-
)
|
|
425
|
-
])
|
|
426
|
-
|
|
427
|
-
|
|
430
|
+
)
|
|
431
|
+
])
|
|
432
|
+
const xx = svgPath(
|
|
433
|
+
p1Array,
|
|
434
|
+
lineConfig.curveType,
|
|
435
|
+
lineConfig.curvature
|
|
436
|
+
)
|
|
437
|
+
setPoints(xx)
|
|
428
438
|
}
|
|
429
439
|
}
|
|
430
440
|
if (lineData2?.length) {
|
|
431
441
|
if (!lineConfig2?.curved) {
|
|
432
442
|
for (let i = 0; i < lineData2.length; i++) {
|
|
433
|
-
if (i < lineConfig2.startIndex || i > lineConfig2.endIndex)
|
|
434
|
-
continue
|
|
443
|
+
if (i < (lineConfig2.startIndex ?? 0) || i > (lineConfig2.endIndex ?? 0)) {
|
|
444
|
+
continue
|
|
445
|
+
}
|
|
435
446
|
const currentBarWidth =
|
|
436
|
-
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
437
|
-
const currentValue = lineData2[i].value
|
|
447
|
+
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
448
|
+
const currentValue = lineData2[i].value
|
|
438
449
|
pp2 +=
|
|
439
|
-
|
|
450
|
+
'L' +
|
|
440
451
|
getXForLineInBar(
|
|
441
452
|
i,
|
|
442
453
|
firstBarWidth,
|
|
@@ -445,24 +456,25 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
445
456
|
lineConfig2,
|
|
446
457
|
spacing
|
|
447
458
|
) +
|
|
448
|
-
|
|
459
|
+
' ' +
|
|
449
460
|
getYForLineInBar(
|
|
450
461
|
currentValue,
|
|
451
462
|
lineConfig2.shiftY,
|
|
452
463
|
containerHeight,
|
|
453
464
|
lineConfig2.isSecondary ? secondaryMaxValue : maxValue
|
|
454
465
|
) +
|
|
455
|
-
|
|
466
|
+
' '
|
|
456
467
|
}
|
|
457
|
-
setPoints2(pp2.replace(
|
|
468
|
+
setPoints2(pp2.replace('L', 'M'))
|
|
458
469
|
} else {
|
|
459
|
-
|
|
470
|
+
const p2Array: number[][] = []
|
|
460
471
|
for (let i = 0; i < lineData2.length; i++) {
|
|
461
|
-
if (i < lineConfig2.startIndex || i > lineConfig2.endIndex)
|
|
462
|
-
continue
|
|
472
|
+
if (i < (lineConfig2.startIndex ?? 0) || i > (lineConfig2.endIndex ?? 0)) {
|
|
473
|
+
continue
|
|
474
|
+
}
|
|
463
475
|
const currentBarWidth =
|
|
464
|
-
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
465
|
-
const currentValue = lineData2[i].value
|
|
476
|
+
data?.[i]?.barWidth ?? props.barWidth ?? BarDefaults.barWidth
|
|
477
|
+
const currentValue = lineData2[i].value
|
|
466
478
|
p2Array.push([
|
|
467
479
|
getXForLineInBar(
|
|
468
480
|
i,
|
|
@@ -477,14 +489,14 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
477
489
|
lineConfig2.shiftY,
|
|
478
490
|
containerHeight,
|
|
479
491
|
lineConfig2.isSecondary ? secondaryMaxValue : maxValue
|
|
480
|
-
)
|
|
481
|
-
])
|
|
482
|
-
|
|
492
|
+
)
|
|
493
|
+
])
|
|
494
|
+
const xx = svgPath(
|
|
483
495
|
p2Array,
|
|
484
496
|
lineConfig2.curveType,
|
|
485
497
|
lineConfig2.curvature
|
|
486
|
-
)
|
|
487
|
-
setPoints2(xx)
|
|
498
|
+
)
|
|
499
|
+
setPoints2(xx)
|
|
488
500
|
}
|
|
489
501
|
}
|
|
490
502
|
}
|
|
@@ -509,86 +521,94 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
509
521
|
spacing,
|
|
510
522
|
yAxisLabelWidth,
|
|
511
523
|
lineConfig.showArrow,
|
|
512
|
-
lineConfig.arrowConfig
|
|
513
|
-
lineConfig.arrowConfig
|
|
514
|
-
lineConfig.arrowConfig
|
|
515
|
-
])
|
|
524
|
+
lineConfig.arrowConfig?.length,
|
|
525
|
+
lineConfig.arrowConfig?.width,
|
|
526
|
+
lineConfig.arrowConfig?.showArrowBase
|
|
527
|
+
])
|
|
516
528
|
useEffect(() => {
|
|
517
529
|
if (initialPointerIndex !== -1) {
|
|
518
|
-
const item = (props.stackData ?? data)?.[initialPointerIndex]
|
|
519
|
-
const stackItem = props.stackData?.[initialPointerIndex]
|
|
530
|
+
const item = (props.stackData ?? data)?.[initialPointerIndex]
|
|
531
|
+
const stackItem = props.stackData?.[initialPointerIndex]
|
|
520
532
|
const stackSum = stackItem?.stacks?.reduce(
|
|
521
533
|
(acc, stack) => acc + (stack.value ?? 0),
|
|
522
534
|
0
|
|
523
|
-
)
|
|
535
|
+
)
|
|
524
536
|
const x =
|
|
525
537
|
initialSpacing +
|
|
526
538
|
(spacing + barWidth) * initialPointerIndex -
|
|
527
|
-
(pointerRadius
|
|
528
|
-
barWidth / 2
|
|
539
|
+
(pointerRadius ?? pointerWidth / 2) +
|
|
540
|
+
barWidth / 2
|
|
529
541
|
const y =
|
|
530
542
|
containerHeight -
|
|
531
543
|
((stackSum ?? data[initialPointerIndex].value) * containerHeight) /
|
|
532
544
|
maxValue -
|
|
533
|
-
(pointerRadius
|
|
534
|
-
10
|
|
545
|
+
(pointerRadius ?? pointerHeight / 2) +
|
|
546
|
+
10
|
|
535
547
|
if (initialPointerAppearDelay) {
|
|
536
548
|
setTimeout(() => {
|
|
537
|
-
setPointerConfig(initialPointerIndex, item, x, y)
|
|
538
|
-
}, initialPointerAppearDelay)
|
|
549
|
+
setPointerConfig(initialPointerIndex, item, x, y)
|
|
550
|
+
}, initialPointerAppearDelay)
|
|
539
551
|
} else {
|
|
540
|
-
setPointerConfig(initialPointerIndex, item, x, y)
|
|
552
|
+
setPointerConfig(initialPointerIndex, item, x, y)
|
|
541
553
|
}
|
|
542
554
|
}
|
|
543
|
-
}, [])
|
|
544
|
-
|
|
545
|
-
const setPointerConfig = (
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
555
|
+
}, [])
|
|
556
|
+
|
|
557
|
+
const setPointerConfig = (
|
|
558
|
+
initialPointerIndex: number,
|
|
559
|
+
item: barDataItem | stackDataItem,
|
|
560
|
+
x: number,
|
|
561
|
+
y: number
|
|
562
|
+
): void => {
|
|
563
|
+
setPointerIndex(initialPointerIndex)
|
|
564
|
+
setPointerItem(item)
|
|
565
|
+
setPointerX(x)
|
|
566
|
+
setPointerY(y)
|
|
567
|
+
}
|
|
551
568
|
|
|
552
569
|
const animatedHeight = heightValue.interpolate({
|
|
553
570
|
inputRange: [0, 1],
|
|
554
|
-
outputRange: [
|
|
555
|
-
})
|
|
571
|
+
outputRange: ['0%', '100%']
|
|
572
|
+
})
|
|
556
573
|
const appearingOpacity = opacValue.interpolate({
|
|
557
574
|
inputRange: [0, 1],
|
|
558
|
-
outputRange: [0, 1]
|
|
559
|
-
})
|
|
575
|
+
outputRange: [0, 1]
|
|
576
|
+
})
|
|
560
577
|
|
|
561
578
|
const animatedWidth = widthValue.interpolate({
|
|
562
579
|
inputRange: [0, 1],
|
|
563
|
-
outputRange: [0, initialSpacing + totalWidth + endSpacing]
|
|
564
|
-
})
|
|
580
|
+
outputRange: [0, initialSpacing + totalWidth + endSpacing]
|
|
581
|
+
})
|
|
565
582
|
|
|
566
|
-
const getPropsCommonForBarAndStack = (
|
|
583
|
+
const getPropsCommonForBarAndStack = (
|
|
584
|
+
item: stackDataItem | barDataItem,
|
|
585
|
+
index: number
|
|
586
|
+
) => {
|
|
567
587
|
return {
|
|
568
588
|
key: index,
|
|
569
|
-
item
|
|
570
|
-
index
|
|
571
|
-
containerHeight
|
|
572
|
-
maxValue
|
|
589
|
+
item,
|
|
590
|
+
index,
|
|
591
|
+
containerHeight,
|
|
592
|
+
maxValue,
|
|
573
593
|
spacing: item.spacing ?? spacing,
|
|
574
594
|
propSpacing: spacing,
|
|
575
|
-
xAxisThickness
|
|
595
|
+
xAxisThickness,
|
|
576
596
|
barWidth: props.barWidth,
|
|
577
|
-
opacity
|
|
578
|
-
disablePress: item.disablePress
|
|
579
|
-
rotateLabel
|
|
580
|
-
showXAxisIndices
|
|
581
|
-
xAxisIndicesHeight
|
|
582
|
-
xAxisIndicesWidth
|
|
583
|
-
xAxisIndicesColor
|
|
584
|
-
horizontal
|
|
585
|
-
rtl
|
|
586
|
-
intactTopLabel
|
|
597
|
+
opacity,
|
|
598
|
+
disablePress: item.disablePress ?? props.disablePress,
|
|
599
|
+
rotateLabel,
|
|
600
|
+
showXAxisIndices,
|
|
601
|
+
xAxisIndicesHeight,
|
|
602
|
+
xAxisIndicesWidth,
|
|
603
|
+
xAxisIndicesColor,
|
|
604
|
+
horizontal,
|
|
605
|
+
rtl,
|
|
606
|
+
intactTopLabel,
|
|
587
607
|
showValuesAsTopLabel: props.showValuesAsTopLabel,
|
|
588
608
|
topLabelContainerStyle: props.topLabelContainerStyle,
|
|
589
609
|
topLabelTextStyle: props.topLabelTextStyle,
|
|
590
610
|
barBorderWidth: props.barBorderWidth,
|
|
591
|
-
barBorderColor
|
|
611
|
+
barBorderColor,
|
|
592
612
|
barBorderRadius: props.barBorderRadius,
|
|
593
613
|
barBorderTopLeftRadius: props.barBorderTopLeftRadius,
|
|
594
614
|
barBorderTopRightRadius: props.barBorderTopRightRadius,
|
|
@@ -605,27 +625,25 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
605
625
|
onPressOut: props.onPressOut,
|
|
606
626
|
focusBarOnPress: props.focusBarOnPress,
|
|
607
627
|
focusedBarConfig: props.focusedBarConfig,
|
|
608
|
-
xAxisTextNumberOfLines
|
|
628
|
+
xAxisTextNumberOfLines,
|
|
609
629
|
xAxisLabelsHeight: props.xAxisLabelsHeight,
|
|
610
630
|
xAxisLabelsVerticalShift,
|
|
611
631
|
renderTooltip: props.renderTooltip,
|
|
612
|
-
leftShiftForTooltip: props.leftShiftForTooltip
|
|
613
|
-
initialSpacing
|
|
614
|
-
selectedIndex
|
|
615
|
-
setSelectedIndex
|
|
616
|
-
activeOpacity: props.activeOpacity
|
|
632
|
+
leftShiftForTooltip: props.leftShiftForTooltip ?? 0,
|
|
633
|
+
initialSpacing,
|
|
634
|
+
selectedIndex,
|
|
635
|
+
setSelectedIndex,
|
|
636
|
+
activeOpacity: props.activeOpacity ?? 0.2,
|
|
617
637
|
noOfSectionsBelowXAxis,
|
|
618
638
|
|
|
619
|
-
leftShiftForLastIndexTooltip: props.leftShiftForLastIndexTooltip
|
|
639
|
+
leftShiftForLastIndexTooltip: props.leftShiftForLastIndexTooltip ?? 0,
|
|
620
640
|
label:
|
|
621
|
-
item.label
|
|
622
|
-
(props.xAxisLabelTexts
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
};
|
|
628
|
-
};
|
|
641
|
+
item.label ??
|
|
642
|
+
(props.xAxisLabelTexts?.[index] ? props.xAxisLabelTexts[index] : ''),
|
|
643
|
+
labelTextStyle: item.labelTextStyle ?? props.xAxisLabelTextStyle,
|
|
644
|
+
pointerConfig
|
|
645
|
+
}
|
|
646
|
+
}
|
|
629
647
|
|
|
630
648
|
const barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes = {
|
|
631
649
|
chartType: chartTypes.BAR,
|
|
@@ -642,8 +660,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
642
660
|
initialSpacing,
|
|
643
661
|
data,
|
|
644
662
|
stackData: props.stackData,
|
|
645
|
-
secondaryData
|
|
646
|
-
barWidth: props.barWidth
|
|
663
|
+
secondaryData,
|
|
664
|
+
barWidth: props.barWidth ?? BarDefaults.barWidth,
|
|
647
665
|
xAxisThickness,
|
|
648
666
|
totalWidth,
|
|
649
667
|
disableScroll,
|
|
@@ -667,7 +685,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
667
685
|
points2,
|
|
668
686
|
arrowPoints,
|
|
669
687
|
|
|
670
|
-
//horizSectionProps-
|
|
688
|
+
// horizSectionProps-
|
|
671
689
|
width: widthFromProps,
|
|
672
690
|
horizSections,
|
|
673
691
|
endSpacing,
|
|
@@ -700,8 +718,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
700
718
|
|
|
701
719
|
onEndReached: props.onEndReached,
|
|
702
720
|
onStartReached: props.onStartReached,
|
|
703
|
-
endReachedOffset: props.endReachedOffset ?? BarDefaults.endReachedOffset
|
|
704
|
-
}
|
|
721
|
+
endReachedOffset: props.endReachedOffset ?? BarDefaults.endReachedOffset
|
|
722
|
+
}
|
|
705
723
|
|
|
706
724
|
return {
|
|
707
725
|
lineConfig,
|
|
@@ -808,6 +826,6 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
808
826
|
getPointerProps,
|
|
809
827
|
pointerIndex,
|
|
810
828
|
getPropsCommonForBarAndStack,
|
|
811
|
-
barAndLineChartsWrapperProps
|
|
812
|
-
}
|
|
813
|
-
}
|
|
829
|
+
barAndLineChartsWrapperProps
|
|
830
|
+
}
|
|
831
|
+
}
|