gifted-charts-core 0.1.13 → 0.1.14

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/README.md CHANGED
@@ -1 +1 @@
1
- This library contains the common code used by [react-native-gifted-charts](https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts) and react-gifted-charts.
1
+ This library contains the common code used by [react-native-gifted-charts](https://www.npmjs.com/package/react-native-gifted-charts) and [react-gifted-charts](https://www.npmjs.com/package/react-gifted-charts).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -119,7 +119,6 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
119
119
  getPointerProps: Function | null;
120
120
  pointerIndex: number;
121
121
  getPropsCommonForBarAndStack: (item: any, index: number) => {
122
- key: number;
123
122
  item: any;
124
123
  index: number;
125
124
  containerHeight: number;
@@ -165,6 +164,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
165
164
  xAxisLabelsVerticalShift: number;
166
165
  renderTooltip: Function | undefined;
167
166
  leftShiftForTooltip: number;
167
+ autoCenterTooltip: boolean | undefined;
168
168
  initialSpacing: number;
169
169
  selectedIndex: number;
170
170
  setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
@@ -30,7 +30,7 @@ import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPad
30
30
  import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
31
31
  export var useBarChart = function (props) {
32
32
  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, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47;
33
- var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue;
33
+ var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip;
34
34
  var _48 = __read(useState(''), 2), points = _48[0], setPoints = _48[1];
35
35
  var _49 = __read(useState(''), 2), points2 = _49[0], setPoints2 = _49[1];
36
36
  var _50 = __read(useState(''), 2), arrowPoints = _50[0], setArrowPoints = _50[1];
@@ -396,7 +396,6 @@ export var useBarChart = function (props) {
396
396
  var getPropsCommonForBarAndStack = function (item, index) {
397
397
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
398
398
  return {
399
- key: index,
400
399
  item: item,
401
400
  index: index,
402
401
  containerHeight: containerHeight,
@@ -442,6 +441,7 @@ export var useBarChart = function (props) {
442
441
  xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
443
442
  renderTooltip: props.renderTooltip,
444
443
  leftShiftForTooltip: (_e = props.leftShiftForTooltip) !== null && _e !== void 0 ? _e : 0,
444
+ autoCenterTooltip: autoCenterTooltip,
445
445
  initialSpacing: initialSpacing,
446
446
  selectedIndex: selectedIndex,
447
447
  setSelectedIndex: setSelectedIndex,
@@ -52,7 +52,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
52
52
  labelsDistanceFromXaxis,
53
53
  autoShiftLabelsForNegativeStacks,
54
54
  focusedBarIndex,
55
- negativeStepValue
55
+ negativeStepValue,
56
+ autoCenterTooltip
56
57
  } = props
57
58
  const [points, setPoints] = useState('')
58
59
  const [points2, setPoints2] = useState('')
@@ -637,7 +638,6 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
637
638
 
638
639
  const getPropsCommonForBarAndStack = (item: any, index: number) => {
639
640
  return {
640
- key: index,
641
641
  item,
642
642
  index,
643
643
  containerHeight,
@@ -684,6 +684,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
684
684
  xAxisLabelsVerticalShift,
685
685
  renderTooltip: props.renderTooltip,
686
686
  leftShiftForTooltip: props.leftShiftForTooltip ?? 0,
687
+ autoCenterTooltip,
687
688
  initialSpacing,
688
689
  selectedIndex,
689
690
  setSelectedIndex,
@@ -215,6 +215,7 @@ export interface BarChartPropsType {
215
215
  disableScroll?: boolean;
216
216
  showScrollIndicator?: boolean;
217
217
  indicatorColor?: 'black' | 'default' | 'white';
218
+ nestedScrollEnabled?: boolean;
218
219
  roundedTop?: boolean;
219
220
  roundedBottom?: boolean;
220
221
  disablePress?: boolean;
@@ -271,6 +272,7 @@ export interface BarChartPropsType {
271
272
  onPressOut?: Function;
272
273
  renderTooltip?: Function;
273
274
  leftShiftForTooltip?: number;
275
+ autoCenterTooltip?: boolean;
274
276
  leftShiftForLastIndexTooltip?: number;
275
277
  barStyle?: object;
276
278
  barInnerComponent?: (item?: stackDataItem | barDataItem, index?: number) => ReactNode;
@@ -406,9 +408,11 @@ export interface barDataItem {
406
408
  patternId?: string;
407
409
  barMarginBottom?: number;
408
410
  leftShiftForTooltip?: number;
411
+ autoCenterTooltip?: boolean;
409
412
  barStyle?: object;
410
413
  barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
411
414
  showXAxisIndex?: boolean;
415
+ isSecondary?: boolean;
412
416
  }
413
417
  export interface Animated2DWithGradientPropsType {
414
418
  item: barDataItem;
@@ -522,6 +526,7 @@ export interface RenderBarsPropsType {
522
526
  xAxisLabelsVerticalShift: number;
523
527
  renderTooltip: Function | undefined;
524
528
  leftShiftForTooltip?: number;
529
+ autoCenterTooltip?: boolean;
525
530
  leftShiftForLastIndexTooltip: number;
526
531
  initialSpacing: number;
527
532
  selectedIndex: number;
@@ -240,6 +240,7 @@ export interface BarChartPropsType {
240
240
  disableScroll?: boolean
241
241
  showScrollIndicator?: boolean
242
242
  indicatorColor?: 'black' | 'default' | 'white'
243
+ nestedScrollEnabled?: boolean
243
244
  roundedTop?: boolean
244
245
  roundedBottom?: boolean
245
246
  disablePress?: boolean
@@ -300,6 +301,7 @@ export interface BarChartPropsType {
300
301
  onPressOut?: Function
301
302
  renderTooltip?: Function
302
303
  leftShiftForTooltip?: number
304
+ autoCenterTooltip?: boolean
303
305
  leftShiftForLastIndexTooltip?: number
304
306
  barStyle?: object
305
307
  barInnerComponent?: (
@@ -446,9 +448,11 @@ export interface barDataItem {
446
448
  patternId?: string
447
449
  barMarginBottom?: number
448
450
  leftShiftForTooltip?: number
451
+ autoCenterTooltip?: boolean
449
452
  barStyle?: object
450
453
  barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode
451
454
  showXAxisIndex?: boolean
455
+ isSecondary?: boolean
452
456
  }
453
457
 
454
458
  export interface Animated2DWithGradientPropsType {
@@ -569,6 +573,7 @@ export interface RenderBarsPropsType {
569
573
  xAxisLabelsVerticalShift: number
570
574
  renderTooltip: Function | undefined
571
575
  leftShiftForTooltip?: number
576
+ autoCenterTooltip?: boolean
572
577
  leftShiftForLastIndexTooltip: number
573
578
  initialSpacing: number
574
579
  selectedIndex: number
@@ -1096,6 +1096,7 @@ export var useLineChart = function (props) {
1096
1096
  endSpacing: endSpacing,
1097
1097
  horizontalRulesStyle: horizontalRulesStyle,
1098
1098
  noOfSections: noOfSections,
1099
+ sectionColors: props.sectionColors,
1099
1100
  showFractionalValues: showFractionalValues,
1100
1101
  axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
1101
1102
  yAxisLabelTexts: props.yAxisLabelTexts,
@@ -1822,6 +1822,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
1822
1822
  endSpacing,
1823
1823
  horizontalRulesStyle,
1824
1824
  noOfSections,
1825
+ sectionColors: props.sectionColors,
1825
1826
  showFractionalValues,
1826
1827
 
1827
1828
  axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
@@ -1,4 +1,4 @@
1
- import { type ColorValue } from 'react-native';
1
+ import { GestureResponderEvent, type ColorValue } from 'react-native';
2
2
  import { type yAxisSides } from '../utils/constants';
3
3
  import { type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType } from '../utils/types';
4
4
  export interface LineChartPropsType {
@@ -6,6 +6,7 @@ export interface LineChartPropsType {
6
6
  overflowTop?: number;
7
7
  overflowBottom?: number;
8
8
  noOfSections?: number;
9
+ sectionColors?: ColorValue[];
9
10
  maxValue?: number;
10
11
  mostNegativeValue?: number;
11
12
  stepHeight?: number;
@@ -107,6 +108,7 @@ export interface LineChartPropsType {
107
108
  pointerConfig?: Pointer;
108
109
  showScrollIndicator?: boolean;
109
110
  indicatorColor?: 'black' | 'default' | 'white';
111
+ nestedScrollEnabled?: boolean;
110
112
  showYAxisIndices?: boolean;
111
113
  showXAxisIndices?: boolean;
112
114
  yAxisIndicesHeight?: number;
@@ -295,6 +297,8 @@ export interface LineChartPropsType {
295
297
  interpolateMissingValues?: boolean;
296
298
  onlyPositive?: boolean;
297
299
  parentWidth?: number;
300
+ onChartAreaPress?: (event: GestureResponderEvent) => void;
301
+ onBackgroundPress?: (event: GestureResponderEvent) => void;
298
302
  }
299
303
  export interface lineDataItem {
300
304
  value: number;
@@ -451,6 +455,7 @@ export interface LineChartBicolorPropsType {
451
455
  disableScroll?: boolean;
452
456
  showScrollIndicator?: boolean;
453
457
  indicatorColor?: 'black' | 'default' | 'white';
458
+ nestedScrollEnabled?: boolean;
454
459
  showYAxisIndices?: boolean;
455
460
  showXAxisIndices?: boolean;
456
461
  yAxisIndicesHeight?: number;
@@ -1,4 +1,4 @@
1
- import { type ColorValue } from 'react-native'
1
+ import { GestureResponderEvent, type ColorValue } from 'react-native'
2
2
  import { type yAxisSides } from '../utils/constants'
3
3
  import {
4
4
  type CurveType,
@@ -20,6 +20,7 @@ export interface LineChartPropsType {
20
20
  overflowTop?: number
21
21
  overflowBottom?: number
22
22
  noOfSections?: number
23
+ sectionColors?: ColorValue[]
23
24
  maxValue?: number
24
25
  mostNegativeValue?: number
25
26
  stepHeight?: number
@@ -125,6 +126,7 @@ export interface LineChartPropsType {
125
126
  pointerConfig?: Pointer
126
127
  showScrollIndicator?: boolean
127
128
  indicatorColor?: 'black' | 'default' | 'white'
129
+ nestedScrollEnabled?: boolean
128
130
 
129
131
  // Indices
130
132
 
@@ -329,6 +331,9 @@ export interface LineChartPropsType {
329
331
  interpolateMissingValues?: boolean
330
332
  onlyPositive?: boolean
331
333
  parentWidth?: number
334
+
335
+ onChartAreaPress?: (event: GestureResponderEvent) => void
336
+ onBackgroundPress?: (event: GestureResponderEvent) => void
332
337
  }
333
338
 
334
339
  export interface lineDataItem {
@@ -502,6 +507,7 @@ export interface LineChartBicolorPropsType {
502
507
  disableScroll?: boolean
503
508
  showScrollIndicator?: boolean
504
509
  indicatorColor?: 'black' | 'default' | 'white'
510
+ nestedScrollEnabled?: boolean
505
511
 
506
512
  // Indices
507
513
 
@@ -545,7 +545,7 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
545
545
  };
546
546
  if (((_c = props.secondaryYAxis) !== null && _c !== void 0 ? _c : (_d = props.lineConfig) === null || _d === void 0 ? void 0 : _d.isSecondary) &&
547
547
  maxValue !== undefined &&
548
- secondaryYAxis.maxValue === undefined) {
548
+ secondaryYAxis && secondaryYAxis.maxValue === undefined) {
549
549
  axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: maxValue });
550
550
  }
551
551
  return axesAndRulesProps;
@@ -744,7 +744,7 @@ export const getAxesAndRulesProps = (
744
744
  if (
745
745
  (props.secondaryYAxis ?? props.lineConfig?.isSecondary) &&
746
746
  maxValue !== undefined &&
747
- secondaryYAxis.maxValue === undefined
747
+ secondaryYAxis && secondaryYAxis.maxValue === undefined
748
748
  ) {
749
749
  axesAndRulesProps.secondaryYAxis = { ...secondaryYAxis, maxValue }
750
750
  }
@@ -246,6 +246,7 @@ export interface BarAndLineChartsWrapperTypes {
246
246
  endReachedOffset: number;
247
247
  isRTL?: boolean;
248
248
  extraWidthDueToDataPoint?: number;
249
+ nestedScrollEnabled?: boolean;
249
250
  }
250
251
  export interface Pointer {
251
252
  height?: number;
@@ -277,6 +277,7 @@ export interface BarAndLineChartsWrapperTypes {
277
277
  endReachedOffset: number
278
278
  isRTL?: boolean
279
279
  extraWidthDueToDataPoint?: number
280
+ nestedScrollEnabled?: boolean
280
281
  }
281
282
 
282
283
  export interface Pointer {