gifted-charts-core 0.0.8 → 0.0.10

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": "gifted-charts-core",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -34,10 +34,15 @@ export const getPropsForAnimated2DWithGradient = (props) => {
34
34
  selectedIndex,
35
35
  focusBarOnPress,
36
36
  focusedBarConfig,
37
+ isThreeD,
37
38
  } = props;
38
39
 
39
40
  const isFocused = focusBarOnPress && selectedIndex === index;
40
- const localBarBorderRadius = item.barBorderRadius ?? barBorderRadius ?? 0;
41
+ const itemOrPropsBarBorderRadius =
42
+ item.barBorderRadius ?? barBorderRadius ?? 0;
43
+ const localBarBorderRadius = isFocused
44
+ ? focusedBarConfig?.borderRadius ?? itemOrPropsBarBorderRadius
45
+ : itemOrPropsBarBorderRadius;
41
46
  const localBarWidth = getBarWidth(
42
47
  isFocused,
43
48
  focusedBarConfig,
@@ -48,7 +53,8 @@ export const getPropsForAnimated2DWithGradient = (props) => {
48
53
  isFocused,
49
54
  focusedBarConfig,
50
55
  item.frontColor,
51
- frontColor
56
+ frontColor,
57
+ isThreeD,
52
58
  );
53
59
  const localGradientColor = item.gradientColor || gradientColor;
54
60
  const localOpacity = opacity || 1;
@@ -60,29 +66,23 @@ export const getPropsForAnimated2DWithGradient = (props) => {
60
66
  height: "100%",
61
67
  borderWidth: barBorderWidth ?? 0,
62
68
  borderColor: barBorderColor,
63
- borderRadius: isFocused
64
- ? focusedBarConfig?.borderRadius ?? localBarBorderRadius
65
- : localBarBorderRadius,
69
+ borderRadius: localBarBorderRadius,
66
70
  borderTopLeftRadius:
67
71
  item.barBorderTopLeftRadius ??
68
72
  barBorderTopLeftRadius ??
69
- item.barBorderRadius ??
70
- barBorderRadius,
73
+ localBarBorderRadius,
71
74
  borderTopRightRadius:
72
75
  item.barBorderTopRightRadius ??
73
76
  barBorderTopRightRadius ??
74
- item.barBorderRadius ??
75
- barBorderRadius,
77
+ localBarBorderRadius,
76
78
  borderBottomLeftRadius:
77
79
  item.barBorderBottomLeftRadius ??
78
80
  barBorderBottomLeftRadius ??
79
- item.barBorderRadius ??
80
- barBorderRadius,
81
+ localBarBorderRadius,
81
82
  borderBottomRightRadius:
82
83
  item.barBorderBottomRightRadius ??
83
84
  barBorderBottomRightRadius ??
84
- item.barBorderRadius ??
85
- barBorderRadius,
85
+ localBarBorderRadius,
86
86
  },
87
87
  ];
88
88
 
