react-native-gifted-charts 1.4.14 → 1.4.16

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.14",
3
+ "version": "1.4.16",
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.10"
28
+ "gifted-charts-core": "^0.1.13"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@babel/core": "^7.22.5",
@@ -73,7 +73,7 @@ const Animated2DWithGradient = (props: Animated2DWithGradientPropsType) => {
73
73
  <View
74
74
  style={{
75
75
  position: 'absolute',
76
- bottom: -0.5,
76
+ bottom: 0,
77
77
  width: '100%',
78
78
  overflow: 'hidden',
79
79
  height:
@@ -53,12 +53,20 @@ const RenderBars = (props: RenderBarsPropsType) => {
53
53
  yAxisOffset,
54
54
  barWidth,
55
55
  labelsDistanceFromXaxis = 0,
56
+ stepHeight,
57
+ stepValue,
58
+ negativeStepHeight,
59
+ negativeStepValue,
56
60
  } = props;
57
61
 
62
+ const heightFactor =
63
+ item.value < 0
64
+ ? negativeStepHeight / negativeStepValue
65
+ : stepHeight / stepValue;
66
+
58
67
  const barHeight = Math.max(
59
68
  minHeight,
60
- (Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200) -
61
- xAxisThickness,
69
+ Math.abs(item.value) * heightFactor - xAxisThickness,
62
70
  );
63
71
 
64
72
  const {
@@ -295,10 +303,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
295
303
  translateY:
296
304
  (containerHeight || 200) -
297
305
  (barHeight - 10 + xAxisLabelsVerticalShift) +
298
- (item.value < 0
299
- ? (Math.abs(item.value) * (containerHeight || 200)) /
300
- (maxValue || 200)
301
- : 0),
306
+ (item.value < 0 ? Math.abs(item.value) * heightFactor : 0),
302
307
  },
303
308
  ],
304
309
  }
@@ -306,9 +311,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
306
311
  ? {
307
312
  transform: [
308
313
  {
309
- translateY:
310
- (Math.abs(item.value) * (containerHeight || 200)) /
311
- (maxValue || 200),
314
+ translateY: Math.abs(item.value) * heightFactor,
312
315
  },
313
316
  {rotateZ: '180deg'},
314
317
  ],
@@ -7,10 +7,12 @@ import {
7
7
  yAxisSides,
8
8
  HorizSectionsType,
9
9
  horizSectionPropTypes,
10
+ chartTypes,
10
11
  } from 'gifted-charts-core';
11
12
 
12
13
  export const renderHorizSections = (props: horizSectionPropTypes) => {
13
14
  const {
15
+ chartType,
14
16
  width,
15
17
  noOfSectionsBelowXAxis,
16
18
  totalWidth,
@@ -18,7 +20,9 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
18
20
  yAxisSide,
19
21
  horizontalRulesStyle,
20
22
  noOfSections,
23
+ sectionColors,
21
24
  stepHeight,
25
+ negativeStepHeight,
22
26
  yAxisLabelWidth,
23
27
  yAxisLabelContainerStyle,
24
28
  yAxisThickness,
@@ -92,7 +96,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
92
96
  : styles.leftPart,
93
97
  {
94
98
  borderColor: yAxisColor,
95
- backgroundColor: backgroundColor,
99
+ backgroundColor: sectionColors?.[invertedIndex] ?? backgroundColor,
96
100
  width: (props.width || totalWidth - spacing) + endSpacing,
97
101
  },
98
102
  !index ? {height: stepHeight / 2, marginTop: stepHeight / 2} : null,
@@ -328,6 +332,12 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
328
332
  );
329
333
  };
330
334
 
335
+ const leftShiftForRIghtYaxis =
336
+ (width ? width + 20 : totalWidth) +
337
+ yAxisLabelWidth / 2 +
338
+ endSpacing -
339
+ (chartType === chartTypes.BAR ? 40 : 60);
340
+
331
341
  return (
332
342
  <>
333
343
  {onlyReferenceLines ? (
@@ -409,7 +419,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
409
419
  : stepHeight,
410
420
  },
411
421
  yAxisSide === yAxisSides.RIGHT && {
412
- left: (width ?? totalWidth) + yAxisLabelWidth / 2,
422
+ left: leftShiftForRIghtYaxis,
413
423
  },
414
424
  horizontal &&
415
425
  !yAxisAtTop && {
@@ -458,7 +468,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
458
468
  {
459
469
  width: (width ?? totalWidth) + 15,
460
470
  },
461
- index === 0 && {marginTop: stepHeight / 2},
471
+ index === 0 && {marginTop: negativeStepHeight / 2},
462
472
  ]}>
463
473
  <View
464
474
  style={[
@@ -469,11 +479,14 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
469
479
  marginLeft: yAxisThickness,
470
480
  },
471
481
  {
472
- height: index === 0 ? stepHeight * 1.5 : stepHeight,
482
+ height:
483
+ index === 0
484
+ ? negativeStepHeight * 1.5
485
+ : negativeStepHeight,
473
486
  width:
474
487
  yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
475
488
  },
476
- index === 0 && {marginTop: -stepHeight / 2},
489
+ index === 0 && {marginTop: -negativeStepHeight / 2},
477
490
  ]}
478
491
  />
479
492
  <View
@@ -521,12 +534,12 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
521
534
  {
522
535
  position: 'absolute',
523
536
  zIndex: 1,
524
- bottom: stepHeight * index,
537
+ bottom: negativeStepHeight * index,
525
538
  width: yAxisLabelWidth,
526
539
  height:
527
- index === noOfSections
528
- ? stepHeight / 2
529
- : stepHeight,
540
+ index === noOfSectionsBelowXAxis
541
+ ? negativeStepHeight / 2
542
+ : negativeStepHeight,
530
543
  },
531
544
  yAxisSide === yAxisSides.RIGHT && {
532
545
  left: (width ?? totalWidth) + yAxisLabelWidth,
@@ -538,8 +551,8 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
538
551
  ellipsizeMode={'clip'}
539
552
  style={[
540
553
  yAxisTextStyle,
541
- index === noOfSections && {
542
- marginBottom: stepHeight / -2,
554
+ index === noOfSectionsBelowXAxis && {
555
+ marginBottom: negativeStepHeight / -2,
543
556
  },
544
557
  ]}>
545
558
  {label}
@@ -16,7 +16,7 @@ export const renderDataPoints = props => {
16
16
  spacing,
17
17
  } = props;
18
18
  return data.map((item: any, index: number) => {
19
- if (index < lineConfig.startIndex || index > lineConfig.endIndex) {
19
+ if (index < lineConfig.startIndex || index > lineConfig.endIndex || item.hideDataPoint) {
20
20
  return null;
21
21
  }
22
22
  const currentBarWidth = item.barWidth || barWidth || 30;
@@ -1518,18 +1518,17 @@ export const LineChart = (props: LineChartPropsType) => {
1518
1518
  }
1519
1519
  }
1520
1520
  if (dataSet?.length) {
1521
- if (dataSet[0].data[factor]) {
1522
- const ysForDataSet = dataSet.map(set => {
1523
- const item = set.data[factor];
1524
- const y =
1525
- containerHeight -
1521
+ const ysForDataSet = dataSet.map(set => {
1522
+ const item = set.data[factor];
1523
+ const y = item
1524
+ ? containerHeight -
1526
1525
  (item.value * containerHeight) / maxValue -
1527
1526
  (pointerRadius || pointerHeight / 2) +
1528
- 10;
1529
- return y;
1530
- });
1531
- setPointerYsForDataSet(ysForDataSet);
1532
- }
1527
+ 10
1528
+ : 0;
1529
+ return y;
1530
+ });
1531
+ setPointerYsForDataSet(ysForDataSet);
1533
1532
  }
1534
1533
  }}
1535
1534
  // onResponderReject={evt => {
package/src/todos.md CHANGED
@@ -1,6 +1,7 @@
1
1
  ## Features
2
2
 
3
- 1. Issue with eslint - tsc https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/222
3
+ 1. Scatter Chart - https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/518
4
+ 2. Issue with eslint - tsc https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/222
4
5
 
5
6
  ## To-dos in documentation-
6
7