react-native-gifted-charts 1.3.30 → 1.3.32

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.30",
3
+ "version": "1.3.32",
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": [
@@ -92,10 +92,10 @@ export const BarChart = (props: BarChartPropsType) => {
92
92
  defaultLineConfig.animationDuration = animationDuration;
93
93
 
94
94
  const lineConfig = props.lineConfig
95
- ? getLineConfigForBarChart(props.lineConfig)
95
+ ? getLineConfigForBarChart(props.lineConfig, initialSpacing)
96
96
  : defaultLineConfig;
97
97
  const lineConfig2 = props.lineConfig2
98
- ? getLineConfigForBarChart(props.lineConfig2)
98
+ ? getLineConfigForBarChart(props.lineConfig2, initialSpacing)
99
99
  : defaultLineConfig;
100
100
  const noOfSections = props.noOfSections ?? AxesAndRulesDefaults.noOfSections;
101
101
  const containerHeight =
@@ -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,
@@ -361,7 +361,7 @@ const RenderLineInBarChart = props => {
361
361
  style={{
362
362
  position: 'absolute',
363
363
  height: containerHeight + 10 + labelsExtraHeight,
364
- left: 34 - yAxisLabelWidth,
364
+ left: 6 - yAxisLabelWidth,
365
365
  bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
366
366
  width: totalWidth,
367
367
  zIndex: lineBehindBars ? -1 : 100000,
@@ -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 =>
@@ -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
  }}>
@@ -1046,7 +1046,7 @@ export const getXForLineInBar = (
1046
1046
  (currentBarWidth + (lineConfig.spacing ?? spacing)) * index +
1047
1047
  lineConfig.shiftX -
1048
1048
  lineConfig.dataPointsWidth / 2 -
1049
- 32;
1049
+ 4;
1050
1050
 
1051
1051
  export const getYForLineInBar = (value, shiftY, containerHeight, maxValue) =>
1052
1052
  containerHeight - shiftY - (value * containerHeight) / maxValue;
@@ -1069,11 +1069,13 @@ export const clone = obj => {
1069
1069
  return temp;
1070
1070
  };
1071
1071
 
1072
- export const getLineConfigForBarChart = lineConfig => {
1072
+ export const getLineConfigForBarChart = (lineConfig, barInitialSpacing) => {
1073
1073
  return {
1074
1074
  initialSpacing:
1075
- lineConfig.initialSpacing ?? defaultLineConfig.initialSpacing,
1076
- spacing: lineConfig.initialSpacing,
1075
+ lineConfig.initialSpacing ??
1076
+ barInitialSpacing ??
1077
+ defaultLineConfig.initialSpacing,
1078
+ spacing: lineConfig.spacing,
1077
1079
  curved: lineConfig.curved || defaultLineConfig.curved,
1078
1080
  curvature: lineConfig.curvature ?? defaultLineConfig.curvature,
1079
1081
  curveType: lineConfig.curveType ?? defaultLineConfig.curveType,