gifted-charts-core 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,343 +1,350 @@
1
- import { useEffect, useMemo, useState } from "react";
1
+ import { useEffect, useMemo, useState } from 'react'
2
2
  import {
3
3
  AxesAndRulesDefaults,
4
4
  LineDefaults,
5
- chartTypes,
6
- } from "../utils/constants";
5
+ chartTypes
6
+ } from '../utils/constants'
7
7
  import {
8
8
  getAxesAndRulesProps,
9
- getExtendedContainerHeightWithPadding,
10
- } from "../utils";
11
- import { bicolorLineDataItem } from "./types";
12
- import { BarAndLineChartsWrapperTypes } from "../utils/types";
13
-
14
- let initialData: Array<bicolorLineDataItem> | null = null;
15
-
16
- type Points = {
17
- points: string;
18
- color: string;
19
- };
20
-
21
- export const useLineChartBiColor = (props) => {
22
- const [toggle, setToggle] = useState(false);
23
- const [pointsArray, setPointsArray] = useState<Array<Points>>([]);
24
- const [fillPointsArray, setFillPointsArray] = useState<Array<Points>>([]);
25
- const [selectedIndex, setSelectedIndex] = useState(-1);
26
- const containerHeight = props.height || AxesAndRulesDefaults.containerHeight;
27
- const noOfSections = props.noOfSections || AxesAndRulesDefaults.noOfSections;
28
- let data = useMemo(() => {
9
+ getExtendedContainerHeightWithPadding
10
+ } from '../utils'
11
+ import { type LineChartBicolorPropsType, type bicolorLineDataItem } from './types'
12
+ import { type BarAndLineChartsWrapperTypes } from '../utils/types'
13
+ import { type Animated } from 'react-native'
14
+
15
+ let initialData: bicolorLineDataItem[] | null = null
16
+
17
+ interface Points {
18
+ points: string
19
+ color: string
20
+ }
21
+
22
+ interface extendedLineChartBicolorPropsType extends LineChartBicolorPropsType {
23
+ heightValue: Animated.Value
24
+ widthValue: Animated.Value
25
+ opacValue: Animated.Value
26
+ }
27
+
28
+ export const useLineChartBiColor = (props: extendedLineChartBicolorPropsType) => {
29
+ const [toggle, setToggle] = useState(false)
30
+ const [pointsArray, setPointsArray] = useState<Points[]>([])
31
+ const [fillPointsArray, setFillPointsArray] = useState<Points[]>([])
32
+ const [selectedIndex, setSelectedIndex] = useState(-1)
33
+ const containerHeight = props.height ?? AxesAndRulesDefaults.containerHeight
34
+ const noOfSections = props.noOfSections ?? AxesAndRulesDefaults.noOfSections
35
+ const data = useMemo(() => {
29
36
  if (!props.data) {
30
- return [];
37
+ return []
31
38
  }
32
39
  if (props.yAxisOffset) {
33
- return props.data.map((item) => {
34
- item.value = item.value - (props.yAxisOffset ?? 0);
35
- return item;
36
- });
40
+ return props.data.map(item => {
41
+ item.value = item.value - (props.yAxisOffset ?? 0)
42
+ return item
43
+ })
37
44
  }
38
- return props.data;
39
- }, [props.yAxisOffset, props.data]);
45
+ return props.data
46
+ }, [props.yAxisOffset, props.data])
40
47
 
41
- const scrollToEnd = props.scrollToEnd ?? LineDefaults.scrollToEnd;
42
- const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation;
48
+ const scrollToEnd = props.scrollToEnd ?? LineDefaults.scrollToEnd
49
+ const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation
43
50
  const scrollEventThrottle =
44
- props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle;
51
+ props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle
45
52
 
46
- const labelsExtraHeight = props.labelsExtraHeight || 0;
53
+ const labelsExtraHeight = props.labelsExtraHeight ?? 0
47
54
 
48
55
  const animationDuration =
49
- props.animationDuration || LineDefaults.animationDuration;
56
+ props.animationDuration ?? LineDefaults.animationDuration
50
57
 
51
- const startIndex1 = props.startIndex || 0;
58
+ const startIndex1 = props.startIndex ?? 0
52
59
 
53
- let endIndex1;
60
+ let endIndex1
54
61
  if (props.endIndex === undefined || props.endIndex === null) {
55
- endIndex1 = data.length - 1;
62
+ endIndex1 = data.length - 1
56
63
  } else {
57
- endIndex1 = props.endIndex;
64
+ endIndex1 = props.endIndex
58
65
  }
59
66
 
60
67
  if (!initialData) {
61
- initialData = [...data];
68
+ initialData = [...data]
62
69
  }
63
70
 
64
- const adjustToWidth = props.adjustToWidth || false;
71
+ const adjustToWidth = props.adjustToWidth ?? false
65
72
 
66
- const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing;
73
+ const initialSpacing = props.initialSpacing ?? LineDefaults.initialSpacing
67
74
  const endSpacing =
68
- props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing);
69
- const thickness = props.thickness || LineDefaults.thickness;
75
+ props.endSpacing ?? (adjustToWidth ? 0 : LineDefaults.endSpacing)
76
+ const thickness = props.thickness ?? LineDefaults.thickness
70
77
 
