gifted-charts-core 0.1.47 → 0.1.49

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.
@@ -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();
@@ -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;
@@ -308,18 +308,18 @@ export var useBarChart = function (props) {
308
308
  ? (_50 = (_49 = props.secondaryYAxis) === null || _49 === void 0 ? void 0 : _49.yAxisOffset) !== null && _50 !== void 0 ? _50 : 0
309
309
  : yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
310
310
  useEffect(function () {
311
- 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;
311
+ 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;
312
312
  if (showLine) {
313
313
  var pp = '';
314
314
  var pp2 = '';
315
- var firstBarWidth = (_c = (_b = (_a = (stackData !== null && stackData !== void 0 ? stackData : data)) === null || _a === void 0 ? void 0 : _a[0].barWidth) !== null && _b !== void 0 ? _b : props.barWidth) !== null && _c !== void 0 ? _c : 30;
315
+ var firstBarWidth = (_c = (_b = (_a = (stackData !== null && stackData !== void 0 ? stackData : data)) === null || _a === void 0 ? void 0 : _a[0].barWidth) !== null && _b !== void 0 ? _b : props.barWidth) !== null && _c !== void 0 ? _c : defaultBarWidth;
316
316
  if (!lineConfig.curved) {
317
317
  for (var i = 0; i < lineData.length; i++) {
318
318
  if (i < ((_d = lineConfig.startIndex) !== null && _d !== void 0 ? _d : 0) ||
319
319
  i > ((_e = lineConfig.endIndex) !== null && _e !== void 0 ? _e : 0)) {
320
320
  continue;
321
321
  }
322
- var currentBarWidth = (_h = (_g = (_f = data === null || data === void 0 ? void 0 : data[i]) === null || _f === void 0 ? void 0 : _f.barWidth) !== null && _g !== void 0 ? _g : props.barWidth) !== null && _h !== void 0 ? _h : defaultBarWidth;
322
+ var currentBarWidth = (_j = (_h = (_g = (_f = (stackData !== null && stackData !== void 0 ? stackData : data)) === null || _f === void 0 ? void 0 : _f[i]) === null || _g === void 0 ? void 0 : _g.barWidth) !== null && _h !== void 0 ? _h : props.barWidth) !== null && _j !== void 0 ? _j : defaultBarWidth;
323
323
  var currentValue = props.lineData
324
324
  ? props.lineData[i].value
325
325
  : stackData
@@ -339,18 +339,18 @@ export var useBarChart = function (props) {
339
339
  var arrowTipX = parseInt(ppArray[ppArray.length - 2].replace('L', ''));
340
340
  var y1 = parseInt(ppArray[ppArray.length - 3]);
341
341
  var x1 = parseInt(ppArray[ppArray.length - 4].replace('L', ''));
342
- var arrowPoints_1 = getArrowPoints(arrowTipX, arrowTipY, x1, y1, (_j = lineConfig.arrowConfig) === null || _j === void 0 ? void 0 : _j.length, (_k = lineConfig.arrowConfig) === null || _k === void 0 ? void 0 : _k.width, (_l = lineConfig.arrowConfig) === null || _l === void 0 ? void 0 : _l.showArrowBase);
342
+ var arrowPoints_1 = getArrowPoints(arrowTipX, arrowTipY, x1, y1, (_k = lineConfig.arrowConfig) === null || _k === void 0 ? void 0 : _k.length, (_l = lineConfig.arrowConfig) === null || _l === void 0 ? void 0 : _l.width, (_m = lineConfig.arrowConfig) === null || _m === void 0 ? void 0 : _m.showArrowBase);
343
343
  setArrowPoints(arrowPoints_1);
344
344
  }
345
345
  }
346
346
  else {
347
347
  var p1Array = [];
348
348
  for (var i = 0; i < lineData.length; i++) {
349
- if (i < ((_m = lineConfig.startIndex) !== null && _m !== void 0 ? _m : 0) ||
350
- i > ((_o = lineConfig.endIndex) !== null && _o !== void 0 ? _o : 0)) {
349
+ if (i < ((_o = lineConfig.startIndex) !== null && _o !== void 0 ? _o : 0) ||
350
+ i > ((_p = lineConfig.endIndex) !== null && _p !== void 0 ? _p : 0)) {
351
351
  continue;
352
352
  }
353
- var currentBarWidth = (_r = (_q = (_p = data === null || data === void 0 ? void 0 : data[i]) === null || _p === void 0 ? void 0 : _p.barWidth) !== null && _q !== void 0 ? _q : props.barWidth) !== null && _r !== void 0 ? _r : defaultBarWidth;
353
+ var currentBarWidth = (_s = (_r = (_q = data === null || data === void 0 ? void 0 : data[i]) === null || _q === void 0 ? void 0 : _q.barWidth) !== null && _r !== void 0 ? _r : props.barWidth) !== null && _s !== void 0 ? _s : defaultBarWidth;
354
354
  var currentValue = props.lineData
355
355
  ? props.lineData[i].value
356
356
  : stackData
@@ -367,11 +367,11 @@ export var useBarChart = function (props) {
367
367
  if (lineData2 === null || lineData2 === void 0 ? void 0 : lineData2.length) {
368
368
  if (!(lineConfig2 === null || lineConfig2 === void 0 ? void 0 : lineConfig2.curved)) {
369
369
  for (var i = 0; i < lineData2.length; i++) {
370
- if (i < ((_s = lineConfig2.startIndex) !== null && _s !== void 0 ? _s : 0) ||
371
- i > ((_t = lineConfig2.endIndex) !== null && _t !== void 0 ? _t : 0)) {
370
+ if (i < ((_t = lineConfig2.startIndex) !== null && _t !== void 0 ? _t : 0) ||
371
+ i > ((_u = lineConfig2.endIndex) !== null && _u !== void 0 ? _u : 0)) {
372
372
  continue;
373
373
  }
374
- var currentBarWidth = (_w = (_v = (_u = data === null || data === void 0 ? void 0 : data[i]) === null || _u === void 0 ? void 0 : _u.barWidth) !== null && _v !== void 0 ? _v : props.barWidth) !== null && _w !== void 0 ? _w : defaultBarWidth;
374
+ var currentBarWidth = (_x = (_w = (_v = data === null || data === void 0 ? void 0 : data[i]) === null || _v === void 0 ? void 0 : _v.barWidth) !== null && _w !== void 0 ? _w : props.barWidth) !== null && _x !== void 0 ? _x : defaultBarWidth;
375
375
  var currentValue = lineData2[i].value;
376
376
  pp2 +=
377
377
  'L' +
@@ -385,11 +385,11 @@ export var useBarChart = function (props) {
385
385
  else {
386
386
  var p2Array = [];
387
387
  for (var i = 0; i < lineData2.length; i++) {
388
- if (i < ((_x = lineConfig2.startIndex) !== null && _x !== void 0 ? _x : 0) ||
389
- i > ((_y = lineConfig2.endIndex) !== null && _y !== void 0 ? _y : 0)) {
388
+ if (i < ((_y = lineConfig2.startIndex) !== null && _y !== void 0 ? _y : 0) ||
389
+ i > ((_z = lineConfig2.endIndex) !== null && _z !== void 0 ? _z : 0)) {
390
390
  continue;
391
391
  }
392
- var currentBarWidth = (_1 = (_0 = (_z = data === null || data === void 0 ? void 0 : data[i]) === null || _z === void 0 ? void 0 : _z.barWidth) !== null && _0 !== void 0 ? _0 : props.barWidth) !== null && _1 !== void 0 ? _1 : defaultBarWidth;
392
+ var currentBarWidth = (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data[i]) === null || _0 === void 0 ? void 0 : _0.barWidth) !== null && _1 !== void 0 ? _1 : props.barWidth) !== null && _2 !== void 0 ? _2 : defaultBarWidth;
393
393
  var currentValue = lineData2[i].value;
394
394
  p2Array.push([
395
395
  getXForLineInBar(i, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig2, spacing),
@@ -469,7 +469,7 @@ export var useBarChart = function (props) {
469
469
  outputRange: [0, initialSpacing + totalWidth]
470
470
  });
471
471
  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;
472
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
473
473
  return {
474
474
  item: item,
475
475
  index: index,
@@ -544,7 +544,8 @@ export var useBarChart = function (props) {
544
544
  secondaryStepValue: secondaryStepValue,
545
545
  secondaryNegativeStepHeight: secondaryNegativeStepHeight,
546
546
  secondaryNegativeStepValue: secondaryNegativeStepValue,
547
- secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis
547
+ secondaryNoOfSectionsBelowXAxis: secondaryNoOfSectionsBelowXAxis,
548
+ barMarginBottom: (_x = (_w = item.barMarginBottom) !== null && _w !== void 0 ? _w : props.barMarginBottom) !== null && _x !== void 0 ? _x : 0
548
549
  };
549
550
  };
550
551
  var barAndLineChartsWrapperProps = {
@@ -614,7 +615,8 @@ export var useBarChart = function (props) {
614
615
  onEndReached: props.onEndReached,
615
616
  onStartReached: props.onStartReached,
616
617
  endReachedOffset: (_58 = props.endReachedOffset) !== null && _58 !== void 0 ? _58 : BarDefaults.endReachedOffset,
617
- onMomentumScrollEnd: props.onMomentumScrollEnd
618
+ onMomentumScrollEnd: props.onMomentumScrollEnd,
619
+ customBackground: props.customBackground
618
620
  };
619
621
  return {
620
622
  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;
@@ -135,6 +136,7 @@ export interface StackedBarChartPropsType {
135
136
  secondaryNegativeStepHeight: number;
136
137
  secondaryNegativeStepValue: number;
137
138
  secondaryNoOfSectionsBelowXAxis: number;
139
+ containerHeightIncludingBelowXAxis?: number;
138
140
  }
139
141
  export interface BarChartPropsType {
140
142
  width?: number;
@@ -233,6 +235,7 @@ export interface BarChartPropsType {
233
235
  showFractionalValues?: boolean;
234
236
  roundToDigits?: number;
235
237
  backgroundColor?: ColorValue;
238
+ customBackground?: CustomBackground;
236
239
  disableScroll?: boolean;
237
240
  showScrollIndicator?: boolean;
238
241
  indicatorColor?: 'black' | 'default' | 'white';
@@ -336,6 +339,7 @@ export interface lineConfigType {
336
339
  delay?: number;
337
340
  thickness?: number;
338
341
  color?: ColorValue | string | any;
342
+ strokeDashArray?: number[];
339
343
  hideDataPoints?: boolean;
340
344
  dataPointsShape?: string;
341
345
  dataPointsWidth?: number;
@@ -156,13 +156,13 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
156
156
  dataPointsRadius5: number;
157
157
  dataPointsColor5: string;
158
158
  dataPointsShape5: string;
159
- areaChart: boolean;
160
- areaChart1: boolean;
161
- areaChart2: boolean;
162
- areaChart3: boolean;
163
- areaChart4: boolean;
164
- areaChart5: boolean;
165
- atLeastOneAreaChart: boolean;
159
+ areaChart: boolean | undefined;
160
+ areaChart1: boolean | undefined;
161
+ areaChart2: boolean | undefined;
162
+ areaChart3: boolean | undefined;
163
+ areaChart4: boolean | undefined;
164
+ areaChart5: boolean | undefined;
165
+ atLeastOneAreaChart: boolean | undefined;
166
166
  getIsNthAreaChart: (n: number) => boolean;
167
167
  stepChart: boolean;
168
168
  stepChart1: boolean;
@@ -283,7 +283,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
283
283
  curved: boolean | undefined;
284
284
  curvature: number;
285
285
  curveType: import("../utils/types").CurveType;
286
- areaChart: boolean;
286
+ areaChart: boolean | undefined;
287
287
  color: import("react-native").ColorValue;
288
288
  thickness: number;
289
289
  zIndex1: number;
@@ -349,10 +349,12 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
349
349
  autoAdjustPointerLabelPosition: boolean;
350
350
  pointerVanishDelay: number;
351
351
  activatePointersOnLongPress: boolean;
352
+ activatePointersInstantlyOnTouch: boolean;
352
353
  activatePointersDelay: number;
353
354
  initialPointerIndex: number;
354
355
  initialPointerAppearDelay: number;
355
356
  persistPointer: boolean;
357
+ resetPointerIndexOnRelease: boolean;
356
358
  hidePointer1: boolean;
357
359
  hidePointer2: boolean;
358
360
  hidePointer3: boolean;
@@ -394,4 +396,7 @@ export declare const useLineChart: (props: extendedLineChartPropsType) => {
394
396
  cumulativeSpacingForSet: any[];
395
397
  stripOverDataPoints: boolean | undefined;
396
398
  strips: any;
399
+ lastLineNumber: number;
400
+ focusTogether: boolean;
401
+ focusProximity: number;
397
402
  };