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
package/src/LineChart/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
AxesAndRulesDefaults,
|
|
4
4
|
LineDefaults,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
chartTypes,
|
|
8
8
|
defaultArrowConfig,
|
|
9
9
|
defaultPointerConfig,
|
|
10
|
-
screenWidth
|
|
11
|
-
} from
|
|
10
|
+
screenWidth
|
|
11
|
+
} from '../utils/constants'
|
|
12
12
|
import {
|
|
13
13
|
adjustToOffset,
|
|
14
14
|
computeMaxAndMinItems,
|
|
@@ -25,13 +25,25 @@ import {
|
|
|
25
25
|
getSanitisedData,
|
|
26
26
|
getSecondaryDataWithOffsetIncluded,
|
|
27
27
|
getSegmentString,
|
|
28
|
-
svgPath
|
|
29
|
-
} from
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
svgPath
|
|
29
|
+
} from '../utils'
|
|
30
|
+
import {
|
|
31
|
+
type IDataSanitisationProps,
|
|
32
|
+
type LineChartPropsType,
|
|
33
|
+
type lineDataItem
|
|
34
|
+
} from './types'
|
|
35
|
+
import {
|
|
36
|
+
type BarAndLineChartsWrapperTypes,
|
|
37
|
+
EdgePosition,
|
|
38
|
+
type LineSegment
|
|
39
|
+
} from '../utils/types'
|
|
40
|
+
import { type Animated } from 'react-native'
|
|
41
|
+
|
|
42
|
+
export interface extendedLineChartPropsType extends LineChartPropsType {
|
|
43
|
+
animations: Animated.Value[]
|
|
44
|
+
heightValue: Animated.Value
|
|
45
|
+
widthValue: Animated.Value
|
|
46
|
+
opacValue: Animated.Value
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
@@ -40,108 +52,90 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
40
52
|
showDataPointsForMissingValues,
|
|
41
53
|
interpolateMissingValues = true,
|
|
42
54
|
onlyPositive,
|
|
43
|
-
yAxisOffset
|
|
44
|
-
} = props
|
|
45
|
-
const curvature = props.curvature ?? LineDefaults.curvature
|
|
46
|
-
const curveType = props.curveType ?? LineDefaults.curveType
|
|
47
|
-
const [scrollX, setScrollX] = useState(0)
|
|
48
|
-
const [arrow1Points, setArrow1Points] = useState(
|
|
49
|
-
const [arrow2Points, setArrow2Points] = useState(
|
|
50
|
-
const [arrow3Points, setArrow3Points] = useState(
|
|
51
|
-
const [arrow4Points, setArrow4Points] = useState(
|
|
52
|
-
const [arrow5Points, setArrow5Points] = useState(
|
|
53
|
-
const [secondaryArrowPoints, setSecondaryArrowPoints] = useState(
|
|
54
|
-
const [pointerIndex, setPointerIndex] = useState(-1)
|
|
55
|
-
const [pointerX, setPointerX] = useState(0)
|
|
56
|
-
const [pointerY, setPointerY] = useState(0)
|
|
57
|
-
const [pointerItem, setPointerItem] = useState(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const [
|
|
63
|
-
const [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const [
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const [
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const [
|
|
78
|
-
const [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const [
|
|
83
|
-
const [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const [
|
|
90
|
-
const [points, setPoints] = useState("");
|
|
91
|
-
const [points2, setPoints2] = useState("");
|
|
92
|
-
const [points3, setPoints3] = useState("");
|
|
93
|
-
const [points4, setPoints4] = useState("");
|
|
94
|
-
const [points5, setPoints5] = useState("");
|
|
95
|
-
const [secondaryPoints, setSecondaryPoints] = useState("");
|
|
96
|
-
const [fillPoints, setFillPoints] = useState("");
|
|
97
|
-
const [fillPoints2, setFillPoints2] = useState("");
|
|
98
|
-
const [fillPoints3, setFillPoints3] = useState("");
|
|
99
|
-
const [fillPoints4, setFillPoints4] = useState("");
|
|
100
|
-
const [fillPoints5, setFillPoints5] = useState("");
|
|
101
|
-
const [secondaryFillPoints, setSecondaryFillPoints] = useState("");
|
|
102
|
-
|
|
103
|
-
const [pointsFromSet, setPointsFromSet] = useState<string[]>([]);
|
|
104
|
-
const [fillPointsFromSet, setFillPointsFromSet] = useState<string[]>([]);
|
|
105
|
-
const [arrowPointsFromSet, setArrowPointsFromSet] = useState<string[]>([]);
|
|
106
|
-
|
|
107
|
-
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
55
|
+
yAxisOffset
|
|
56
|
+
} = props
|
|
57
|
+
const curvature = props.curvature ?? LineDefaults.curvature
|
|
58
|
+
const curveType = props.curveType ?? LineDefaults.curveType
|
|
59
|
+
const [scrollX, setScrollX] = useState(0)
|
|
60
|
+
const [arrow1Points, setArrow1Points] = useState('')
|
|
61
|
+
const [arrow2Points, setArrow2Points] = useState('')
|
|
62
|
+
const [arrow3Points, setArrow3Points] = useState('')
|
|
63
|
+
const [arrow4Points, setArrow4Points] = useState('')
|
|
64
|
+
const [arrow5Points, setArrow5Points] = useState('')
|
|
65
|
+
const [secondaryArrowPoints, setSecondaryArrowPoints] = useState('')
|
|
66
|
+
const [pointerIndex, setPointerIndex] = useState(-1)
|
|
67
|
+
const [pointerX, setPointerX] = useState(0)
|
|
68
|
+
const [pointerY, setPointerY] = useState(0)
|
|
69
|
+
const [pointerItem, setPointerItem] = useState<lineDataItem>()
|
|
70
|
+
|
|
71
|
+
const [pointerY2, setPointerY2] = useState(0)
|
|
72
|
+
const [pointerItem2, setPointerItem2] = useState<lineDataItem>()
|
|
73
|
+
const [pointerY3, setPointerY3] = useState(0)
|
|
74
|
+
const [pointerItem3, setPointerItem3] = useState<lineDataItem>()
|
|
75
|
+
const [pointerY4, setPointerY4] = useState(0)
|
|
76
|
+
const [pointerItem4, setPointerItem4] = useState<lineDataItem>()
|
|
77
|
+
const [pointerY5, setPointerY5] = useState(0)
|
|
78
|
+
const [pointerItem5, setPointerItem5] = useState<lineDataItem>()
|
|
79
|
+
const [secondaryPointerY, setSecondaryPointerY] = useState(0)
|
|
80
|
+
const [secondaryPointerItem, setSecondaryPointerItem] = useState()
|
|
81
|
+
|
|
82
|
+
const [responderStartTime, setResponderStartTime] = useState(0)
|
|
83
|
+
const [responderActive, setResponderActive] = useState(false)
|
|
84
|
+
const [points, setPoints] = useState('')
|
|
85
|
+
const [points2, setPoints2] = useState('')
|
|
86
|
+
const [points3, setPoints3] = useState('')
|
|
87
|
+
const [points4, setPoints4] = useState('')
|
|
88
|
+
const [points5, setPoints5] = useState('')
|
|
89
|
+
const [secondaryPoints, setSecondaryPoints] = useState('')
|
|
90
|
+
const [fillPoints, setFillPoints] = useState('')
|
|
91
|
+
const [fillPoints2, setFillPoints2] = useState('')
|
|
92
|
+
const [fillPoints3, setFillPoints3] = useState('')
|
|
93
|
+
const [fillPoints4, setFillPoints4] = useState('')
|
|
94
|
+
const [fillPoints5, setFillPoints5] = useState('')
|
|
95
|
+
const [secondaryFillPoints, setSecondaryFillPoints] = useState('')
|
|
96
|
+
|
|
97
|
+
const [pointsFromSet, setPointsFromSet] = useState<string[]>([])
|
|
98
|
+
const [fillPointsFromSet, setFillPointsFromSet] = useState<string[]>([])
|
|
99
|
+
const [arrowPointsFromSet, setArrowPointsFromSet] = useState<string[]>([])
|
|
100
|
+
|
|
101
|
+
const [selectedIndex, setSelectedIndex] = useState(-1)
|
|
108
102
|
|
|
109
103
|
const noOfSections = getNoOfSections(
|
|
110
104
|
props.noOfSections,
|
|
111
105
|
props.maxValue,
|
|
112
106
|
props.stepValue
|
|
113
|
-
)
|
|
107
|
+
)
|
|
114
108
|
const containerHeight =
|
|
115
109
|
props.height ??
|
|
116
110
|
((props.stepHeight ?? 0) * noOfSections ||
|
|
117
|
-
AxesAndRulesDefaults.containerHeight)
|
|
111
|
+
AxesAndRulesDefaults.containerHeight)
|
|
118
112
|
|
|
119
|
-
const dataSanitisationProps = {
|
|
113
|
+
const dataSanitisationProps: IDataSanitisationProps = {
|
|
120
114
|
showDataPointsForMissingValues,
|
|
121
115
|
interpolateMissingValues,
|
|
122
116
|
onlyPositive,
|
|
123
|
-
yAxisOffset
|
|
124
|
-
}
|
|
117
|
+
yAxisOffset
|
|
118
|
+
}
|
|
125
119
|
const data = useMemo(
|
|
126
120
|
() => getSanitisedData(props.data, dataSanitisationProps),
|
|
127
121
|
[yAxisOffset, props.data]
|
|
128
|
-
)
|
|
122
|
+
)
|
|
129
123
|
const data2 = useMemo(
|
|
130
124
|
() => getSanitisedData(props.data2, dataSanitisationProps),
|
|
131
125
|
[yAxisOffset, props.data2]
|
|
132
|
-
)
|
|
126
|
+
)
|
|
133
127
|
const data3 = useMemo(
|
|
134
128
|
() => getSanitisedData(props.data3, dataSanitisationProps),
|
|
135
129
|
[yAxisOffset, props.data3]
|
|
136
|
-
)
|
|
130
|
+
)
|
|
137
131
|
const data4 = useMemo(
|
|
138
132
|
() => getSanitisedData(props.data4, dataSanitisationProps),
|
|
139
133
|
[yAxisOffset, props.data4]
|
|
140
|
-
)
|
|
134
|
+
)
|
|
141
135
|
const data5 = useMemo(
|
|
142
136
|
() => getSanitisedData(props.data5, dataSanitisationProps),
|
|
143
137
|
[yAxisOffset, props.data5]
|
|
144
|
-
)
|
|
138
|
+
)
|
|
145
139
|
|
|
146
140
|
const secondaryData =
|
|
147
141
|
getSecondaryDataWithOffsetIncluded(
|
|
@@ -150,9 +144,9 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
150
144
|
showDataPointsForMissingValues,
|
|
151
145
|
interpolateMissingValues,
|
|
152
146
|
onlyPositive
|
|
153
|
-
)
|
|
147
|
+
) ?? []
|
|
154
148
|
|
|
155
|
-
let dataSet = props.dataSet
|
|
149
|
+
let dataSet = props.dataSet
|
|
156
150
|
if (dataSet?.length) {
|
|
157
151
|
dataSet = useMemo(() => {
|
|
158
152
|
return dataSet?.map((dataSetItem) => {
|
|
@@ -161,426 +155,411 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
161
155
|
showDataPointsForMissingValues,
|
|
162
156
|
interpolateMissingValues,
|
|
163
157
|
onlyPositive
|
|
164
|
-
)
|
|
158
|
+
)
|
|
165
159
|
return {
|
|
166
160
|
...dataSetItem,
|
|
167
|
-
data: adjustToOffset(nullishHandledDataItem, yAxisOffset)
|
|
168
|
-
}
|
|
169
|
-
})
|
|
170
|
-
}, [yAxisOffset, dataSet])
|
|
161
|
+
data: adjustToOffset(nullishHandledDataItem, yAxisOffset)
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
}, [yAxisOffset, dataSet])
|
|
171
165
|
}
|
|
172
166
|
|
|
173
|
-
const data0 = dataSet?.[0]?.data
|
|
167
|
+
const data0 = dataSet?.[0]?.data
|
|
174
168
|
|
|
175
|
-
const scrollToEnd = props.scrollToEnd
|
|
176
|
-
const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation
|
|
169
|
+
const scrollToEnd = props.scrollToEnd ?? LineDefaults.scrollToEnd
|
|
170
|
+
const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation
|
|
177
171
|
const scrollEventThrottle =
|
|
178
|
-
props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle
|
|
172
|
+
props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle
|
|
179
173
|
|
|
180
|
-
const labelsExtraHeight = props.labelsExtraHeight
|
|
174
|
+
const labelsExtraHeight = props.labelsExtraHeight ?? 0
|
|
181
175
|
|
|
182
176
|
const animationDuration =
|
|
183
|
-
props.animationDuration
|
|
177
|
+
props.animationDuration ?? LineDefaults.animationDuration
|
|
184
178
|
const onDataChangeAnimationDuration =
|
|
185
|
-
props.onDataChangeAnimationDuration
|
|
186
|
-
const animateTogether = props.animateTogether
|
|
179
|
+
props.onDataChangeAnimationDuration ?? 400
|
|
180
|
+
const animateTogether = props.animateTogether ?? LineDefaults.animateTogether
|
|
187
181
|
const animateOnDataChange = yAxisOffset
|
|
188
182
|
? false
|
|
189
|
-
: props.animateOnDataChange
|
|
183
|
+
: props.animateOnDataChange ?? false
|
|
190
184
|
|
|
191
|
-
const startIndex1 = props.startIndex1 ?? props.startIndex ?? 0
|
|
185
|
+
const startIndex1 = props.startIndex1 ?? props.startIndex ?? 0
|
|
192
186
|
|
|
193
|
-
let endIndex1
|
|
187
|
+
let endIndex1: number
|
|
194
188
|
if (props.endIndex1 === undefined || props.endIndex1 === null) {
|
|
195
189
|
if (props.endIndex === undefined || props.endIndex === null) {
|
|
196
|
-
endIndex1 = data.length - 1
|
|
190
|
+
endIndex1 = data.length - 1
|
|
197
191
|
} else {
|
|
198
|
-
endIndex1 = props.endIndex
|
|
192
|
+
endIndex1 = props.endIndex
|
|
199
193
|
}
|
|
200
194
|
} else {
|
|
201
|
-
endIndex1 = props.endIndex1
|
|
195
|
+
endIndex1 = props.endIndex1
|
|
202
196
|
}
|
|
203
197
|
|
|
204
|
-
const startIndex2 = props.startIndex2
|
|
205
|
-
const endIndex2 = props.endIndex2 ?? data2.length - 1
|
|
198
|
+
const startIndex2 = props.startIndex2 ?? 0
|
|
199
|
+
const endIndex2 = props.endIndex2 ?? data2.length - 1
|
|
206
200
|
|
|
207
|
-
const startIndex3 = props.startIndex3
|
|
208
|
-
const endIndex3 = props.endIndex3 ?? data3.length - 1
|
|
209
|
-
const startIndex4 = props.startIndex4
|
|
210
|
-
const endIndex4 = props.endIndex4 ?? data4.length - 1
|
|
211
|
-
const startIndex5 = props.startIndex5
|
|
212
|
-
const endIndex5 = props.endIndex5 ?? data5.length - 1
|
|
201
|
+
const startIndex3 = props.startIndex3 ?? 0
|
|
202
|
+
const endIndex3 = props.endIndex3 ?? data3.length - 1
|
|
203
|
+
const startIndex4 = props.startIndex4 ?? 0
|
|
204
|
+
const endIndex4 = props.endIndex4 ?? data4.length - 1
|
|
205
|
+
const startIndex5 = props.startIndex5 ?? 0
|
|
206
|
+
const endIndex5 = props.endIndex5 ?? data5.length - 1
|
|
213
207
|
|
|
214
208
|
const lineSegments = !interpolateMissingValues
|
|
215
209
|
? getLineSegmentsForMissingValues(props.data)
|
|
216
|
-
: props.lineSegments
|
|
210
|
+
: props.lineSegments
|
|
217
211
|
const lineSegments2 = !interpolateMissingValues
|
|
218
212
|
? getLineSegmentsForMissingValues(props.data2)
|
|
219
|
-
: props.lineSegments2
|
|
213
|
+
: props.lineSegments2
|
|
220
214
|
const lineSegments3 = !interpolateMissingValues
|
|
221
215
|
? getLineSegmentsForMissingValues(props.data3)
|
|
222
|
-
: props.lineSegments3
|
|
216
|
+
: props.lineSegments3
|
|
223
217
|
const lineSegments4 = !interpolateMissingValues
|
|
224
218
|
? getLineSegmentsForMissingValues(props.data4)
|
|
225
|
-
: props.lineSegments4
|
|
219
|
+
: props.lineSegments4
|
|
226
220
|
const lineSegments5 = !interpolateMissingValues
|
|
227
221
|
? getLineSegmentsForMissingValues(props.data5)
|
|
228
|
-
: props.lineSegments5
|
|
222
|
+
: props.lineSegments5
|
|
229
223
|
|
|
230
|
-
const highlightedRange = props.highlightedRange
|
|
224
|
+
const highlightedRange = props.highlightedRange
|
|
231
225
|
|
|
232
|
-
let newPoints =
|
|
233
|
-
|
|
234
|
-
let counter = 0
|
|
226
|
+
let newPoints = ''
|
|
227
|
+
let newFillPoints = ''
|
|
228
|
+
let counter = 0
|
|
235
229
|
|
|
236
|
-
const adjustToWidth = props.adjustToWidth
|
|
230
|
+
const adjustToWidth = props.adjustToWidth ?? false
|
|
237
231
|
|
|
238
|
-
const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing
|
|
232
|
+
const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing
|
|
239
233
|
const endSpacing =
|
|
240
|
-
props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing)
|
|
234
|
+
props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing)
|
|
241
235
|
|
|
242
|
-
const thickness = props.thickness ?? LineDefaults.thickness
|
|
236
|
+
const thickness = props.thickness ?? LineDefaults.thickness
|
|
243
237
|
|
|
244
238
|
const yAxisLabelWidth =
|
|
245
239
|
props.yAxisLabelWidth ??
|
|
246
240
|
(props.hideYAxisText
|
|
247
241
|
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
248
|
-
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
242
|
+
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
249
243
|
|
|
250
244
|
const spacing =
|
|
251
245
|
props.spacing ??
|
|
252
246
|
(adjustToWidth
|
|
253
247
|
? ((props.width ?? screenWidth - yAxisLabelWidth) - initialSpacing) /
|
|
254
248
|
Math.max((data0 ?? data).length - 1, 1)
|
|
255
|
-
: LineDefaults.spacing)
|
|
249
|
+
: LineDefaults.spacing)
|
|
256
250
|
|
|
257
251
|
const xAxisThickness =
|
|
258
|
-
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
|
|
252
|
+
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
|
|
259
253
|
const dataPointsHeight1 =
|
|
260
254
|
props.dataPointsHeight1 ??
|
|
261
255
|
props.dataPointsHeight ??
|
|
262
|
-
LineDefaults.dataPointsHeight
|
|
256
|
+
LineDefaults.dataPointsHeight
|
|
263
257
|
const dataPointsWidth1 =
|
|
264
258
|
props.dataPointsWidth1 ??
|
|
265
259
|
props.dataPointsWidth ??
|
|
266
|
-
LineDefaults.dataPointsWidth
|
|
260
|
+
LineDefaults.dataPointsWidth
|
|
267
261
|
const dataPointsRadius1 =
|
|
268
262
|
props.dataPointsRadius1 ??
|
|
269
263
|
props.dataPointsRadius ??
|
|
270
|
-
LineDefaults.dataPointsRadius
|
|
264
|
+
LineDefaults.dataPointsRadius
|
|
271
265
|
const dataPointsColor1 =
|
|
272
266
|
props.dataPointsColor1 ??
|
|
273
267
|
props.dataPointsColor ??
|
|
274
|
-
LineDefaults.dataPointsColor
|
|
268
|
+
LineDefaults.dataPointsColor
|
|
275
269
|
const dataPointsShape1 =
|
|
276
270
|
props.dataPointsShape1 ??
|
|
277
271
|
props.dataPointsShape ??
|
|
278
|
-
LineDefaults.dataPointsShape
|
|
272
|
+
LineDefaults.dataPointsShape
|
|
279
273
|
|
|
280
274
|
const dataPointsHeight2 =
|
|
281
275
|
props.dataPointsHeight2 ??
|
|
282
276
|
props.dataPointsHeight ??
|
|
283
|
-
LineDefaults.dataPointsHeight
|
|
277
|
+
LineDefaults.dataPointsHeight
|
|
284
278
|
const dataPointsWidth2 =
|
|
285
279
|
props.dataPointsWidth2 ??
|
|
286
280
|
props.dataPointsWidth ??
|
|
287
|
-
LineDefaults.dataPointsWidth
|
|
281
|
+
LineDefaults.dataPointsWidth
|
|
288
282
|
const dataPointsRadius2 =
|
|
289
283
|
props.dataPointsRadius2 ??
|
|
290
284
|
props.dataPointsRadius ??
|
|
291
|
-
LineDefaults.dataPointsRadius
|
|
285
|
+
LineDefaults.dataPointsRadius
|
|
292
286
|
const dataPointsColor2 =
|
|
293
287
|
props.dataPointsColor2 ??
|
|
294
288
|
props.dataPointsColor ??
|
|
295
|
-
LineDefaults.dataPointsColor2
|
|
289
|
+
LineDefaults.dataPointsColor2
|
|
296
290
|
const dataPointsShape2 =
|
|
297
291
|
props.dataPointsShape2 ??
|
|
298
292
|
props.dataPointsShape ??
|
|
299
|
-
LineDefaults.dataPointsShape
|
|
293
|
+
LineDefaults.dataPointsShape
|
|
300
294
|
|
|
301
295
|
const dataPointsHeight3 =
|
|
302
296
|
props.dataPointsHeight3 ??
|
|
303
297
|
props.dataPointsHeight ??
|
|
304
|
-
LineDefaults.dataPointsHeight
|
|
298
|
+
LineDefaults.dataPointsHeight
|
|
305
299
|
const dataPointsWidth3 =
|
|
306
300
|
props.dataPointsWidth3 ??
|
|
307
301
|
props.dataPointsWidth ??
|
|
308
|
-
LineDefaults.dataPointsWidth
|
|
302
|
+
LineDefaults.dataPointsWidth
|
|
309
303
|
const dataPointsRadius3 =
|
|
310
304
|
props.dataPointsRadius3 ??
|
|
311
305
|
props.dataPointsRadius ??
|
|
312
|
-
LineDefaults.dataPointsRadius
|
|
306
|
+
LineDefaults.dataPointsRadius
|
|
313
307
|
const dataPointsColor3 =
|
|
314
308
|
props.dataPointsColor3 ??
|
|
315
309
|
props.dataPointsColor ??
|
|
316
|
-
LineDefaults.dataPointsColor3
|
|
310
|
+
LineDefaults.dataPointsColor3
|
|
317
311
|
const dataPointsShape3 =
|
|
318
312
|
props.dataPointsShape3 ??
|
|
319
313
|
props.dataPointsShape ??
|
|
320
|
-
LineDefaults.dataPointsShape
|
|
314
|
+
LineDefaults.dataPointsShape
|
|
321
315
|
|
|
322
316
|
const dataPointsHeight4 =
|
|
323
317
|
props.dataPointsHeight4 ??
|
|
324
318
|
props.dataPointsHeight ??
|
|
325
|
-
LineDefaults.dataPointsHeight
|
|
319
|
+
LineDefaults.dataPointsHeight
|
|
326
320
|
const dataPointsWidth4 =
|
|
327
321
|
props.dataPointsWidth4 ??
|
|
328
322
|
props.dataPointsWidth ??
|
|
329
|
-
LineDefaults.dataPointsWidth
|
|
323
|
+
LineDefaults.dataPointsWidth
|
|
330
324
|
const dataPointsRadius4 =
|
|
331
325
|
props.dataPointsRadius4 ??
|
|
332
326
|
props.dataPointsRadius ??
|
|
333
|
-
LineDefaults.dataPointsRadius
|
|
327
|
+
LineDefaults.dataPointsRadius
|
|
334
328
|
const dataPointsColor4 =
|
|
335
329
|
props.dataPointsColor4 ??
|
|
336
330
|
props.dataPointsColor ??
|
|
337
|
-
LineDefaults.dataPointsColor
|
|
331
|
+
LineDefaults.dataPointsColor
|
|
338
332
|
const dataPointsShape4 =
|
|
339
333
|
props.dataPointsShape4 ??
|
|
340
334
|
props.dataPointsShape ??
|
|
341
|
-
LineDefaults.dataPointsShape
|
|
335
|
+
LineDefaults.dataPointsShape
|
|
342
336
|
|
|
343
337
|
const dataPointsHeight5 =
|
|
344
338
|
props.dataPointsHeight5 ??
|
|
345
339
|
props.dataPointsHeight ??
|
|
346
|
-
LineDefaults.dataPointsHeight
|
|
340
|
+
LineDefaults.dataPointsHeight
|
|
347
341
|
const dataPointsWidth5 =
|
|
348
342
|
props.dataPointsWidth5 ??
|
|
349
343
|
props.dataPointsWidth ??
|
|
350
|
-
LineDefaults.dataPointsWidth
|
|
344
|
+
LineDefaults.dataPointsWidth
|
|
351
345
|
const dataPointsRadius5 =
|
|
352
346
|
props.dataPointsRadius5 ??
|
|
353
347
|
props.dataPointsRadius ??
|
|
354
|
-
LineDefaults.dataPointsRadius
|
|
348
|
+
LineDefaults.dataPointsRadius
|
|
355
349
|
const dataPointsColor5 =
|
|
356
350
|
props.dataPointsColor5 ??
|
|
357
351
|
props.dataPointsColor ??
|
|
358
|
-
LineDefaults.dataPointsColor
|
|
352
|
+
LineDefaults.dataPointsColor
|
|
359
353
|
const dataPointsShape5 =
|
|
360
354
|
props.dataPointsShape5 ??
|
|
361
355
|
props.dataPointsShape ??
|
|
362
|
-
LineDefaults.dataPointsShape
|
|
356
|
+
LineDefaults.dataPointsShape
|
|
363
357
|
|
|
364
|
-
const areaChart = props.areaChart ?? false
|
|
365
|
-
const areaChart1 = props.areaChart1 ?? false
|
|
366
|
-
const areaChart2 = props.areaChart2 ?? false
|
|
367
|
-
const areaChart3 = props.areaChart3 ?? false
|
|
368
|
-
const areaChart4 = props.areaChart4 ?? false
|
|
369
|
-
const areaChart5 = props.areaChart5 ?? false
|
|
358
|
+
const areaChart = props.areaChart ?? false
|
|
359
|
+
const areaChart1 = props.areaChart1 ?? false
|
|
360
|
+
const areaChart2 = props.areaChart2 ?? false
|
|
361
|
+
const areaChart3 = props.areaChart3 ?? false
|
|
362
|
+
const areaChart4 = props.areaChart4 ?? false
|
|
363
|
+
const areaChart5 = props.areaChart5 ?? false
|
|
370
364
|
|
|
371
365
|
const atLeastOneAreaChart =
|
|
372
|
-
dataSet?.some((set) => set.areaChart)
|
|
373
|
-
areaChart
|
|
374
|
-
areaChart1
|
|
375
|
-
areaChart2
|
|
376
|
-
areaChart3
|
|
377
|
-
areaChart4
|
|
378
|
-
areaChart5
|
|
379
|
-
|
|
380
|
-
const stepChart = props.stepChart ?? false
|
|
381
|
-
const stepChart1 = props.stepChart1 ?? false
|
|
382
|
-
const stepChart2 = props.stepChart2 ?? false
|
|
383
|
-
const stepChart3 = props.stepChart3 ?? false
|
|
384
|
-
const stepChart4 = props.stepChart4 ?? false
|
|
385
|
-
const stepChart5 = props.stepChart5 ?? false
|
|
386
|
-
|
|
387
|
-
const edgePosition = props.edgePosition ?? LineDefaults.edgePosition
|
|
366
|
+
dataSet?.some((set) => set.areaChart) ??
|
|
367
|
+
areaChart ??
|
|
368
|
+
areaChart1 ??
|
|
369
|
+
areaChart2 ??
|
|
370
|
+
areaChart3 ??
|
|
371
|
+
areaChart4 ??
|
|
372
|
+
areaChart5
|
|
373
|
+
|
|
374
|
+
const stepChart = props.stepChart ?? false
|
|
375
|
+
const stepChart1 = props.stepChart1 ?? false
|
|
376
|
+
const stepChart2 = props.stepChart2 ?? false
|
|
377
|
+
const stepChart3 = props.stepChart3 ?? false
|
|
378
|
+
const stepChart4 = props.stepChart4 ?? false
|
|
379
|
+
const stepChart5 = props.stepChart5 ?? false
|
|
380
|
+
|
|
381
|
+
const edgePosition = props.edgePosition ?? LineDefaults.edgePosition
|
|
388
382
|
|
|
389
383
|
const textFontSize1 =
|
|
390
|
-
props.textFontSize1 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
384
|
+
props.textFontSize1 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
391
385
|
const textFontSize2 =
|
|
392
|
-
props.textFontSize2 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
386
|
+
props.textFontSize2 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
393
387
|
const textFontSize3 =
|
|
394
|
-
props.textFontSize3 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
388
|
+
props.textFontSize3 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
395
389
|
const textFontSize4 =
|
|
396
|
-
props.textFontSize4 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
390
|
+
props.textFontSize4 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
397
391
|
const textFontSize5 =
|
|
398
|
-
props.textFontSize5 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
392
|
+
props.textFontSize5 ?? props.textFontSize ?? LineDefaults.textFontSize
|
|
399
393
|
const textColor1 =
|
|
400
|
-
props.textColor1 ?? props.textColor ?? LineDefaults.textColor
|
|
394
|
+
props.textColor1 ?? props.textColor ?? LineDefaults.textColor
|
|
401
395
|
const textColor2 =
|
|
402
|
-
props.textColor2 ?? props.textColor ?? LineDefaults.textColor
|
|
396
|
+
props.textColor2 ?? props.textColor ?? LineDefaults.textColor
|
|
403
397
|
const textColor3 =
|
|
404
|
-
props.textColor3 ?? props.textColor ?? LineDefaults.textColor
|
|
398
|
+
props.textColor3 ?? props.textColor ?? LineDefaults.textColor
|
|
405
399
|
const textColor4 =
|
|
406
|
-
props.textColor4 ?? props.textColor ?? LineDefaults.textColor
|
|
400
|
+
props.textColor4 ?? props.textColor ?? LineDefaults.textColor
|
|
407
401
|
const textColor5 =
|
|
408
|
-
props.textColor5 ?? props.textColor ?? LineDefaults.textColor
|
|
402
|
+
props.textColor5 ?? props.textColor ?? LineDefaults.textColor
|
|
409
403
|
|
|
410
|
-
const totalWidth = initialSpacing + spacing * (data0 ?? data).length
|
|
404
|
+
const totalWidth = initialSpacing + spacing * (data0 ?? data).length
|
|
411
405
|
|
|
412
406
|
const { maxItem, minItem } = computeMaxAndMinItems(
|
|
413
407
|
data0 ?? data,
|
|
414
408
|
props.roundToDigits,
|
|
415
409
|
props.showFractionalValues
|
|
416
|
-
)
|
|
410
|
+
)
|
|
417
411
|
|
|
418
412
|
const maxValue = getMaxValue(
|
|
419
413
|
props.maxValue,
|
|
420
414
|
props.stepValue,
|
|
421
415
|
noOfSections,
|
|
422
416
|
maxItem
|
|
423
|
-
)
|
|
417
|
+
)
|
|
424
418
|
|
|
425
|
-
const mostNegativeValue = props.mostNegativeValue
|
|
419
|
+
const mostNegativeValue = props.mostNegativeValue ?? minItem
|
|
426
420
|
|
|
427
|
-
const overflowTop = props.overflowTop ?? 0
|
|
421
|
+
const overflowTop = props.overflowTop ?? 0
|
|
428
422
|
|
|
429
423
|
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
430
424
|
containerHeight,
|
|
431
425
|
overflowTop
|
|
432
|
-
)
|
|
433
|
-
const getX = (index) => initialSpacing + spacing * index - 1
|
|
434
|
-
const getY = (value) =>
|
|
435
|
-
extendedContainerHeight - (value * containerHeight) / maxValue
|
|
426
|
+
)
|
|
427
|
+
const getX = (index: number): number => initialSpacing + spacing * index - 1
|
|
428
|
+
const getY = (value: number): number =>
|
|
429
|
+
extendedContainerHeight - (value * containerHeight) / maxValue
|
|
436
430
|
|
|
437
431
|
const { maxItem: secondaryMaxItem } = computeMaxAndMinItems(
|
|
438
432
|
secondaryData,
|
|
439
433
|
props.secondaryYAxis?.roundToDigits,
|
|
440
434
|
props.secondaryYAxis?.showFractionalValues
|
|
441
|
-
)
|
|
435
|
+
)
|
|
442
436
|
const secondaryMaxValue =
|
|
443
|
-
props.secondaryYAxis?.maxValue ?? (secondaryMaxItem || maxValue)
|
|
444
|
-
const getSecondaryY = (value) =>
|
|
445
|
-
extendedContainerHeight - (value * containerHeight) / secondaryMaxValue
|
|
446
|
-
const heightUptoXaxis = extendedContainerHeight - xAxisThickness
|
|
437
|
+
props.secondaryYAxis?.maxValue ?? (secondaryMaxItem || maxValue)
|
|
438
|
+
const getSecondaryY = (value: number): number =>
|
|
439
|
+
extendedContainerHeight - (value * containerHeight) / secondaryMaxValue
|
|
440
|
+
const heightUptoXaxis = extendedContainerHeight - xAxisThickness
|
|
447
441
|
|
|
448
442
|
if (animateOnDataChange) {
|
|
449
443
|
animations.forEach((item, index) => {
|
|
450
444
|
item.addListener((val) => {
|
|
451
|
-
const temp = data[index]?.value ?? 0
|
|
452
|
-
data[index].value = val.value
|
|
453
|
-
let pp =
|
|
454
|
-
|
|
445
|
+
const temp = data[index]?.value ?? 0
|
|
446
|
+
data[index].value = val.value
|
|
447
|
+
let pp = ''
|
|
448
|
+
let ppp = ''
|
|
455
449
|
if (!(dataSet?.[0].curved ?? props.curved)) {
|
|
456
450
|
for (let i = 0; i < (data0 ?? data).length; i++) {
|
|
457
|
-
pp +=
|
|
451
|
+
pp += 'L' + getX(i) + ' ' + getY((data0 ?? data)[i].value) + ' '
|
|
458
452
|
}
|
|
459
453
|
if (dataSet?.[0]?.areaChart ?? areaChart) {
|
|
460
|
-
ppp =
|
|
461
|
-
ppp += pp
|
|
454
|
+
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
455
|
+
ppp += pp
|
|
462
456
|
ppp +=
|
|
463
|
-
|
|
457
|
+
'L' +
|
|
464
458
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
465
|
-
|
|
466
|
-
heightUptoXaxis
|
|
467
|
-
ppp +=
|
|
459
|
+
' ' +
|
|
460
|
+
heightUptoXaxis
|
|
461
|
+
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
468
462
|
}
|
|
469
|
-
newPoints = pp
|
|
470
|
-
newFillPoints = ppp
|
|
471
|
-
setPointsOnChange()
|
|
463
|
+
newPoints = pp
|
|
464
|
+
newFillPoints = ppp
|
|
465
|
+
setPointsOnChange()
|
|
472
466
|
}
|
|
473
|
-
counter
|
|
474
|
-
data[index].value = temp
|
|
475
|
-
})
|
|
476
|
-
})
|
|
467
|
+
counter++
|
|
468
|
+
data[index].value = temp
|
|
469
|
+
})
|
|
470
|
+
})
|
|
477
471
|
}
|
|
478
472
|
|
|
479
|
-
const setPointsOnChange = () => {
|
|
473
|
+
const setPointsOnChange = (): void => {
|
|
480
474
|
if (counter === data.length) {
|
|
481
475
|
if (!props.curved) {
|
|
482
|
-
setPoints(newPoints.replace(
|
|
476
|
+
setPoints(newPoints.replace('L', 'M'))
|
|
483
477
|
if (areaChart) {
|
|
484
|
-
setFillPoints(newFillPoints.replace(
|
|
478
|
+
setFillPoints(newFillPoints.replace('L', 'M'))
|
|
485
479
|
}
|
|
486
480
|
}
|
|
487
481
|
}
|
|
488
|
-
}
|
|
482
|
+
}
|
|
489
483
|
|
|
490
484
|
const showValuesAsDataPointsText =
|
|
491
|
-
props.showValuesAsDataPointsText ?? LineDefaults.showValuesAsDataPointsText
|
|
485
|
+
props.showValuesAsDataPointsText ?? LineDefaults.showValuesAsDataPointsText
|
|
492
486
|
|
|
493
487
|
const thickness1 =
|
|
494
|
-
props.thickness1 ?? props.thickness ?? LineDefaults.thickness
|
|
488
|
+
props.thickness1 ?? props.thickness ?? LineDefaults.thickness
|
|
495
489
|
const thickness2 =
|
|
496
|
-
props.thickness2 ?? props.thickness ?? LineDefaults.thickness
|
|
490
|
+
props.thickness2 ?? props.thickness ?? LineDefaults.thickness
|
|
497
491
|
const thickness3 =
|
|
498
|
-
props.thickness3 ?? props.thickness ?? LineDefaults.thickness
|
|
492
|
+
props.thickness3 ?? props.thickness ?? LineDefaults.thickness
|
|
499
493
|
const thickness4 =
|
|
500
|
-
props.thickness4 ?? props.thickness ?? LineDefaults.thickness
|
|
494
|
+
props.thickness4 ?? props.thickness ?? LineDefaults.thickness
|
|
501
495
|
const thickness5 =
|
|
502
|
-
props.thickness5 ?? props.thickness ?? LineDefaults.thickness
|
|
503
|
-
|
|
504
|
-
const zIndex1 = props.zIndex1 ?? 0
|
|
505
|
-
const zIndex2 = props.zIndex2 ?? 0
|
|
506
|
-
const zIndex3 = props.zIndex3 ?? 0
|
|
507
|
-
const zIndex4 = props.zIndex4 ?? 0
|
|
508
|
-
const zIndex5 = props.zIndex5 ?? 0
|
|
509
|
-
|
|
510
|
-
const strokeDashArray1 = props.strokeDashArray1 ?? props.strokeDashArray
|
|
511
|
-
const strokeDashArray2 = props.strokeDashArray2 ?? props.strokeDashArray
|
|
512
|
-
const strokeDashArray3 = props.strokeDashArray3 ?? props.strokeDashArray
|
|
513
|
-
const strokeDashArray4 = props.strokeDashArray4 ?? props.strokeDashArray
|
|
514
|
-
const strokeDashArray5 = props.strokeDashArray5 ?? props.strokeDashArray
|
|
515
|
-
|
|
516
|
-
const rotateLabel = props.rotateLabel ?? false
|
|
517
|
-
const isAnimated = props.isAnimated ?? false
|
|
518
|
-
const hideDataPoints1 =
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const color1 = props.color1 ?? props.color ?? LineDefaults.color;
|
|
530
|
-
const color2 = props.color2 ?? props.color ?? LineDefaults.color;
|
|
531
|
-
const color3 = props.color3 ?? props.color ?? LineDefaults.color;
|
|
532
|
-
const color4 = props.color4 ?? props.color ?? LineDefaults.color;
|
|
533
|
-
const color5 = props.color5 ?? props.color ?? LineDefaults.color;
|
|
496
|
+
props.thickness5 ?? props.thickness ?? LineDefaults.thickness
|
|
497
|
+
|
|
498
|
+
const zIndex1 = props.zIndex1 ?? 0
|
|
499
|
+
const zIndex2 = props.zIndex2 ?? 0
|
|
500
|
+
const zIndex3 = props.zIndex3 ?? 0
|
|
501
|
+
const zIndex4 = props.zIndex4 ?? 0
|
|
502
|
+
const zIndex5 = props.zIndex5 ?? 0
|
|
503
|
+
|
|
504
|
+
const strokeDashArray1 = props.strokeDashArray1 ?? props.strokeDashArray
|
|
505
|
+
const strokeDashArray2 = props.strokeDashArray2 ?? props.strokeDashArray
|
|
506
|
+
const strokeDashArray3 = props.strokeDashArray3 ?? props.strokeDashArray
|
|
507
|
+
const strokeDashArray4 = props.strokeDashArray4 ?? props.strokeDashArray
|
|
508
|
+
const strokeDashArray5 = props.strokeDashArray5 ?? props.strokeDashArray
|
|
509
|
+
|
|
510
|
+
const rotateLabel = props.rotateLabel ?? false
|
|
511
|
+
const isAnimated = props.isAnimated ?? false
|
|
512
|
+
const hideDataPoints1 = props.hideDataPoints ?? props.hideDataPoints1 ?? false
|
|
513
|
+
const hideDataPoints2 = props.hideDataPoints ?? props.hideDataPoints2 ?? false
|
|
514
|
+
const hideDataPoints3 = props.hideDataPoints ?? props.hideDataPoints3 ?? false
|
|
515
|
+
const hideDataPoints4 = props.hideDataPoints ?? props.hideDataPoints4 ?? false
|
|
516
|
+
const hideDataPoints5 = props.hideDataPoints ?? props.hideDataPoints5 ?? false
|
|
517
|
+
|
|
518
|
+
const color1 = props.color1 ?? props.color ?? LineDefaults.color
|
|
519
|
+
const color2 = props.color2 ?? props.color ?? LineDefaults.color
|
|
520
|
+
const color3 = props.color3 ?? props.color ?? LineDefaults.color
|
|
521
|
+
const color4 = props.color4 ?? props.color ?? LineDefaults.color
|
|
522
|
+
const color5 = props.color5 ?? props.color ?? LineDefaults.color
|
|
534
523
|
|
|
535
524
|
const startFillColor1 =
|
|
536
|
-
props.startFillColor1 ??
|
|
537
|
-
props.startFillColor ??
|
|
538
|
-
LineDefaults.startFillColor;
|
|
525
|
+
props.startFillColor1 ?? props.startFillColor ?? LineDefaults.startFillColor
|
|
539
526
|
const endFillColor1 =
|
|
540
|
-
props.endFillColor1 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
541
|
-
const startOpacity = props.startOpacity ?? LineDefaults.startOpacity
|
|
542
|
-
const endOpacity = props.endOpacity ?? LineDefaults.endOpacity
|
|
543
|
-
const startOpacity1 = props.startOpacity1 ?? startOpacity
|
|
544
|
-
const endOpacity1 = props.endOpacity1 ?? endOpacity
|
|
527
|
+
props.endFillColor1 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
528
|
+
const startOpacity = props.startOpacity ?? LineDefaults.startOpacity
|
|
529
|
+
const endOpacity = props.endOpacity ?? LineDefaults.endOpacity
|
|
530
|
+
const startOpacity1 = props.startOpacity1 ?? startOpacity
|
|
531
|
+
const endOpacity1 = props.endOpacity1 ?? endOpacity
|
|
545
532
|
|
|
546
533
|
const startFillColor2 =
|
|
547
|
-
props.startFillColor2 ??
|
|
548
|
-
props.startFillColor ??
|
|
549
|
-
LineDefaults.startFillColor;
|
|
534
|
+
props.startFillColor2 ?? props.startFillColor ?? LineDefaults.startFillColor
|
|
550
535
|
const endFillColor2 =
|
|
551
|
-
props.endFillColor2 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
552
|
-
const startOpacity2 = props.startOpacity2 ?? startOpacity
|
|
553
|
-
const endOpacity2 = props.endOpacity2 ?? endOpacity
|
|
536
|
+
props.endFillColor2 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
537
|
+
const startOpacity2 = props.startOpacity2 ?? startOpacity
|
|
538
|
+
const endOpacity2 = props.endOpacity2 ?? endOpacity
|
|
554
539
|
|
|
555
540
|
const startFillColor3 =
|
|
556
|
-
props.startFillColor3 ??
|
|
557
|
-
props.startFillColor ??
|
|
558
|
-
LineDefaults.startFillColor;
|
|
541
|
+
props.startFillColor3 ?? props.startFillColor ?? LineDefaults.startFillColor
|
|
559
542
|
const endFillColor3 =
|
|
560
|
-
props.endFillColor3 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
561
|
-
const startOpacity3 = props.startOpacity3 ?? startOpacity
|
|
562
|
-
const endOpacity3 = props.endOpacity3 ?? endOpacity
|
|
543
|
+
props.endFillColor3 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
544
|
+
const startOpacity3 = props.startOpacity3 ?? startOpacity
|
|
545
|
+
const endOpacity3 = props.endOpacity3 ?? endOpacity
|
|
563
546
|
|
|
564
547
|
const startFillColor4 =
|
|
565
|
-
props.startFillColor4 ??
|
|
566
|
-
props.startFillColor ??
|
|
567
|
-
LineDefaults.startFillColor;
|
|
548
|
+
props.startFillColor4 ?? props.startFillColor ?? LineDefaults.startFillColor
|
|
568
549
|
const endFillColor4 =
|
|
569
|
-
props.endFillColor4 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
570
|
-
const startOpacity4 = props.startOpacity4 ?? startOpacity
|
|
571
|
-
const endOpacity4 = props.endOpacity4 ?? endOpacity
|
|
550
|
+
props.endFillColor4 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
551
|
+
const startOpacity4 = props.startOpacity4 ?? startOpacity
|
|
552
|
+
const endOpacity4 = props.endOpacity4 ?? endOpacity
|
|
572
553
|
|
|
573
554
|
const startFillColor5 =
|
|
574
|
-
props.startFillColor5 ??
|
|
575
|
-
props.startFillColor ??
|
|
576
|
-
LineDefaults.startFillColor;
|
|
555
|
+
props.startFillColor5 ?? props.startFillColor ?? LineDefaults.startFillColor
|
|
577
556
|
const endFillColor5 =
|
|
578
|
-
props.endFillColor5 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
579
|
-
const startOpacity5 = props.startOpacity5 ?? startOpacity
|
|
580
|
-
const endOpacity5 = props.endOpacity5 ?? endOpacity
|
|
557
|
+
props.endFillColor5 ?? props.endFillColor ?? LineDefaults.endFillColor
|
|
558
|
+
const startOpacity5 = props.startOpacity5 ?? startOpacity
|
|
559
|
+
const endOpacity5 = props.endOpacity5 ?? endOpacity
|
|
581
560
|
|
|
582
|
-
defaultArrowConfig.strokeWidth = dataSet?.[0]?.thickness ?? thickness1
|
|
583
|
-
defaultArrowConfig.strokeColor = dataSet?.[0]?.color ?? color1
|
|
561
|
+
defaultArrowConfig.strokeWidth = dataSet?.[0]?.thickness ?? thickness1
|
|
562
|
+
defaultArrowConfig.strokeColor = dataSet?.[0]?.color ?? color1
|
|
584
563
|
const {
|
|
585
564
|
arrowLength1,
|
|
586
565
|
arrowWidth1,
|
|
@@ -617,8 +596,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
617
596
|
arrowStrokeWidthsFromSet,
|
|
618
597
|
arrowStrokeColorsFromSet,
|
|
619
598
|
arrowFillColorsFromSet,
|
|
620
|
-
showArrowBasesFromSet
|
|
621
|
-
} = getAllArrowProperties(props, defaultArrowConfig)
|
|
599
|
+
showArrowBasesFromSet
|
|
600
|
+
} = getAllArrowProperties(props, defaultArrowConfig)
|
|
622
601
|
|
|
623
602
|
const secondaryLineConfig = {
|
|
624
603
|
zIndex: props.secondaryLineConfig?.zIndex ?? zIndex1,
|
|
@@ -656,72 +635,83 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
656
635
|
textFontSize: props.secondaryLineConfig?.textFontSize ?? textFontSize1,
|
|
657
636
|
textColor: props.secondaryLineConfig?.textColor ?? textColor1,
|
|
658
637
|
showArrow: props.secondaryLineConfig?.showArrow ?? props.showArrows,
|
|
659
|
-
arrowConfig: props.secondaryLineConfig?.arrowConfig ?? props.arrowConfig
|
|
660
|
-
}
|
|
638
|
+
arrowConfig: props.secondaryLineConfig?.arrowConfig ?? props.arrowConfig
|
|
639
|
+
}
|
|
661
640
|
|
|
662
641
|
const addLeadingAndTrailingPathForAreaFill = (
|
|
663
|
-
initialPath,
|
|
664
|
-
value,
|
|
665
|
-
dataLength
|
|
666
|
-
) => {
|
|
642
|
+
initialPath: string,
|
|
643
|
+
value: number,
|
|
644
|
+
dataLength: number
|
|
645
|
+
): string => {
|
|
667
646
|
return (
|
|
668
|
-
|
|
647
|
+
'M ' +
|
|
669
648
|
initialSpacing +
|
|
670
|
-
|
|
649
|
+
',' +
|
|
671
650
|
heightUptoXaxis +
|
|
672
|
-
|
|
673
|
-
|
|
651
|
+
' ' +
|
|
652
|
+
'L ' +
|
|
674
653
|
initialSpacing +
|
|
675
|
-
|
|
654
|
+
',' +
|
|
676
655
|
getY(value) +
|
|
677
|
-
|
|
656
|
+
' ' +
|
|
678
657
|
initialPath +
|
|
679
|
-
|
|
680
|
-
|
|
658
|
+
' ' +
|
|
659
|
+
'L ' +
|
|
681
660
|
(initialSpacing + spacing * (dataLength - 1)) +
|
|
682
|
-
|
|
661
|
+
',' +
|
|
683
662
|
heightUptoXaxis +
|
|
684
|
-
|
|
685
|
-
|
|
663
|
+
' ' +
|
|
664
|
+
'L ' +
|
|
686
665
|
initialSpacing +
|
|
687
|
-
|
|
666
|
+
',' +
|
|
688
667
|
heightUptoXaxis +
|
|
689
|
-
|
|
690
|
-
)
|
|
691
|
-
}
|
|
668
|
+
' '
|
|
669
|
+
)
|
|
670
|
+
}
|
|
692
671
|
|
|
693
|
-
const getNextPoint = (
|
|
694
|
-
|
|
672
|
+
const getNextPoint = (
|
|
673
|
+
data: lineDataItem[],
|
|
674
|
+
index: number,
|
|
675
|
+
around: boolean,
|
|
676
|
+
before: boolean
|
|
677
|
+
): string => {
|
|
678
|
+
const isLast = index === data.length - 1
|
|
695
679
|
return isLast && !(around || before)
|
|
696
|
-
?
|
|
697
|
-
:
|
|
680
|
+
? ' '
|
|
681
|
+
: ' L' +
|
|
698
682
|
(getX(index) +
|
|
699
683
|
(around ? (isLast ? 0 : spacing / 2) : before ? 0 : spacing)) +
|
|
700
|
-
|
|
684
|
+
' ' +
|
|
701
685
|
getY(data[index].value) +
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
const getStepPath = (data, i) => {
|
|
705
|
-
const around = edgePosition === EdgePosition.AROUND_DATA_POINT
|
|
706
|
-
const before = edgePosition === EdgePosition.BEFORE_DATA_POINT
|
|
686
|
+
' '
|
|
687
|
+
}
|
|
688
|
+
const getStepPath = (data: lineDataItem[], i: number): string => {
|
|
689
|
+
const around = edgePosition === EdgePosition.AROUND_DATA_POINT
|
|
690
|
+
const before = edgePosition === EdgePosition.BEFORE_DATA_POINT
|
|
707
691
|
return (
|
|
708
|
-
|
|
692
|
+
'L' +
|
|
709
693
|
(getX(i) -
|
|
710
694
|
(around && i > 0 ? spacing / 2 : before && i > 0 ? spacing : 0)) +
|
|
711
|
-
|
|
695
|
+
' ' +
|
|
712
696
|
getY(data[i].value) +
|
|
713
697
|
getNextPoint(data, i, around, before)
|
|
714
|
-
)
|
|
715
|
-
}
|
|
698
|
+
)
|
|
699
|
+
}
|
|
716
700
|
|
|
717
|
-
const getSegmentPath = (
|
|
701
|
+
const getSegmentPath = (
|
|
702
|
+
data: lineDataItem[],
|
|
703
|
+
i: number,
|
|
704
|
+
lineSegment: LineSegment[] | undefined,
|
|
705
|
+
startIndex: number,
|
|
706
|
+
endIndex: number
|
|
707
|
+
): string => {
|
|
718
708
|
let path =
|
|
719
|
-
|
|
709
|
+
'L' +
|
|
720
710
|
getX(i) +
|
|
721
|
-
|
|
711
|
+
' ' +
|
|
722
712
|
getY(data[i].value) +
|
|
723
|
-
|
|
724
|
-
getSegmentString(lineSegment, i, SEGMENT_START, SEGMENT_END)
|
|
713
|
+
' ' +
|
|
714
|
+
getSegmentString(lineSegment, i, SEGMENT_START, SEGMENT_END)
|
|
725
715
|
|
|
726
716
|
if (highlightedRange) {
|
|
727
717
|
path += getPathWithHighlight(
|
|
@@ -732,32 +722,32 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
732
722
|
endIndex,
|
|
733
723
|
getX,
|
|
734
724
|
getY
|
|
735
|
-
)
|
|
725
|
+
)
|
|
736
726
|
}
|
|
737
|
-
return path
|
|
738
|
-
}
|
|
727
|
+
return path
|
|
728
|
+
}
|
|
739
729
|
|
|
740
730
|
useEffect(() => {
|
|
741
731
|
if (dataSet) {
|
|
742
|
-
const pointsArray: string[] = []
|
|
743
|
-
const arrowPointsArray: string[] = []
|
|
744
|
-
const fillPointsArray: string[] = []
|
|
732
|
+
const pointsArray: string[] = []
|
|
733
|
+
const arrowPointsArray: string[] = []
|
|
734
|
+
const fillPointsArray: string[] = []
|
|
745
735
|
dataSet.map((set, index) => {
|
|
746
736
|
if (set.curved ?? props.curved) {
|
|
747
|
-
const pArray:
|
|
737
|
+
const pArray: number[][] = []
|
|
748
738
|
for (let i = 0; i < set.data.length; i++) {
|
|
749
739
|
if (
|
|
750
740
|
i >= (set.startIndex ?? 0) &&
|
|
751
741
|
i <= (set.endIndex ?? set.data.length - 1)
|
|
752
742
|
) {
|
|
753
|
-
pArray.push([getX(i), getY(set.data[i].value)])
|
|
743
|
+
pArray.push([getX(i), getY(set.data[i].value)])
|
|
754
744
|
}
|
|
755
745
|
}
|
|
756
746
|
let xx = svgPath(
|
|
757
747
|
pArray,
|
|
758
748
|
set.curveType ?? curveType,
|
|
759
749
|
set.curvature ?? curvature
|
|
760
|
-
)
|
|
750
|
+
)
|
|
761
751
|
pointsArray.push(
|
|
762
752
|
getCurvePathWithSegments(
|
|
763
753
|
xx,
|
|
@@ -765,46 +755,46 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
765
755
|
SEGMENT_START,
|
|
766
756
|
SEGMENT_END
|
|
767
757
|
)
|
|
768
|
-
)
|
|
758
|
+
)
|
|
769
759
|
|
|
770
760
|
// For Arrow-
|
|
771
761
|
if (set.data.length > 1 && (set.showArrow ?? props.showArrows)) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
762
|
+
const arrowTipY = pArray[pArray.length - 1][1]
|
|
763
|
+
const arrowTipX = pArray[pArray.length - 1][0]
|
|
764
|
+
const y1 = pArray[pArray.length - 2][1]
|
|
765
|
+
const x1 = pArray[pArray.length - 2][0]
|
|
776
766
|
|
|
777
|
-
|
|
767
|
+
const arrowPoints = getArrowPoints(
|
|
778
768
|
arrowTipX,
|
|
779
769
|
arrowTipY,
|
|
780
770
|
x1,
|
|
781
771
|
y1,
|
|
782
|
-
arrowLengthsFromSet[index],
|
|
783
|
-
arrowWidthsFromSet[index],
|
|
784
|
-
showArrowBasesFromSet[index]
|
|
785
|
-
)
|
|
772
|
+
arrowLengthsFromSet?.[index],
|
|
773
|
+
arrowWidthsFromSet?.[index],
|
|
774
|
+
showArrowBasesFromSet?.[index]
|
|
775
|
+
)
|
|
786
776
|
|
|
787
|
-
arrowPointsArray.push(arrowPoints)
|
|
777
|
+
arrowPointsArray.push(arrowPoints)
|
|
788
778
|
}
|
|
789
779
|
|
|
790
780
|
// For Area charts-
|
|
791
|
-
if ((set.areaChart
|
|
781
|
+
if ((set.areaChart ?? areaChart) && set.data.length > 0) {
|
|
792
782
|
xx = addLeadingAndTrailingPathForAreaFill(
|
|
793
783
|
xx,
|
|
794
784
|
set.data[0].value,
|
|
795
785
|
set.data.length
|
|
796
|
-
)
|
|
797
|
-
fillPointsArray.push(xx)
|
|
786
|
+
)
|
|
787
|
+
fillPointsArray.push(xx)
|
|
798
788
|
}
|
|
799
789
|
} else {
|
|
800
|
-
let pp =
|
|
790
|
+
let pp = ''
|
|
801
791
|
for (let i = 0; i < set.data.length; i++) {
|
|
802
792
|
if (
|
|
803
793
|
i >= (set.startIndex ?? 0) &&
|
|
804
794
|
i <= (set.endIndex ?? set.data.length - 1)
|
|
805
795
|
) {
|
|
806
|
-
if (set.stepChart
|
|
807
|
-
pp += getStepPath(set.data, i)
|
|
796
|
+
if (set.stepChart ?? stepChart) {
|
|
797
|
+
pp += getStepPath(set.data, i)
|
|
808
798
|
} else {
|
|
809
799
|
pp += getSegmentPath(
|
|
810
800
|
set.data,
|
|
@@ -812,64 +802,66 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
812
802
|
set.lineSegments,
|
|
813
803
|
set.startIndex ?? 0,
|
|
814
804
|
set.endIndex ?? set.data.length - 1
|
|
815
|
-
)
|
|
805
|
+
)
|
|
816
806
|
}
|
|
817
807
|
}
|
|
818
808
|
}
|
|
819
|
-
pointsArray.push(pp.replace(
|
|
809
|
+
pointsArray.push(pp.replace('L', 'M'))
|
|
820
810
|
|
|
821
811
|
// For Arrow-
|
|
822
812
|
if (set.data.length > 1 && (set.showArrow ?? props.showArrows)) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
ppArray[ppArray.length - 2].replace(
|
|
827
|
-
)
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
813
|
+
const ppArray = pp.trim().split(' ')
|
|
814
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
815
|
+
const arrowTipX = parseInt(
|
|
816
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
817
|
+
)
|
|
818
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
819
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
820
|
+
|
|
821
|
+
const arrowPoints = getArrowPoints(
|
|
832
822
|
arrowTipX,
|
|
833
823
|
arrowTipY,
|
|
834
824
|
x1,
|
|
835
825
|
y1,
|
|
836
|
-
arrowLengthsFromSet[index],
|
|
837
|
-
arrowWidthsFromSet[index],
|
|
838
|
-
showArrowBasesFromSet[index]
|
|
839
|
-
)
|
|
826
|
+
arrowLengthsFromSet?.[index],
|
|
827
|
+
arrowWidthsFromSet?.[index],
|
|
828
|
+
showArrowBasesFromSet?.[index]
|
|
829
|
+
)
|
|
840
830
|
|
|
841
|
-
arrowPointsArray.push(arrowPoints)
|
|
831
|
+
arrowPointsArray.push(arrowPoints)
|
|
842
832
|
}
|
|
843
833
|
|
|
844
834
|
// For Area charts-
|
|
845
|
-
if ((set.areaChart
|
|
846
|
-
let ppp =
|
|
847
|
-
ppp += pp
|
|
835
|
+
if ((set.areaChart ?? areaChart) && set.data.length > 0) {
|
|
836
|
+
let ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
837
|
+
ppp += pp
|
|
848
838
|
ppp +=
|
|
849
|
-
|
|
839
|
+
'L' +
|
|
850
840
|
(initialSpacing + spacing * (set.data.length - 1)) +
|
|
851
|
-
|
|
852
|
-
heightUptoXaxis
|
|
853
|
-
ppp +=
|
|
854
|
-
fillPointsArray.push(ppp.replace(
|
|
841
|
+
' ' +
|
|
842
|
+
heightUptoXaxis
|
|
843
|
+
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
844
|
+
fillPointsArray.push(ppp.replace('L', 'M'))
|
|
855
845
|
}
|
|
856
846
|
}
|
|
857
|
-
});
|
|
858
847
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
848
|
+
return null
|
|
849
|
+
})
|
|
850
|
+
|
|
851
|
+
setPointsFromSet(pointsArray)
|
|
852
|
+
setArrowPointsFromSet(arrowPointsArray)
|
|
853
|
+
setFillPointsFromSet(fillPointsArray)
|
|
862
854
|
} else {
|
|
863
|
-
let pp =
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
855
|
+
let pp = ''
|
|
856
|
+
let pp2 = ''
|
|
857
|
+
let pp3 = ''
|
|
858
|
+
let pp4 = ''
|
|
859
|
+
let pp5 = ''
|
|
868
860
|
if (!props.curved) {
|
|
869
861
|
for (let i = 0; i < data.length; i++) {
|
|
870
862
|
if (i >= startIndex1 && i <= endIndex1 && !animateOnDataChange) {
|
|
871
|
-
if (stepChart
|
|
872
|
-
pp += getStepPath(data, i)
|
|
863
|
+
if (stepChart ?? stepChart1) {
|
|
864
|
+
pp += getStepPath(data, i)
|
|
873
865
|
} else {
|
|
874
866
|
pp += getSegmentPath(
|
|
875
867
|
data,
|
|
@@ -877,13 +869,12 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
877
869
|
lineSegments,
|
|
878
870
|
startIndex1,
|
|
879
871
|
endIndex1
|
|
880
|
-
)
|
|
872
|
+
)
|
|
881
873
|
}
|
|
882
874
|
}
|
|
883
|
-
if (data2.length && i >= startIndex2 && i <= endIndex2) {
|
|
884
|
-
if (stepChart
|
|
885
|
-
pp2 += getStepPath(data2, i)
|
|
886
|
-
(" ");
|
|
875
|
+
if (data2.length > 0 && i >= startIndex2 && i <= endIndex2) {
|
|
876
|
+
if (stepChart ?? stepChart2) {
|
|
877
|
+
pp2 += getStepPath(data2, i)
|
|
887
878
|
} else {
|
|
888
879
|
pp2 += getSegmentPath(
|
|
889
880
|
data2,
|
|
@@ -891,12 +882,12 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
891
882
|
lineSegments2,
|
|
892
883
|
startIndex2,
|
|
893
884
|
endIndex2
|
|
894
|
-
)
|
|
885
|
+
)
|
|
895
886
|
}
|
|
896
887
|
}
|
|
897
|
-
if (data3.length && i >= startIndex3 && i <= endIndex3) {
|
|
898
|
-
if (stepChart
|
|
899
|
-
pp3 += getStepPath(data3, i)
|
|
888
|
+
if (data3.length > 0 && i >= startIndex3 && i <= endIndex3) {
|
|
889
|
+
if (stepChart ?? stepChart3) {
|
|
890
|
+
pp3 += getStepPath(data3, i)
|
|
900
891
|
} else {
|
|
901
892
|
pp3 += getSegmentPath(
|
|
902
893
|
data3,
|
|
@@ -904,12 +895,12 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
904
895
|
lineSegments3,
|
|
905
896
|
startIndex3,
|
|
906
897
|
endIndex3
|
|
907
|
-
)
|
|
898
|
+
)
|
|
908
899
|
}
|
|
909
900
|
}
|
|
910
|
-
if (data4.length && i >= startIndex4 && i <= endIndex4) {
|
|
911
|
-
if (stepChart
|
|
912
|
-
pp4 += getStepPath(data4, i)
|
|
901
|
+
if (data4.length > 0 && i >= startIndex4 && i <= endIndex4) {
|
|
902
|
+
if (stepChart ?? stepChart4) {
|
|
903
|
+
pp4 += getStepPath(data4, i)
|
|
913
904
|
} else {
|
|
914
905
|
pp4 += getSegmentPath(
|
|
915
906
|
data4,
|
|
@@ -917,12 +908,12 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
917
908
|
lineSegments4,
|
|
918
909
|
startIndex4,
|
|
919
910
|
endIndex4
|
|
920
|
-
)
|
|
911
|
+
)
|
|
921
912
|
}
|
|
922
913
|
}
|
|
923
|
-
if (data5.length && i >= startIndex5 && i <= endIndex5) {
|
|
924
|
-
if (stepChart
|
|
925
|
-
pp5 += getStepPath(data5, i)
|
|
914
|
+
if (data5.length > 0 && i >= startIndex5 && i <= endIndex5) {
|
|
915
|
+
if (stepChart ?? stepChart5) {
|
|
916
|
+
pp5 += getStepPath(data5, i)
|
|
926
917
|
} else {
|
|
927
918
|
pp5 += getSegmentPath(
|
|
928
919
|
data5,
|
|
@@ -930,27 +921,27 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
930
921
|
lineSegments5,
|
|
931
922
|
startIndex5,
|
|
932
923
|
endIndex5
|
|
933
|
-
)
|
|
924
|
+
)
|
|
934
925
|
}
|
|
935
926
|
}
|
|
936
927
|
}
|
|
937
|
-
setPoints2(pp2.replace(
|
|
938
|
-
setPoints3(pp3.replace(
|
|
939
|
-
setPoints4(pp4.replace(
|
|
940
|
-
setPoints5(pp5.replace(
|
|
941
|
-
|
|
942
|
-
setPoints(pp.replace(
|
|
943
|
-
|
|
944
|
-
if (data.length > 1 && (props.showArrow1
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
ppArray[ppArray.length - 2].replace(
|
|
949
|
-
)
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
928
|
+
setPoints2(pp2.replace('L', 'M'))
|
|
929
|
+
setPoints3(pp3.replace('L', 'M'))
|
|
930
|
+
setPoints4(pp4.replace('L', 'M'))
|
|
931
|
+
setPoints5(pp5.replace('L', 'M'))
|
|
932
|
+
|
|
933
|
+
setPoints(pp.replace('L', 'M'))
|
|
934
|
+
|
|
935
|
+
if (data.length > 1 && (props.showArrow1 ?? props.showArrows)) {
|
|
936
|
+
const ppArray = pp.trim().split(' ')
|
|
937
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
938
|
+
const arrowTipX = parseInt(
|
|
939
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
940
|
+
)
|
|
941
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
942
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
943
|
+
|
|
944
|
+
const arrowPoints = getArrowPoints(
|
|
954
945
|
arrowTipX,
|
|
955
946
|
arrowTipY,
|
|
956
947
|
x1,
|
|
@@ -958,21 +949,21 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
958
949
|
arrowLength1,
|
|
959
950
|
arrowWidth1,
|
|
960
951
|
showArrowBase1
|
|
961
|
-
)
|
|
952
|
+
)
|
|
962
953
|
|
|
963
|
-
setArrow1Points(arrowPoints)
|
|
954
|
+
setArrow1Points(arrowPoints)
|
|
964
955
|
}
|
|
965
956
|
|
|
966
|
-
if (data2.length > 1 && (props.showArrow2
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
ppArray[ppArray.length - 2].replace(
|
|
971
|
-
)
|
|
972
|
-
|
|
973
|
-
|
|
957
|
+
if (data2.length > 1 && (props.showArrow2 ?? props.showArrows)) {
|
|
958
|
+
const ppArray = pp2.trim().split(' ')
|
|
959
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
960
|
+
const arrowTipX = parseInt(
|
|
961
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
962
|
+
)
|
|
963
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
964
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
974
965
|
|
|
975
|
-
|
|
966
|
+
const arrowPoints = getArrowPoints(
|
|
976
967
|
arrowTipX,
|
|
977
968
|
arrowTipY,
|
|
978
969
|
x1,
|
|
@@ -980,21 +971,21 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
980
971
|
arrowLength2,
|
|
981
972
|
arrowWidth2,
|
|
982
973
|
showArrowBase2
|
|
983
|
-
)
|
|
974
|
+
)
|
|
984
975
|
|
|
985
|
-
setArrow2Points(arrowPoints)
|
|
976
|
+
setArrow2Points(arrowPoints)
|
|
986
977
|
}
|
|
987
978
|
|
|
988
|
-
if (data3.length > 1 && (props.showArrow3
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
ppArray[ppArray.length - 2].replace(
|
|
993
|
-
)
|
|
994
|
-
|
|
995
|
-
|
|
979
|
+
if (data3.length > 1 && (props.showArrow3 ?? props.showArrows)) {
|
|
980
|
+
const ppArray = pp3.trim().split(' ')
|
|
981
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
982
|
+
const arrowTipX = parseInt(
|
|
983
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
984
|
+
)
|
|
985
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
986
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
996
987
|
|
|
997
|
-
|
|
988
|
+
const arrowPoints = getArrowPoints(
|
|
998
989
|
arrowTipX,
|
|
999
990
|
arrowTipY,
|
|
1000
991
|
x1,
|
|
@@ -1002,21 +993,21 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1002
993
|
arrowLength3,
|
|
1003
994
|
arrowWidth3,
|
|
1004
995
|
showArrowBase3
|
|
1005
|
-
)
|
|
996
|
+
)
|
|
1006
997
|
|
|
1007
|
-
setArrow3Points(arrowPoints)
|
|
998
|
+
setArrow3Points(arrowPoints)
|
|
1008
999
|
}
|
|
1009
1000
|
|
|
1010
|
-
if (data4.length > 1 && (props.showArrow4
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
ppArray[ppArray.length - 2].replace(
|
|
1015
|
-
)
|
|
1016
|
-
|
|
1017
|
-
|
|
1001
|
+
if (data4.length > 1 && (props.showArrow4 ?? props.showArrows)) {
|
|
1002
|
+
const ppArray = pp4.trim().split(' ')
|
|
1003
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
1004
|
+
const arrowTipX = parseInt(
|
|
1005
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
1006
|
+
)
|
|
1007
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
1008
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
1018
1009
|
|
|
1019
|
-
|
|
1010
|
+
const arrowPoints = getArrowPoints(
|
|
1020
1011
|
arrowTipX,
|
|
1021
1012
|
arrowTipY,
|
|
1022
1013
|
x1,
|
|
@@ -1024,21 +1015,21 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1024
1015
|
arrowLength4,
|
|
1025
1016
|
arrowWidth4,
|
|
1026
1017
|
showArrowBase4
|
|
1027
|
-
)
|
|
1018
|
+
)
|
|
1028
1019
|
|
|
1029
|
-
setArrow4Points(arrowPoints)
|
|
1020
|
+
setArrow4Points(arrowPoints)
|
|
1030
1021
|
}
|
|
1031
1022
|
|
|
1032
|
-
if (data5.length > 1 && (props.showArrow5
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
ppArray[ppArray.length - 2].replace(
|
|
1037
|
-
)
|
|
1038
|
-
|
|
1039
|
-
|
|
1023
|
+
if (data5.length > 1 && (props.showArrow5 ?? props.showArrows)) {
|
|
1024
|
+
const ppArray = pp5.trim().split(' ')
|
|
1025
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
1026
|
+
const arrowTipX = parseInt(
|
|
1027
|
+
ppArray[ppArray.length - 2].replace('L', '')
|
|
1028
|
+
)
|
|
1029
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
1030
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
1040
1031
|
|
|
1041
|
-
|
|
1032
|
+
const arrowPoints = getArrowPoints(
|
|
1042
1033
|
arrowTipX,
|
|
1043
1034
|
arrowTipY,
|
|
1044
1035
|
x1,
|
|
@@ -1046,117 +1037,117 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1046
1037
|
arrowLength5,
|
|
1047
1038
|
arrowWidth5,
|
|
1048
1039
|
showArrowBase5
|
|
1049
|
-
)
|
|
1040
|
+
)
|
|
1050
1041
|
|
|
1051
|
-
setArrow5Points(arrowPoints)
|
|
1042
|
+
setArrow5Points(arrowPoints)
|
|
1052
1043
|
}
|
|
1053
1044
|
|
|
1054
|
-
|
|
1045
|
+
/** ************************* For Area Charts *************************/
|
|
1055
1046
|
if (atLeastOneAreaChart) {
|
|
1056
|
-
let ppp =
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1047
|
+
let ppp = ''
|
|
1048
|
+
let ppp2 = ''
|
|
1049
|
+
let ppp3 = ''
|
|
1050
|
+
let ppp4 = ''
|
|
1051
|
+
let ppp5 = ''
|
|
1061
1052
|
|
|
1062
1053
|
if (
|
|
1063
|
-
(areaChart
|
|
1064
|
-
data.length &&
|
|
1054
|
+
(areaChart ?? areaChart1) &&
|
|
1055
|
+
data.length > 0 &&
|
|
1065
1056
|
!animateOnDataChange
|
|
1066
1057
|
) {
|
|
1067
|
-
ppp =
|
|
1068
|
-
ppp += pp
|
|
1058
|
+
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1059
|
+
ppp += pp
|
|
1069
1060
|
ppp +=
|
|
1070
|
-
|
|
1061
|
+
'L' +
|
|
1071
1062
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
1072
|
-
|
|
1073
|
-
heightUptoXaxis
|
|
1074
|
-
ppp +=
|
|
1075
|
-
setFillPoints(ppp.replace(
|
|
1063
|
+
' ' +
|
|
1064
|
+
heightUptoXaxis
|
|
1065
|
+
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1066
|
+
setFillPoints(ppp.replace('L', 'M'))
|
|
1076
1067
|
}
|
|
1077
1068
|
|
|
1078
|
-
if ((areaChart
|
|
1079
|
-
ppp2 =
|
|
1080
|
-
ppp2 += pp2
|
|
1069
|
+
if ((areaChart ?? areaChart2) && data2.length > 0) {
|
|
1070
|
+
ppp2 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1071
|
+
ppp2 += pp2
|
|
1081
1072
|
ppp2 +=
|
|
1082
|
-
|
|
1073
|
+
'L' +
|
|
1083
1074
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
1084
|
-
|
|
1085
|
-
heightUptoXaxis
|
|
1086
|
-
ppp2 +=
|
|
1087
|
-
setFillPoints2(ppp2.replace(
|
|
1075
|
+
' ' +
|
|
1076
|
+
heightUptoXaxis
|
|
1077
|
+
ppp2 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1078
|
+
setFillPoints2(ppp2.replace('L', 'M'))
|
|
1088
1079
|
}
|
|
1089
1080
|
|
|
1090
|
-
if ((areaChart
|
|
1091
|
-
ppp3 =
|
|
1092
|
-
ppp3 += pp3
|
|
1081
|
+
if ((areaChart ?? areaChart3) && data3.length > 0) {
|
|
1082
|
+
ppp3 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1083
|
+
ppp3 += pp3
|
|
1093
1084
|
ppp3 +=
|
|
1094
|
-
|
|
1085
|
+
'L' +
|
|
1095
1086
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
1096
|
-
|
|
1097
|
-
heightUptoXaxis
|
|
1098
|
-
ppp3 +=
|
|
1099
|
-
setFillPoints3(ppp3.replace(
|
|
1087
|
+
' ' +
|
|
1088
|
+
heightUptoXaxis
|
|
1089
|
+
ppp3 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1090
|
+
setFillPoints3(ppp3.replace('L', 'M'))
|
|
1100
1091
|
}
|
|
1101
|
-
if ((areaChart
|
|
1102
|
-
ppp4 =
|
|
1103
|
-
ppp4 += pp4
|
|
1092
|
+
if ((areaChart ?? areaChart4) && data4.length > 0) {
|
|
1093
|
+
ppp4 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1094
|
+
ppp4 += pp4
|
|
1104
1095
|
ppp4 +=
|
|
1105
|
-
|
|
1096
|
+
'L' +
|
|
1106
1097
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
1107
|
-
|
|
1108
|
-
heightUptoXaxis
|
|
1109
|
-
ppp4 +=
|
|
1110
|
-
setFillPoints4(ppp4.replace(
|
|
1098
|
+
' ' +
|
|
1099
|
+
heightUptoXaxis
|
|
1100
|
+
ppp4 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1101
|
+
setFillPoints4(ppp4.replace('L', 'M'))
|
|
1111
1102
|
}
|
|
1112
1103
|
|
|
1113
|
-
if ((areaChart
|
|
1114
|
-
ppp5 =
|
|
1115
|
-
ppp5 += pp5
|
|
1104
|
+
if ((areaChart ?? areaChart5) && data5.length > 0) {
|
|
1105
|
+
ppp5 = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1106
|
+
ppp5 += pp5
|
|
1116
1107
|
ppp5 +=
|
|
1117
|
-
|
|
1108
|
+
'L' +
|
|
1118
1109
|
(initialSpacing + spacing * (data.length - 1)) +
|
|
1119
|
-
|
|
1120
|
-
heightUptoXaxis
|
|
1121
|
-
ppp5 +=
|
|
1122
|
-
setFillPoints5(ppp5.replace(
|
|
1110
|
+
' ' +
|
|
1111
|
+
heightUptoXaxis
|
|
1112
|
+
ppp5 += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1113
|
+
setFillPoints5(ppp5.replace('L', 'M'))
|
|
1123
1114
|
}
|
|
1124
1115
|
}
|
|
1125
1116
|
|
|
1126
1117
|
/*************************************************************************************/
|
|
1127
1118
|
} else {
|
|
1128
|
-
const p1Array:
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1119
|
+
const p1Array: number[][] = []
|
|
1120
|
+
const p2Array: number[][] = []
|
|
1121
|
+
const p3Array: number[][] = []
|
|
1122
|
+
const p4Array: number[][] = []
|
|
1123
|
+
const p5Array: number[][] = []
|
|
1133
1124
|
for (let i = 0; i < data.length; i++) {
|
|
1134
1125
|
if (i >= startIndex1 && i <= endIndex1) {
|
|
1135
|
-
p1Array.push([getX(i), getY(data[i].value)])
|
|
1126
|
+
p1Array.push([getX(i), getY(data[i].value)])
|
|
1136
1127
|
}
|
|
1137
|
-
if (data2.length && i >= startIndex2 && i <= endIndex2) {
|
|
1138
|
-
p2Array.push([getX(i), getY(data2[i].value)])
|
|
1128
|
+
if (data2.length > 0 && i >= startIndex2 && i <= endIndex2) {
|
|
1129
|
+
p2Array.push([getX(i), getY(data2[i].value)])
|
|
1139
1130
|
}
|
|
1140
|
-
if (data3.length && i >= startIndex3 && i <= endIndex3) {
|
|
1141
|
-
p3Array.push([getX(i), getY(data3[i].value)])
|
|
1131
|
+
if (data3.length > 0 && i >= startIndex3 && i <= endIndex3) {
|
|
1132
|
+
p3Array.push([getX(i), getY(data3[i].value)])
|
|
1142
1133
|
}
|
|
1143
|
-
if (data4.length && i >= startIndex4 && i <= endIndex4) {
|
|
1144
|
-
p4Array.push([getX(i), getY(data4[i].value)])
|
|
1134
|
+
if (data4.length > 0 && i >= startIndex4 && i <= endIndex4) {
|
|
1135
|
+
p4Array.push([getX(i), getY(data4[i].value)])
|
|
1145
1136
|
}
|
|
1146
|
-
if (data5.length && i >= startIndex5 && i <= endIndex5) {
|
|
1147
|
-
p5Array.push([getX(i), getY(data5[i].value)])
|
|
1137
|
+
if (data5.length > 0 && i >= startIndex5 && i <= endIndex5) {
|
|
1138
|
+
p5Array.push([getX(i), getY(data5[i].value)])
|
|
1148
1139
|
}
|
|
1149
1140
|
}
|
|
1150
1141
|
|
|
1151
|
-
let xx = svgPath(p1Array, curveType, curvature)
|
|
1152
|
-
let xx2 = svgPath(p2Array, curveType, curvature)
|
|
1153
|
-
let xx3 = svgPath(p3Array, curveType, curvature)
|
|
1154
|
-
let xx4 = svgPath(p4Array, curveType, curvature)
|
|
1155
|
-
let xx5 = svgPath(p5Array, curveType, curvature)
|
|
1142
|
+
let xx = svgPath(p1Array, curveType, curvature)
|
|
1143
|
+
let xx2 = svgPath(p2Array, curveType, curvature)
|
|
1144
|
+
let xx3 = svgPath(p3Array, curveType, curvature)
|
|
1145
|
+
let xx4 = svgPath(p4Array, curveType, curvature)
|
|
1146
|
+
let xx5 = svgPath(p5Array, curveType, curvature)
|
|
1156
1147
|
|
|
1157
1148
|
setPoints(
|
|
1158
1149
|
getCurvePathWithSegments(xx, lineSegments, SEGMENT_START, SEGMENT_END)
|
|
1159
|
-
)
|
|
1150
|
+
)
|
|
1160
1151
|
setPoints2(
|
|
1161
1152
|
getCurvePathWithSegments(
|
|
1162
1153
|
xx2,
|
|
@@ -1164,7 +1155,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1164
1155
|
SEGMENT_START,
|
|
1165
1156
|
SEGMENT_END
|
|
1166
1157
|
)
|
|
1167
|
-
)
|
|
1158
|
+
)
|
|
1168
1159
|
setPoints3(
|
|
1169
1160
|
getCurvePathWithSegments(
|
|
1170
1161
|
xx3,
|
|
@@ -1172,7 +1163,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1172
1163
|
SEGMENT_START,
|
|
1173
1164
|
SEGMENT_END
|
|
1174
1165
|
)
|
|
1175
|
-
)
|
|
1166
|
+
)
|
|
1176
1167
|
setPoints4(
|
|
1177
1168
|
getCurvePathWithSegments(
|
|
1178
1169
|
xx4,
|
|
@@ -1180,7 +1171,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1180
1171
|
SEGMENT_START,
|
|
1181
1172
|
SEGMENT_END
|
|
1182
1173
|
)
|
|
1183
|
-
)
|
|
1174
|
+
)
|
|
1184
1175
|
setPoints5(
|
|
1185
1176
|
getCurvePathWithSegments(
|
|
1186
1177
|
xx5,
|
|
@@ -1188,15 +1179,15 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1188
1179
|
SEGMENT_START,
|
|
1189
1180
|
SEGMENT_END
|
|
1190
1181
|
)
|
|
1191
|
-
)
|
|
1182
|
+
)
|
|
1192
1183
|
|
|
1193
|
-
if (data.length > 1 && (props.showArrow1
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1184
|
+
if (data.length > 1 && (props.showArrow1 ?? props.showArrows)) {
|
|
1185
|
+
const arrowTipY = p1Array[p1Array.length - 1][1]
|
|
1186
|
+
const arrowTipX = p1Array[p1Array.length - 1][0]
|
|
1187
|
+
const y1 = p1Array[p1Array.length - 2][1]
|
|
1188
|
+
const x1 = p1Array[p1Array.length - 2][0]
|
|
1198
1189
|
|
|
1199
|
-
|
|
1190
|
+
const arrowPoints = getArrowPoints(
|
|
1200
1191
|
arrowTipX,
|
|
1201
1192
|
arrowTipY,
|
|
1202
1193
|
x1,
|
|
@@ -1204,18 +1195,18 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1204
1195
|
arrowLength1,
|
|
1205
1196
|
arrowWidth1,
|
|
1206
1197
|
showArrowBase1
|
|
1207
|
-
)
|
|
1198
|
+
)
|
|
1208
1199
|
|
|
1209
|
-
setArrow1Points(arrowPoints)
|
|
1200
|
+
setArrow1Points(arrowPoints)
|
|
1210
1201
|
}
|
|
1211
1202
|
|
|
1212
|
-
if (data2.length > 1 && (props.showArrow2
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1203
|
+
if (data2.length > 1 && (props.showArrow2 ?? props.showArrows)) {
|
|
1204
|
+
const arrowTipY = p2Array[p2Array.length - 1][1]
|
|
1205
|
+
const arrowTipX = p2Array[p2Array.length - 1][0]
|
|
1206
|
+
const y1 = p2Array[p2Array.length - 2][1]
|
|
1207
|
+
const x1 = p2Array[p2Array.length - 2][0]
|
|
1217
1208
|
|
|
1218
|
-
|
|
1209
|
+
const arrowPoints = getArrowPoints(
|
|
1219
1210
|
arrowTipX,
|
|
1220
1211
|
arrowTipY,
|
|
1221
1212
|
x1,
|
|
@@ -1223,18 +1214,18 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1223
1214
|
arrowLength2,
|
|
1224
1215
|
arrowWidth2,
|
|
1225
1216
|
showArrowBase2
|
|
1226
|
-
)
|
|
1217
|
+
)
|
|
1227
1218
|
|
|
1228
|
-
setArrow2Points(arrowPoints)
|
|
1219
|
+
setArrow2Points(arrowPoints)
|
|
1229
1220
|
}
|
|
1230
1221
|
|
|
1231
|
-
if (data3.length > 1 && (props.showArrow3
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1222
|
+
if (data3.length > 1 && (props.showArrow3 ?? props.showArrows)) {
|
|
1223
|
+
const arrowTipY = p3Array[p3Array.length - 1][1]
|
|
1224
|
+
const arrowTipX = p3Array[p3Array.length - 1][0]
|
|
1225
|
+
const y1 = p3Array[p3Array.length - 2][1]
|
|
1226
|
+
const x1 = p3Array[p3Array.length - 2][0]
|
|
1236
1227
|
|
|
1237
|
-
|
|
1228
|
+
const arrowPoints = getArrowPoints(
|
|
1238
1229
|
arrowTipX,
|
|
1239
1230
|
arrowTipY,
|
|
1240
1231
|
x1,
|
|
@@ -1242,18 +1233,18 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1242
1233
|
arrowLength3,
|
|
1243
1234
|
arrowWidth3,
|
|
1244
1235
|
showArrowBase3
|
|
1245
|
-
)
|
|
1236
|
+
)
|
|
1246
1237
|
|
|
1247
|
-
setArrow2Points(arrowPoints)
|
|
1238
|
+
setArrow2Points(arrowPoints)
|
|
1248
1239
|
}
|
|
1249
1240
|
|
|
1250
|
-
if (data4.length > 1 && (props.showArrow4
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1241
|
+
if (data4.length > 1 && (props.showArrow4 ?? props.showArrows)) {
|
|
1242
|
+
const arrowTipY = p4Array[p4Array.length - 1][1]
|
|
1243
|
+
const arrowTipX = p4Array[p4Array.length - 1][0]
|
|
1244
|
+
const y1 = p4Array[p4Array.length - 2][1]
|
|
1245
|
+
const x1 = p4Array[p4Array.length - 2][0]
|
|
1255
1246
|
|
|
1256
|
-
|
|
1247
|
+
const arrowPoints = getArrowPoints(
|
|
1257
1248
|
arrowTipX,
|
|
1258
1249
|
arrowTipY,
|
|
1259
1250
|
x1,
|
|
@@ -1261,18 +1252,18 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1261
1252
|
arrowLength4,
|
|
1262
1253
|
arrowWidth4,
|
|
1263
1254
|
showArrowBase4
|
|
1264
|
-
)
|
|
1255
|
+
)
|
|
1265
1256
|
|
|
1266
|
-
setArrow2Points(arrowPoints)
|
|
1257
|
+
setArrow2Points(arrowPoints)
|
|
1267
1258
|
}
|
|
1268
1259
|
|
|
1269
|
-
if (data5.length > 1 && (props.showArrow5
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1260
|
+
if (data5.length > 1 && (props.showArrow5 ?? props.showArrows)) {
|
|
1261
|
+
const arrowTipY = p5Array[p5Array.length - 1][1]
|
|
1262
|
+
const arrowTipX = p5Array[p5Array.length - 1][0]
|
|
1263
|
+
const y1 = p5Array[p5Array.length - 2][1]
|
|
1264
|
+
const x1 = p5Array[p5Array.length - 2][0]
|
|
1274
1265
|
|
|
1275
|
-
|
|
1266
|
+
const arrowPoints = getArrowPoints(
|
|
1276
1267
|
arrowTipX,
|
|
1277
1268
|
arrowTipY,
|
|
1278
1269
|
x1,
|
|
@@ -1280,57 +1271,57 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1280
1271
|
arrowLength5,
|
|
1281
1272
|
arrowWidth5,
|
|
1282
1273
|
showArrowBase5
|
|
1283
|
-
)
|
|
1274
|
+
)
|
|
1284
1275
|
|
|
1285
|
-
setArrow2Points(arrowPoints)
|
|
1276
|
+
setArrow2Points(arrowPoints)
|
|
1286
1277
|
}
|
|
1287
1278
|
|
|
1288
|
-
|
|
1279
|
+
/** ************************* For Area Charts *************************/
|
|
1289
1280
|
|
|
1290
1281
|
if (atLeastOneAreaChart) {
|
|
1291
|
-
if ((areaChart
|
|
1282
|
+
if ((areaChart ?? areaChart1) && data.length > 0) {
|
|
1292
1283
|
xx = addLeadingAndTrailingPathForAreaFill(
|
|
1293
1284
|
xx,
|
|
1294
1285
|
data[0].value,
|
|
1295
1286
|
data.length
|
|
1296
|
-
)
|
|
1297
|
-
setFillPoints(xx)
|
|
1287
|
+
)
|
|
1288
|
+
setFillPoints(xx)
|
|
1298
1289
|
}
|
|
1299
1290
|
|
|
1300
|
-
if ((areaChart
|
|
1291
|
+
if ((areaChart ?? areaChart2) && data2.length > 0) {
|
|
1301
1292
|
xx2 = addLeadingAndTrailingPathForAreaFill(
|
|
1302
1293
|
xx2,
|
|
1303
1294
|
data2[0].value,
|
|
1304
1295
|
data2.length
|
|
1305
|
-
)
|
|
1306
|
-
setFillPoints2(xx2)
|
|
1296
|
+
)
|
|
1297
|
+
setFillPoints2(xx2)
|
|
1307
1298
|
}
|
|
1308
1299
|
|
|
1309
|
-
if ((areaChart
|
|
1300
|
+
if ((areaChart ?? areaChart3) && data3.length > 0) {
|
|
1310
1301
|
xx3 = addLeadingAndTrailingPathForAreaFill(
|
|
1311
1302
|
xx3,
|
|
1312
1303
|
data3[0].value,
|
|
1313
1304
|
data3.length
|
|
1314
|
-
)
|
|
1315
|
-
setFillPoints3(xx3)
|
|
1305
|
+
)
|
|
1306
|
+
setFillPoints3(xx3)
|
|
1316
1307
|
}
|
|
1317
1308
|
|
|
1318
|
-
if ((areaChart
|
|
1309
|
+
if ((areaChart ?? areaChart4) && data4.length > 0) {
|
|
1319
1310
|
xx4 = addLeadingAndTrailingPathForAreaFill(
|
|
1320
1311
|
xx4,
|
|
1321
1312
|
data4[0].value,
|
|
1322
1313
|
data4.length
|
|
1323
|
-
)
|
|
1324
|
-
setFillPoints4(xx4)
|
|
1314
|
+
)
|
|
1315
|
+
setFillPoints4(xx4)
|
|
1325
1316
|
}
|
|
1326
1317
|
|
|
1327
|
-
if ((areaChart
|
|
1318
|
+
if ((areaChart ?? areaChart5) && data5.length > 0) {
|
|
1328
1319
|
xx5 = addLeadingAndTrailingPathForAreaFill(
|
|
1329
1320
|
xx5,
|
|
1330
1321
|
data5[0].value,
|
|
1331
1322
|
data5.length
|
|
1332
|
-
)
|
|
1333
|
-
setFillPoints5(xx5)
|
|
1323
|
+
)
|
|
1324
|
+
setFillPoints5(xx5)
|
|
1334
1325
|
}
|
|
1335
1326
|
}
|
|
1336
1327
|
|
|
@@ -1389,11 +1380,11 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1389
1380
|
showArrowBase4,
|
|
1390
1381
|
arrowLength5,
|
|
1391
1382
|
arrowWidth5,
|
|
1392
|
-
showArrowBase5
|
|
1393
|
-
])
|
|
1383
|
+
showArrowBase5
|
|
1384
|
+
])
|
|
1394
1385
|
|
|
1395
1386
|
useEffect(() => {
|
|
1396
|
-
let pp =
|
|
1387
|
+
let pp = ''
|
|
1397
1388
|
if (!secondaryLineConfig.curved) {
|
|
1398
1389
|
for (let i = 0; i < secondaryData.length; i++) {
|
|
1399
1390
|
if (
|
|
@@ -1402,20 +1393,20 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1402
1393
|
!animateOnDataChange
|
|
1403
1394
|
) {
|
|
1404
1395
|
pp +=
|
|
1405
|
-
|
|
1396
|
+
'L' + getX(i) + ' ' + getSecondaryY(secondaryData[i].value) + ' '
|
|
1406
1397
|
}
|
|
1407
1398
|
}
|
|
1408
1399
|
|
|
1409
|
-
setSecondaryPoints(pp.replace(
|
|
1400
|
+
setSecondaryPoints(pp.replace('L', 'M'))
|
|
1410
1401
|
|
|
1411
1402
|
if (secondaryData.length > 1 && secondaryLineConfig.showArrow) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1403
|
+
const ppArray = pp.trim().split(' ')
|
|
1404
|
+
const arrowTipY = parseInt(ppArray[ppArray.length - 1])
|
|
1405
|
+
const arrowTipX = parseInt(ppArray[ppArray.length - 2].replace('L', ''))
|
|
1406
|
+
const y1 = parseInt(ppArray[ppArray.length - 3])
|
|
1407
|
+
const x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''))
|
|
1417
1408
|
|
|
1418
|
-
|
|
1409
|
+
const arrowPoints = getArrowPoints(
|
|
1419
1410
|
arrowTipX,
|
|
1420
1411
|
arrowTipY,
|
|
1421
1412
|
x1,
|
|
@@ -1423,36 +1414,36 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1423
1414
|
secondaryLineConfig.arrowConfig?.length,
|
|
1424
1415
|
secondaryLineConfig.arrowConfig?.width,
|
|
1425
1416
|
secondaryLineConfig.arrowConfig?.showArrowBase
|
|
1426
|
-
)
|
|
1417
|
+
)
|
|
1427
1418
|
|
|
1428
|
-
setSecondaryArrowPoints(arrowPoints)
|
|
1419
|
+
setSecondaryArrowPoints(arrowPoints)
|
|
1429
1420
|
}
|
|
1430
1421
|
|
|
1431
|
-
|
|
1422
|
+
/** ************************* For Area Chart *************************/
|
|
1432
1423
|
if (secondaryLineConfig.areaChart) {
|
|
1433
|
-
let ppp =
|
|
1424
|
+
let ppp = ''
|
|
1434
1425
|
|
|
1435
|
-
if (secondaryData.length && !animateOnDataChange) {
|
|
1436
|
-
ppp =
|
|
1437
|
-
ppp += pp
|
|
1426
|
+
if (secondaryData.length > 0 && !animateOnDataChange) {
|
|
1427
|
+
ppp = 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1428
|
+
ppp += pp
|
|
1438
1429
|
ppp +=
|
|
1439
|
-
|
|
1430
|
+
'L' +
|
|
1440
1431
|
(initialSpacing + spacing * (secondaryData.length - 1)) +
|
|
1441
|
-
|
|
1442
|
-
heightUptoXaxis
|
|
1443
|
-
ppp +=
|
|
1444
|
-
setSecondaryFillPoints(ppp.replace(
|
|
1432
|
+
' ' +
|
|
1433
|
+
heightUptoXaxis
|
|
1434
|
+
ppp += 'L' + initialSpacing + ' ' + heightUptoXaxis + ' '
|
|
1435
|
+
setSecondaryFillPoints(ppp.replace('L', 'M'))
|
|
1445
1436
|
}
|
|
1446
1437
|
}
|
|
1447
1438
|
} else {
|
|
1448
|
-
|
|
1449
|
-
const p1Array:
|
|
1439
|
+
/** ************************* For Curved Charts *************************/
|
|
1440
|
+
const p1Array: number[][] = []
|
|
1450
1441
|
for (let i = 0; i < secondaryData.length; i++) {
|
|
1451
1442
|
if (
|
|
1452
1443
|
i >= secondaryLineConfig.startIndex &&
|
|
1453
1444
|
i <= secondaryLineConfig.endIndex
|
|
1454
1445
|
) {
|
|
1455
|
-
p1Array.push([getX(i), getSecondaryY(secondaryData[i].value)])
|
|
1446
|
+
p1Array.push([getX(i), getSecondaryY(secondaryData[i].value)])
|
|
1456
1447
|
}
|
|
1457
1448
|
}
|
|
1458
1449
|
|
|
@@ -1460,17 +1451,17 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1460
1451
|
p1Array,
|
|
1461
1452
|
secondaryLineConfig.curveType,
|
|
1462
1453
|
secondaryLineConfig.curvature
|
|
1463
|
-
)
|
|
1454
|
+
)
|
|
1464
1455
|
|
|
1465
|
-
setSecondaryPoints(xx)
|
|
1456
|
+
setSecondaryPoints(xx)
|
|
1466
1457
|
|
|
1467
|
-
if (secondaryData.length > 1 && (props.showArrow1
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1458
|
+
if (secondaryData.length > 1 && (props.showArrow1 ?? props.showArrows)) {
|
|
1459
|
+
const arrowTipY = p1Array[p1Array.length - 1][1]
|
|
1460
|
+
const arrowTipX = p1Array[p1Array.length - 1][0]
|
|
1461
|
+
const y1 = p1Array[p1Array.length - 2][1]
|
|
1462
|
+
const x1 = p1Array[p1Array.length - 2][0]
|
|
1472
1463
|
|
|
1473
|
-
|
|
1464
|
+
const arrowPoints = getArrowPoints(
|
|
1474
1465
|
arrowTipX,
|
|
1475
1466
|
arrowTipY,
|
|
1476
1467
|
x1,
|
|
@@ -1478,233 +1469,226 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1478
1469
|
arrowLength1,
|
|
1479
1470
|
arrowWidth1,
|
|
1480
1471
|
showArrowBase1
|
|
1481
|
-
)
|
|
1472
|
+
)
|
|
1482
1473
|
|
|
1483
|
-
setSecondaryArrowPoints(arrowPoints)
|
|
1474
|
+
setSecondaryArrowPoints(arrowPoints)
|
|
1484
1475
|
}
|
|
1485
1476
|
|
|
1486
|
-
|
|
1477
|
+
/** ************************* For Curved Area Charts *************************/
|
|
1487
1478
|
|
|
1488
1479
|
if (secondaryLineConfig.areaChart) {
|
|
1489
|
-
if (secondaryData.length) {
|
|
1480
|
+
if (secondaryData.length > 0) {
|
|
1490
1481
|
xx = addLeadingAndTrailingPathForAreaFill(
|
|
1491
1482
|
xx,
|
|
1492
1483
|
secondaryData[0].value,
|
|
1493
1484
|
secondaryData.length
|
|
1494
|
-
)
|
|
1495
|
-
setSecondaryFillPoints(xx)
|
|
1485
|
+
)
|
|
1486
|
+
setSecondaryFillPoints(xx)
|
|
1496
1487
|
}
|
|
1497
1488
|
}
|
|
1498
1489
|
}
|
|
1499
|
-
}, [secondaryData, secondaryLineConfig])
|
|
1490
|
+
}, [secondaryData, secondaryLineConfig])
|
|
1500
1491
|
|
|
1501
|
-
const gradientDirection = props.gradientDirection ??
|
|
1502
|
-
const horizSections = [{ value:
|
|
1503
|
-
const stepHeight = props.stepHeight
|
|
1504
|
-
const stepValue = props.stepValue
|
|
1492
|
+
const gradientDirection = props.gradientDirection ?? 'vertical'
|
|
1493
|
+
const horizSections = [{ value: '0' }]
|
|
1494
|
+
const stepHeight = props.stepHeight ?? containerHeight / noOfSections
|
|
1495
|
+
const stepValue = props.stepValue ?? maxValue / noOfSections
|
|
1505
1496
|
const noOfSectionsBelowXAxis =
|
|
1506
|
-
props.noOfSectionsBelowXAxis ?? -mostNegativeValue / (stepValue || 1)
|
|
1497
|
+
props.noOfSectionsBelowXAxis ?? -mostNegativeValue / (stepValue || 1)
|
|
1507
1498
|
|
|
1508
1499
|
const showXAxisIndices =
|
|
1509
|
-
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
|
|
1500
|
+
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
|
|
1510
1501
|
const xAxisIndicesHeight =
|
|
1511
|
-
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
|
|
1502
|
+
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
|
|
1512
1503
|
const xAxisIndicesWidth =
|
|
1513
|
-
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
|
|
1504
|
+
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
|
|
1514
1505
|
const xAxisIndicesColor =
|
|
1515
|
-
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
|
|
1506
|
+
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
|
|
1516
1507
|
|
|
1517
1508
|
const xAxisTextNumberOfLines =
|
|
1518
|
-
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
|
|
1509
|
+
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
|
|
1519
1510
|
const xAxisLabelsVerticalShift =
|
|
1520
1511
|
props.xAxisLabelsVerticalShift ??
|
|
1521
|
-
AxesAndRulesDefaults.xAxisLabelsVerticalShift
|
|
1522
|
-
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
1512
|
+
AxesAndRulesDefaults.xAxisLabelsVerticalShift
|
|
1513
|
+
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
1523
1514
|
const showFractionalValues =
|
|
1524
|
-
props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues
|
|
1515
|
+
props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues
|
|
1525
1516
|
|
|
1526
|
-
const horizontal = false
|
|
1527
|
-
const yAxisAtTop = false
|
|
1517
|
+
const horizontal = false
|
|
1518
|
+
const yAxisAtTop = false
|
|
1528
1519
|
|
|
1529
|
-
defaultPointerConfig.pointerStripHeight = containerHeight
|
|
1520
|
+
defaultPointerConfig.pointerStripHeight = containerHeight
|
|
1530
1521
|
|
|
1531
|
-
const pointerConfig = props.pointerConfig
|
|
1532
|
-
const getPointerProps = props.getPointerProps
|
|
1533
|
-
const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height
|
|
1534
|
-
const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width
|
|
1535
|
-
const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius
|
|
1522
|
+
const pointerConfig = props.pointerConfig
|
|
1523
|
+
const getPointerProps = props.getPointerProps ?? null
|
|
1524
|
+
const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height
|
|
1525
|
+
const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width
|
|
1526
|
+
const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius
|
|
1536
1527
|
const pointerColor =
|
|
1537
|
-
pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor
|
|
1528
|
+
pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor
|
|
1538
1529
|
const pointerComponent =
|
|
1539
|
-
pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent
|
|
1530
|
+
pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent
|
|
1540
1531
|
|
|
1541
1532
|
const showPointerStrip =
|
|
1542
1533
|
pointerConfig?.showPointerStrip === false
|
|
1543
1534
|
? false
|
|
1544
|
-
: defaultPointerConfig.showPointerStrip
|
|
1535
|
+
: defaultPointerConfig.showPointerStrip
|
|
1545
1536
|
const pointerStripHeight =
|
|
1546
|
-
pointerConfig?.pointerStripHeight ??
|
|
1547
|
-
defaultPointerConfig.pointerStripHeight;
|
|
1537
|
+
pointerConfig?.pointerStripHeight ?? defaultPointerConfig.pointerStripHeight
|
|
1548
1538
|
const pointerStripWidth =
|
|
1549
|
-
pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth
|
|
1539
|
+
pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth
|
|
1550
1540
|
const pointerStripColor =
|
|
1551
|
-
pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor
|
|
1541
|
+
pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor
|
|
1552
1542
|
const pointerStripUptoDataPoint =
|
|
1553
1543
|
pointerConfig?.pointerStripUptoDataPoint ??
|
|
1554
|
-
defaultPointerConfig.pointerStripUptoDataPoint
|
|
1544
|
+
defaultPointerConfig.pointerStripUptoDataPoint
|
|
1555
1545
|
const pointerLabelComponent =
|
|
1556
1546
|
pointerConfig?.pointerLabelComponent ??
|
|
1557
|
-
defaultPointerConfig.pointerLabelComponent
|
|
1547
|
+
defaultPointerConfig.pointerLabelComponent
|
|
1558
1548
|
const stripOverPointer =
|
|
1559
|
-
pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer
|
|
1549
|
+
pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer
|
|
1560
1550
|
const shiftPointerLabelX =
|
|
1561
|
-
pointerConfig?.shiftPointerLabelX ??
|
|
1562
|
-
defaultPointerConfig.shiftPointerLabelX;
|
|
1551
|
+
pointerConfig?.shiftPointerLabelX ?? defaultPointerConfig.shiftPointerLabelX
|
|
1563
1552
|
const shiftPointerLabelY =
|
|
1564
|
-
pointerConfig?.shiftPointerLabelY ??
|
|
1565
|
-
defaultPointerConfig.shiftPointerLabelY;
|
|
1553
|
+
pointerConfig?.shiftPointerLabelY ?? defaultPointerConfig.shiftPointerLabelY
|
|
1566
1554
|
const pointerLabelWidth =
|
|
1567
|
-
pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth
|
|
1555
|
+
pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth
|
|
1568
1556
|
const pointerLabelHeight =
|
|
1569
|
-
pointerConfig?.pointerLabelHeight ??
|
|
1570
|
-
defaultPointerConfig.pointerLabelHeight;
|
|
1557
|
+
pointerConfig?.pointerLabelHeight ?? defaultPointerConfig.pointerLabelHeight
|
|
1571
1558
|
const autoAdjustPointerLabelPosition =
|
|
1572
1559
|
pointerConfig?.autoAdjustPointerLabelPosition ??
|
|
1573
|
-
defaultPointerConfig.autoAdjustPointerLabelPosition
|
|
1560
|
+
defaultPointerConfig.autoAdjustPointerLabelPosition
|
|
1574
1561
|
const pointerVanishDelay =
|
|
1575
|
-
pointerConfig?.pointerVanishDelay ??
|
|
1576
|
-
defaultPointerConfig.pointerVanishDelay;
|
|
1562
|
+
pointerConfig?.pointerVanishDelay ?? defaultPointerConfig.pointerVanishDelay
|
|
1577
1563
|
const activatePointersOnLongPress =
|
|
1578
1564
|
pointerConfig?.activatePointersOnLongPress ??
|
|
1579
|
-
defaultPointerConfig.activatePointersOnLongPress
|
|
1565
|
+
defaultPointerConfig.activatePointersOnLongPress
|
|
1580
1566
|
const activatePointersDelay =
|
|
1581
1567
|
pointerConfig?.activatePointersDelay ??
|
|
1582
|
-
defaultPointerConfig.activatePointersDelay
|
|
1568
|
+
defaultPointerConfig.activatePointersDelay
|
|
1583
1569
|
const initialPointerIndex =
|
|
1584
1570
|
pointerConfig?.initialPointerIndex ??
|
|
1585
|
-
defaultPointerConfig.initialPointerIndex
|
|
1571
|
+
defaultPointerConfig.initialPointerIndex
|
|
1586
1572
|
const initialPointerAppearDelay =
|
|
1587
1573
|
pointerConfig?.initialPointerAppearDelay ??
|
|
1588
1574
|
(isAnimated
|
|
1589
1575
|
? animationDuration
|
|
1590
|
-
: defaultPointerConfig.initialPointerAppearDelay)
|
|
1576
|
+
: defaultPointerConfig.initialPointerAppearDelay)
|
|
1591
1577
|
const persistPointer =
|
|
1592
|
-
pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer
|
|
1578
|
+
pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer
|
|
1593
1579
|
const hidePointer1 =
|
|
1594
|
-
pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1
|
|
1580
|
+
pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1
|
|
1595
1581
|
const hidePointer2 =
|
|
1596
|
-
pointerConfig?.hidePointer2 ?? defaultPointerConfig.hidePointer2
|
|
1582
|
+
pointerConfig?.hidePointer2 ?? defaultPointerConfig.hidePointer2
|
|
1597
1583
|
const hidePointer3 =
|
|
1598
|
-
pointerConfig?.hidePointer3 ?? defaultPointerConfig.hidePointer3
|
|
1584
|
+
pointerConfig?.hidePointer3 ?? defaultPointerConfig.hidePointer3
|
|
1599
1585
|
const hidePointer4 =
|
|
1600
|
-
pointerConfig?.hidePointer4 ?? defaultPointerConfig.hidePointer4
|
|
1586
|
+
pointerConfig?.hidePointer4 ?? defaultPointerConfig.hidePointer4
|
|
1601
1587
|
const hidePointer5 =
|
|
1602
|
-
pointerConfig?.hidePointer5 ?? defaultPointerConfig.hidePointer5
|
|
1588
|
+
pointerConfig?.hidePointer5 ?? defaultPointerConfig.hidePointer5
|
|
1603
1589
|
const hideSecondaryPointer =
|
|
1604
1590
|
pointerConfig?.hideSecondaryPointer ??
|
|
1605
|
-
defaultPointerConfig.hideSecondaryPointer
|
|
1591
|
+
defaultPointerConfig.hideSecondaryPointer
|
|
1606
1592
|
const resetPointerOnDataChange =
|
|
1607
1593
|
pointerConfig?.resetPointerOnDataChange ??
|
|
1608
|
-
defaultPointerConfig.resetPointerOnDataChange
|
|
1609
|
-
const pointerEvents = pointerConfig?.pointerEvents
|
|
1594
|
+
defaultPointerConfig.resetPointerOnDataChange
|
|
1595
|
+
const pointerEvents = pointerConfig?.pointerEvents
|
|
1610
1596
|
const disableScroll =
|
|
1611
|
-
props.disableScroll
|
|
1597
|
+
props.disableScroll ??
|
|
1612
1598
|
(pointerConfig
|
|
1613
1599
|
? activatePointersOnLongPress
|
|
1614
|
-
? responderActive
|
|
1615
|
-
? true
|
|
1616
|
-
: false
|
|
1600
|
+
? !!responderActive
|
|
1617
1601
|
: true
|
|
1618
|
-
: false)
|
|
1602
|
+
: false)
|
|
1619
1603
|
const showScrollIndicator =
|
|
1620
|
-
props.showScrollIndicator ?? LineDefaults.showScrollIndicator
|
|
1604
|
+
props.showScrollIndicator ?? LineDefaults.showScrollIndicator
|
|
1621
1605
|
|
|
1622
|
-
const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled
|
|
1606
|
+
const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled
|
|
1623
1607
|
const showDataPointOnFocus =
|
|
1624
|
-
props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus
|
|
1608
|
+
props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus
|
|
1625
1609
|
const showStripOnFocus =
|
|
1626
|
-
props.showStripOnFocus ?? LineDefaults.showStripOnFocus
|
|
1627
|
-
const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus
|
|
1628
|
-
const stripHeight = props.stripHeight
|
|
1629
|
-
const stripWidth = props.stripWidth ?? LineDefaults.stripWidth
|
|
1630
|
-
const stripColor = props.stripColor ?? color1
|
|
1631
|
-
const stripOpacity = props.stripOpacity ?? (startOpacity1 + endOpacity1) / 2
|
|
1610
|
+
props.showStripOnFocus ?? LineDefaults.showStripOnFocus
|
|
1611
|
+
const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus
|
|
1612
|
+
const stripHeight = props.stripHeight
|
|
1613
|
+
const stripWidth = props.stripWidth ?? LineDefaults.stripWidth
|
|
1614
|
+
const stripColor = props.stripColor ?? color1
|
|
1615
|
+
const stripOpacity = props.stripOpacity ?? (startOpacity1 + endOpacity1) / 2
|
|
1632
1616
|
const unFocusOnPressOut =
|
|
1633
|
-
props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut
|
|
1617
|
+
props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut
|
|
1634
1618
|
const delayBeforeUnFocus =
|
|
1635
|
-
props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus
|
|
1619
|
+
props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus
|
|
1636
1620
|
|
|
1637
1621
|
const containerHeightIncludingBelowXAxis =
|
|
1638
|
-
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight
|
|
1622
|
+
extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight
|
|
1639
1623
|
|
|
1640
|
-
const lineGradient = props.lineGradient ?? LineDefaults.lineGradient
|
|
1641
|
-
const lineGradientDirection = props.lineGradientDirection ??
|
|
1624
|
+
const lineGradient = props.lineGradient ?? LineDefaults.lineGradient
|
|
1625
|
+
const lineGradientDirection = props.lineGradientDirection ?? 'vertical'
|
|
1642
1626
|
const lineGradientStartColor =
|
|
1643
|
-
props.lineGradientStartColor ?? LineDefaults.lineGradientStartColor
|
|
1627
|
+
props.lineGradientStartColor ?? LineDefaults.lineGradientStartColor
|
|
1644
1628
|
const lineGradientEndColor =
|
|
1645
|
-
props.lineGradientEndColor ?? LineDefaults.lineGradientEndColor
|
|
1629
|
+
props.lineGradientEndColor ?? LineDefaults.lineGradientEndColor
|
|
1646
1630
|
|
|
1647
|
-
const getPointerY = (value) =>
|
|
1631
|
+
const getPointerY = (value: number): number =>
|
|
1648
1632
|
value
|
|
1649
1633
|
? containerHeight -
|
|
1650
1634
|
(value * containerHeight) / maxValue -
|
|
1651
1635
|
(pointerRadius || pointerHeight / 2) +
|
|
1652
1636
|
10
|
|
1653
|
-
: 0
|
|
1637
|
+
: 0
|
|
1654
1638
|
|
|
1655
|
-
const initialisePointers = () => {
|
|
1639
|
+
const initialisePointers = (): void => {
|
|
1656
1640
|
if (initialPointerIndex !== -1) {
|
|
1657
|
-
const item = (data0 ?? data)[initialPointerIndex]
|
|
1641
|
+
const item = (data0 ?? data)[initialPointerIndex]
|
|
1658
1642
|
const x =
|
|
1659
1643
|
initialSpacing +
|
|
1660
1644
|
spacing * initialPointerIndex -
|
|
1661
1645
|
(pointerRadius || pointerWidth / 2) -
|
|
1662
|
-
1
|
|
1663
|
-
const y = getPointerY(item.value)
|
|
1664
|
-
const y2 = getPointerY(data2?.[initialPointerIndex]?.value)
|
|
1665
|
-
const y3 = getPointerY(data3?.[initialPointerIndex]?.value)
|
|
1666
|
-
const y4 = getPointerY(data4?.[initialPointerIndex]?.value)
|
|
1667
|
-
const y5 = getPointerY(data5?.[initialPointerIndex]?.value)
|
|
1646
|
+
1
|
|
1647
|
+
const y = getPointerY(item.value)
|
|
1648
|
+
const y2 = getPointerY(data2?.[initialPointerIndex]?.value)
|
|
1649
|
+
const y3 = getPointerY(data3?.[initialPointerIndex]?.value)
|
|
1650
|
+
const y4 = getPointerY(data4?.[initialPointerIndex]?.value)
|
|
1651
|
+
const y5 = getPointerY(data5?.[initialPointerIndex]?.value)
|
|
1668
1652
|
|
|
1669
1653
|
if (initialPointerAppearDelay) {
|
|
1670
1654
|
setTimeout(() => {
|
|
1671
|
-
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1672
|
-
}, initialPointerAppearDelay)
|
|
1655
|
+
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1656
|
+
}, initialPointerAppearDelay)
|
|
1673
1657
|
} else {
|
|
1674
|
-
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1658
|
+
setPointerConfig(initialPointerIndex, item, x, y, y2, y3, y4, y5)
|
|
1675
1659
|
}
|
|
1676
1660
|
}
|
|
1677
|
-
}
|
|
1661
|
+
}
|
|
1678
1662
|
|
|
1679
1663
|
useEffect(() => {
|
|
1680
|
-
initialisePointers()
|
|
1681
|
-
}, [])
|
|
1664
|
+
initialisePointers()
|
|
1665
|
+
}, [])
|
|
1682
1666
|
|
|
1683
1667
|
useEffect(() => {
|
|
1684
1668
|
if (resetPointerOnDataChange) {
|
|
1685
|
-
initialisePointers()
|
|
1669
|
+
initialisePointers()
|
|
1686
1670
|
}
|
|
1687
|
-
}, [data])
|
|
1671
|
+
}, [data])
|
|
1688
1672
|
|
|
1689
1673
|
const setPointerConfig = (
|
|
1690
|
-
initialPointerIndex,
|
|
1691
|
-
item,
|
|
1692
|
-
x,
|
|
1693
|
-
y,
|
|
1694
|
-
y2,
|
|
1695
|
-
y3,
|
|
1696
|
-
y4,
|
|
1697
|
-
y5
|
|
1698
|
-
) => {
|
|
1699
|
-
setPointerIndex(initialPointerIndex)
|
|
1700
|
-
setPointerItem(item)
|
|
1701
|
-
setPointerX(x)
|
|
1702
|
-
setPointerY(y)
|
|
1703
|
-
setPointerY2(y2)
|
|
1704
|
-
setPointerY3(y3)
|
|
1705
|
-
setPointerY4(y4)
|
|
1706
|
-
setPointerY5(y5)
|
|
1707
|
-
}
|
|
1674
|
+
initialPointerIndex: number,
|
|
1675
|
+
item: lineDataItem,
|
|
1676
|
+
x: number,
|
|
1677
|
+
y: number,
|
|
1678
|
+
y2: number,
|
|
1679
|
+
y3: number,
|
|
1680
|
+
y4: number,
|
|
1681
|
+
y5: number
|
|
1682
|
+
): void => {
|
|
1683
|
+
setPointerIndex(initialPointerIndex)
|
|
1684
|
+
setPointerItem(item)
|
|
1685
|
+
setPointerX(x)
|
|
1686
|
+
setPointerY(y)
|
|
1687
|
+
setPointerY2(y2)
|
|
1688
|
+
setPointerY3(y3)
|
|
1689
|
+
setPointerY4(y4)
|
|
1690
|
+
setPointerY5(y5)
|
|
1691
|
+
}
|
|
1708
1692
|
|
|
1709
1693
|
const barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes = {
|
|
1710
1694
|
chartType: chartTypes.LINE,
|
|
@@ -1721,7 +1705,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1721
1705
|
initialSpacing,
|
|
1722
1706
|
data: data0 ?? data,
|
|
1723
1707
|
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
1724
|
-
secondaryData
|
|
1708
|
+
secondaryData,
|
|
1725
1709
|
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
1726
1710
|
xAxisThickness,
|
|
1727
1711
|
totalWidth,
|
|
@@ -1742,10 +1726,10 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1742
1726
|
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
1743
1727
|
lineBehindBars: false,
|
|
1744
1728
|
points,
|
|
1745
|
-
points2:
|
|
1729
|
+
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
1746
1730
|
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
1747
1731
|
|
|
1748
|
-
//horizSectionProps-
|
|
1732
|
+
// horizSectionProps-
|
|
1749
1733
|
width: props.width,
|
|
1750
1734
|
horizSections,
|
|
1751
1735
|
endSpacing,
|
|
@@ -1756,7 +1740,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1756
1740
|
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
|
1757
1741
|
|
|
1758
1742
|
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
1759
|
-
yAxisOffset
|
|
1743
|
+
yAxisOffset,
|
|
1760
1744
|
rotateYAxisTexts: 0,
|
|
1761
1745
|
hideAxesAndRules: props.hideAxesAndRules,
|
|
1762
1746
|
|
|
@@ -1772,8 +1756,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1772
1756
|
|
|
1773
1757
|
onEndReached: props.onEndReached,
|
|
1774
1758
|
onStartReached: props.onStartReached,
|
|
1775
|
-
endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset
|
|
1776
|
-
}
|
|
1759
|
+
endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset
|
|
1760
|
+
}
|
|
1777
1761
|
|
|
1778
1762
|
return {
|
|
1779
1763
|
curvature,
|
|
@@ -2116,6 +2100,6 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
2116
2100
|
getPointerY,
|
|
2117
2101
|
initialisePointers,
|
|
2118
2102
|
setPointerConfig,
|
|
2119
|
-
barAndLineChartsWrapperProps
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2103
|
+
barAndLineChartsWrapperProps
|
|
2104
|
+
}
|
|
2105
|
+
}
|