71
78
  const spacing =
72
79
  props.spacing ??
73
80
  (adjustToWidth
74
- ? ((props.width || AxesAndRulesDefaults.width) - initialSpacing) /
81
+ ? ((props.width ?? AxesAndRulesDefaults.width) - initialSpacing) /
75
82
  data.length
76
- : LineDefaults.spacing);
83
+ : LineDefaults.spacing)
77
84
 
78
85
  const xAxisThickness =
79
- props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness;
86
+ props.xAxisThickness ?? AxesAndRulesDefaults.xAxisThickness
80
87
  const dataPointsHeight1 =
81
- props.dataPointsHeight ?? LineDefaults.dataPointsHeight;
88
+ props.dataPointsHeight ?? LineDefaults.dataPointsHeight
82
89
  const dataPointsWidth1 =
83
- props.dataPointsWidth ?? LineDefaults.dataPointsWidth;
90
+ props.dataPointsWidth ?? LineDefaults.dataPointsWidth
84
91
  const dataPointsRadius1 =
85
- props.dataPointsRadius ?? LineDefaults.dataPointsRadius;
92
+ props.dataPointsRadius ?? LineDefaults.dataPointsRadius
86
93
  const dataPointsColor1 =
87
- props.dataPointsColor ?? LineDefaults.dataPointsColor;
94
+ props.dataPointsColor ?? LineDefaults.dataPointsColor
88
95
  const dataPointsShape1 =
89
- props.dataPointsShape ?? LineDefaults.dataPointsShape;
96
+ props.dataPointsShape ?? LineDefaults.dataPointsShape
90
97
 
91
- const areaChart = props.areaChart || false;
92
- const textFontSize1 = props.textFontSize || LineDefaults.textFontSize;
93
- const textColor1 = props.textColor || LineDefaults.textColor;
98
+ const areaChart = props.areaChart ?? false
99
+ const textFontSize1 = props.textFontSize ?? LineDefaults.textFontSize
100
+ const textColor1 = props.textColor ?? LineDefaults.textColor
94
101
 
95
- let totalWidth = initialSpacing;
96
- let maxItem = 0,
97
- minItem = 0;
102
+ let totalWidth = initialSpacing
103
+ let maxItem = 0
104
+ let minItem = 0
98
105
  data.forEach((item: bicolorLineDataItem) => {
99
106
  if (item.value > maxItem) {
100
- maxItem = item.value;
107
+ maxItem = item.value
101
108
  }
102
109
  if (item.value < minItem) {
103
- minItem = item.value;
110
+ minItem = item.value
104
111
  }
105
- totalWidth += spacing;
106
- });
112
+ totalWidth += spacing
113
+ })
107
114
 
108
- if (props.showFractionalValues || props.roundToDigits) {
109
- maxItem *= 10 * (props.roundToDigits || 1);
110
- maxItem = maxItem + (10 - (maxItem % 10));
111
- maxItem /= 10 * (props.roundToDigits || 1);
112
- maxItem = parseFloat(maxItem.toFixed(props.roundToDigits || 1));
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))
113
120
 
114
121
  if (minItem !== 0) {
115
- minItem *= 10 * (props.roundToDigits || 1);
116
- minItem = minItem - (10 + (minItem % 10));
117
- minItem /= 10 * (props.roundToDigits || 1);
118
- minItem = parseFloat(minItem.toFixed(props.roundToDigits || 1));
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))
119
126
  }
