react-native-gifted-charts 1.3.20 → 1.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.3.20",
3
+ "version": "1.3.21",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -5,7 +5,6 @@ import {
5
5
  LayoutAnimation,
6
6
  Platform,
7
7
  UIManager,
8
- Text,
9
8
  } from 'react-native';
10
9
  import LinearGradient from 'react-native-linear-gradient';
11
10
  import Svg, {Defs, Rect} from 'react-native-svg';
@@ -36,9 +35,6 @@ type propTypes = {
36
35
  capRadius?: number;
37
36
  horizontal: boolean;
38
37
  intactTopLabel: boolean;
39
- showValuesAsTopLabel: boolean;
40
- topLabelContainerStyle?: any;
41
- topLabelTextStyle?: any;
42
38
  barBorderRadius?: number;
43
39
  barBorderTopLeftRadius?: number;
44
40
  barBorderTopRightRadius?: number;
@@ -71,10 +67,6 @@ const Animated2DWithGradient = (props: propTypes) => {
71
67
  barBorderTopRightRadius,
72
68
  barBorderBottomLeftRadius,
73
69
  barBorderBottomRightRadius,
74
- intactTopLabel,
75
- showValuesAsTopLabel,
76
- topLabelContainerStyle,
77
- topLabelTextStyle,
78
70
  } = props;
79
71
  const [height, setHeight] = useState(noAnimation ? props.height : 0.2);
80
72
  const [initialRender, setInitialRender] = useState(
@@ -307,7 +299,7 @@ const Animated2DWithGradient = (props: propTypes) => {
307
299
  </Svg>
308
300
  )}
309
301
  </View>
310
- {(item.topLabelComponent || showValuesAsTopLabel) && (
302
+ {item.topLabelComponent && (
311
303
  <View
312
304
  style={[
313
305
  {
@@ -316,7 +308,8 @@ const Animated2DWithGradient = (props: propTypes) => {
316
308
  height: item.barWidth || barWidth || 30,
317
309
  width: item.barWidth || barWidth || 30,
318
310
  justifyContent:
319
- (props.horizontal && !intactTopLabel) || item.value < 0
311
+ (props.horizontal && !props.intactTopLabel) ||
312
+ item.value < 0
320
313
  ? 'center'
321
314
  : 'flex-end',
322
315
  alignItems: 'center',
@@ -324,14 +317,10 @@ const Animated2DWithGradient = (props: propTypes) => {
324
317
  },
325
318
  item.value < 0 && {transform: [{rotate: '180deg'}]},
326
319
  props.horizontal &&
327
- !intactTopLabel && {transform: [{rotate: '270deg'}]},
328
- topLabelContainerStyle ?? item.topLabelContainerStyle,
320
+ !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
321
+ item.topLabelContainerStyle,
329
322
  ]}>
330
- {showValuesAsTopLabel ? (
331
- <Text style={topLabelTextStyle}>{item.value}</Text>
332
- ) : (
333
- item.topLabelComponent?.()
334
- )}
323
+ {item.topLabelComponent()}
335
324
  </View>
336
325
  )}
337
326
  </View>
@@ -22,7 +22,6 @@ type Props = {
22
22
  topColor?: ColorValue;
23
23
  topLabelComponent?: Component;
24
24
  topLabelContainerStyle?: any;
25
- topLabelTextStyle?: any;
26
25
  opacity?: number;
27
26
  side?: String;
28
27
  labelTextStyle?: any;
@@ -60,7 +59,6 @@ type Props = {
60
59
  horizontal: boolean;
61
60
  rtl: boolean;
62
61
  intactTopLabel: boolean;
63
- showValuesAsTopLabel?: boolean;
64
62
  barBorderRadius?: number;
65
63
  barBorderTopLeftRadius?: number;
66
64
  barBorderTopRightRadius?: number;
@@ -123,10 +121,6 @@ const RenderBars = (props: Props) => {
123
121
  xAxisThickness,
124
122
  horizontal,
125
123
  rtl,
126
- intactTopLabel,
127
- showValuesAsTopLabel,
128
- topLabelContainerStyle,
129
- topLabelTextStyle,
130
124
  pointerConfig,
131
125
  } = props;
132
126
 
@@ -321,7 +315,7 @@ const RenderBars = (props: Props) => {
321
315
  patternIdFromProps={props.patternId}
322
316
  />
323
317
  )}
324
- {(item.topLabelComponent || showValuesAsTopLabel) && (
318
+ {item.topLabelComponent && (
325
319
  <View
326
320
  style={[
327
321
  {
@@ -330,21 +324,17 @@ const RenderBars = (props: Props) => {
330
324
  height: item.barWidth || props.barWidth || 30,
331
325
  width: item.barWidth || props.barWidth || 30,
332
326
  justifyContent:
333
- (horizontal && !intactTopLabel) || item.value < 0
327
+ (horizontal && !props.intactTopLabel) || item.value < 0
334
328
  ? 'center'
335
329
  : 'flex-end',
336
330
  alignItems: 'center',
337
331
  },
338
332
  item.value < 0 && {transform: [{rotate: '180deg'}]},
339
333
  horizontal &&
340
- !intactTopLabel && {transform: [{rotate: '270deg'}]},
341
- topLabelContainerStyle ?? item.topLabelContainerStyle,
334
+ !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
335
+ item.topLabelContainerStyle,
342
336
  ]}>
343
- {showValuesAsTopLabel ? (
344
- <Text style={topLabelTextStyle}>{item.value}</Text>
345
- ) : (
346
- item.topLabelComponent?.()
347
- )}
337
+ {item.topLabelComponent()}
348
338
  </View>
349
339
  )}
350
340
  </>
@@ -405,41 +395,6 @@ const RenderBars = (props: Props) => {
405
395
  (pointerConfig && pointerConfig.barTouchable !== true);
406
396
 
407
397
  const barContent = () => {
408
- const animated2DWithGradient = noGradient => (
409
- <Animated2DWithGradient
410
- barBackgroundPattern={props.barBackgroundPattern}
411
- patternId={props.patternId}
412
- barWidth={props.barWidth || 30}
413
- barStyle={barStyle}
414
- item={item}
415
- opacity={opacity}
416
- animationDuration={animationDuration || 800}
417
- roundedBottom={props.roundedBottom || false}
418
- roundedTop={props.roundedTop || false}
419
- noGradient={noGradient}
420
- gradientColor={noGradient ? undefined : props.gradientColor}
421
- frontColor={props.frontColor || 'black'}
422
- containerHeight={containerHeight}
423
- maxValue={maxValue}
424
- height={barHeight}
425
- minHeight={minHeight ?? 0}
426
- barMarginBottom={barMarginBottom}
427
- cappedBars={props.cappedBars}
428
- capThickness={props.capThickness}
429
- capColor={props.capColor}
430
- capRadius={props.capRadius}
431
- horizontal={horizontal}
432
- intactTopLabel={intactTopLabel}
433
- showValuesAsTopLabel={!!showValuesAsTopLabel}
434
- topLabelContainerStyle={topLabelContainerStyle}
435
- topLabelTextStyle={topLabelTextStyle}
436
- barBorderRadius={props.barBorderRadius || 0}
437
- barBorderTopLeftRadius={barBorderTopLeftRadius}
438
- barBorderTopRightRadius={barBorderTopRightRadius}
439
- barBorderBottomLeftRadius={barBorderBottomLeftRadius}
440
- barBorderBottomRightRadius={barBorderBottomRightRadius}
441
- />
442
- );
443
398
  return (
444
399
  <>
445
400
  {(props.showXAxisIndices || item.showXAxisIndex) && (
@@ -465,6 +420,7 @@ const RenderBars = (props: Props) => {
465
420
  item.barBackgroundPattern || props.barBackgroundPattern
466
421
  }
467
422
  patternId={item.patternId || props.patternId}
423
+ topLabelContainerStyle={item.topLabelContainerStyle}
468
424
  width={item.barWidth || props.barWidth || 30}
469
425
  barStyle={barStyle}
470
426
  item={item}
@@ -479,13 +435,11 @@ const RenderBars = (props: Props) => {
479
435
  topColor={item.topColor || props.topColor || ''}
480
436
  showGradient={item.showGradient || props.showGradient || false}
481
437
  gradientColor={item.gradientColor || props.gradientColor}
438
+ topLabelComponent={item.topLabelComponent}
482
439
  opacity={opacity || 1}
483
440
  animationDuration={animationDuration || 800}
484
441
  height={barHeight}
485
- intactTopLabel={intactTopLabel}
486
- showValuesAsTopLabel={!!showValuesAsTopLabel}
487
- topLabelContainerStyle={topLabelContainerStyle}
488
- topLabelTextStyle={topLabelTextStyle}
442
+ intactTopLabel={props.intactTopLabel}
489
443
  horizontal={horizontal}
490
444
  />
491
445
  ) : (
@@ -496,6 +450,7 @@ const RenderBars = (props: Props) => {
496
450
  patternId={item.patternId || props.patternId}
497
451
  style={{}}
498
452
  color={''}
453
+ topLabelContainerStyle={item.topLabelContainerStyle}
499
454
  width={item.barWidth || props.barWidth || 30}
500
455
  sideWidth={
501
456
  item.sideWidth ||
@@ -510,26 +465,111 @@ const RenderBars = (props: Props) => {
510
465
  topColor={item.topColor || props.topColor || ''}
511
466
  showGradient={item.showGradient || props.showGradient || false}
512
467
  gradientColor={item.gradientColor || props.gradientColor}
468
+ topLabelComponent={item.topLabelComponent || null}
513
469
  opacity={opacity || 1}
514
470
  horizontal={horizontal}
515
- intactTopLabel={intactTopLabel}
516
- showValuesAsTopLabel={!!showValuesAsTopLabel}
517
- topLabelContainerStyle={topLabelContainerStyle}
518
- topLabelTextStyle={topLabelTextStyle}
471
+ intactTopLabel={props.intactTopLabel}
519
472
  height={barHeight}
520
473
  value={item.value}
521
474
  />
522
475
  )
523
476
  ) : item.showGradient || props.showGradient ? (
524
477
  isAnimated ? (
525
- animated2DWithGradient(false)
478
+ <Animated2DWithGradient
479
+ barBackgroundPattern={props.barBackgroundPattern}
480
+ patternId={props.patternId}
481
+ barWidth={props.barWidth || 30}
482
+ barStyle={barStyle}
483
+ item={item}
484
+ opacity={opacity}
485
+ animationDuration={animationDuration || 800}
486
+ roundedBottom={props.roundedBottom || false}
487
+ roundedTop={props.roundedTop || false}
488
+ gradientColor={props.gradientColor}
489
+ frontColor={props.frontColor || 'black'}
490
+ containerHeight={containerHeight}
491
+ maxValue={maxValue}
492
+ height={barHeight}
493
+ minHeight={minHeight ?? 0}
494
+ barMarginBottom={barMarginBottom}
495
+ cappedBars={props.cappedBars}
496
+ capThickness={props.capThickness}
497
+ capColor={props.capColor}
498
+ capRadius={props.capRadius}
499
+ horizontal={horizontal}
500
+ intactTopLabel={props.intactTopLabel}
501
+ barBorderRadius={props.barBorderRadius || 0}
502
+ barBorderTopLeftRadius={barBorderTopLeftRadius}
503
+ barBorderTopRightRadius={barBorderTopRightRadius}
504
+ barBorderBottomLeftRadius={barBorderBottomLeftRadius}
505
+ barBorderBottomRightRadius={barBorderBottomRightRadius}
506
+ />
526
507
  ) : (
527
508
  static2DWithGradient(item)
528
509
  )
529
510
  ) : isAnimated ? (
530
- animated2DWithGradient(true)
511
+ <Animated2DWithGradient
512
+ barBackgroundPattern={props.barBackgroundPattern}
513
+ patternId={props.patternId}
514
+ barWidth={props.barWidth || 30}
515
+ barStyle={barStyle}
516
+ item={item}
517
+ opacity={opacity}
518
+ animationDuration={animationDuration || 800}
519
+ roundedBottom={props.roundedBottom || false}
520
+ roundedTop={props.roundedTop || false}
521
+ gradientColor={props.gradientColor}
522
+ noGradient
523
+ frontColor={props.frontColor || 'black'}
524
+ containerHeight={containerHeight}
525
+ maxValue={maxValue}
526
+ height={barHeight}
527
+ minHeight={minHeight || 0}
528
+ barMarginBottom={barMarginBottom}
529
+ cappedBars={props.cappedBars}
530
+ capThickness={props.capThickness}
531
+ capColor={props.capColor}
532
+ capRadius={props.capRadius}
533
+ horizontal={horizontal}
534
+ intactTopLabel={props.intactTopLabel}
535
+ barBorderRadius={props.barBorderRadius || 0}
536
+ barBorderTopLeftRadius={barBorderTopLeftRadius}
537
+ barBorderTopRightRadius={barBorderTopRightRadius}
538
+ barBorderBottomLeftRadius={barBorderBottomLeftRadius}
539
+ barBorderBottomRightRadius={barBorderBottomRightRadius}
540
+ />
531
541
  ) : (
532
- animated2DWithGradient(true)
542
+ <Animated2DWithGradient
543
+ barBackgroundPattern={props.barBackgroundPattern}
544
+ patternId={props.patternId}
545
+ barWidth={props.barWidth || 30}
546
+ barStyle={barStyle}
547
+ item={item}
548
+ opacity={opacity}
549
+ animationDuration={animationDuration || 800}
550
+ roundedBottom={props.roundedBottom || false}
551
+ roundedTop={props.roundedTop || false}
552
+ gradientColor={props.gradientColor}
553
+ noGradient
554
+ noAnimation
555
+ frontColor={props.frontColor || 'black'}
556
+ containerHeight={containerHeight}
557
+ maxValue={maxValue}
558
+ height={barHeight}
559
+ minHeight={minHeight || 0}
560
+ barMarginBottom={barMarginBottom}
561
+ cappedBars={props.cappedBars}
562
+ capThickness={props.capThickness}
563
+ capColor={props.capColor}
564
+ capRadius={props.capRadius}
565
+ horizontal={horizontal}
566
+ intactTopLabel={props.intactTopLabel}
567
+ barBorderRadius={props.barBorderRadius || 0}
568
+ barBorderTopLeftRadius={barBorderTopLeftRadius}
569
+ barBorderTopRightRadius={barBorderTopRightRadius}
570
+ barBorderBottomLeftRadius={barBorderBottomLeftRadius}
571
+ barBorderBottomRightRadius={barBorderBottomRightRadius}
572
+ />
533
573
  )}
534
574
  {isAnimated
535
575
  ? renderAnimatedLabel(label, labelTextStyle, item.value)
@@ -303,7 +303,6 @@ export const BarChart = (props: BarChartPropsType) => {
303
303
  pointerConfig?.persistPointer ?? defaultPointerConfig.persistPointer;
304
304
  const hidePointer1 =
305
305
  pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1;
306
- const pointerEvents = pointerConfig?.pointerEvents;
307
306
 
308
307
  const disableScroll =
309
308
  props.disableScroll ||
@@ -613,7 +612,6 @@ export const BarChart = (props: BarChartPropsType) => {
613
612
  pointerConfig,
614
613
  pointerLabelComponent,
615
614
  scrollX: 0,
616
- pointerEvents,
617
615
  });
618
616
  };
619
617
 
@@ -714,7 +712,7 @@ export const BarChart = (props: BarChartPropsType) => {
714
712
  {renderChart()}
715
713
  {pointerX > 0 ? (
716
714
  <View
717
- pointerEvents={pointerEvents ?? 'none'}
715
+ pointerEvents="none"
718
716
  style={{
719
717
  position: 'absolute',
720
718
  height:
@@ -757,9 +755,6 @@ export const BarChart = (props: BarChartPropsType) => {
757
755
  horizontal: horizontal,
758
756
  rtl: rtl,
759
757
  intactTopLabel: intactTopLabel,
760
- showValuesAsTopLabel: props.showValuesAsTopLabel,
761
- topLabelContainerStyle: props.topLabelContainerStyle,
762
- topLabelTextStyle: props.topLabelTextStyle,
763
758
  barBorderRadius: props.barBorderRadius,
764
759
  barBorderTopLeftRadius: props.barBorderTopLeftRadius,
765
760
  barBorderTopRightRadius: props.barBorderTopRightRadius,
@@ -126,9 +126,6 @@ export type BarChartPropsType = {
126
126
  yAxisAtTop?: boolean;
127
127
 
128
128
  intactTopLabel?: boolean;
129
- showValuesAsTopLabel?: boolean;
130
- topLabelContainerStyle?: any;
131
- topLabelTextStyle?: any;
132
129
 
133
130
  horizSections?: Array<sectionType>;
134
131
  barBorderRadius?: number;
@@ -6,7 +6,6 @@ import {
6
6
  LayoutAnimation,
7
7
  Platform,
8
8
  UIManager,
9
- Text,
10
9
  } from 'react-native';
11
10
  import LinearGradient from 'react-native-linear-gradient';
12
11
  import Svg, {Defs, Rect} from 'react-native-svg';
@@ -33,13 +32,12 @@ type animatedBarPropTypes = {
33
32
  frontColor: ColorValue;
34
33
  sideColor: ColorValue;
35
34
  topColor: ColorValue;
35
+ topLabelComponent: any;
36
+ topLabelContainerStyle: any;
36
37
  opacity: number;
37
38
  side: String;
38
39
  horizontal: boolean;
39
40
  intactTopLabel: boolean;
40
- showValuesAsTopLabel: boolean;
41
- topLabelContainerStyle?: any;
42
- topLabelTextStyle?: any;
43
41
  barBackgroundPattern?: Function;
44
42
  patternId?: String;
45
43
  barStyle?: object;
@@ -109,18 +107,9 @@ const AnimatedBar = (props: animatedBarPropTypes) => {
109
107
  setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
110
108
  };
111
109
 
112
- const {
113
- item,
114
- width,
115
- sideWidth,
116
- barStyle,
117
- barBackgroundPattern,
118
- patternId,
119
- intactTopLabel,
120
- showValuesAsTopLabel,
121
- topLabelContainerStyle,
122
- topLabelTextStyle,
123
- } = props;
110
+ const {item, width, sideWidth, barStyle} = props;
111
+
112
+ const {barBackgroundPattern, patternId} = props;
124
113
 
125
114
  const showGradient = props.showGradient || false;
126
115
  const gradientColor = props.gradientColor || 'white';
@@ -129,6 +118,9 @@ const AnimatedBar = (props: animatedBarPropTypes) => {
129
118
  const sideColor = props.sideColor || '#cc2233';
130
119
  const topColor = props.topColor || '#ff4433';
131
120
 
121
+ const topLabelComponent = props.topLabelComponent || null;
122
+ const topLabelContainerStyle = props.topLabelContainerStyle || {};
123
+
132
124
  const opacity = props.opacity || 1;
133
125
 
134
126
  return (
@@ -202,17 +194,16 @@ const AnimatedBar = (props: animatedBarPropTypes) => {
202
194
  ) : null}
203
195
 
204
196
  <View
205
- style={[
206
- {
207
- width: width,
208
- height: height, //animatedHeight
209
- backgroundColor: frontColor,
210
- borderLeftWidth: StyleSheet.hairlineWidth,
211
- borderTopWidth: StyleSheet.hairlineWidth,
212
- borderColor: 'white',
213
- opacity: opacity,
214
- },
215
- item.barStyle || barStyle,
197
+ style={[{
198
+ width: width,
199
+ height: height, //animatedHeight
200
+ backgroundColor: frontColor,
201
+ borderLeftWidth: StyleSheet.hairlineWidth,
202
+ borderTopWidth: StyleSheet.hairlineWidth,
203
+ borderColor: 'white',
204
+ opacity: opacity,
205
+ },
206
+ item.barStyle || barStyle
216
207
  ]}>
217
208
  {showGradient && (
218
209
  <LinearGradient
@@ -239,7 +230,7 @@ const AnimatedBar = (props: animatedBarPropTypes) => {
239
230
 
240
231
  {/******************* Top Label *****************/}
241
232
 
242
- {(item.topLabelComponent || showValuesAsTopLabel) && (
233
+ {topLabelComponent && (
243
234
  <View
244
235
  style={[
245
236
  {
@@ -252,15 +243,11 @@ const AnimatedBar = (props: animatedBarPropTypes) => {
252
243
  opacity: opacity,
253
244
  },
254
245
  props.horizontal &&
255
- !intactTopLabel && {transform: [{rotate: '270deg'}]},
246
+ !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
256
247
  props.side === 'right' && {transform: [{rotateY: '180deg'}]},
257
- topLabelContainerStyle ?? item.topLabelContainerStyle,
248
+ topLabelContainerStyle,
258
249
  ]}>
259
- {showValuesAsTopLabel ? (
260
- <Text style={topLabelTextStyle}>{item.value}</Text>
261
- ) : (
262
- item.topLabelComponent?.()
263
- )}
250
+ {topLabelComponent()}
264
251
  </View>
265
252
  )}
266
253
 
@@ -103,9 +103,6 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
103
103
  const xAxisLabelsVerticalShift =
104
104
  axesAndRulesProps.xAxisLabelsVerticalShift ??
105
105
  AxesAndRulesDefaults.xAxisLabelsVerticalShift;
106
- const xAxisLabelsHeight =
107
- axesAndRulesProps.xAxisLabelsHeight;
108
- const xAxisTextNumberOfLines = axesAndRulesProps.xAxisTextNumberOfLines;
109
106
  const dashWidth =
110
107
  axesAndRulesProps.dashWidth ?? AxesAndRulesDefaults.dashWidth;
111
108
  const dashGap = axesAndRulesProps.dashGap ?? AxesAndRulesDefaults.dashGap;
@@ -337,7 +334,7 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
337
334
  stepHeight / 2 +
338
335
  xAxisLabelsVerticalShift +
339
336
  50,
340
- marginBottom: (xAxisLabelsHeight ?? xAxisTextNumberOfLines*18) - 50, //This is to not let the Things that should be rendered below the chart overlap with it
337
+ marginBottom: 15, //This is to not let the Things that should be rendered below the chart overlap with it
341
338
  };
342
339
 
343
340
  return (
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {View, StyleSheet, ColorValue, Text} from 'react-native';
2
+ import {View, StyleSheet, ColorValue} from 'react-native';
3
3
  import LinearGradient from 'react-native-linear-gradient';
4
4
  import Svg, {Defs, Rect} from 'react-native-svg';
5
5
  import {styles} from './styles';
@@ -15,13 +15,12 @@ type PropTypes = {
15
15
  frontColor: ColorValue;
16
16
  sideColor: ColorValue;
17
17
  topColor: ColorValue;
18
+ topLabelComponent: any;
19
+ topLabelContainerStyle: any;
18
20
  opacity: number;
19
21
  side: String;
20
22
  horizontal: boolean;
21
23
  intactTopLabel: boolean;
22
- showValuesAsTopLabel: boolean;
23
- topLabelContainerStyle?: any;
24
- topLabelTextStyle?: any;
25
24
  value: number;
26
25
  barBackgroundPattern?: Function;
27
26
  patternId?: String;
@@ -81,12 +80,8 @@ const ThreeDBar = (props: PropTypes) => {
81
80
  const sideColor = props.sideColor || '#cc2233';
82
81
  const topColor = props.topColor || '#ff4433';
83
82
 
84
- const {
85
- intactTopLabel,
86
- showValuesAsTopLabel,
87
- topLabelContainerStyle,
88
- topLabelTextStyle,
89
- } = props;
83
+ const topLabelComponent = props.topLabelComponent || null;
84
+ const topLabelContainerStyle = props.topLabelContainerStyle || {};
90
85
 
91
86
  const opacity = props.opacity || 1;
92
87
  return (
@@ -189,7 +184,7 @@ const ThreeDBar = (props: PropTypes) => {
189
184
 
190
185
  {/******************* Top Label *****************/}
191
186
 
192
- {(item.topLabelComponent || showValuesAsTopLabel) && (
187
+ {topLabelComponent && (
193
188
  <View
194
189
  style={[
195
190
  {
@@ -202,17 +197,13 @@ const ThreeDBar = (props: PropTypes) => {
202
197
  },
203
198
  value < 0 && {transform: [{rotate: '180deg'}]},
204
199
  props.horizontal &&
205
- !intactTopLabel && {transform: [{rotate: '270deg'}]},
200
+ !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
206
201
  props.side === 'right'
207
202
  ? {right: (-1 * width) / 4}
208
203
  : {left: (-1 * width) / 4},
209
- topLabelContainerStyle ?? item.topLabelContainerStyle,
204
+ topLabelContainerStyle,
210
205
  ]}>
211
- {showValuesAsTopLabel ? (
212
- <Text style={topLabelTextStyle}>{item.value}</Text>
213
- ) : (
214
- item.topLabelComponent?.()
215
- )}
206
+ {topLabelComponent()}
216
207
  </View>
217
208
  )}
218
209
 
@@ -27,7 +27,6 @@ export const StripAndLabel = props => {
27
27
  pointerLabelComponent,
28
28
  secondaryPointerItem,
29
29
  scrollX,
30
- pointerEvents,
31
30
  } = props;
32
31
  let left = 0,
33
32
  top = 0;
@@ -126,7 +125,7 @@ export const StripAndLabel = props => {
126
125
 
127
126
  {pointerLabelComponent && (
128
127
  <View
129
- pointerEvents={pointerEvents ?? 'none'}
128
+ pointerEvents="none"
130
129
  style={[
131
130
  {
132
131
  position: 'absolute',
@@ -45,7 +45,6 @@ import {
45
45
  chartTypes,
46
46
  defaultArrowConfig,
47
47
  defaultPointerConfig,
48
- loc,
49
48
  screenWidth,
50
49
  } from '../utils/constants';
51
50
  import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
@@ -259,14 +258,17 @@ export const LineChart = (props: LineChartPropsType) => {
259
258
  const startIndex5 = props.startIndex5 || 0;
260
259
  const endIndex5 = props.endIndex5 ?? data5.length - 1;
261
260
 
261
+ const startIndicesFromSet = dataSet?.map(set => set.startIndex ?? 0);
262
+ const endIndicesFromSet = dataSet?.map(
263
+ set => set.endIndex ?? set.data.length - 1,
264
+ );
265
+
262
266
  const lineSegments = props.lineSegments;
263
267
  const lineSegments2 = props.lineSegments2;
264
268
  const lineSegments3 = props.lineSegments3;
265
269
  const lineSegments4 = props.lineSegments4;
266
270
  const lineSegments5 = props.lineSegments5;
267
271
 
268
- const highlightedRange = props.highlightedRange;
269
-
270
272
  if (!initialData) {
271
273
  initialData = data0 ?? [...data];
272
274
  animations = initialData.map(item => new Animated.Value(item.value));
@@ -883,57 +885,13 @@ export const LineChart = (props: LineChartPropsType) => {
883
885
  getNextPoint(data, i, around)
884
886
  );
885
887
  };
886
-
887
- const getRegionPrefix = (currentPointRegion, nextPointRegion) =>
888
- currentPointRegion === loc.OUT && nextPointRegion === loc.IN
889
- ? 'RangeEnter' + JSON.stringify(highlightedRange)
890
- : 'RangeExit';
891
-
892
- const getSegmentPath = (data, i, lineSegment, startIndex, endIndex) => {
893
- let path =
894
- 'L' +
895
- getX(i) +
896
- ' ' +
897
- getY(data[i].value) +
898
- ' ' +
899
- getSegmentString(lineSegment, i);
900
-
901
- if (highlightedRange && i !== endIndex) {
902
- const {from, to} = highlightedRange;
903
- console.log('from..',from);
904
- console.log('to..',to);
905
- const currentPointRegion =
906
- data[i].value >= from && data[i].value <= to ? loc.IN : loc.OUT;
907
- const nextPointRegion =
908
- data[i + 1].value >= from && data[i + 1].value <= to ? loc.IN : loc.OUT;
909
- console.log('currentPointRegion..',currentPointRegion);
910
- console.log('nextPointRegion..',nextPointRegion);
911
- if (currentPointRegion !== nextPointRegion) {
912
- const x1 = getX(i),
913
- y1 = getY(data[i].value),
914
- x2 = getX(i + 1),
915
- y2 = getY(data[i + 1].value);
916
-
917
- if (x2 - x1 === 0) {
918
- } else {
919
- const y = data[i + 1].value > data[i].value ? getY(from) : getY(to);
920
- const m = (y2 - y1) / (x2 - x1);
921
- const x = (y - y1) / m + x1;
922
-
923
- path +=
924
- getRegionPrefix(currentPointRegion, nextPointRegion) +
925
- 'L' +
926
- x +
927
- ' ' +
928
- y +
929
- ' ';
930
- }
931
- } else {
932
- }
933
- }
934
- console.log('path..',path);
935
- return path;
936
- };
888
+ const getSegmentPath = (data, i, lineSegment) =>
889
+ 'L' +
890
+ getX(i) +
891
+ ' ' +
892
+ getY(data[i].value) +
893
+ ' ' +
894
+ getSegmentString(lineSegment, i);
937
895
 
938
896
  useEffect(() => {
939
897
  if (dataSet) {
@@ -949,8 +907,8 @@ export const LineChart = (props: LineChartPropsType) => {
949
907
  const pArray: Array<Array<number>> = [];
950
908
  for (let i = 0; i < setData.length; i++) {
951
909
  if (
952
- i >= (set.startIndex ?? 0) &&
953
- i <= (set.endIndex ?? set.data.length - 1)
910
+ i >= (startIndicesFromSet?.[index] ?? 0) &&
911
+ i <= (endIndicesFromSet?.[index] ?? -1)
954
912
  ) {
955
913
  pArray.push([getX(i), getY(setData[i].value)]);
956
914
  }
@@ -995,19 +953,13 @@ export const LineChart = (props: LineChartPropsType) => {
995
953
  let pp = '';
996
954
  for (let i = 0; i < setData.length; i++) {
997
955
  if (
998
- i >= (set.startIndex ?? 0) &&
999
- i <= (set.endIndex ?? set.data.length - 1)
956
+ i >= (startIndicesFromSet?.[index] ?? 0) &&
957
+ i <= (endIndicesFromSet?.[index] ?? -1)
1000
958
  ) {
1001
959
  if (set.stepChart || stepChart) {
1002
960
  pp += getStepPath(setData, i);
1003
961
  } else {
1004
- pp += getSegmentPath(
1005
- setData,
1006
- i,
1007
- set.lineSegments,
1008
- set.startIndex ?? 0,
1009
- set.endIndex ?? set.data.length - 1,
1010
- );
962
+ pp += getSegmentPath(setData, i, set.lineSegments);
1011
963
  }
1012
964
  }
1013
965
  }
@@ -1066,13 +1018,7 @@ export const LineChart = (props: LineChartPropsType) => {
1066
1018
  if (stepChart || stepChart1) {
1067
1019
  pp += getStepPath(data, i);
1068
1020
  } else {
1069
- pp += getSegmentPath(
1070
- data,
1071
- i,
1072
- lineSegments,
1073
- startIndex1,
1074
- endIndex1,
1075
- );
1021
+ pp += getSegmentPath(data, i, lineSegments);
1076
1022
  }
1077
1023
  }
1078
1024
  if (data2.length && i >= startIndex2 && i <= endIndex2) {
@@ -1080,52 +1026,28 @@ export const LineChart = (props: LineChartPropsType) => {
1080
1026
  pp2 += getStepPath(data2, i);
1081
1027
  (' ');
1082
1028
  } else {
1083
- pp2 += getSegmentPath(
1084
- data2,
1085
- i,
1086
- lineSegments2,
1087
- startIndex2,
1088
- endIndex2,
1089
- );
1029
+ pp2 += getSegmentPath(data2, i, lineSegments2);
1090
1030
  }
1091
1031
  }
1092
1032
  if (data3.length && i >= startIndex3 && i <= endIndex3) {
1093
1033
  if (stepChart || stepChart3) {
1094
1034
  pp3 += getStepPath(data3, i);
1095
1035
  } else {
1096
- pp3 += getSegmentPath(
1097
- data2,
1098
- i,
1099
- lineSegments2,
1100
- startIndex3,
1101
- endIndex3,
1102
- );
1036
+ pp3 += getSegmentPath(data2, i, lineSegments2);
1103
1037
  }
1104
1038
  }
1105
1039
  if (data4.length && i >= startIndex4 && i <= endIndex4) {
1106
1040
  if (stepChart || stepChart4) {
1107
1041
  pp4 += getStepPath(data4, i);
1108
1042
  } else {
1109
- pp4 += getSegmentPath(
1110
- data4,
1111
- i,
1112
- lineSegments4,
1113
- startIndex4,
1114
- endIndex4,
1115
- );
1043
+ pp4 += getSegmentPath(data4, i, lineSegments4);
1116
1044
  }
1117
1045
  }
1118
1046
  if (data5.length && i >= startIndex5 && i <= endIndex5) {
1119
1047
  if (stepChart || stepChart5) {
1120
1048
  pp5 += getStepPath(data5, i);
1121
1049
  } else {
1122
- pp5 += getSegmentPath(
1123
- data5,
1124
- i,
1125
- lineSegments5,
1126
- startIndex5,
1127
- endIndex4,
1128
- );
1050
+ pp5 += getSegmentPath(data5, i, lineSegments5);
1129
1051
  }
1130
1052
  }
1131
1053
  }
@@ -1769,7 +1691,6 @@ export const LineChart = (props: LineChartPropsType) => {
1769
1691
  const hideSecondaryPointer =
1770
1692
  pointerConfig?.hideSecondaryPointer ??
1771
1693
  defaultPointerConfig.hideSecondaryPointer;
1772
- const pointerEvents = pointerConfig?.pointerEvents;
1773
1694
  const disableScroll =
1774
1695
  props.disableScroll ||
1775
1696
  (pointerConfig
@@ -2342,7 +2263,6 @@ export const LineChart = (props: LineChartPropsType) => {
2342
2263
  pointerLabelComponent,
2343
2264
  secondaryPointerItem,
2344
2265
  scrollX,
2345
- pointerEvents,
2346
2266
  });
2347
2267
  };
2348
2268
 
@@ -2410,7 +2330,7 @@ export const LineChart = (props: LineChartPropsType) => {
2410
2330
  if (!points) return null;
2411
2331
  const isCurved = points.includes('C');
2412
2332
  let ar: [any] = [{}];
2413
- if (points.includes('RangeStart')) {
2333
+ if (points.includes('segmentStart')) {
2414
2334
  ar = getSegmentedPathObjects(
2415
2335
  points,
2416
2336
  color,
@@ -2418,19 +2338,6 @@ export const LineChart = (props: LineChartPropsType) => {
2418
2338
  thickness,
2419
2339
  strokeDashArray,
2420
2340
  isCurved,
2421
- 'RangeEnter',
2422
- 'RangeExit',
2423
- );
2424
- } else if (points.includes('segmentStart')) {
2425
- ar = getSegmentedPathObjects(
2426
- points,
2427
- color,
2428
- currentLineThickness,
2429
- thickness,
2430
- strokeDashArray,
2431
- isCurved,
2432
- 'segmentStart',
2433
- 'segmentEnd',
2434
2341
  );
2435
2342
  }
2436
2343
  const lineSvgPropsOuter: LineSvgProps = {
@@ -2451,12 +2358,10 @@ export const LineChart = (props: LineChartPropsType) => {
2451
2358
  ) {
2452
2359
  lineSvgPropsOuter.strokeDasharray = strokeDashArray;
2453
2360
  }
2454
-
2455
- return null;
2456
2361
  return (
2457
2362
  <Svg>
2458
2363
  {lineGradient && getLineGradientComponent()}
2459
- {points.includes('segmentStart') || points.includes('RangeStart') ? (
2364
+ {points.includes('segmentStart') ? (
2460
2365
  ar.map((item, index) => {
2461
2366
  const lineSvgProps: LineSvgProps = {
2462
2367
  d: item.d,
@@ -3482,15 +3387,14 @@ export const LineChart = (props: LineChartPropsType) => {
3482
3387
  : null}
3483
3388
  {pointerX > 0 ? (
3484
3389
  <View
3485
- pointerEvents={pointerEvents ?? 'none'}
3390
+ pointerEvents="none"
3486
3391
  style={{
3487
3392
  position: 'absolute',
3488
3393
  height:
3489
3394
  extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
3490
3395
  bottom: 58 + labelsExtraHeight + xAxisLabelsVerticalShift,
3491
- // width: totalWidth,
3396
+ width: totalWidth,
3492
3397
  zIndex: 20,
3493
- backgroundColor: 'orange',
3494
3398
  }}>
3495
3399
  {!stripOverPointer && renderStripAndLabel()}
3496
3400
  {dataSet ? (
@@ -4,7 +4,6 @@ import {
4
4
  CurveType,
5
5
  DataSet,
6
6
  EdgePosition,
7
- HighlightedRange,
8
7
  LineSegment,
9
8
  Pointer,
10
9
  RuleType,
@@ -311,7 +310,6 @@ export type LineChartPropsType = {
311
310
  lineSegments3?: Array<LineSegment>;
312
311
  lineSegments4?: Array<LineSegment>;
313
312
  lineSegments5?: Array<LineSegment>;
314
- highlightedRange?: HighlightedRange;
315
313
  };
316
314
 
317
315
  type referenceConfigType = {
@@ -24,18 +24,12 @@ export enum yAxisSides {
24
24
  RIGHT,
25
25
  }
26
26
 
27
- export enum loc {
28
- IN,
29
- OUT
30
- }
31
-
32
27
  export const ruleTypes: RuleTypes = {
33
28
  SOLID: 'solid',
34
29
  DASHED: 'dashed',
35
30
  DOTTED: 'dotted',
36
31
  };
37
32
 
38
-
39
33
  export const AxesAndRulesDefaults = {
40
34
  yAxisSide: yAxisSides.LEFT,
41
35
  yAxisColor: 'black',
@@ -245,7 +239,6 @@ export const defaultPointerConfig = {
245
239
  hidePointer5: false,
246
240
  hideSecondaryPointer: false,
247
241
  barTouchable: false,
248
- // pointerEvents: PointerEvent
249
242
  };
250
243
 
251
244
  // Pie chart specific
@@ -168,7 +168,7 @@ export const bezierCommand = (
168
168
 
169
169
  export const getSegmentString = (lineSegment, index) => {
170
170
  const segment = lineSegment?.find(segment => segment.startIndex === index);
171
- return segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '';
171
+ return segment ? 'segmentStart' + JSON.stringify(segment) + 'segmentEnd' : '';
172
172
  };
173
173
 
174
174
  export const getCurvePathWithSegments = (
@@ -183,7 +183,7 @@ export const getCurvePathWithSegments = (
183
183
  newPath +=
184
184
  (pathArray[i].startsWith('M') ? '' : 'C') +
185
185
  pathArray[i] +
186
- (segment ? startDelimeter + JSON.stringify(segment) + endDelimeter : '');
186
+ (segment ? 'segmentStart' + JSON.stringify(segment) + 'segmentEnd' : '');
187
187
  }
188
188
  return newPath;
189
189
  };
@@ -200,17 +200,6 @@ export const getPreviousSegmentsLastPoint = (isCurved, previousSegment) => {
200
200
  );
201
201
  };
202
202
 
203
- // export const getRegionPathObjects = (
204
- // points,
205
- // color,
206
- // currentLineThickness,
207
- // thickness,
208
- // strokeDashArray,
209
- // isCurved,
210
- // ) => {
211
-
212
- // }
213
-
214
203
  export const getSegmentedPathObjects = (
215
204
  points,
216
205
  color,
@@ -218,17 +207,15 @@ export const getSegmentedPathObjects = (
218
207
  thickness,
219
208
  strokeDashArray,
220
209
  isCurved,
221
- startDelimeter,
222
- endDelimeter,
223
210
  ) => {
224
211
  const ar: [any] = [{}];
225
212
  let tempStr = points;
226
213
 
227
- if (!points.startsWith(startDelimeter)) {
214
+ if (!points.startsWith('segmentStart')) {
228
215
  /********************** line upto first segment *****************/
229
216
 
230
217
  const lineSvgProps: LineProperties = {
231
- d: points.substring(0, points.indexOf(startDelimeter)),
218
+ d: points.substring(0, points.indexOf('segmentStart')),
232
219
  color,
233
220
  strokeWidth: currentLineThickness || thickness,
234
221
  };
@@ -238,20 +225,20 @@ export const getSegmentedPathObjects = (
238
225
  ar.push(lineSvgProps);
239
226
  }
240
227
 
241
- while (tempStr.includes(startDelimeter)) {
242
- const startDelimeterIndex = tempStr.indexOf(startDelimeter);
243
- const endDelimeterIndex = tempStr.indexOf(endDelimeter);
228
+ while (tempStr.includes('segmentStart')) {
229
+ const startDelimeterIndex = tempStr.indexOf('segmentStart');
230
+ const endDelimeterIndex = tempStr.indexOf('segmentEnd');
244
231
 
245
232
  const segmentConfig = JSON.parse(
246
233
  tempStr.substring(
247
- startDelimeterIndex + startDelimeter.length,
234
+ startDelimeterIndex + 'segmentStart'.length,
248
235
  endDelimeterIndex,
249
236
  ),
250
237
  );
251
238
 
252
239
  const {startIndex, endIndex} = segmentConfig;
253
240
  const segmentLength = endIndex - startIndex;
254
- let segment = tempStr.substring(endDelimeterIndex + endDelimeter.length);
241
+ let segment = tempStr.substring(endDelimeterIndex + 'segmentEnd'.length);
255
242
  let c = 0,
256
243
  s = 0,
257
244
  i;
@@ -283,9 +270,9 @@ export const getSegmentedPathObjects = (
283
270
  }
284
271
  ar.push(lineSvgProps);
285
272
 
286
- tempStr = tempStr.substring(endDelimeterIndex + endDelimeter.length + i);
273
+ tempStr = tempStr.substring(endDelimeterIndex + 'segmentEnd'.length + i);
287
274
 
288
- const nextDelimiterIndex = tempStr.indexOf(startDelimeter);
275
+ const nextDelimiterIndex = tempStr.indexOf('segmentStart');
289
276
  const stringUptoNextSegment = tempStr.substring(0, nextDelimiterIndex);
290
277
 
291
278
  /********************** line upto the next segment *****************/
@@ -331,7 +318,6 @@ export const getSegmentedPathObjects = (
331
318
  }
332
319
 
333
320
  ar.shift();
334
- console.log('ar...',ar)
335
321
  return ar;
336
322
  };
337
323
 
@@ -394,7 +380,6 @@ export const getAxesAndRulesProps = (
394
380
  xAxisColor: props.xAxisColor,
395
381
  xAxisLength: props.xAxisLength,
396
382
  xAxisType: props.xAxisType,
397
- xAxisTextNumberOfLines: props.xAxisTextNumberOfLines ?? 1,
398
383
  xAxisLabelsHeight: props.xAxisLabelsHeight,
399
384
  xAxisLabelsVerticalShift: props.xAxisLabelsVerticalShift,
400
385
  dashWidth: props.dashWidth,
@@ -29,8 +29,6 @@ export type RulesConfig = {
29
29
  dashGap?: number;
30
30
  };
31
31
 
32
- export type PointerEvents = "box-none" | "none" | "box-only" | "auto";
33
-
34
32
  export type secondaryYAxisType = {
35
33
  noOfSections?: number;
36
34
  maxValue?: number;
@@ -276,17 +274,8 @@ export type Pointer = {
276
274
  hideSecondaryPointer?: boolean;
277
275
  strokeDashArray?: Array<number>;
278
276
  barTouchable?: boolean;
279
- pointerEvents?: PointerEvents;
280
277
  };
281
278
 
282
- export type HighlightedRange = {
283
- from: number;
284
- to: number;
285
- color?: string | ColorValue;
286
- thickness?: number;
287
- strokeDashArray?: Array<number>;
288
- }
289
-
290
279
  export type LineSegment = {
291
280
  startIndex: number;
292
281
  endIndex: number;