react-native-gifted-charts 1.3.29 → 1.3.31

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.29",
3
+ "version": "1.3.31",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -628,6 +628,7 @@ export const BarChart = (props: BarChartPropsType) => {
628
628
  pointerLabelComponent,
629
629
  scrollX: 0,
630
630
  pointerEvents,
631
+ isBarChart: true,
631
632
  });
632
633
  };
633
634
 
@@ -55,6 +55,7 @@ export type stackItemType = {
55
55
  export type BarChartPropsType = {
56
56
  width?: number;
57
57
  height?: number;
58
+ overflowTop?: number;
58
59
  minHeight?: number;
59
60
  noOfSections?: number;
60
61
  noOfSectionsBelowXAxis?: number;
@@ -354,7 +354,8 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
354
354
  labelsExtraHeight +
355
355
  xAxisLabelsVerticalShift +
356
356
  (trimYAxisAtTop ? 0 : yAxisExtraHeight) +
357
- 50,
357
+ 50 -
358
+ overflowTop,
358
359
  marginTop: trimYAxisAtTop ? containerHeight / 20 : 0,
359
360
  marginBottom: (xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18) - 55, //This is to not let the Things that should be rendered below the chart overlap with it
360
361
  },
@@ -393,9 +394,7 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
393
394
  ? 0
394
395
  : yAxisLabelWidth + yAxisThickness,
395
396
  position: 'absolute',
396
- bottom:
397
- overflowTop +
398
- (chartType === chartTypes.LINE_BI_COLOR ? 0 : xAxisThickness),
397
+ bottom: chartType === chartTypes.LINE_BI_COLOR ? 0 : xAxisThickness,
399
398
  },
400
399
  !!props.width && {width: props.width},