120
127
  } else {
121
- maxItem = maxItem + (10 - (maxItem % 10));
128
+ maxItem = maxItem + (10 - (maxItem % 10))
122
129
  if (minItem !== 0) {
123
- minItem = minItem - (10 + (minItem % 10));
130
+ minItem = minItem - (10 + (minItem % 10))
124
131
  }
125
132
  }
126
133
 
127
- const maxValue = props.maxValue || maxItem;
128
- const mostNegativeValue = props.mostNegativeValue || minItem;
134
+ const maxValue = props.maxValue ?? maxItem
135
+ const mostNegativeValue = props.mostNegativeValue ?? minItem
129
136
 
130
137
  const extendedContainerHeight = getExtendedContainerHeightWithPadding(
131
138
  containerHeight,
132
139
  props.overflowTop
133
- );
140
+ )
134
141
 
135
- let yAtxAxis = extendedContainerHeight - xAxisThickness / 2;
136
- const getX = (index) => initialSpacing + spacing * index;
137
- const getY = (index) =>
138
- yAtxAxis - (data[index].value * containerHeight) / maxValue;
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
139
146
 
140
147
  useEffect(() => {
141
- let ppArray: Array<Points> = [];
142
- let pp = "M" + initialSpacing + " " + getY(0),
143
- prevValuev,
144
- nextValue;
148
+ const ppArray: Points[] = []
149
+ let pp = 'M' + initialSpacing + ' ' + getY(0)
150
+ let prevValuev
151
+ let nextValue
145
152
  for (let i = 0; i < data.length - 1; i++) {
146
- prevValuev = data[i].value;
147
- nextValue = data[i + 1].value;
153
+ prevValuev = data[i].value
154
+ nextValue = data[i + 1].value
148
155
 
149
156
  if (prevValuev < 0 && nextValue < 0) {
150
- pp += "L" + getX(i) + " " + getY(i) + " ";
157
+ pp += 'L' + getX(i) + ' ' + getY(i) + ' '
151
158
  } else if (prevValuev < 0 && nextValue > 0) {
152
- pp += "L" + getX(i) + " " + getY(i) + " ";
153
- let prevX = getX(i);
154
- let prevY = getY(i);
155
- let nextX = getX(i + 1);
156
- let nextY = getY(i + 1);
157
- let slope = (nextY - prevY) / (nextX - prevX);
158
- let x = (yAtxAxis - prevY) / slope + prevX;
159
- pp += "L" + (x - thickness / 2) + " " + yAtxAxis + " ";
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 + ' '
160
167
 
161
168
  let pointsOb = {
162
- points: pp.startsWith("L") ? pp.replace("L", "M") : pp,
163
- color: "red",
164
- };
165
- ppArray.push(pointsOb);
166
- setPointsArray([...ppArray]);
167
- pp = "M" + x + " " + yAtxAxis + " L" + nextX + " " + nextY + " ";
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 + ' '
168
175
  pointsOb = {
169
176
  points: pp,
170
- color: "green",
171
- };
172
- ppArray.push(pointsOb);
177
+ color: 'green'
178
+ }
179
+ ppArray.push(pointsOb)
173
180
  } else if (prevValuev > 0 && nextValue < 0) {
174
- pp += "L" + getX(i) + " " + getY(i) + " ";
175
- let prevX = getX(i);
176
- let prevY = getY(i);
177
- let nextX = getX(i + 1);
178
- let nextY = getY(i + 1);
179
- let slope = (nextY - prevY) / (nextX - prevX);
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)
180
187
 
181
- let x = (yAtxAxis - prevY) / slope + prevX;
182
- pp += "L" + (x - thickness / 2) + " " + yAtxAxis + " ";
188
+ const x = (yAtxAxis - prevY) / slope + prevX
189
+ pp += 'L' + (x - thickness / 2) + ' ' + yAtxAxis + ' '
183
190
 
184
191
  let pointsOb = {
185
- points: pp.startsWith("L") ? pp.replace("L", "M") : pp,
186
- color: "green",
187
- };
188
- ppArray.push(pointsOb);
189
- setPointsArray([...ppArray]);
190
- pp = "M" + x + " " + yAtxAxis + " L" + nextX + " " + nextY + " ";
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 + ' '
191
198
  pointsOb = {
192
199
  points: pp,
193
- color: "red",
194
- };
195
- ppArray.push(pointsOb);
200
+ color: 'red'
201
+ }
202
+ ppArray.push(pointsOb)
196
203
  } else {
197
- pp += "L" + getX(i) + " " + getY(i) + " ";
204
+ pp += 'L' + getX(i) + ' ' + getY(i) + ' '
198
205
  }
