react-native-gifted-charts 1.4.5 → 1.4.7

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.5",
3
+ "version": "1.4.7",
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": [
@@ -24,7 +24,7 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "dependencies": {
27
- "gifted-charts-core": "^0.0.15"
27
+ "gifted-charts-core": "^0.0.21"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.22.5",
@@ -31,13 +31,14 @@ import {
31
31
  lineDataItem,
32
32
  LineSvgProps,
33
33
  useLineChart,
34
+ adjustToOffset,
34
35
  } from 'gifted-charts-core';
35
36
  import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
36
37
  import {StripAndLabel} from '../Components/common/StripAndLabel';
37
38
  import {Pointer} from '../Components/common/Pointer';
38
39
 
39
40
  let initialData: Array<lineDataItem> | null = null;
40
- let animations: Array<any> = [];
41
+ let animations: Array<Animated.Value> = [];
41
42
 
42
43
  export const LineChart = (props: LineChartPropsType) => {
43
44
  const scrollRef = props.scrollRef ?? useRef(null);
@@ -48,6 +49,11 @@ export const LineChart = (props: LineChartPropsType) => {
48
49
  const widthValue4 = useMemo(() => new Animated.Value(0), []);
49
50
  const widthValue5 = useMemo(() => new Animated.Value(0), []);
50
51
 
52
+ if (!initialData) {
53
+ initialData = props.dataSet?.[0]?.data ?? props.data ?? [];
54
+ animations = initialData.map(item => new Animated.Value(item.value));
55
+ }
56
+
51
57
  const {
52
58
  scrollX,
53
59
  setScrollX,
@@ -295,11 +301,6 @@ export const LineChart = (props: LineChartPropsType) => {
295
301
  barAndLineChartsWrapperProps,
296
302
  } = useLineChart({...props, animations});
297
303
 
298
- if (!initialData) {
299
- initialData = data0 ?? [...data];
300
- animations = initialData?.map(item => new Animated.Value(item.value));
301
- }
302
-
303
304
  const widthValuesFromSet = useMemo(
304
305
  () => dataSet?.map(set => new Animated.Value(0)),
305
306
  [],
@@ -1120,14 +1121,10 @@ export const LineChart = (props: LineChartPropsType) => {
1120
1121
 
1121
1122
  {dataSet?.map(set => renderSpecificVerticalLines(set?.data)) ?? null}
1122
1123
  {dataSet?.map(set => {
1123
- const setData = set.data.map(item => {
1124
- item.value = item.value - (props.yAxisOffset ?? 0);
1125
- return item;
1126
- });
1127
1124
  return renderDataPoints(
1128
1125
  set.hideDataPoints ?? hideDataPoints1,
1129
- setData,
1130
1126
  set.data,
1127
+ adjustToOffset(set.data, -(props.yAxisOffset ?? 0)), // need the actual values passed by user
1131
1128
  set.dataPointsShape ?? dataPointsShape1,
1132
1129
  set.dataPointsWidth ?? dataPointsWidth1,
1133
1130
  set.dataPointsHeight ?? dataPointsHeight1,
@@ -135,6 +135,8 @@ export const PieChart = (props: PieChartPropsType) => {
135
135
  props.data[selectedIndex].strokeWidth || undefined,
136
136
  gradientCenterColor:
137
137
  props.data[selectedIndex].gradientCenterColor || undefined,
138
+ shiftTextX: props.data[selectedIndex].shiftTextX || undefined,
139
+ shiftTextY: props.data[selectedIndex].shiftTextY || undefined,
138
140
  },
139
141
  {
140
142
  value: total - props.data[selectedIndex].value,
@@ -264,8 +264,12 @@ export const PieChartMain = (props: PieChartMainProps) => {
264
264
  {/* <Line x1={mx} x2={cx} y1={my} y2={cy} stroke="black" /> */}
265
265
  {showTextBackground ? (
266
266
  <Circle
267
- cx={x}
268
- cy={y - (item.textSize || textSize) / 4}
267
+ cx={x + (item.shiftTextBackgroundX ?? item.shiftTextX ?? 0)}
268
+ cy={
269
+ y +
270
+ (item.shiftTextBackgroundY ?? item.shiftTextY ?? 0) -
271
+ (item.textSize || textSize) / 4
272
+ }
269
273
  r={
270
274
  item.textBackgroundRadius ||
271
275
  props.textBackgroundRadius ||