@@ -121,7 +121,7 @@ export const getPropsForAnimated2DWithGradient = (props) => {
121
121
  ? focusedBarConfig?.barInnerComponent ?? localBarInnerComponent
122
122
  : localBarInnerComponent,
123
123
  patternId: item.patternId || patternId,
124
- width: localBarWidth,
124
+ barWidth: localBarWidth,
125
125
  barStyle: barStyle,
126
126
  item: item,
127
127
  index: index,
@@ -1,4 +1,4 @@
1
- import { ColorValue, GestureResponderEvent } from "react-native";
1
+ import { ColorValue, GestureResponderEvent, ViewStyle } from "react-native";
2
2
  import { yAxisSides } from "../utils/constants";
3
3
  import {
4
4
  CurveType,
@@ -305,6 +305,8 @@ export type BarChartPropsType = {
305
305
 
306
306
  export type FocusedBarConfig = {
307
307
  color?: ColorValue;
308
+ sideColor?: ColorValue;
309
+ topColor?: ColorValue;
308
310
  gradientColor?: ColorValue;
309
311
  width?: number;
310
312
  borderRadius?: number;
@@ -312,7 +314,7 @@ export type FocusedBarConfig = {
312
314
  roundedBottom?: boolean;
313
315
  opacity?: number;
314
316
  barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
315
- }
317
+ };
316
318
 
317
319
  type lineConfigType = {
318
320
  initialSpacing?: number;
@@ -460,6 +462,8 @@ export type Animated2DWithGradientPropsType = {
460
462
  barMarginBottom?: number;
461
463
  barStyle?: object;
462
464
  barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
465
+ commonStyleForBar?: ViewStyle[];
466
+ barStyleWithBackground?: ViewStyle[];
463
467
  };
464
468
 
465
469
  export type RenderBarsPropsType = {
@@ -540,6 +544,7 @@ export type RenderBarsPropsType = {
540
544
  barStyle?: object;
541
545
  xAxisThickness?: number;
542
546
  pointerConfig?: Pointer;
547
+ focusBarOnPress?: boolean;
543
548
  };
544
549
 
545
550
  export type trianglePropTypes = {
@@ -551,7 +556,7 @@ export type trianglePropTypes = {
551
556
  export type animatedBarPropTypes = {
552
557
  isAnimated?: boolean;
553
558
  animationDuration: number;
554
- width: number;
559
+ barWidth: number;
555
560
  sideWidth: number;
556
561
  height: number;
557
562
  showGradient: boolean;
@@ -579,20 +584,20 @@ export type animatedBarPropTypes = {
579
584
 
580
585
  export type CommonPropsFor2Dand3DbarsType = {
581
586
  barBackgroundPattern: Function;
582
- barInnerComponent: (item?: barDataItem, index?: number) => ReactNode;
583
- patternId: String;
584
- width: number;
585
- barStyle: object;
586
- item: barDataItem;
587
- index: number;
587
+ barInnerComponent: (item?: barDataItem, index?: number) => ReactNode;
588
+ patternId: String;
589
+ barWidth: number;
590
+ barStyle: object;
591
+ item: barDataItem;
592
+ index: number;
588
593
 
589
- frontColor: ColorValue;
590
- showGradient: boolean;
591
- gradientColor: ColorValue;
592
- opacity: number;
593
- height: number;
594
- intactTopLabel: boolean;
595
- showValuesAsTopLabel: boolean;
596
- topLabelContainerStyle: any;
597
- topLabelTextStyle: any;
598
- }
594
+ frontColor: ColorValue;
595
+ showGradient: boolean;
596
+ gradientColor: ColorValue;
597
+ opacity: number;
598
+ height: number;
599
+ intactTopLabel: boolean;
600
+ showValuesAsTopLabel: boolean;
601
+ topLabelContainerStyle: any;
602
+ topLabelTextStyle: any;
603
+ };
@@ -323,8 +323,12 @@ export const useBarAndLineChartsWrapper = (
323
323
  );
324
324
  };
325
325
 
326
- const isCloseToStart = ({ layoutMeasurement, contentOffset }) => {
327
- return layoutMeasurement.width + contentOffset.x <= initialSpacing;
326
+ // const isCloseToStart = ({ layoutMeasurement, contentOffset }) => {
327
+ // return layoutMeasurement.width + contentOffset.x <= initialSpacing;
328
+ // };
329
+
330
+ const isCloseToStart = ({ contentOffset }) => {
331
+ return contentOffset.x <= initialSpacing;
328
332
  };
329
333
 
330
334
  useEffect(() => {
@@ -146,12 +146,14 @@ export const BarDefaults = {
146
146
  animationDuration: 800,
147
147
  opacity: 1,
148
148
  isThreeD: false,
149
+ frontColor: "black",
149
150
  threeDBarGradientColor: "white",
150
151
  threeDBarFrontColor: "#C0CA3A",
151
152
  threeDBarSideColor: "#887A24",
152
153
  threeDBarTopColor: "#D9E676",
153
154
  endReachedOffset: defaultEndReachedOffset,
154
155
  focusedBarFrontColor: 'lightgreen',
156
+ focusedThreeDBarFrontColor: '#B0B929',
155
157
  focusedBarSideColor: '#776913',
156
158
  focusedBarTopColor: '#C8D565',
157
159
  };
@@ -1155,12 +1155,22 @@ export const getBarFrontColor = (
1155
1155
  isFocused,
1156
1156
  focusedBarConfig,
1157
1157
  itemFrontColor,
1158
- frontColor
1158
+ frontColor,
1159
+ isThreeD
1159
1160
  ) => {
1160
1161
  if (isFocused) {
1161
- return focusedBarConfig?.frontColor ?? BarDefaults.focusedBarFrontColor;
1162
+ return (
1163
+ focusedBarConfig?.color ??
1164
+ (isThreeD
1165
+ ? BarDefaults.focusedThreeDBarFrontColor
1166
+ : BarDefaults.focusedBarFrontColor)
1167
+ );
1162
1168
  }
1163
- return itemFrontColor || frontColor || "";
1169
+ return (
1170
+ itemFrontColor ||
1171
+ frontColor ||
1172
+ (isThreeD ? BarDefaults.threeDBarFrontColor : BarDefaults.frontColor)
1173
+ );
1164
1174
  };
1165
1175
 
1166
1176
  export const getBarSideColor = (