199
206
  }
200
- let i = data.length - 1;
201
- prevValuev = data[i - 1].value;
202
- nextValue = data[i].value;
207
+ let i = data.length - 1
208
+ prevValuev = data[i - 1].value
209
+ nextValue = data[i].value
203
210
  if (
204
211
  (prevValuev > 0 && nextValue > 0) ||
205
212
  (prevValuev < 0 && nextValue < 0)
206
213
  ) {
207
- pp += "L" + getX(i) + " " + getY(i) + " ";
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'
208
219
  }
209
- let pointsOb = {
210
- points: pp.startsWith("L") ? pp.replace("L", "M") : pp,
211
- color: nextValue > 0 ? "green" : "red",
212
- };
213
- ppArray.push(pointsOb);
214
- setPointsArray([...ppArray]);
215
-
216
- /*************************** For Area Charts *************************/
217
-
218
- let startIndex = -1,
219
- endIndex = -1,
220
- startX,
221
- startY,
222
- endY,
223
- color = "green",
224
- localArray: Array<Points> = [],
225
- broken = false;
226
-
227
- pp = "M" + initialSpacing + " " + yAtxAxis;
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
228
235
  for (i = 0; i < data.length - 1; i++) {
229
- prevValuev = data[i].value;
230
- nextValue = data[i + 1].value;
231
- pp += "L" + getX(i) + " " + getY(i) + " ";
236
+ prevValuev = data[i].value
237
+ nextValue = data[i + 1].value
238
+ pp += 'L' + getX(i) + ' ' + getY(i) + ' '
232
239
  if (
233
240
  (prevValuev > 0 && nextValue < 0) ||
234
241
  (prevValuev < 0 && nextValue > 0)
235
242
  ) {
236
- let prevX = getX(i);
237
- let prevY = getY(i);
238
- let nextX = getX(i + 1);
239
- let nextY = getY(i + 1);
240
- let slope = (nextY - prevY) / (nextX - prevX);
241
-
242
- let x = (yAtxAxis - prevY) / slope + prevX;
243
- pp += "L" + (x - thickness / 2) + " " + yAtxAxis + " ";
244
- broken = true;
245
- break;
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
246
253
  }
247
254
  }
248
255
  if (!broken) {
249
- i = data.length - 1;
256
+ i = data.length - 1
250
257
  pp +=
251
- "L" +
258
+ 'L' +
252
259
  getX(i) +
253
- " " +
260
+ ' ' +
254
261
  getY(i) +
255
- " L" +
262
+ ' L' +
256
263
  getX(i) +
257
- " " +
258
- (yAtxAxis - xAxisThickness / 2);
264
+ ' ' +
265
+ (yAtxAxis - xAxisThickness / 2)
259
266
  }
260
267
  localArray.push({
261
268
  points: pp,
262
- color: data[0].value >= 0 ? "green" : "red",
263
- });
269
+ color: data[0].value >= 0 ? 'green' : 'red'
270
+ })
264
271
 
265
- let xs: Array<string> = [];
272
+ const xs: string[] = []
266
273
  data.forEach((item, index) => {
267
- let x = getX(index);
268
- xs.push(x + "");
269
- });
274
+ const x = getX(index)
275
+ xs.push(x + '')
276
+ })
270
277
 
