gifted-charts-core 0.1.20 → 0.1.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/{src → dist}/BarChart/types.d.ts +2 -1
- package/{src → dist}/LineChart/index.d.ts +0 -3
- package/{src → dist}/LineChart/index.js +5 -54
- package/{src → dist}/LineChart/types.d.ts +2 -1
- package/{src → dist}/PopulationPyramid/index.js +4 -3
- package/{src → dist}/PopulationPyramid/types.d.ts +3 -1
- package/{src → dist}/components/BarAndLineChartsWrapper/index.d.ts +1 -0
- package/{src → dist}/components/BarAndLineChartsWrapper/index.js +6 -4
- package/{src → dist}/components/common/types.d.ts +9 -8
- package/{src → dist}/index.d.ts +2 -1
- package/{src → dist}/utils/constants.d.ts +2 -0
- package/{src → dist}/utils/constants.js +2 -0
- package/{src → dist}/utils/index.js +1 -0
- package/{src → dist}/utils/types.d.ts +1 -0
- package/package.json +4 -4
- package/src/BarChart/Animated2DWithGradient.js.map +0 -1
- package/src/BarChart/Animated2DWithGradient.ts +0 -192
- package/src/BarChart/RenderStackBars.js.map +0 -1
- package/src/BarChart/RenderStackBars.ts +0 -160
- package/src/BarChart/index.js.map +0 -1
- package/src/BarChart/index.ts +0 -909
- package/src/BarChart/types.js.map +0 -1
- package/src/BarChart/types.ts +0 -666
- package/src/LineChart/LineChartBiColor.js.map +0 -1
- package/src/LineChart/LineChartBiColor.ts +0 -613
- package/src/LineChart/index.js.map +0 -1
- package/src/LineChart/index.ts +0 -2205
- package/src/LineChart/types.js.map +0 -1
- package/src/LineChart/types.ts +0 -614
- package/src/PieChart/index.js.map +0 -1
- package/src/PieChart/index.ts +0 -180
- package/src/PieChart/main.js.map +0 -1
- package/src/PieChart/main.ts +0 -173
- package/src/PieChart/pro.ts +0 -309
- package/src/PieChart/types.js.map +0 -1
- package/src/PieChart/types.ts +0 -105
- package/src/PopulationPyramid/index.js.map +0 -1
- package/src/PopulationPyramid/index.ts +0 -358
- package/src/PopulationPyramid/types.js.map +0 -1
- package/src/PopulationPyramid/types.ts +0 -256
- package/src/components/AnimatedThreeDBar/index.js.map +0 -1
- package/src/components/AnimatedThreeDBar/index.ts +0 -60
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js.map +0 -1
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.ts +0 -408
- package/src/components/BarAndLineChartsWrapper/index.js.map +0 -1
- package/src/components/BarAndLineChartsWrapper/index.ts +0 -404
- package/src/components/common/StripAndLabel.js.map +0 -1
- package/src/components/common/StripAndLabel.ts +0 -80
- package/src/components/common/types.ts +0 -32
- package/src/index.ts +0 -152
- package/src/utils/constants.js.map +0 -1
- package/src/utils/constants.ts +0 -347
- package/src/utils/index.js.map +0 -1
- package/src/utils/index.ts +0 -1562
- package/src/utils/types.js.map +0 -1
- package/src/utils/types.ts +0 -436
- /package/{src → dist}/BarChart/Animated2DWithGradient.d.ts +0 -0
- /package/{src → dist}/BarChart/Animated2DWithGradient.js +0 -0
- /package/{src → dist}/BarChart/RenderStackBars.d.ts +0 -0
- /package/{src → dist}/BarChart/RenderStackBars.js +0 -0
- /package/{src → dist}/BarChart/index.d.ts +0 -0
- /package/{src → dist}/BarChart/index.js +0 -0
- /package/{src → dist}/BarChart/types.js +0 -0
- /package/{src → dist}/LineChart/LineChartBiColor.d.ts +0 -0
- /package/{src → dist}/LineChart/LineChartBiColor.js +0 -0
- /package/{src → dist}/LineChart/types.js +0 -0
- /package/{src → dist}/PieChart/index.d.ts +0 -0
- /package/{src → dist}/PieChart/index.js +0 -0
- /package/{src → dist}/PieChart/main.d.ts +0 -0
- /package/{src → dist}/PieChart/main.js +0 -0
- /package/{src → dist}/PieChart/pro.d.ts +0 -0
- /package/{src → dist}/PieChart/pro.js +0 -0
- /package/{src → dist}/PieChart/types.d.ts +0 -0
- /package/{src → dist}/PieChart/types.js +0 -0
- /package/{src → dist}/PopulationPyramid/index.d.ts +0 -0
- /package/{src → dist}/PopulationPyramid/types.js +0 -0
- /package/{src → dist}/components/AnimatedThreeDBar/index.d.ts +0 -0
- /package/{src → dist}/components/AnimatedThreeDBar/index.js +0 -0
- /package/{src → dist}/components/BarAndLineChartsWrapper/getHorizSectionsVals.d.ts +0 -0
- /package/{src → dist}/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +0 -0
- /package/{src → dist}/components/common/StripAndLabel.d.ts +0 -0
- /package/{src → dist}/components/common/StripAndLabel.js +0 -0
- /package/{src → dist}/components/common/types.js +0 -0
- /package/{src → dist}/index.js +0 -0
- /package/{src → dist}/utils/index.d.ts +0 -0
- /package/{src → dist}/utils/types.js +0 -0
|
@@ -1,613 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
AxesAndRulesDefaults,
|
|
4
|
-
LineDefaults,
|
|
5
|
-
chartTypes
|
|
6
|
-
} from '../utils/constants'
|
|
7
|
-
import {
|
|
8
|
-
getAxesAndRulesProps,
|
|
9
|
-
getExtendedContainerHeightWithPadding
|
|
10
|
-
} from '../utils'
|
|
11
|
-
import {
|
|
12
|
-
type LineChartBicolorPropsType,
|
|
13
|
-
type bicolorLineDataItem
|
|
14
|
-
} from './types'
|
|
15
|
-
import { type BarAndLineChartsWrapperTypes } from '../utils/types'
|
|
16
|
-
import { type Animated } from 'react-native'
|
|
17
|
-
|
|
18
|
-
let initialData: bicolorLineDataItem[] | null = null
|
|
19
|
-
|
|
20
|
-
interface Points {
|
|
21
|
-
points: string
|
|
22
|
-
color: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface extendedLineChartBicolorPropsType extends LineChartBicolorPropsType {
|
|
26
|
-
parentWidth: number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const useLineChartBiColor = (
|
|
30
|
-
props: extendedLineChartBicolorPropsType
|
|
31
|
-
) => {
|
|
32
|
-
const [toggle, setToggle] = useState(false)
|
|
33
|
-
const [pointsArray, setPointsArray] = useState<Points[]>([])
|
|
34
|
-
const [fillPointsArray, setFillPointsArray] = useState<Points[]>([])
|
|
35
|
-
const [selectedIndex, setSelectedIndex] = useState(-1)
|
|
36
|
-
const containerHeight = props.height ?? AxesAndRulesDefaults.containerHeight
|
|
37
|
-
const noOfSections = props.noOfSections ?? AxesAndRulesDefaults.noOfSections
|
|
38
|
-
const data = useMemo(() => {
|
|
39
|
-
if (!props.data) {
|
|
40
|
-
return []
|
|
41
|
-
}
|
|
42
|
-
if (props.yAxisOffset) {
|
|
43
|
-
return props.data.map((item) => {
|
|
44
|
-
item.value = item.value - (props.yAxisOffset ?? 0)
|
|
45
|
-
return item
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
return props.data
|
|
49
|
-
}, [props.yAxisOffset, props.data])
|
|
50
|
-
|
|
51
|
-
const scrollToEnd = props.scrollToEnd ?? LineDefaults.scrollToEnd
|
|
52
|
-
const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation
|
|
53
|
-
const scrollEventThrottle =
|
|
54
|
-
props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle
|
|
55
|
-
|
|
56
|
-
const labelsExtraHeight = props.labelsExtraHeight ?? 0
|
|
57
|
-
|
|
58
|
-
const animationDuration =
|
|
59
|
-
props.animationDuration ?? LineDefaults.animationDuration
|
|
60
|
-
|
|
61
|
-
const startIndex1 = props.startIndex ?? 0
|
|
62
|
-
|
|
63
|
-
let endIndex1
|
|
64
|
-
if (props.endIndex === undefined || props.endIndex === null) {
|
|
65
|
-
endIndex1 = data.length - 1
|
|
66
|
-
} else {
|
|
67
|
-
endIndex1 = props.endIndex
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!initialData) {
|
|
71
|
-
initialData = [...data]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const adjustToWidth = props.adjustToWidth ?? false
|
|
75
|
-
|
|
76
|
-
const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing
|
|
77
|
-
const endSpacing =
|
|
78
|
-
props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing)
|
|
79
|
-
const thickness = props.thickness ?? LineDefaults.thickness
|
|
80
|
-
|
|
81
|
-
const spacing =
|
|
82
|
-
props.spacing ??
|
|
83
|
-
(adjustToWidth
|
|
84
|
-
? ((props.width ?? AxesAndRulesDefaults.width) - initialSpacing) /
|
|
85
|
-
data.length
|
|
86
|
-
: LineDefaults.spacing)
|
|
87
|
-
|
|
88
|
-
const xAxisThickness =
|
|
89
|
-
props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
|
|
90
|
-
const dataPointsHeight1 =
|
|
91
|
-
props.dataPointsHeight ?? LineDefaults.dataPointsHeight
|
|
92
|
-
const dataPointsWidth1 = props.dataPointsWidth ?? LineDefaults.dataPointsWidth
|
|
93
|
-
const dataPointsRadius1 =
|
|
94
|
-
props.dataPointsRadius ?? LineDefaults.dataPointsRadius
|
|
95
|
-
const dataPointsColor1 = props.dataPointsColor ?? LineDefaults.dataPointsColor
|
|
96
|
-
const dataPointsShape1 = props.dataPointsShape ?? LineDefaults.dataPointsShape
|
|
97
|
-
|
|
98
|
-
const areaChart = props.areaChart ?? false
|
|
99
|
-
const textFontSize1 = props.textFontSize ?? LineDefaults.textFontSize
|
|
100
|
-
const textColor1 = props.textColor ?? LineDefaults.textColor
|
|
101
|
-
|
|
102
|
-
let totalWidth = initialSpacing + endSpacing
|
|
103
|
-
let maxItem = 0
|
|
104
|
-
let minItem = 0
|
|
105
|
-
data.forEach((item: bicolorLineDataItem, index) => {
|
|
106
|
-
if (item.value > maxItem) {
|
|
107
|
-
maxItem = item.value
|
|
108
|
-
}
|
|
109
|
-
if (item.value < minItem) {
|
|
110
|
-
minItem = item.value
|
|
111
|
-
}
|
|
112
|
-
totalWidth += index === data.length - 1 ? 0 : spacing
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
if (props.showFractionalValues ?? props.roundToDigits) {
|
|
116
|
-
maxItem *= 10 * (props.roundToDigits ?? 1)
|
|
117
|
-
maxItem = maxItem + (10 - (maxItem % 10))
|
|
118
|
-
maxItem /= 10 * (props.roundToDigits ?? 1)
|
|
119
|
-
maxItem = parseFloat(maxItem.toFixed(props.roundToDigits ?? 1))
|
|
120
|
-
|
|
121
|
-
if (minItem !== 0) {
|
|
122
|
-
minItem *= 10 * (props.roundToDigits ?? 1)
|
|
123
|
-
minItem = minItem - (10 + (minItem % 10))
|
|
124
|
-
minItem /= 10 * (props.roundToDigits ?? 1)
|
|
125
|
-
minItem = parseFloat(minItem.toFixed(props.roundToDigits ?? 1))
|
|
126
|
-
}
|
|
127
|
-
} else {
|
|
128
|
-
maxItem = maxItem + (10 - (maxItem % 10))
|
|
129
|
-
if (minItem !== 0) {
|
|
130
|
-
minItem = minItem - (10 + (minItem % 10))
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const maxValue = props.maxValue ?? maxItem
|
|
135
|
-
const mostNegativeValue = props.mostNegativeValue ?? minItem
|
|
136
|
-
|
|
137
|
-
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
138
|
-
containerHeight,
|
|
139
|
-
props.overflowTop
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
const yAtxAxis = extendedContainerHeight - xAxisThickness / 2
|
|
143
|
-
const getX = (index: number): number => initialSpacing + spacing * index
|
|
144
|
-
const getY = (index: number): number =>
|
|
145
|
-
yAtxAxis - (data[index].value * containerHeight) / maxValue
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
const ppArray: Points[] = []
|
|
149
|
-
let pp = 'M' + initialSpacing + ' ' + getY(0)
|
|
150
|
-
let prevValuev
|
|
151
|
-
let nextValue
|
|
152
|
-
for (let i = 0; i < data.length - 1; i++) {
|
|
153
|
-
prevValuev = data[i].value
|
|
154
|
-
nextValue = data[i + 1].value
|
|
155
|
-
|
|
156
|
-
if (prevValuev < 0 && nextValue < 0) {
|
|
157
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
158
|
-
} else if (prevValuev < 0 && nextValue > 0) {
|
|
159
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
160
|
-
const prevX = getX(i)
|
|
161
|
-
const prevY = getY(i)
|
|
162
|
-
const nextX = getX(i + 1)
|
|
163
|
-
const nextY = getY(i + 1)
|
|
164
|
-
const slope = (nextY - prevY) / (nextX - prevX)
|
|
165
|
-
const x = (yAtxAxis - prevY) / slope + prevX
|
|
166
|
-
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' '
|
|
167
|
-
|
|
168
|
-
let pointsOb = {
|
|
169
|
-
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
170
|
-
color: 'red'
|
|
171
|
-
}
|
|
172
|
-
ppArray.push(pointsOb)
|
|
173
|
-
setPointsArray([...ppArray])
|
|
174
|
-
pp = 'M' + x + ' ' + yAtxAxis + ' L' + nextX + ' ' + nextY + ' '
|
|
175
|
-
pointsOb = {
|
|
176
|
-
points: pp,
|
|
177
|
-
color: 'green'
|
|
178
|
-
}
|
|
179
|
-
ppArray.push(pointsOb)
|
|
180
|
-
} else if (prevValuev > 0 && nextValue < 0) {
|
|
181
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
182
|
-
const prevX = getX(i)
|
|
183
|
-
const prevY = getY(i)
|
|
184
|
-
const nextX = getX(i + 1)
|
|
185
|
-
const nextY = getY(i + 1)
|
|
186
|
-
const slope = (nextY - prevY) / (nextX - prevX)
|
|
187
|
-
|
|
188
|
-
const x = (yAtxAxis - prevY) / slope + prevX
|
|
189
|
-
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' '
|
|
190
|
-
|
|
191
|
-
let pointsOb = {
|
|
192
|
-
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
193
|
-
color: 'green'
|
|
194
|
-
}
|
|
195
|
-
ppArray.push(pointsOb)
|
|
196
|
-
setPointsArray([...ppArray])
|
|
197
|
-
pp = 'M' + x + ' ' + yAtxAxis + ' L' + nextX + ' ' + nextY + ' '
|
|
198
|
-
pointsOb = {
|
|
199
|
-
points: pp,
|
|
200
|
-
color: 'red'
|
|
201
|
-
}
|
|
202
|
-
ppArray.push(pointsOb)
|
|
203
|
-
} else {
|
|
204
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
let i = data.length - 1
|
|
208
|
-
prevValuev = data[i - 1].value
|
|
209
|
-
nextValue = data[i].value
|
|
210
|
-
if (
|
|
211
|
-
(prevValuev > 0 && nextValue > 0) ||
|
|
212
|
-
(prevValuev < 0 && nextValue < 0)
|
|
213
|
-
) {
|
|
214
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
215
|
-
}
|
|
216
|
-
const pointsOb = {
|
|
217
|
-
points: pp.startsWith('L') ? pp.replace('L', 'M') : pp,
|
|
218
|
-
color: nextValue > 0 ? 'green' : 'red'
|
|
219
|
-
}
|
|
220
|
-
ppArray.push(pointsOb)
|
|
221
|
-
setPointsArray([...ppArray])
|
|
222
|
-
|
|
223
|
-
/** ************************* For Area Charts *************************/
|
|
224
|
-
|
|
225
|
-
let startIndex = -1
|
|
226
|
-
let endIndex = -1
|
|
227
|
-
let startX: string
|
|
228
|
-
let startY: string
|
|
229
|
-
let endY: string
|
|
230
|
-
let color = 'green'
|
|
231
|
-
const localArray: Points[] = []
|
|
232
|
-
let broken = false
|
|
233
|
-
|
|
234
|
-
pp = 'M' + initialSpacing + ' ' + yAtxAxis
|
|
235
|
-
for (i = 0; i < data.length - 1; i++) {
|
|
236
|
-
prevValuev = data[i].value
|
|
237
|
-
nextValue = data[i + 1].value
|
|
238
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
239
|
-
if (
|
|
240
|
-
(prevValuev > 0 && nextValue < 0) ||
|
|
241
|
-
(prevValuev < 0 && nextValue > 0)
|
|
242
|
-
) {
|
|
243
|
-
const prevX = getX(i)
|
|
244
|
-
const prevY = getY(i)
|
|
245
|
-
const nextX = getX(i + 1)
|
|
246
|
-
const nextY = getY(i + 1)
|
|
247
|
-
const slope = (nextY - prevY) / (nextX - prevX)
|
|
248
|
-
|
|
249
|
-
const x = (yAtxAxis - prevY) / slope + prevX
|
|
250
|
-
pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' '
|
|
251
|
-
broken = true
|
|
252
|
-
break
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (!broken) {
|
|
256
|
-
i = data.length - 1
|
|
257
|
-
pp +=
|
|
258
|
-
'L' +
|
|
259
|
-
getX(i) +
|
|
260
|
-
' ' +
|
|
261
|
-
getY(i) +
|
|
262
|
-
' L' +
|
|
263
|
-
getX(i) +
|
|
264
|
-
' ' +
|
|
265
|
-
(yAtxAxis - xAxisThickness / 2)
|
|
266
|
-
}
|
|
267
|
-
localArray.push({
|
|
268
|
-
points: pp,
|
|
269
|
-
color: data[0].value >= 0 ? 'green' : 'red'
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
const xs: string[] = []
|
|
273
|
-
data.forEach((item, index) => {
|
|
274
|
-
const x = getX(index)
|
|
275
|
-
xs.push(x + '')
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
pointsArray.forEach((item, index) => {
|
|
279
|
-
const splitArray = item.points
|
|
280
|
-
.split(' ')
|
|
281
|
-
.filter((spItem) => spItem && spItem !== ' ')
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
splitArray[1] === yAtxAxis + '' &&
|
|
285
|
-
!xs.includes(splitArray[0].replace('M', '').replace('L', ''))
|
|
286
|
-
) {
|
|
287
|
-
startIndex = index
|
|
288
|
-
startX = splitArray[0].replace('M', '').replace('L', '')
|
|
289
|
-
if (splitArray.length > 3) {
|
|
290
|
-
startY = splitArray[1].replace('M', '').replace('L', '')
|
|
291
|
-
endY = splitArray[3].replace('M', '').replace('L', '')
|
|
292
|
-
if (Number(startY) < Number(endY)) {
|
|
293
|
-
color = 'red'
|
|
294
|
-
} else {
|
|
295
|
-
color = 'green'
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (
|
|
300
|
-
splitArray[splitArray.length - 1] === yAtxAxis + '' &&
|
|
301
|
-
!xs.includes(
|
|
302
|
-
splitArray[splitArray.length - 2].replace('M', '').replace('L', '')
|
|
303
|
-
)
|
|
304
|
-
) {
|
|
305
|
-
endIndex = index
|
|
306
|
-
}
|
|
307
|
-
if (startX) {
|
|
308
|
-
let filPts = ''
|
|
309
|
-
for (let j = startIndex; j <= endIndex; j++) {
|
|
310
|
-
if (pointsArray[j]) {
|
|
311
|
-
filPts += pointsArray[j].points.replaceAll('M', 'L')
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
filPts += 'L ' + startX + ' ' + yAtxAxis
|
|
315
|
-
localArray.push({ points: filPts.replace('L', 'M'), color })
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
if (broken) {
|
|
319
|
-
pp = 'M' + getX(data.length - 1) + ' ' + yAtxAxis
|
|
320
|
-
for (let i = data.length - 1; i > 0; i--) {
|
|
321
|
-
prevValuev = data[i].value
|
|
322
|
-
nextValue = data[i - 1].value
|
|
323
|
-
pp += 'L' + getX(i) + ' ' + getY(i) + ' '
|
|
324
|
-
if (
|
|
325
|
-
(prevValuev > 0 && nextValue < 0) ||
|
|
326
|
-
(prevValuev < 0 && nextValue > 0)
|
|
327
|
-
) {
|
|
328
|
-
const prevX = getX(i)
|
|
329
|
-
const prevY = getY(i)
|
|
330
|
-
const nextX = getX(i - 1)
|
|
331
|
-
const nextY = getY(i - 1)
|
|
332
|
-
const slope = (nextY - prevY) / (nextX - prevX)
|
|
333
|
-
|
|
334
|
-
const x = (yAtxAxis - prevY) / slope + prevX
|
|
335
|
-
pp += 'L' + x + ' ' + yAtxAxis + ' '
|
|
336
|
-
break
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
localArray.push({
|
|
341
|
-
points: pp,
|
|
342
|
-
color: data[data.length - 1].value > 0 ? 'green' : 'red'
|
|
343
|
-
})
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
setFillPointsArray([...localArray])
|
|
347
|
-
setToggle(true)
|
|
348
|
-
}, [
|
|
349
|
-
areaChart,
|
|
350
|
-
containerHeight,
|
|
351
|
-
data,
|
|
352
|
-
dataPointsWidth1,
|
|
353
|
-
initialSpacing,
|
|
354
|
-
spacing,
|
|
355
|
-
xAxisThickness,
|
|
356
|
-
toggle,
|
|
357
|
-
maxValue
|
|
358
|
-
])
|
|
359
|
-
|
|
360
|
-
const horizSections = [{ value: '0' }]
|
|
361
|
-
const stepHeight = props.stepHeight ?? containerHeight / noOfSections
|
|
362
|
-
const stepValue = props.stepValue ?? maxValue / noOfSections
|
|
363
|
-
const noOfSectionsBelowXAxis =
|
|
364
|
-
props.noOfSectionsBelowXAxis ??
|
|
365
|
-
Math.round(Math.ceil(-mostNegativeValue / stepValue))
|
|
366
|
-
const thickness1 = props.thickness ?? LineDefaults.thickness
|
|
367
|
-
const zIndex = props.zIndex ?? 0
|
|
368
|
-
|
|
369
|
-
const strokeDashArray1 = props.strokeDashArray
|
|
370
|
-
|
|
371
|
-
const rotateLabel = props.rotateLabel ?? AxesAndRulesDefaults.rotateLabel
|
|
372
|
-
const isAnimated = props.isAnimated ?? LineDefaults.isAnimated
|
|
373
|
-
const hideDataPoints1 = props.hideDataPoints ?? LineDefaults.hideDataPoints
|
|
374
|
-
|
|
375
|
-
const color = props.color ?? 'green'
|
|
376
|
-
const colorNegative = props.colorNegative ?? 'red'
|
|
377
|
-
|
|
378
|
-
const startFillColor = props.startFillColor ?? 'lightgreen'
|
|
379
|
-
const endFillColor = props.endFillColor ?? 'white'
|
|
380
|
-
const startOpacity = props.startOpacity ?? LineDefaults.startOpacity
|
|
381
|
-
const endOpacity = props.endOpacity ?? LineDefaults.endOpacity
|
|
382
|
-
const startFillColorNegative = props.startFillColorNegative ?? 'pink'
|
|
383
|
-
const endFillColorNegative = props.endFillColorNegative ?? 'white'
|
|
384
|
-
const startOpacityNegative =
|
|
385
|
-
props.startOpacityNegative ?? LineDefaults.startOpacity
|
|
386
|
-
const endOpacityNegative = props.endOpacityNegative ?? LineDefaults.endOpacity
|
|
387
|
-
|
|
388
|
-
const gradientDirection = props.gradientDirection ?? 'vertical'
|
|
389
|
-
|
|
390
|
-
const showXAxisIndices =
|
|
391
|
-
props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
|
|
392
|
-
const xAxisIndicesHeight =
|
|
393
|
-
props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
|
|
394
|
-
const xAxisIndicesWidth =
|
|
395
|
-
props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
|
|
396
|
-
const xAxisIndicesColor =
|
|
397
|
-
props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
|
|
398
|
-
|
|
399
|
-
const xAxisTextNumberOfLines =
|
|
400
|
-
props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
|
|
401
|
-
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
402
|
-
const showFractionalValues =
|
|
403
|
-
props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues
|
|
404
|
-
const yAxisLabelWidth =
|
|
405
|
-
props.yAxisLabelWidth ??
|
|
406
|
-
(props.hideYAxisText
|
|
407
|
-
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
408
|
-
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
409
|
-
|
|
410
|
-
const horizontal = false
|
|
411
|
-
const yAxisAtTop = false
|
|
412
|
-
|
|
413
|
-
const disableScroll = props.disableScroll ?? LineDefaults.disableScroll
|
|
414
|
-
const showScrollIndicator =
|
|
415
|
-
props.showScrollIndicator ?? LineDefaults.showScrollIndicator
|
|
416
|
-
|
|
417
|
-
const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled
|
|
418
|
-
const showDataPointOnFocus =
|
|
419
|
-
props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus
|
|
420
|
-
const showStripOnFocus =
|
|
421
|
-
props.showStripOnFocus ?? LineDefaults.showStripOnFocus
|
|
422
|
-
const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus
|
|
423
|
-
const stripHeight = props.stripHeight
|
|
424
|
-
const stripWidth = props.stripWidth ?? LineDefaults.stripWidth
|
|
425
|
-
const stripColor = props.stripColor ?? color
|
|
426
|
-
const stripOpacity = props.stripOpacity ?? (startOpacity + endOpacity) / 2
|
|
427
|
-
const unFocusOnPressOut =
|
|
428
|
-
props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut
|
|
429
|
-
const delayBeforeUnFocus =
|
|
430
|
-
props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus
|
|
431
|
-
|
|
432
|
-
horizSections.pop()
|
|
433
|
-
for (let i = 0; i <= noOfSections; i++) {
|
|
434
|
-
let value = maxValue - stepValue * i
|
|
435
|
-
if (props.showFractionalValues ?? props.roundToDigits) {
|
|
436
|
-
value = parseFloat(value.toFixed(props.roundToDigits ?? 1))
|
|
437
|
-
}
|
|
438
|
-
horizSections.push({
|
|
439
|
-
value: props.yAxisLabelTexts
|
|
440
|
-
? props.yAxisLabelTexts[noOfSections - i] ?? value.toString()
|
|
441
|
-
: value.toString()
|
|
442
|
-
})
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const dataPointsRadius =
|
|
446
|
-
props.dataPointsRadius ?? LineDefaults.dataPointsRadius
|
|
447
|
-
const dataPointsWidth = props.dataPointsWidth ?? LineDefaults.dataPointsWidth
|
|
448
|
-
|
|
449
|
-
const extraWidthDueToDataPoint = props.hideDataPoints
|
|
450
|
-
? 0
|
|
451
|
-
: dataPointsRadius ?? dataPointsWidth
|
|
452
|
-
|
|
453
|
-
const barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes = {
|
|
454
|
-
chartType: chartTypes.LINE_BI_COLOR,
|
|
455
|
-
containerHeight,
|
|
456
|
-
noOfSectionsBelowXAxis,
|
|
457
|
-
stepHeight,
|
|
458
|
-
negativeStepHeight: stepHeight,
|
|
459
|
-
labelsExtraHeight,
|
|
460
|
-
yAxisLabelWidth,
|
|
461
|
-
horizontal,
|
|
462
|
-
rtl: false,
|
|
463
|
-
shiftX: 0,
|
|
464
|
-
shiftY: 0,
|
|
465
|
-
yAxisAtTop,
|
|
466
|
-
initialSpacing,
|
|
467
|
-
data,
|
|
468
|
-
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
469
|
-
secondaryData: [],
|
|
470
|
-
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
471
|
-
xAxisThickness,
|
|
472
|
-
totalWidth,
|
|
473
|
-
disableScroll,
|
|
474
|
-
showScrollIndicator,
|
|
475
|
-
scrollToEnd,
|
|
476
|
-
scrollToIndex: props.scrollToIndex,
|
|
477
|
-
scrollAnimation,
|
|
478
|
-
scrollEventThrottle,
|
|
479
|
-
indicatorColor: props.indicatorColor,
|
|
480
|
-
selectedIndex,
|
|
481
|
-
setSelectedIndex,
|
|
482
|
-
spacing,
|
|
483
|
-
showLine: false,
|
|
484
|
-
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
485
|
-
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
486
|
-
maxValue,
|
|
487
|
-
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
488
|
-
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
489
|
-
lineBehindBars: false,
|
|
490
|
-
points: pointsArray,
|
|
491
|
-
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
492
|
-
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
493
|
-
remainingScrollViewProps: {},
|
|
494
|
-
|
|
495
|
-
// horizSectionProps-
|
|
496
|
-
width: props.width,
|
|
497
|
-
horizSections,
|
|
498
|
-
endSpacing,
|
|
499
|
-
horizontalRulesStyle,
|
|
500
|
-
noOfSections,
|
|
501
|
-
showFractionalValues,
|
|
502
|
-
|
|
503
|
-
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
|
504
|
-
|
|
505
|
-
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
506
|
-
yAxisOffset: props.yAxisOffset,
|
|
507
|
-
rotateYAxisTexts: 0,
|
|
508
|
-
hideAxesAndRules: props.hideAxesAndRules,
|
|
509
|
-
|
|
510
|
-
showXAxisIndices,
|
|
511
|
-
xAxisIndicesHeight,
|
|
512
|
-
xAxisIndicesWidth,
|
|
513
|
-
xAxisIndicesColor,
|
|
514
|
-
|
|
515
|
-
// These are Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
516
|
-
pointerConfig: undefined,
|
|
517
|
-
getPointerProps: null,
|
|
518
|
-
pointerIndex: 0,
|
|
519
|
-
pointerX: 0,
|
|
520
|
-
pointerY: 0,
|
|
521
|
-
endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset,
|
|
522
|
-
extraWidthDueToDataPoint
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return {
|
|
526
|
-
toggle,
|
|
527
|
-
setToggle,
|
|
528
|
-
pointsArray,
|
|
529
|
-
setPointsArray,
|
|
530
|
-
fillPointsArray,
|
|
531
|
-
setFillPointsArray,
|
|
532
|
-
selectedIndex,
|
|
533
|
-
setSelectedIndex,
|
|
534
|
-
containerHeight,
|
|
535
|
-
noOfSections,
|
|
536
|
-
data,
|
|
537
|
-
scrollToEnd,
|
|
538
|
-
scrollAnimation,
|
|
539
|
-
scrollEventThrottle,
|
|
540
|
-
labelsExtraHeight,
|
|
541
|
-
animationDuration,
|
|
542
|
-
startIndex1,
|
|
543
|
-
endIndex1,
|
|
544
|
-
initialData,
|
|
545
|
-
adjustToWidth,
|
|
546
|
-
initialSpacing,
|
|
547
|
-
endSpacing,
|
|
548
|
-
thickness,
|
|
549
|
-
spacing,
|
|
550
|
-
xAxisThickness,
|
|
551
|
-
dataPointsHeight1,
|
|
552
|
-
dataPointsWidth1,
|
|
553
|
-
dataPointsRadius1,
|
|
554
|
-
dataPointsColor1,
|
|
555
|
-
dataPointsShape1,
|
|
556
|
-
areaChart,
|
|
557
|
-
textFontSize1,
|
|
558
|
-
textColor1,
|
|
559
|
-
totalWidth,
|
|
560
|
-
maxItem,
|
|
561
|
-
minItem,
|
|
562
|
-
maxValue,
|
|
563
|
-
mostNegativeValue,
|
|
564
|
-
extendedContainerHeight,
|
|
565
|
-
getX,
|
|
566
|
-
getY,
|
|
567
|
-
yAtxAxis,
|
|
568
|
-
stepHeight,
|
|
569
|
-
stepValue,
|
|
570
|
-
noOfSectionsBelowXAxis,
|
|
571
|
-
thickness1,
|
|
572
|
-
zIndex,
|
|
573
|
-
strokeDashArray1,
|
|
574
|
-
rotateLabel,
|
|
575
|
-
isAnimated,
|
|
576
|
-
hideDataPoints1,
|
|
577
|
-
color,
|
|
578
|
-
colorNegative,
|
|
579
|
-
startFillColor,
|
|
580
|
-
endFillColor,
|
|
581
|
-
startOpacity,
|
|
582
|
-
endOpacity,
|
|
583
|
-
startFillColorNegative,
|
|
584
|
-
endFillColorNegative,
|
|
585
|
-
startOpacityNegative,
|
|
586
|
-
endOpacityNegative,
|
|
587
|
-
gradientDirection,
|
|
588
|
-
showXAxisIndices,
|
|
589
|
-
xAxisIndicesHeight,
|
|
590
|
-
xAxisIndicesWidth,
|
|
591
|
-
xAxisIndicesColor,
|
|
592
|
-
xAxisTextNumberOfLines,
|
|
593
|
-
horizontalRulesStyle,
|
|
594
|
-
showFractionalValues,
|
|
595
|
-
yAxisLabelWidth,
|
|
596
|
-
horizontal,
|
|
597
|
-
yAxisAtTop,
|
|
598
|
-
disableScroll,
|
|
599
|
-
showScrollIndicator,
|
|
600
|
-
focusEnabled,
|
|
601
|
-
showDataPointOnFocus,
|
|
602
|
-
showStripOnFocus,
|
|
603
|
-
showTextOnFocus,
|
|
604
|
-
stripHeight,
|
|
605
|
-
stripWidth,
|
|
606
|
-
stripColor,
|
|
607
|
-
stripOpacity,
|
|
608
|
-
unFocusOnPressOut,
|
|
609
|
-
delayBeforeUnFocus,
|
|
610
|
-
horizSections,
|
|
611
|
-
barAndLineChartsWrapperProps
|
|
612
|
-
}
|
|
613
|
-
}
|