gifted-charts-core 0.1.48 → 0.1.50

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.
@@ -1,8 +1,8 @@
1
1
  import { type ColorValue, type ViewStyle } from 'react-native';
2
- import { type FocusedBarConfig, type BarChartPropsType, type CommonPropsFor2dand3dBarsType, type barDataItem, type stackDataItem } from './types';
2
+ import { type FocusedBarConfig, type BarChartPropsType, type CommonPropsFor2dand3dBarsType, type barDataItem, type stackDataItem, barDataItemNullSafe } from './types';
3
3
  import { type ReactNode } from 'react';
4
4
  interface Animated2dWithGradientPropsType extends BarChartPropsType {
5
- item: barDataItem;
5
+ item: barDataItemNullSafe;
6
6
  index: number;
7
7
  barHeight: number;
8
8
  selectedIndex: number;
@@ -26,7 +26,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
26
26
  import { getBarFrontColor, getBarWidth } from '../utils';
27
27
  export var getPropsForAnimated2DWithGradient = function (props) {
28
28
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
29
- var barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, barBorderRadius = props.barBorderRadius, item = props.item, barBorderTopLeftRadius = props.barBorderTopLeftRadius, barBorderTopRightRadius = props.barBorderTopRightRadius, barBorderBottomLeftRadius = props.barBorderBottomLeftRadius, barBorderBottomRightRadius = props.barBorderBottomRightRadius, barWidth = props.barWidth, barInnerComponent = props.barInnerComponent, barStyle = props.barStyle, index = props.index, opacity = props.opacity, barHeight = props.barHeight, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, roundedBottom = props.roundedBottom, cappedBars = props.cappedBars, capRadius = props.capRadius, roundedTop = props.roundedTop, barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, frontColor = props.frontColor, showGradient = props.showGradient, gradientColor = props.gradientColor, selectedIndex = props.selectedIndex, focusBarOnPress = props.focusBarOnPress, focusedBarConfig = props.focusedBarConfig, isThreeD = props.isThreeD, yAxisOffset = props.yAxisOffset;
29
+ var barBorderWidth = props.barBorderWidth, barBorderColor = props.barBorderColor, barBorderRadius = props.barBorderRadius, barMarginBottom = props.barMarginBottom, item = props.item, barBorderTopLeftRadius = props.barBorderTopLeftRadius, barBorderTopRightRadius = props.barBorderTopRightRadius, barBorderBottomLeftRadius = props.barBorderBottomLeftRadius, barBorderBottomRightRadius = props.barBorderBottomRightRadius, barWidth = props.barWidth, barInnerComponent = props.barInnerComponent, barStyle = props.barStyle, index = props.index, opacity = props.opacity, barHeight = props.barHeight, intactTopLabel = props.intactTopLabel, showValuesAsTopLabel = props.showValuesAsTopLabel, topLabelContainerStyle = props.topLabelContainerStyle, topLabelTextStyle = props.topLabelTextStyle, roundedBottom = props.roundedBottom, cappedBars = props.cappedBars, capRadius = props.capRadius, roundedTop = props.roundedTop, barBackgroundPattern = props.barBackgroundPattern, patternId = props.patternId, frontColor = props.frontColor, showGradient = props.showGradient, gradientColor = props.gradientColor, selectedIndex = props.selectedIndex, focusBarOnPress = props.focusBarOnPress, focusedBarConfig = props.focusedBarConfig, isThreeD = props.isThreeD, yAxisOffset = props.yAxisOffset;
30
30
  var isFocused = (focusBarOnPress !== null && focusBarOnPress !== void 0 ? focusBarOnPress : false) && selectedIndex === index;
31
31
  var itemOrPropsBarBorderRadius = (_b = (_a = item.barBorderRadius) !== null && _a !== void 0 ? _a : barBorderRadius) !== null && _b !== void 0 ? _b : 0;
32
32
  var localBarBorderRadius = (isFocused !== null && isFocused !== void 0 ? isFocused : false)
@@ -41,6 +41,7 @@ export var getPropsForAnimated2DWithGradient = function (props) {
41
41
  position: 'absolute',
42
42
  width: '100%',
43
43
  height: '100%',
44
+ bottom: barMarginBottom,
44
45
  borderWidth: (_f = (_e = item.barBorderWidth) !== null && _e !== void 0 ? _e : barBorderWidth) !== null && _f !== void 0 ? _f : 0,
45
46
  borderColor: (_g = item.barBorderColor) !== null && _g !== void 0 ? _g : barBorderColor,
46
47
  borderRadius: localBarBorderRadius,
@@ -14,7 +14,7 @@ export declare const useRenderStackBars: (props: StackedBarChartPropsType) => {
14
14
  height: number;
15
15
  setHeight: import("react").Dispatch<import("react").SetStateAction<number>>;
16
16
  getBarHeight: (value: number, marginBottom?: number) => number;
17
- getPosition: (index: number) => number;
17
+ getPosition: (index: number, height: number) => number;
18
18
  getLowestPosition: () => number;
19
19
  lowestBarPosition: number;
20
20
  getStackBorderRadii: (item: stackDataItem, index: number) => {
@@ -45,10 +45,13 @@ export var useRenderStackBars = function (props) {
45
45
  return (Math.abs(value) * (value < 0 ? negativeHeightFactor : heightFactor) -
46
46
  (marginBottom !== null && marginBottom !== void 0 ? marginBottom : 0));
47
47
  };
48
- var getPosition = function (index) {
48
+ var getPosition = function (index, height) {
49
49
  /* Returns bottom position for stack item
50
50
  negative values are below origin (-> negative position) */
51
- var height = getBarHeight(item.stacks[index].value, item.stacks[index].marginBottom);
51
+ // const height = getBarHeight(
52
+ // item.stacks[index].value,
53
+ // item.stacks[index].marginBottom
54
+ // )
52
55
  var itemValue = item.stacks[index].value;
53
56
  var isNegative = itemValue <= 0;
54
57
  var position = isNegative ? -(height || 0) - xAxisThickness : 0;
@@ -68,7 +71,9 @@ export var useRenderStackBars = function (props) {
68
71
  var getLowestPosition = function () {
69
72
  var _a;
70
73
  return (((_a = item.stacks
71
- .map(function (_, index) { return getPosition(index); })
74
+ .map(function (_, index) {
75
+ return getPosition(index, getBarHeight(index, _.marginBottom));
76
+ })
72
77
  .sort(function (a, b) { return a - b; })) === null || _a === void 0 ? void 0 : _a[0]) || 0);
73
78
  };
74
79
  var lowestBarPosition = getLowestPosition();
@@ -1,4 +1,4 @@
1
- import { type lineConfigType, type barDataItem, type stackDataItem, BarChartPropsTypeForWeb } from './types';
1
+ import { type lineConfigType, type barDataItem, type stackDataItem, BarChartPropsTypeForWeb, barDataItemNullSafe } from './types';
2
2
  import { type BarAndLineChartsWrapperTypes, type secondaryYAxisType } from '../utils/types';
3
3
  import { type Animated } from 'react-native';
4
4
  export interface extendedBarChartPropsType extends BarChartPropsTypeForWeb {
@@ -41,7 +41,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
41
41
  setPointerItem: import("react").Dispatch<import("react").SetStateAction<barDataItem | stackDataItem | undefined>>;
42
42
  initialSpacing: number;
43
43
  spacing: number;
44
- data: barDataItem[];
44
+ data: barDataItemNullSafe[];
45
45
  barWidth: number;
46
46
  setPointerX: import("react").Dispatch<import("react").SetStateAction<number>>;
47
47
  setPointerIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
@@ -191,6 +191,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
191
191
  secondaryNegativeStepHeight: number;
192
192
  secondaryNegativeStepValue: number;
193
193
  secondaryNoOfSectionsBelowXAxis: number;
194
+ barMarginBottom: any;
194
195
  };
195
196
  barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
196
197
  yAxisExtraHeightAtTop: number;
@@ -49,7 +49,10 @@ export var useBarChart = function (props) {
49
49
  return (__assign(__assign({}, item), { value: ((_a = item.value) !== null && _a !== void 0 ? _a : 0) - yAxisOffset }));
50
50
  });
51
51
  }
52
- return props.data;
52
+ return props.data.map(function (item) {
53
+ var _a;
54
+ return (__assign(__assign({}, item), { value: (_a = item.value) !== null && _a !== void 0 ? _a : 0 }));
55
+ });
53
56
  }, [yAxisOffset, props.data]);
54
57
  var stackData = useMemo(function () {
55
58
  if (!props.stackData) {
@@ -469,7 +472,7 @@ export var useBarChart = function (props) {
469
472
  outputRange: [0, initialSpacing + totalWidth]
470
473
  });
471
474
  var getPropsCommonForBarAndStack = function (item, index) {
472
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
475
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
473
476
  return {
474
477
  item: item,
475
478
  index: index,
@@ -544,7 +547,8 @@ export var useBarChart = function (props) {
544
547
  secondaryStepValue: secondaryStepValue,
545
548
  secondaryNegativeStepHeight: secondaryNegativeStepHeight,
546
549
  secondaryNegativeStepValue: secondaryNegativeStepValue,
547
- secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
550
+ secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
551
+ barMarginBottom: (_x = (_w = item.barMarginBottom) !== null && _w !== void 0 ? _w : props.barMarginBottom) !== null && _x !== void 0 ? _x : 0
548
552
  };
549
553
  };
550
554
  var barAndLineChartsWrapperProps = {
@@ -614,7 +618,8 @@ export var useBarChart = function (props) {
614
618
  onEndReached: props.onEndReached,
615
619
  onStartReached: props.onStartReached,
616
620
  endReachedOffset: (_58 = props.endReachedOffset) !== null && _58 !== void 0 ? _58 : BarDefaults.endReachedOffset,
617
- onMomentumScrollEnd: props.onMomentumScrollEnd
621
+ onMomentumScrollEnd: props.onMomentumScrollEnd,
622
+ customBackground: props.customBackground
618
623
  };
619
624
  return {
620
625
  lineConfig: lineConfig,
@@ -1,6 +1,6 @@
1
1
  import { type ColorValue, type GestureResponderEvent, type ViewStyle } from 'react-native';
2
2
  import { type yAxisSides } from '../utils/constants';
3
- import { XAxisConfig, type CurveType, type Pointer, type RuleType, type RulesConfig, type referenceConfigType, type secondaryYAxisType, type Linecap } from '../utils/types';
3
+ import { XAxisConfig, type CurveType, type Pointer, type RuleType, type RulesConfig, type referenceConfigType, type secondaryYAxisType, type Linecap, CustomBackground } from '../utils/types';
4
4
  import { type Component, type ReactNode } from 'react';
5
5
  import { type lineDataItem } from '../LineChart/types';
6
6
  export interface stackDataItem {
@@ -99,6 +99,7 @@ export interface StackedBarChartPropsType {
99
99
  barBorderBottomLeftRadius?: number;
100
100
  barBorderBottomRightRadius?: number;
101
101
  barInnerComponent?: (item?: barDataItem | stackDataItem, index?: number) => ReactNode;
102
+ barMarginBottom: number;
102
103
  stackBorderRadius?: number;
103
104
  stackBorderTopLeftRadius?: number;
104
105
  stackBorderTopRightRadius?: number;
@@ -234,6 +235,7 @@ export interface BarChartPropsType {
234
235
  showFractionalValues?: boolean;
235
236
  roundToDigits?: number;
236
237
  backgroundColor?: ColorValue;
238
+ customBackground?: CustomBackground;
237
239
  disableScroll?: boolean;
238
240
  showScrollIndicator?: boolean;
239
241
  indicatorColor?: 'black' | 'default' | 'white';
@@ -337,6 +339,7 @@ export interface lineConfigType {
337
339
  delay?: number;
338
340
  thickness?: number;
339
341
  color?: ColorValue | string | any;
342
+ strokeDashArray?: number[];
340
343
  hideDataPoints?: boolean;
341
344
  dataPointsShape?: string;
342
345
  dataPointsWidth?: number;
@@ -404,7 +407,7 @@ interface sectionType {
404
407
  value: string;
405
408
  }
406
409
  export interface barDataItem {
407
- value: number;
410
+ value?: number;
408
411
  onPress?: any;
409
412
  onLongPress?: any;
410
413
  onPressOut?: any;
@@ -451,8 +454,11 @@ export interface barDataItem {
451
454
  onMouseEnter?: Function;
452
455
  onMouseLeave?: Function;
453
456
  }
457
+ export interface barDataItemNullSafe extends barDataItem {
458
+ value: number;
459
+ }
454
460
  export interface Animated2DWithGradientPropsType {
455
- item: barDataItem;
461
+ item: barDataItemNullSafe;
456
462
  index: number;
457
463
  height: number;
458
464
  minHeight: number;
@@ -510,7 +516,7 @@ export interface RenderBarsPropsType {
510
516
  side?: string;
511
517
  labelTextStyle?: any;
512
518
  secondaryLabelTextStyle?: any;
513
- item: barDataItem;
519
+ item: barDataItemNullSafe;
514
520
  index: number;
515
521
  label: string;
516
522
  secondaryLabel: string;
@@ -630,7 +636,7 @@ export interface CommonPropsFor2dand3dBarsType {
630
636
  patternId?: string;
631
637
  barWidth: number;
632
638
  barStyle?: object;
633
- item: barDataItem;
639
+ item: barDataItemNullSafe;
634
640
  index: number;
635
641
  frontColor: ColorValue;
636
642
  showGradient: boolean;
@@ -1,5 +1,5 @@
1
- import { type LineChartPropsType, type lineDataItem } from './types';
2
- import { type BarAndLineChartsWrapperTypes, EdgePosition, type LineSegment } from '../utils/types';
1
+ import { lineDataItemNullSafe, type LineChartPropsType, type lineDataItem } from './types';
2
+ import { type BarAndLineChartsWrapperTypes, EdgePosition, type LineSegment, DataSetNullSafe } from '../utils/types';
3
3
  export interface extendedLineChartPropsType extends LineChartPropsType {
4
4
  parentWidth: number;
5
5
  }
@@ -92,14 +92,14 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
92
92
  setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
93
93
  noOfSections: number;
94
94
  containerHeight: number;
95
- data: lineDataItem[];
96
- data2: lineDataItem[];
97
- data3: lineDataItem[];
98
- data4: lineDataItem[];
99
- data5: lineDataItem[];
100
- secondaryData: lineDataItem[] | import("..").barDataItem[];
101
- dataSet: import("../utils/types").DataSet[] | undefined;
102
- data0: lineDataItem[] | undefined;
95
+ data: lineDataItemNullSafe[];
96
+ data2: lineDataItemNullSafe[];
97
+ data3: lineDataItemNullSafe[];
98
+ data4: lineDataItemNullSafe[];
99
+ data5: lineDataItemNullSafe[];
100
+ secondaryData: lineDataItemNullSafe[] | import("..").barDataItemNullSafe[];
101
+ dataSet: DataSetNullSafe[] | undefined;
102
+ data0: lineDataItemNullSafe[] | undefined;
103
103
  scrollToEnd: boolean;
104
104
  scrollAnimation: boolean;
105
105
  scrollEventThrottle: number;
@@ -107,6 +107,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
107
107
  animationDuration: number;
108
108
  onDataChangeAnimationDuration: number;
109
109
  animateTogether: boolean;
110
+ renderDataPointsAfterAnimationEnds: boolean;
110
111
  animateOnDataChange: boolean;
111
112
  startIndex1: number;
112
113
  startIndex2: number;
@@ -156,13 +157,13 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
156
157
  dataPointsRadius5: number;
157
158
  dataPointsColor5: string;
158
159
  dataPointsShape5: string;
159
- areaChart: boolean;
160
- areaChart1: boolean;
161
- areaChart2: boolean;
162
- areaChart3: boolean;
163
- areaChart4: boolean;
164
- areaChart5: boolean;
165
- atLeastOneAreaChart: boolean;
160
+ areaChart: boolean | undefined;
161
+ areaChart1: boolean | undefined;
162
+ areaChart2: boolean | undefined;
163
+ areaChart3: boolean | undefined;
164
+ areaChart4: boolean | undefined;
165
+ areaChart5: boolean | undefined;
166
+ atLeastOneAreaChart: boolean | undefined;
166
167
  getIsNthAreaChart: (n: number) => boolean;
167
168
  stepChart: boolean;
168
169
  stepChart1: boolean;
@@ -283,7 +284,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
283
284
  curved: boolean | undefined;
284
285
  curvature: number;
285
286
  curveType: import("../utils/types").CurveType;
286
- areaChart: boolean;
287
+ areaChart: boolean | undefined;
287
288
  color: import("react-native").ColorValue;
288
289
  thickness: number;
289
290
  zIndex1: number;
@@ -307,9 +308,9 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
307
308
  arrowConfig: import("../utils/types").arrowConfigType | undefined;
308
309
  };
309
310
  addLeadingAndTrailingPathForAreaFill: (initialPath: string, value: number, dataLength: number) => string;
310
- getNextPoint: (data: lineDataItem[], index: number, around: boolean, before: boolean, spacingArray: number[]) => string;
311
- getStepPath: (data: lineDataItem[], i: number, spacingArray: number[]) => string;
312
- getSegmentPath: (data: lineDataItem[], i: number, lineSegment: LineSegment[] | undefined, startIndex: number, endIndex: number, spacingArray: number[], isSecondary?: boolean) => string;
311
+ getNextPoint: (data: lineDataItemNullSafe[], index: number, around: boolean, before: boolean, spacingArray: number[]) => string;
312
+ getStepPath: (data: lineDataItemNullSafe[], i: number, spacingArray: number[]) => string;
313
+ getSegmentPath: (data: lineDataItemNullSafe[], i: number, lineSegment: LineSegment[] | undefined, startIndex: number, endIndex: number, spacingArray: number[], isSecondary?: boolean) => string;
313
314
  gradientDirection: string;
314
315
  horizSections: {
315
316
  value: string;
@@ -349,10 +350,12 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
349
350
  autoAdjustPointerLabelPosition: boolean;
350
351
  pointerVanishDelay: number;
351
352
  activatePointersOnLongPress: boolean;
353
+ activatePointersInstantlyOnTouch: boolean;
352
354
  activatePointersDelay: number;
353
355
  initialPointerIndex: number;
354
356
  initialPointerAppearDelay: number;
355
357
  persistPointer: boolean;
358
+ resetPointerIndexOnRelease: boolean;
356
359
  hidePointer1: boolean;
357
360
  hidePointer2: boolean;
358
361
  hidePointer3: boolean;
@@ -394,4 +397,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
394
397
  cumulativeSpacingForSet: any[];
395
398
  stripOverDataPoints: boolean | undefined;
396
399
  strips: any;
400
+ lastLineNumber: number;
401
+ focusTogether: boolean;
402
+ focusProximity: number;
397
403
  };