271
- pointsArray.forEach((item: any, index) => {
272
- let splitArray = item.points
273
- .split(" ")
274
- .filter((spItem) => spItem && spItem !== " ");
278
+ pointsArray.forEach((item, index) => {
279
+ const splitArray = item.points
280
+ .split(' ')
281
+ .filter((spItem) => spItem && spItem !== ' ')
275
282
 
276
283
  if (
277
- splitArray[1] === yAtxAxis + "" &&
278
- !xs.includes(splitArray[0].replace("M", "").replace("L", ""))
284
+ splitArray[1] === yAtxAxis + '' &&
285
+ !xs.includes(splitArray[0].replace('M', '').replace('L', ''))
279
286
  ) {
280
- startIndex = index;
281
- startX = splitArray[0].replace("M", "").replace("L", "");
287
+ startIndex = index
288
+ startX = splitArray[0].replace('M', '').replace('L', '')
282
289
  if (splitArray.length > 3) {
283
- startY = splitArray[1].replace("M", "").replace("L", "");
284
- endY = splitArray[3].replace("M", "").replace("L", "");
290
+ startY = splitArray[1].replace('M', '').replace('L', '')
291
+ endY = splitArray[3].replace('M', '').replace('L', '')
285
292
  if (Number(startY) < Number(endY)) {
286
- color = "red";
293
+ color = 'red'
287
294
  } else {
288
- color = "green";
295
+ color = 'green'
289
296
  }
290
297
  }
291
298
  }
292
299
  if (
293
- splitArray[splitArray.length - 1] === yAtxAxis + "" &&
300
+ splitArray[splitArray.length - 1] === yAtxAxis + '' &&
294
301
  !xs.includes(
295
- splitArray[splitArray.length - 2].replace("M", "").replace("L", "")
302
+ splitArray[splitArray.length - 2].replace('M', '').replace('L', '')
296
303
  )
297
304
  ) {
298
- endIndex = index;
305
+ endIndex = index
299
306
  }
300
307
  if (startX) {
301
- let filPts = "";
308
+ let filPts = ''
302
309
  for (let j = startIndex; j <= endIndex; j++) {
303
310
  if (pointsArray[j]) {
304
- filPts += pointsArray[j].points.replaceAll("M", "L");
311
+ filPts += pointsArray[j].points.replaceAll('M', 'L')
305
312
  }
306
313
  }
307
- filPts += "L " + startX + " " + yAtxAxis;
308
- localArray.push({ points: filPts.replace("L", "M"), color });
314
+ filPts += 'L ' + startX + ' ' + yAtxAxis
315
+ localArray.push({ points: filPts.replace('L', 'M'), color })
309
316
  }
310
- });
317
+ })
311
318
  if (broken) {
312
- pp = "M" + getX(data.length - 1) + " " + yAtxAxis;
319
+ pp = 'M' + getX(data.length - 1) + ' ' + yAtxAxis
313
320
  for (let i = data.length - 1; i > 0; i--) {
314
- prevValuev = data[i].value;
315
- nextValue = data[i - 1].value;
316
- pp += "L" + getX(i) + " " + getY(i) + " ";
321
+ prevValuev = data[i].value
322
+ nextValue = data[i - 1].value
323
+ pp += 'L' + getX(i) + ' ' + getY(i) + ' '
317
324
  if (
318
325
  (prevValuev > 0 && nextValue < 0) ||
319
326
  (prevValuev < 0 && nextValue > 0)
320
327
  ) {
321
- let prevX = getX(i);
322
- let prevY = getY(i);
323
- let nextX = getX(i - 1);
324
- let nextY = getY(i - 1);
325
- let slope = (nextY - prevY) / (nextX - prevX);
326
-
327
- let x = (yAtxAxis - prevY) / slope + prevX;
328
- pp += "L" + x + " " + yAtxAxis + " ";
329
- break;
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
330
337
  }
331
338
  }
332
339
 
333
340
  localArray.push({
334
341
  points: pp,
335
- color: data[data.length - 1].value > 0 ? "green" : "red",
336
- });
342
+ color: data[data.length - 1].value > 0 ? 'green' : 'red'
343
+ })
337
344
  }
338
345
 
339
- setFillPointsArray([...localArray]);
340
- setToggle(true);
346
+ setFillPointsArray([...localArray])
347
+ setToggle(true)
341
348
  }, [
342
349
  areaChart,
343
350
  containerHeight,
@@ -347,92 +354,92 @@ export const useLineChartBiColor = (props) => {
347
354
  spacing,
348
355
  xAxisThickness,
349
356
  toggle,
350
- maxValue,
351
- ]);
357
+ maxValue
358
+ ])
352
359
 