401
400
  horizontal && {
@@ -409,7 +408,6 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
409
408
  containerHeightIncludingBelowXAxis +
410
409
  yAxisExtraHeight +
411
410
  labelsExtraHeight +
412
- stepHeight / 2 +
413
411
  (50 + xAxisLabelsVerticalShift),
414
412
  width: Math.max(
415
413
  props.width ?? 0,
@@ -664,6 +664,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
664
664
  </View>
665
665
  ) : (
666
666
  <View
667
+ pointerEvents='none'
667
668
  style={{
668
669
  flexDirection: 'row',
669
670
  marginTop: stepHeight / -2,
@@ -28,6 +28,7 @@ export const StripAndLabel = props => {
28
28
  secondaryPointerItem,
29
29
  scrollX,
30
30
  pointerEvents,
31
+ isBarChart,
31
32
  } = props;
32
33
  let left = 0,
33
34
  top = 0;
@@ -86,7 +87,11 @@ export const StripAndLabel = props => {
86
87
  left: pointerX + (pointerItemLocal[0].pointerShiftX || 0),
87
88
  top: pointerYLocal,
88
89
  }}>
89
- {showPointerStrip && !pointerLabelComponent ? (
90
+ {(
91
+ isBarChart
92
+ ? showPointerStrip && !pointerLabelComponent
93
+ : showPointerStrip
94
+ ) ? (
90
95
  <View
91
96
  style={{
92
97
  position: 'absolute',
@@ -467,9 +467,11 @@ export const LineChart = (props: LineChartPropsType) => {
467
467
  const maxValue = props.maxValue || maxItem;
468
468
  const mostNegativeValue = props.mostNegativeValue || minItem;
469
469
 
470
+ const overflowTop = props.overflowTop ?? 0;
471
+
470
472
  const extendedContainerHeight = getExtendedContainerHeightWithPadding(
471
473
  containerHeight,
472
- props.overflowTop,
474
+ overflowTop,
473
475
  );
474
476
  const getX = index => initialSpacing + spacing * index - 1;
475
477
  const getY = value =>
@@ -1081,9 +1083,9 @@ export const LineChart = (props: LineChartPropsType) => {
1081
1083
  pp3 += getStepPath(data3, i);
1082
1084
  } else {
1083
1085
  pp3 += getSegmentPath(
1084
- data2,
1086
+ data3,
1085
1087
  i,
1086
- lineSegments2,
1088
+ lineSegments3,
1087
1089
  startIndex3,
1088
1090
  endIndex3,
1089
1091
  );
@@ -1111,7 +1113,7 @@ export const LineChart = (props: LineChartPropsType) => {
1111
1113
  i,
1112
1114
  lineSegments5,
1113
1115
  startIndex5,
1114
- endIndex4,
1116
+ endIndex5,
1115
1117
  );
1116
1118
  }
1117
1119
  }
@@ -2107,7 +2109,7 @@ export const LineChart = (props: LineChartPropsType) => {
2107
2109
  x={initialSpacing + (spacing * index - spacing / 2)}
2108
2110
  y={8}
2109
2111
  width={spacing}
2110
- height={containerHeight - 0}
2112
+ height={containerHeight}
2111
2113
  fill={'none'}
2112
2114
  />
2113
2115
  )}
@@ -2128,7 +2130,7 @@ export const LineChart = (props: LineChartPropsType) => {
2128
2130
  width={currentStripWidth}
2129
2131
  height={
2130
2132
  currentStripHeight ||
2131
- (item.value * containerHeight) / maxValue - 2
2133
+ (item.value * containerHeight) / maxValue - 2 + overflowTop
2132
2134
  }
2133
2135
  opacity={currentStripOpacity}
2134
2136
  fill={stripColor}
@@ -3544,10 +3546,7 @@ export const LineChart = (props: LineChartPropsType) => {
3544
3546
  height:
3545
3547
  extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
3546
3548
  bottom:
3547
- 58 +
3548
- labelsExtraHeight +
3549
- xAxisLabelsVerticalShift -
3550
- (props.overflowTop ?? 0),
3549
+ 58 + labelsExtraHeight + xAxisLabelsVerticalShift - overflowTop,
3551
3550
  // width: totalWidth,
3552
3551
  zIndex: 20,
3553
3552
  }}>
@@ -128,8 +128,8 @@ export const PieChartMain = (props: propTypes) => {
128
128
  const labelsPosition = props.labelsPosition
129
129
  ? props.labelsPosition
130
130
  : donut || props.centerLabelComponent
131
- ? 'outward'
132
- : 'mid';
131
+ ? 'outward'
132
+ : 'mid';
133
133
 
134
134
  const showTextBackground = props.showTextBackground || false;
135
135
  const textBackgroundColor = props.textBackgroundColor || 'white';
@@ -201,7 +201,7 @@ export const PieChartMain = (props: propTypes) => {
201
201
  isThreeD && {transform: [{rotateX: tiltAngle}]},
202
202
  ]}>
203
203
  <Svg
204
- pointerEvents={rnVersion >= 700000 ? 'box-none' : 'auto'}
204
+ pointerEvents={rnVersion >= 720000 ? 'box-none' : 'auto'} // use 'box-none' react-native version 0.72 onwards
205
205
  viewBox={`${strokeWidth / -2 + minShiftX} ${
206
206
  strokeWidth / -2 + minShiftY
207
207
  } ${
@@ -257,8 +257,8 @@ export const PieChartMain = (props: propTypes) => {
257
257
  data[0].onPress
258
258
  ? data[0].onPress()
259
259
  : props.onPress
260
- ? props.onPress(data[0], 0)
261
- : null;
260
+ ? props.onPress(data[0], 0)
261
+ : null;
262
262
  }}
263
263
  />
264
264
  </>
@@ -298,15 +298,15 @@ export const PieChartMain = (props: propTypes) => {
298
298
  props.focusOnPress && props.selectedIndex === index
299
299
  ? 0
300
300
  : item.strokeWidth === 0
301
- ? 0
302
- : item.strokeWidth || strokeWidth
301
+ ? 0
302
+ : item.strokeWidth || strokeWidth
303
303
  }
304
304
  fill={
305
305
  props.selectedIndex === index || item.peripheral
306
306
  ? 'transparent'
307
307
  : showGradient
308
- ? `url(#grad${index})`
309
- : item.color || pieColors[index % 9]
308
+ ? `url(#grad${index})`
309
+ : item.color || pieColors[index % 9]
310
310
  }
311
311
  onPress={() => {
312
312
  if (item.onPress) {
@@ -391,12 +391,12 @@ export const PieChartMain = (props: propTypes) => {
391
391
  item.onLabelPress
392
392
  ? item.onLabelPress()
393
393
  : props.onLabelPress
394
- ? props.onLabelPress(item, index)
395
- : item.onPress
396
- ? item.onPress()
397
- : props.onPress
398
- ? props.onPress(item, index)
399
- : null;
394
+ ? props.onLabelPress(item, index)
395
+ : item.onPress
396
+ ? item.onPress()
397
+ : props.onPress
398
+ ? props.onPress(item, index)
399
+ : null;
400
400
  if (props.focusOnPress) {
401
401
  if (props.selectedIndex === index) {
402
402
  if (toggleFocusOnPress) {
@@ -427,12 +427,12 @@ export const PieChartMain = (props: propTypes) => {
427
427
  item.onLabelPress
428
428
  ? item.onLabelPress()
429
429
  : props.onLabelPress
430
- ? props.onLabelPress(item, index)
431
- : item.onPress
432
- ? item.onPress()
433
- : props.onPress
434
- ? props.onPress(item, index)
435
- : null;
430
+ ? props.onLabelPress(item, index)
431
+ : item.onPress
432
+ ? item.onPress()
433
+ : props.onPress
434
+ ? props.onPress(item, index)
435
+ : null;
436
436
  if (props.focusOnPress) {
437
437
  if (props.selectedIndex === index) {
438
438
  if (toggleFocusOnPress) {