react-native-gifted-charts 1.4.13 → 1.4.14

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.4.13",
3
+ "version": "1.4.14",
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": [
@@ -25,7 +25,7 @@
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  },
27
27
  "dependencies": {
28
- "gifted-charts-core": "^0.1.8"
28
+ "gifted-charts-core": "^0.1.10"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/core": "^7.22.5",
@@ -52,6 +52,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
52
52
  noOfSectionsBelowXAxis,
53
53
  yAxisOffset,
54
54
  barWidth,
55
+ labelsDistanceFromXaxis = 0,
55
56
  } = props;
56
57
 
57
58
  const barHeight = Math.max(
@@ -97,7 +98,8 @@ const RenderBars = (props: RenderBarsPropsType) => {
97
98
  (rotateLabel
98
99
  ? -40
99
100
  : -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
100
- barMarginBottom,
101
+ barMarginBottom -
102
+ labelsDistanceFromXaxis,
101
103
  },
102
104
  rotateLabel
103
105
  ? horizontal
@@ -406,7 +408,9 @@ const RenderBars = (props: RenderBarsPropsType) => {
406
408
  activeOpacity={props.activeOpacity || 0.2}
407
409
  onPress={() => {
408
410
  if (renderTooltip || props.focusBarOnPress) {
409
- setSelectedIndex(index);
411
+ if (props.focusedBarIndex === undefined || !props.onPress) {
412
+ setSelectedIndex(index);
413
+ }
410
414
  }
411
415
  item.onPress
412
416
  ? item.onPress()
@@ -8,7 +8,7 @@ import {
8
8
  UIManager,
9
9
  } from 'react-native';
10
10
  import Svg, {Defs, Rect} from 'react-native-svg';
11
- import LinearGradient from "../Components/common/LinearGradient";
11
+ import LinearGradient from '../Components/common/LinearGradient';
12
12
  import {
13
13
  useRenderStackBars,
14
14
  BarDefaults,
@@ -49,6 +49,8 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
49
49
  stackBorderBottomLeftRadius,
50
50
  stackBorderBottomRightRadius,
51
51
  showValuesAsTopLabel,
52
+ autoShiftLabelsForNegativeStacks = true,
53
+ labelsDistanceFromXaxis = 0,
52
54
  } = props;
53
55
  const {
54
56
  cotainsNegative,
@@ -78,9 +80,9 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
78
80
  width:
79
81
  (item.stacks[0].barWidth || props.barWidth || 30) + spacing / 2,
80
82
  position: 'absolute',
81
- bottom: rotateLabel
82
- ? -40
83
- : -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition,
83
+ bottom: autoShiftLabelsForNegativeStacks
84
+ ? -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition
85
+ : -labelsDistanceFromXaxis,
84
86
  },
85
87
  rotateLabel
86
88
  ? props.horizontal
@@ -86,7 +86,14 @@ export const BarChart = (props: BarChartPropsType) => {
86
86
  autoShiftLabels,
87
87
  getPropsCommonForBarAndStack,
88
88
  barAndLineChartsWrapperProps,
89
- } = useBarChart({...props, heightValue, widthValue, opacValue, parentWidth: props.parentWidth ?? screenWidth});
89
+ autoShiftLabelsForNegativeStacks,
90
+ } = useBarChart({
91
+ ...props,
92
+ heightValue,
93
+ widthValue,
94
+ opacValue,
95
+ parentWidth: props.parentWidth ?? screenWidth,
96
+ });
90
97
 
91
98
  const labelsAppear = useCallback(() => {
92
99
  opacValue.setValue(0);
@@ -327,6 +334,7 @@ export const BarChart = (props: BarChartPropsType) => {
327
334
  stackBorderTopRightRadius={props.stackBorderTopRightRadius}
328
335
  stackBorderBottomLeftRadius={props.stackBorderBottomLeftRadius}
329
336
  stackBorderBottomRightRadius={props.stackBorderBottomRightRadius}
337
+ autoShiftLabelsForNegativeStacks={autoShiftLabelsForNegativeStacks}
330
338
  {...getPropsCommonForBarAndStack(item, index)}
331
339
  />
332
340
  );