353
- const horizSections = [{ value: "0" }];
354
- const stepHeight = props.stepHeight || containerHeight / noOfSections;
355
- const stepValue = props.stepValue || maxValue / noOfSections;
360
+ const horizSections = [{ value: '0' }]
361
+ const stepHeight = props.stepHeight ?? containerHeight / noOfSections
362
+ const stepValue = props.stepValue ?? maxValue / noOfSections
356
363
  const noOfSectionsBelowXAxis =
357
- props.noOfSectionsBelowXAxis || -mostNegativeValue / stepValue;
358
- const thickness1 = props.thickness || LineDefaults.thickness;
359
- const zIndex = props.zIndex || 0;
364
+ props.noOfSectionsBelowXAxis ?? -mostNegativeValue / stepValue
365
+ const thickness1 = props.thickness ?? LineDefaults.thickness
366
+ const zIndex = props.zIndex ?? 0
360
367
 
361
- const strokeDashArray1 = props.strokeDashArray;
368
+ const strokeDashArray1 = props.strokeDashArray
362
369
 
363
- const rotateLabel = props.rotateLabel ?? AxesAndRulesDefaults.rotateLabel;
364
- const isAnimated = props.isAnimated ?? LineDefaults.isAnimated;
365
- const hideDataPoints1 = props.hideDataPoints ?? LineDefaults.hideDataPoints;
370
+ const rotateLabel = props.rotateLabel ?? AxesAndRulesDefaults.rotateLabel
371
+ const isAnimated = props.isAnimated ?? LineDefaults.isAnimated
372
+ const hideDataPoints1 = props.hideDataPoints ?? LineDefaults.hideDataPoints
366
373
 
367
- const color = props.color || "green";
368
- const colorNegative = props.colorNegative || "red";
374
+ const color = props.color ?? 'green'
375
+ const colorNegative = props.colorNegative ?? 'red'
369
376
 
370
- const startFillColor = props.startFillColor || "lightgreen";
371
- const endFillColor = props.endFillColor || "white";
372
- const startOpacity = props.startOpacity ?? LineDefaults.startOpacity;
373
- const endOpacity = props.endOpacity ?? LineDefaults.endOpacity;
374
- const startFillColorNegative = props.startFillColorNegative || "pink";
375
- const endFillColorNegative = props.endFillColorNegative || "white";
377
+ const startFillColor = props.startFillColor ?? 'lightgreen'
378
+ const endFillColor = props.endFillColor ?? 'white'
379
+ const startOpacity = props.startOpacity ?? LineDefaults.startOpacity
380
+ const endOpacity = props.endOpacity ?? LineDefaults.endOpacity
381
+ const startFillColorNegative = props.startFillColorNegative ?? 'pink'
382
+ const endFillColorNegative = props.endFillColorNegative ?? 'white'
376
383
  const startOpacityNegative =
377
- props.startOpacityNegative ?? LineDefaults.startOpacity;
384
+ props.startOpacityNegative ?? LineDefaults.startOpacity
378
385
  const endOpacityNegative =
379
- props.endOpacityNegative ?? LineDefaults.endOpacity;
386
+ props.endOpacityNegative ?? LineDefaults.endOpacity
380
387
 
381
- const gradientDirection = props.gradientDirection || "vertical";
388
+ const gradientDirection = props.gradientDirection ?? 'vertical'
382
389
 
383
390
  const showXAxisIndices =
384
- props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices;
391
+ props.showXAxisIndices ?? AxesAndRulesDefaults.showXAxisIndices
385
392
  const xAxisIndicesHeight =
386
- props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight;
393
+ props.xAxisIndicesHeight ?? AxesAndRulesDefaults.xAxisIndicesHeight
387
394
  const xAxisIndicesWidth =
388
- props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth;
395
+ props.xAxisIndicesWidth ?? AxesAndRulesDefaults.xAxisIndicesWidth
389
396
  const xAxisIndicesColor =
390
- props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor;
397
+ props.xAxisIndicesColor ?? AxesAndRulesDefaults.xAxisIndicesColor
391
398
 
392
399
  const xAxisTextNumberOfLines =
393
- props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines;
394
- const horizontalRulesStyle = props.horizontalRulesStyle;
400
+ props.xAxisTextNumberOfLines ?? AxesAndRulesDefaults.xAxisTextNumberOfLines
401
+ const horizontalRulesStyle = props.horizontalRulesStyle
395
402
  const showFractionalValues =
