react-native-gifted-charts 1.2.31 → 1.2.34

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.2.31",
3
+ "version": "1.2.34",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -40,6 +40,7 @@ type PropTypes = {
40
40
  // animationEasing?: any;
41
41
  opacity?: number;
42
42
  isThreeD?: Boolean;
43
+ xAxisLength?: number;
43
44
  xAxisThickness?: number;
44
45
  xAxisColor?: ColorValue;
45
46
  yAxisThickness?: number;
@@ -53,6 +54,7 @@ type PropTypes = {
53
54
  yAxisLabelWidth?: number;
54
55
  hideYAxisText?: Boolean;
55
56
  yAxisSide?: string;
57
+ yAxisOffset?: number;
56
58
  initialSpacing?: number;
57
59
  barWidth?: number;
58
60
  sideWidth?: number;
@@ -67,6 +69,7 @@ type PropTypes = {
67
69
 
68
70
  hideAxesAndRules?: Boolean;
69
71
  hideRules?: Boolean;
72
+ rulesLength?: number;
70
73
  rulesColor?: ColorValue;
71
74
  rulesThickness?: number;
72
75
  rulesType?: String;
@@ -202,7 +205,18 @@ export const BarChart = (props: PropTypes) => {
202
205
  const showLine = props.showLine || false;
203
206
  const initialSpacing =
204
207
  props.initialSpacing === 0 ? 0 : props.initialSpacing || 40;
205
- const data = useMemo(() => props.data || [], [props.data]);
208
+ const data = useMemo(() => {
209
+ if (!props.data) {
210
+ return [];
211
+ }
212
+ if (props.yAxisOffset) {
213
+ return props.data.map(item => {
214
+ item.value = item.value - props.yAxisOffset;
215
+ return item;
216
+ });
217
+ }
218
+ return props.data;
219
+ }, [props.yAxisOffset, props.data]);
206
220
  const lineData = props.lineData || data;
207
221
  const defaultLineConfig = {
208
222
  initialSpacing: initialSpacing,
@@ -348,6 +362,7 @@ export const BarChart = (props: PropTypes) => {
348
362
  const showVerticalLines = props.showVerticalLines || false;
349
363
  const rulesThickness =
350
364
  props.rulesThickness === 0 ? 0 : props.rulesThickness || 1;
365
+ const rulesLength = props.rulesLength;
351
366
  const rulesColor = props.rulesColor || 'lightgray';
352
367
  const verticalLinesThickness =
353
368
  props.verticalLinesThickness === 0 ? 0 : props.verticalLinesThickness || 1;
@@ -379,6 +394,7 @@ export const BarChart = (props: PropTypes) => {
379
394
  props.xAxisThickness === 0
380
395
  ? props.xAxisThickness
381
396
  : props.xAxisThickness || 1;
397
+ const xAxisLength = props.xAxisLength;
382
398
  const xAxisColor = props.xAxisColor || 'black';
383
399
 
384
400
  const hideRules = props.hideRules || false;
@@ -653,15 +669,20 @@ export const BarChart = (props: PropTypes) => {
653
669
  (props.yAxisLabelTexts && props.yAxisLabelTexts[index] !== undefined)
654
670
  ) {
655
671
  if (val) {
656
- label = val;
672
+ label = props.yAxisOffset
673
+ ? (Number(val) + props.yAxisOffset).toString()
674
+ : val;
657
675
  } else {
658
- label = '0';
676
+ label = props.yAxisOffset ? props.yAxisOffset.toString() : '0';
659
677
  }
660
678
  } else {
661
679
  if (val) {
662
680
  label = val.toString().split('.')[0];
681
+ if (props.yAxisOffset) {
682
+ label = (Number(label) + props.yAxisOffset).toString();
683
+ }
663
684
  } else {
664
- label = '0';
685
+ label = props.yAxisOffset ? props.yAxisOffset.toString() : '0';
665
686
  }
666
687
  }
667
688
 
@@ -722,9 +743,11 @@ export const BarChart = (props: PropTypes) => {
722
743
  config={{
723
744
  thickness: xAxisThickness,
724
745
  color: xAxisColor,
725
- width: horizontal
726
- ? props.width || Math.min(300, totalWidth)
727
- : (props.width || totalWidth) + 11,
746
+ width:
747
+ xAxisLength ||
748
+ (horizontal
749
+ ? props.width || Math.min(300, totalWidth)
750
+ : (props.width || totalWidth) + 11),
728
751
  dashWidth: dashWidth,
729
752
  dashGap: dashGap,
730
753
  type: xAxisType,
@@ -735,9 +758,11 @@ export const BarChart = (props: PropTypes) => {
735
758
  config={{
736
759
  thickness: rulesThickness,
737
760
  color: rulesColor,
738
- width: horizontal
739
- ? props.width || Math.min(300, totalWidth)
740
- : (props.width || totalWidth) + 11,
761
+ width:
762
+ rulesLength ||
763
+ (horizontal
764
+ ? props.width || Math.min(300, totalWidth)
765
+ : (props.width || totalWidth) + 11),
741
766
  dashWidth: dashWidth,
742
767
  dashGap: dashGap,
743
768
  type: rulesType,
@@ -855,9 +880,11 @@ export const BarChart = (props: PropTypes) => {
855
880
  config={{
856
881
  thickness: rulesThickness,
857
882
  color: rulesColor,
858
- width: horizontal
859
- ? props.width || totalWidth
860
- : (props.width || totalWidth) + 11,
883
+ width:
884
+ rulesLength ||
885
+ (horizontal
886
+ ? props.width || totalWidth
887
+ : (props.width || totalWidth) + 11),
861
888
  dashWidth: dashWidth,
862
889
  dashGap: dashGap,
863
890
  type: rulesType,