396
- props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues;
403
+ props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues
397
404
  const yAxisLabelWidth =
398
405
  props.yAxisLabelWidth ??
399
406
  (props.hideYAxisText
400
407
  ? AxesAndRulesDefaults.yAxisEmptyLabelWidth
401
- : AxesAndRulesDefaults.yAxisLabelWidth);
408
+ : AxesAndRulesDefaults.yAxisLabelWidth)
402
409
 
403
- const horizontal = false;
404
- const yAxisAtTop = false;
410
+ const horizontal = false
411
+ const yAxisAtTop = false
405
412
 
406
- const disableScroll = props.disableScroll ?? LineDefaults.disableScroll;
413
+ const disableScroll = props.disableScroll ?? LineDefaults.disableScroll
407
414
  const showScrollIndicator =
408
- props.showScrollIndicator || LineDefaults.showScrollIndicator;
415
+ props.showScrollIndicator ?? LineDefaults.showScrollIndicator
409
416
 
410
- const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled;
417
+ const focusEnabled = props.focusEnabled ?? LineDefaults.focusEnabled
411
418
  const showDataPointOnFocus =
412
- props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus;
419
+ props.showDataPointOnFocus ?? LineDefaults.showDataPointOnFocus
413
420
  const showStripOnFocus =
414
- props.showStripOnFocus ?? LineDefaults.showStripOnFocus;
415
- const showTextOnFocus = props.showTextOnFocus ?? LineDefaults.showTextOnFocus;
416
- const stripHeight = props.stripHeight;
417
- const stripWidth = props.stripWidth ?? LineDefaults.stripWidth;
418
- const stripColor = props.stripColor ?? color;
419
- const stripOpacity = props.stripOpacity ?? (startOpacity + endOpacity) / 2;
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
420
427
  const unFocusOnPressOut =
421
- props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut;
428
+ props.unFocusOnPressOut ?? LineDefaults.unFocusOnPressOut
422
429
  const delayBeforeUnFocus =
423
- props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus;
430
+ props.delayBeforeUnFocus ?? LineDefaults.delayBeforeUnFocus
424
431
 
425
- horizSections.pop();
432
+ horizSections.pop()
426
433
  for (let i = 0; i <= noOfSections; i++) {
427
- let value = maxValue - stepValue * i;
428
- if (props.showFractionalValues || props.roundToDigits) {
429
- value = parseFloat(value.toFixed(props.roundToDigits || 1));
434
+ let value = maxValue - stepValue * i
435
+ if (props.showFractionalValues ?? props.roundToDigits) {
436
+ value = parseFloat(value.toFixed(props.roundToDigits ?? 1))
430
437
  }
431
438
  horizSections.push({
432
439
  value: props.yAxisLabelTexts
433
440
  ? props.yAxisLabelTexts[noOfSections - i] ?? value.toString()
434
- : value.toString(),
435
- });
441
+ : value.toString()
442
+ })
436
443
  }
437
444
 
438
445
  const barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes = {
@@ -471,11 +478,11 @@ export const useLineChartBiColor = (props) => {
471
478
  lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
472
479
  lineBehindBars: false,
473
480
  points: pointsArray,
474
- points2: "", // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
481
+ points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
475
482
  arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
476
483
  remainingScrollViewProps: {},
477
484
 
478
- //horizSectionProps-
485
+ // horizSectionProps-
479
486
  width: props.width,
480
487
  horizSections,
481
488
  endSpacing,
@@ -501,8 +508,8 @@ export const useLineChartBiColor = (props) => {
501
508
  pointerIndex: 0,
502
509
  pointerX: 0,
503
510
  pointerY: 0,
504
- endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset,
505
- };
511
+ endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset
512
+ }
506
513
 
507
514
  return {
508
515
  toggle,
@@ -590,6 +597,6 @@ export const useLineChartBiColor = (props) => {
590
597
  unFocusOnPressOut,
591
598
  delayBeforeUnFocus,
592
599
  horizSections,
593
- barAndLineChartsWrapperProps,
594
- };
595
- };
600
+ barAndLineChartsWrapperProps
601
+ }
602
+ }