gifted-charts-core 0.1.63 → 0.1.64

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.
@@ -29,18 +29,18 @@ import { useEffect, useMemo, useState } from 'react';
29
29
  import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getLineConfigForBarChart, getMaxValue, getMostNegativeValue, getNoOfSections, getXForLineInBar, getYForLineInBar, indexOfFirstNonZeroDigit, maxAndMinUtil, svgPath } from '../utils';
30
30
  import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
31
31
  export var useBarChart = function (props) {
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, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64;
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, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68;
33
33
  var heightValue = props.heightValue, widthValue = props.widthValue, opacityValue = props.opacityValue, 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
- var _65 = __read(useState(''), 2), points = _65[0], setPoints = _65[1];
35
- var _66 = __read(useState(''), 2), points2 = _66[0], setPoints2 = _66[1];
36
- var _67 = __read(useState(''), 2), arrowPoints = _67[0], setArrowPoints = _67[1];
37
- var _68 = __read(useState(function () {
34
+ var _69 = __read(useState(''), 2), points = _69[0], setPoints = _69[1];
35
+ var _70 = __read(useState(''), 2), points2 = _70[0], setPoints2 = _70[1];
36
+ var _71 = __read(useState(''), 2), arrowPoints = _71[0], setArrowPoints = _71[1];
37
+ var _72 = __read(useState(function () {
38
38
  if (Array.isArray(focusedBarIndex)) {
39
39
  return focusedBarIndex;
40
40
  }
41
41
  return [focusedBarIndex !== null && focusedBarIndex !== void 0 ? focusedBarIndex : -1];
42
- }), 2), selectedIndex = _68[0], setSelectedIndex = _68[1];
43
- var _69 = __read(useState((_a = props.highlightedStackIndex) !== null && _a !== void 0 ? _a : -1), 2), selectedStackIndex = _69[0], setSelectedStackIndex = _69[1];
42
+ }), 2), selectedIndex = _72[0], setSelectedIndex = _72[1];
43
+ var _73 = __read(useState((_a = props.highlightedStackIndex) !== null && _a !== void 0 ? _a : -1), 2), selectedStackIndex = _73[0], setSelectedStackIndex = _73[1];
44
44
  var showLine = (_b = props.showLine) !== null && _b !== void 0 ? _b : BarDefaults.showLine;
45
45
  useEffect(function () {
46
46
  var newIndex = Array.isArray(focusedBarIndex)
@@ -93,29 +93,31 @@ export var useBarChart = function (props) {
93
93
  }
94
94
  return props.stackData;
95
95
  }, [yAxisOffset, props.stackData]);
96
- var yAxisLabelWidth = (_g = props.yAxisLabelWidth) !== null && _g !== void 0 ? _g : (props.hideYAxisText
96
+ // adjustToWidth should work for data or stacked data
97
+ var dataLength = (_k = (_h = (_g = props.data) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : (_j = props.stackData) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0;
98
+ var yAxisLabelWidth = (_l = props.yAxisLabelWidth) !== null && _l !== void 0 ? _l : (props.hideYAxisText
97
99
  ? AxesAndRulesDefaults.yAxisEmptyLabelWidth
98
100
  : AxesAndRulesDefaults.yAxisLabelWidth);
99
101
  var autoComputedSectionWidth = props.initialSpacing !== undefined
100
- ? (parentWidth - yAxisLabelWidth) / data.length - props.initialSpacing
101
- : (parentWidth - yAxisLabelWidth) / (data.length + 0.5);
102
+ ? (parentWidth - yAxisLabelWidth) / dataLength - props.initialSpacing
103
+ : (parentWidth - yAxisLabelWidth) / (dataLength + 0.5);
102
104
  var autoComputedBarWidth = autoComputedSectionWidth * 0.6;
103
105
  var defaultBarWidth = adjustToWidth
104
106
  ? autoComputedBarWidth
105
107
  : BarDefaults.barWidth;
106
- var barWidth = (_h = props.barWidth) !== null && _h !== void 0 ? _h : defaultBarWidth;
108
+ var barWidth = (_m = props.barWidth) !== null && _m !== void 0 ? _m : defaultBarWidth;
107
109
  var autoComputedSpacing = autoComputedSectionWidth * 0.4;
108
- var spacing = (_j = props.spacing) !== null && _j !== void 0 ? _j : (adjustToWidth ? autoComputedSpacing : BarDefaults.spacing);
109
- var initialSpacing = (_k = props.initialSpacing) !== null && _k !== void 0 ? _k : spacing;
110
- var endSpacing = (_l = props.endSpacing) !== null && _l !== void 0 ? _l : spacing;
111
- var horizontal = (_m = props.horizontal) !== null && _m !== void 0 ? _m : BarDefaults.horizontal;
112
- var rtl = (_o = props.rtl) !== null && _o !== void 0 ? _o : BarDefaults.rtl;
113
- var yAxisAtTop = (_p = props.yAxisAtTop) !== null && _p !== void 0 ? _p : BarDefaults.yAxisAtTop;
114
- var intactTopLabel = (_q = props.intactTopLabel) !== null && _q !== void 0 ? _q : BarDefaults.intactTopLabel;
110
+ var spacing = (_o = props.spacing) !== null && _o !== void 0 ? _o : (adjustToWidth ? autoComputedSpacing : BarDefaults.spacing);
111
+ var initialSpacing = (_p = props.initialSpacing) !== null && _p !== void 0 ? _p : spacing;
112
+ var endSpacing = (_q = props.endSpacing) !== null && _q !== void 0 ? _q : spacing;
113
+ var horizontal = (_r = props.horizontal) !== null && _r !== void 0 ? _r : BarDefaults.horizontal;
114
+ var rtl = (_s = props.rtl) !== null && _s !== void 0 ? _s : BarDefaults.rtl;
115
+ var yAxisAtTop = (_t = props.yAxisAtTop) !== null && _t !== void 0 ? _t : BarDefaults.yAxisAtTop;
116
+ var intactTopLabel = (_u = props.intactTopLabel) !== null && _u !== void 0 ? _u : BarDefaults.intactTopLabel;
115
117
  var heightFromProps = horizontal ? props.width : props.height;
116
118
  var widthFromProps = horizontal ? props.height : props.width;
117
- var isAnimated = (_r = props.isAnimated) !== null && _r !== void 0 ? _r : BarDefaults.isAnimated;
118
- var animationDuration = (_s = props.animationDuration) !== null && _s !== void 0 ? _s : BarDefaults.animationDuration;
119
+ var isAnimated = (_v = props.isAnimated) !== null && _v !== void 0 ? _v : BarDefaults.isAnimated;
120
+ var animationDuration = (_w = props.animationDuration) !== null && _w !== void 0 ? _w : BarDefaults.animationDuration;
119
121
  // const secondaryData = getSecondaryDataWithOffsetIncluded(
120
122
  // props.secondaryData,
121
123
  // props.secondaryYAxis
@@ -133,7 +135,7 @@ export var useBarChart = function (props) {
133
135
  return props.lineData;
134
136
  }, [yAxisOffset, props.lineData, data, stackData]);
135
137
  var lineData2 = props.lineData2;
136
- var lineBehindBars = (_t = props.lineBehindBars) !== null && _t !== void 0 ? _t : BarDefaults.lineBehindBars;
138
+ var lineBehindBars = (_x = props.lineBehindBars) !== null && _x !== void 0 ? _x : BarDefaults.lineBehindBars;
137
139
  defaultLineConfig.initialSpacing = initialSpacing;
138
140
  defaultLineConfig.endIndex = lineData.length - 1;
139
141
  defaultLineConfig.animationDuration = animationDuration;
@@ -148,12 +150,12 @@ export var useBarChart = function (props) {
148
150
  ? props.stepHeight * noOfSections
149
151
  : AxesAndRulesDefaults.containerHeight);
150
152
  var horizSections = [{ value: '0' }];
151
- var stepHeight = (_u = props.stepHeight) !== null && _u !== void 0 ? _u : containerHeight / noOfSections;
152
- var labelWidth = (_v = props.labelWidth) !== null && _v !== void 0 ? _v : AxesAndRulesDefaults.labelWidth;
153
- var scrollToEnd = (_w = props.scrollToEnd) !== null && _w !== void 0 ? _w : BarDefaults.scrollToEnd;
154
- var scrollAnimation = (_x = props.scrollAnimation) !== null && _x !== void 0 ? _x : BarDefaults.scrollAnimation;
155
- var scrollEventThrottle = (_y = props.scrollEventThrottle) !== null && _y !== void 0 ? _y : BarDefaults.scrollEventThrottle;
156
- var labelsExtraHeight = (_z = props.labelsExtraHeight) !== null && _z !== void 0 ? _z : AxesAndRulesDefaults.labelsExtraHeight;
153
+ var stepHeight = (_y = props.stepHeight) !== null && _y !== void 0 ? _y : containerHeight / noOfSections;
154
+ var labelWidth = (_z = props.labelWidth) !== null && _z !== void 0 ? _z : AxesAndRulesDefaults.labelWidth;
155
+ var scrollToEnd = (_0 = props.scrollToEnd) !== null && _0 !== void 0 ? _0 : BarDefaults.scrollToEnd;
156
+ var scrollAnimation = (_1 = props.scrollAnimation) !== null && _1 !== void 0 ? _1 : BarDefaults.scrollAnimation;
157
+ var scrollEventThrottle = (_2 = props.scrollEventThrottle) !== null && _2 !== void 0 ? _2 : BarDefaults.scrollEventThrottle;
158
+ var labelsExtraHeight = (_3 = props.labelsExtraHeight) !== null && _3 !== void 0 ? _3 : AxesAndRulesDefaults.labelsExtraHeight;
157
159
  var secondaryMaxItem = 0;
158
160
  var secondaryMinItem = 0;
159
161
  if (lineConfig.isSecondary) {
@@ -198,7 +200,7 @@ export var useBarChart = function (props) {
198
200
  }
199
201
  totalWidth +=
200
202
  ((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
201
- (index === data.length - 1 ? 0 : (_c = stackItem.spacing) !== null && _c !== void 0 ? _c : spacing);
203
+ (index === dataLength - 1 ? 0 : (_c = stackItem.spacing) !== null && _c !== void 0 ? _c : spacing);
202
204
  });
203
205
  }
204
206
  else {
@@ -225,17 +227,17 @@ export var useBarChart = function (props) {
225
227
  }
226
228
  totalWidth +=
227
229
  ((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
228
- (index === data.length - 1 ? spacing : (_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
230
+ (index === dataLength - 1 ? spacing : (_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
229
231
  });
230
232
  }
231
233
  var valuesRange = maxItem - minPositiveItem; // Diff bw largest & smallest +ve values
232
- var showFractionalValues = (_0 = props.showFractionalValues) !== null && _0 !== void 0 ? _0 : valuesRange <= 1;
233
- var roundToDigits = (_1 = props.roundToDigits) !== null && _1 !== void 0 ? _1 : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
234
+ var showFractionalValues = (_4 = props.showFractionalValues) !== null && _4 !== void 0 ? _4 : valuesRange <= 1;
235
+ var roundToDigits = (_5 = props.roundToDigits) !== null && _5 !== void 0 ? _5 : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
234
236
  var maxAndMin = maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
235
237
  var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxAndMin.maxItem) || 10;
236
238
  var secondaryRange = secondaryMaxItem - secondaryMinPositiveItem; // Diff bw largest & smallest +ve values
237
- var showSecondaryFractionalValues = (_3 = (_2 = props.secondaryYAxis) === null || _2 === void 0 ? void 0 : _2.showFractionalValues) !== null && _3 !== void 0 ? _3 : secondaryRange <= 1;
238
- var secondaryRoundToDigits = (_5 = (_4 = props.secondaryYAxis) === null || _4 === void 0 ? void 0 : _4.roundToDigits) !== null && _5 !== void 0 ? _5 : (showSecondaryFractionalValues
239
+ var showSecondaryFractionalValues = (_7 = (_6 = props.secondaryYAxis) === null || _6 === void 0 ? void 0 : _6.showFractionalValues) !== null && _7 !== void 0 ? _7 : secondaryRange <= 1;
240
+ var secondaryRoundToDigits = (_9 = (_8 = props.secondaryYAxis) === null || _8 === void 0 ? void 0 : _8.roundToDigits) !== null && _9 !== void 0 ? _9 : (showSecondaryFractionalValues
239
241
  ? indexOfFirstNonZeroDigit(secondaryRange) + 1
240
242
  : 0);
241
243
  var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, secondaryRoundToDigits, showSecondaryFractionalValues);
@@ -245,88 +247,88 @@ export var useBarChart = function (props) {
245
247
  // secondaryMaxAndMin.maxItem
246
248
  // : secondaryMaxAndMin.maxItem
247
249
  // : maxValue
248
- var secondaryMaxValue = (_7 = (_6 = props.secondaryYAxis) === null || _6 === void 0 ? void 0 : _6.maxValue) !== null && _7 !== void 0 ? _7 : secondaryMaxAndMin.maxItem;
250
+ var secondaryMaxValue = (_11 = (_10 = props.secondaryYAxis) === null || _10 === void 0 ? void 0 : _10.maxValue) !== null && _11 !== void 0 ? _11 : secondaryMaxAndMin.maxItem;
249
251
  var mostNegativeValue = getMostNegativeValue(props.mostNegativeValue, props.negativeStepValue, props.noOfSectionsBelowXAxis, maxAndMin.minItem);
250
- var stepValue = (_8 = props.stepValue) !== null && _8 !== void 0 ? _8 : maxValue / noOfSections;
252
+ var stepValue = (_12 = props.stepValue) !== null && _12 !== void 0 ? _12 : maxValue / noOfSections;
251
253
  var effectiveNegativeStepValue = negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue;
252
- var noOfSectionsBelowXAxis = (_9 = props.noOfSectionsBelowXAxis) !== null && _9 !== void 0 ? _9 : (effectiveNegativeStepValue
254
+ var noOfSectionsBelowXAxis = (_13 = props.noOfSectionsBelowXAxis) !== null && _13 !== void 0 ? _13 : (effectiveNegativeStepValue
253
255
  ? Math.round(Math.ceil(-mostNegativeValue / effectiveNegativeStepValue))
254
256
  : 0);
255
- var showScrollIndicator = (_10 = props.showScrollIndicator) !== null && _10 !== void 0 ? _10 : BarDefaults.showScrollIndicator;
256
- var side = (_11 = props.side) !== null && _11 !== void 0 ? _11 : BarDefaults.side;
257
- var rotateLabel = (_12 = props.rotateLabel) !== null && _12 !== void 0 ? _12 : AxesAndRulesDefaults.rotateLabel;
258
- var opacity = (_13 = props.opacity) !== null && _13 !== void 0 ? _13 : BarDefaults.opacity;
259
- var isThreeD = (_14 = props.isThreeD) !== null && _14 !== void 0 ? _14 : BarDefaults.isThreeD;
260
- var showXAxisIndices = (_15 = props.showXAxisIndices) !== null && _15 !== void 0 ? _15 : AxesAndRulesDefaults.showXAxisIndices;
261
- var xAxisIndicesHeight = (_16 = props.xAxisIndicesHeight) !== null && _16 !== void 0 ? _16 : AxesAndRulesDefaults.xAxisIndicesHeight;
262
- var xAxisIndicesWidth = (_17 = props.xAxisIndicesWidth) !== null && _17 !== void 0 ? _17 : AxesAndRulesDefaults.xAxisIndicesWidth;
263
- var xAxisIndicesColor = (_18 = props.xAxisIndicesColor) !== null && _18 !== void 0 ? _18 : AxesAndRulesDefaults.xAxisIndicesColor;
264
- var xAxisThickness = (_19 = props.xAxisThickness) !== null && _19 !== void 0 ? _19 : AxesAndRulesDefaults.xAxisThickness;
265
- var xAxisTextNumberOfLines = (_20 = props.xAxisTextNumberOfLines) !== null && _20 !== void 0 ? _20 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
266
- var xAxisLabelsVerticalShift = (_21 = props.xAxisLabelsVerticalShift) !== null && _21 !== void 0 ? _21 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
267
- var xAxisLabelsAtBottom = (_22 = props.xAxisLabelsAtBottom) !== null && _22 !== void 0 ? _22 : false;
257
+ var showScrollIndicator = (_14 = props.showScrollIndicator) !== null && _14 !== void 0 ? _14 : BarDefaults.showScrollIndicator;
258
+ var side = (_15 = props.side) !== null && _15 !== void 0 ? _15 : BarDefaults.side;
259
+ var rotateLabel = (_16 = props.rotateLabel) !== null && _16 !== void 0 ? _16 : AxesAndRulesDefaults.rotateLabel;
260
+ var opacity = (_17 = props.opacity) !== null && _17 !== void 0 ? _17 : BarDefaults.opacity;
261
+ var isThreeD = (_18 = props.isThreeD) !== null && _18 !== void 0 ? _18 : BarDefaults.isThreeD;
262
+ var showXAxisIndices = (_19 = props.showXAxisIndices) !== null && _19 !== void 0 ? _19 : AxesAndRulesDefaults.showXAxisIndices;
263
+ var xAxisIndicesHeight = (_20 = props.xAxisIndicesHeight) !== null && _20 !== void 0 ? _20 : AxesAndRulesDefaults.xAxisIndicesHeight;
264
+ var xAxisIndicesWidth = (_21 = props.xAxisIndicesWidth) !== null && _21 !== void 0 ? _21 : AxesAndRulesDefaults.xAxisIndicesWidth;
265
+ var xAxisIndicesColor = (_22 = props.xAxisIndicesColor) !== null && _22 !== void 0 ? _22 : AxesAndRulesDefaults.xAxisIndicesColor;
266
+ var xAxisThickness = (_23 = props.xAxisThickness) !== null && _23 !== void 0 ? _23 : AxesAndRulesDefaults.xAxisThickness;
267
+ var xAxisTextNumberOfLines = (_24 = props.xAxisTextNumberOfLines) !== null && _24 !== void 0 ? _24 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
268
+ var xAxisLabelsVerticalShift = (_25 = props.xAxisLabelsVerticalShift) !== null && _25 !== void 0 ? _25 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
269
+ var xAxisLabelsAtBottom = (_26 = props.xAxisLabelsAtBottom) !== null && _26 !== void 0 ? _26 : false;
268
270
  var horizontalRulesStyle = props.horizontalRulesStyle;
269
- var autoShiftLabels = (_23 = props.autoShiftLabels) !== null && _23 !== void 0 ? _23 : false;
270
- var barBorderColor = (_24 = props.barBorderColor) !== null && _24 !== void 0 ? _24 : BarDefaults.barBorderColor;
271
+ var autoShiftLabels = (_27 = props.autoShiftLabels) !== null && _27 !== void 0 ? _27 : false;
272
+ var barBorderColor = (_28 = props.barBorderColor) !== null && _28 !== void 0 ? _28 : BarDefaults.barBorderColor;
271
273
  var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
272
274
  var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue !== null && negativeStepValue !== void 0 ? negativeStepValue : stepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
273
- var _70 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepHeight = _70.stepHeight, secondaryStepValue = _70.stepValue, secondaryNegativeStepHeight = _70.negativeStepHeight, secondaryNegativeStepValue = _70.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _70.noOfSectionsBelowXAxis;
274
- var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((_25 = props.negativeStepHeight) !== null && _25 !== void 0 ? _25 : stepHeight);
275
+ var _74 = axesAndRulesProps.secondaryYAxisConfig, secondaryStepHeight = _74.stepHeight, secondaryStepValue = _74.stepValue, secondaryNegativeStepHeight = _74.negativeStepHeight, secondaryNegativeStepValue = _74.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _74.noOfSectionsBelowXAxis;
276
+ var primary4thQuadrantHeight = noOfSectionsBelowXAxis * ((_29 = props.negativeStepHeight) !== null && _29 !== void 0 ? _29 : stepHeight);
275
277
  var secondary4thQuadrantHeight = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
276
278
  var fourthQuadrantHeight = Math.max(primary4thQuadrantHeight, secondary4thQuadrantHeight);
277
279
  var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
278
- var _71 = __read(useState(-1), 2), pointerIndex = _71[0], setPointerIndex = _71[1];
279
- var _72 = __read(useState(0), 2), pointerX = _72[0], setPointerX = _72[1];
280
- var _73 = __read(useState(0), 2), pointerY = _73[0], setPointerY = _73[1];
281
- var _74 = __read(useState(), 2), pointerItem = _74[0], setPointerItem = _74[1];
282
- var _75 = __read(useState(0), 2), responderStartTime = _75[0], setResponderStartTime = _75[1];
283
- var _76 = __read(useState(false), 2), responderActive = _76[0], setResponderActive = _76[1];
280
+ var _75 = __read(useState(-1), 2), pointerIndex = _75[0], setPointerIndex = _75[1];
281
+ var _76 = __read(useState(0), 2), pointerX = _76[0], setPointerX = _76[1];
282
+ var _77 = __read(useState(0), 2), pointerY = _77[0], setPointerY = _77[1];
283
+ var _78 = __read(useState(), 2), pointerItem = _78[0], setPointerItem = _78[1];
284
+ var _79 = __read(useState(0), 2), responderStartTime = _79[0], setResponderStartTime = _79[1];
285
+ var _80 = __read(useState(false), 2), responderActive = _80[0], setResponderActive = _80[1];
284
286
  var pointerConfig = props.pointerConfig;
285
- var getPointerProps = (_26 = props.getPointerProps) !== null && _26 !== void 0 ? _26 : null;
286
- var pointerHeight = (_27 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _27 !== void 0 ? _27 : defaultPointerConfig.height;
287
- var pointerWidth = (_28 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _28 !== void 0 ? _28 : defaultPointerConfig.width;
288
- var pointerRadius = (_29 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _29 !== void 0 ? _29 : defaultPointerConfig.radius;
289
- var pointerColor = (_30 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _30 !== void 0 ? _30 : defaultPointerConfig.pointerColor;
290
- var pointerComponent = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.pointerComponent;
287
+ var getPointerProps = (_30 = props.getPointerProps) !== null && _30 !== void 0 ? _30 : null;
288
+ var pointerHeight = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.height;
289
+ var pointerWidth = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.width;
290
+ var pointerRadius = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.radius;
291
+ var pointerColor = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.pointerColor;
292
+ var pointerComponent = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _35 !== void 0 ? _35 : defaultPointerConfig.pointerComponent;
291
293
  var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
292
294
  ? false
293
295
  : defaultPointerConfig.showPointerStrip;
294
- var pointerStripHeight = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.pointerStripHeight;
295
- var pointerStripWidth = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.pointerStripWidth;
296
- var pointerStripColor = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.pointerStripColor;
297
- var pointerStripUptoDataPoint = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _35 !== void 0 ? _35 : defaultPointerConfig.pointerStripUptoDataPoint;
298
- var pointerLabelComponent = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.pointerLabelComponent;
299
- var stripOverPointer = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.stripOverPointer;
300
- var shiftPointerLabelX = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.shiftPointerLabelX;
301
- var shiftPointerLabelY = (_39 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _39 !== void 0 ? _39 : defaultPointerConfig.shiftPointerLabelY;
302
- var pointerLabelWidth = (_40 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _40 !== void 0 ? _40 : defaultPointerConfig.pointerLabelWidth;
303
- var pointerLabelHeight = (_41 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _41 !== void 0 ? _41 : defaultPointerConfig.pointerLabelHeight;
304
- var autoAdjustPointerLabelPosition = (_42 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _42 !== void 0 ? _42 : defaultPointerConfig.autoAdjustPointerLabelPosition;
305
- var pointerVanishDelay = (_43 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _43 !== void 0 ? _43 : defaultPointerConfig.pointerVanishDelay;
306
- var activatePointersOnLongPress = (_44 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _44 !== void 0 ? _44 : defaultPointerConfig.activatePointersOnLongPress;
307
- var activatePointersDelay = (_45 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _45 !== void 0 ? _45 : defaultPointerConfig.activatePointersDelay;
308
- var initialPointerIndex = (_46 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _46 !== void 0 ? _46 : defaultPointerConfig.initialPointerIndex;
309
- var initialPointerAppearDelay = (_47 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _47 !== void 0 ? _47 : (isAnimated
296
+ var pointerStripHeight = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.pointerStripHeight;
297
+ var pointerStripWidth = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.pointerStripWidth;
298
+ var pointerStripColor = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.pointerStripColor;
299
+ var pointerStripUptoDataPoint = (_39 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _39 !== void 0 ? _39 : defaultPointerConfig.pointerStripUptoDataPoint;
300
+ var pointerLabelComponent = (_40 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _40 !== void 0 ? _40 : defaultPointerConfig.pointerLabelComponent;
301
+ var stripOverPointer = (_41 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _41 !== void 0 ? _41 : defaultPointerConfig.stripOverPointer;
302
+ var shiftPointerLabelX = (_42 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _42 !== void 0 ? _42 : defaultPointerConfig.shiftPointerLabelX;
303
+ var shiftPointerLabelY = (_43 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _43 !== void 0 ? _43 : defaultPointerConfig.shiftPointerLabelY;
304
+ var pointerLabelWidth = (_44 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _44 !== void 0 ? _44 : defaultPointerConfig.pointerLabelWidth;
305
+ var pointerLabelHeight = (_45 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _45 !== void 0 ? _45 : defaultPointerConfig.pointerLabelHeight;
306
+ var autoAdjustPointerLabelPosition = (_46 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _46 !== void 0 ? _46 : defaultPointerConfig.autoAdjustPointerLabelPosition;
307
+ var pointerVanishDelay = (_47 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _47 !== void 0 ? _47 : defaultPointerConfig.pointerVanishDelay;
308
+ var activatePointersOnLongPress = (_48 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _48 !== void 0 ? _48 : defaultPointerConfig.activatePointersOnLongPress;
309
+ var activatePointersDelay = (_49 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _49 !== void 0 ? _49 : defaultPointerConfig.activatePointersDelay;
310
+ var initialPointerIndex = (_50 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _50 !== void 0 ? _50 : defaultPointerConfig.initialPointerIndex;
311
+ var initialPointerAppearDelay = (_51 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _51 !== void 0 ? _51 : (isAnimated
310
312
  ? animationDuration
311
313
  : defaultPointerConfig.initialPointerAppearDelay);
312
- var persistPointer = (_48 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _48 !== void 0 ? _48 : defaultPointerConfig.persistPointer;
313
- var hidePointer1 = (_49 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _49 !== void 0 ? _49 : defaultPointerConfig.hidePointer1;
314
+ var persistPointer = (_52 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _52 !== void 0 ? _52 : defaultPointerConfig.persistPointer;
315
+ var hidePointer1 = (_53 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _53 !== void 0 ? _53 : defaultPointerConfig.hidePointer1;
314
316
  var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
315
- var stripBehindBars = (_50 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _50 !== void 0 ? _50 : defaultPointerConfig.stripBehindBars;
316
- var disableScroll = (_51 = props.disableScroll) !== null && _51 !== void 0 ? _51 : (pointerConfig
317
+ var stripBehindBars = (_54 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _54 !== void 0 ? _54 : defaultPointerConfig.stripBehindBars;
318
+ var disableScroll = (_55 = props.disableScroll) !== null && _55 !== void 0 ? _55 : (pointerConfig
317
319
  ? activatePointersOnLongPress
318
320
  ? !!responderActive
319
321
  : true
320
322
  : false);
321
323
  var yAxisExtraHeightAtTop = props.trimYAxisAtTop
322
324
  ? 0
323
- : (_52 = props.yAxisExtraHeight) !== null && _52 !== void 0 ? _52 : containerHeight / 20;
325
+ : (_56 = props.yAxisExtraHeight) !== null && _56 !== void 0 ? _56 : containerHeight / 20;
324
326
  var barInnerComponent = props.barInnerComponent;
325
327
  var localYAxisOffset1 = lineConfig.isSecondary
326
- ? (_54 = (_53 = props.secondaryYAxis) === null || _53 === void 0 ? void 0 : _53.yAxisOffset) !== null && _54 !== void 0 ? _54 : 0
328
+ ? (_58 = (_57 = props.secondaryYAxis) === null || _57 === void 0 ? void 0 : _57.yAxisOffset) !== null && _58 !== void 0 ? _58 : 0
327
329
  : yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
328
330
  var localYAxisOffset2 = lineConfig2.isSecondary
329
- ? (_56 = (_55 = props.secondaryYAxis) === null || _55 === void 0 ? void 0 : _55.yAxisOffset) !== null && _56 !== void 0 ? _56 : 0
331
+ ? (_60 = (_59 = props.secondaryYAxis) === null || _59 === void 0 ? void 0 : _59.yAxisOffset) !== null && _60 !== void 0 ? _60 : 0
330
332
  : yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0;
331
333
  useEffect(function () {
332
334
  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;
@@ -442,9 +444,9 @@ export var useBarChart = function (props) {
442
444
  spacing,
443
445
  yAxisLabelWidth,
444
446
  lineConfig.showArrow,
445
- (_57 = lineConfig.arrowConfig) === null || _57 === void 0 ? void 0 : _57.length,
446
- (_58 = lineConfig.arrowConfig) === null || _58 === void 0 ? void 0 : _58.width,
447
- (_59 = lineConfig.arrowConfig) === null || _59 === void 0 ? void 0 : _59.showArrowBase
447
+ (_61 = lineConfig.arrowConfig) === null || _61 === void 0 ? void 0 : _61.length,
448
+ (_62 = lineConfig.arrowConfig) === null || _62 === void 0 ? void 0 : _62.width,
449
+ (_63 = lineConfig.arrowConfig) === null || _63 === void 0 ? void 0 : _63.showArrowBase
448
450
  ]);
449
451
  useEffect(function () {
450
452
  var _a, _b;
@@ -581,19 +583,19 @@ export var useBarChart = function (props) {
581
583
  containerHeight: containerHeight,
582
584
  noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
583
585
  stepHeight: stepHeight,
584
- negativeStepHeight: (_60 = props.negativeStepHeight) !== null && _60 !== void 0 ? _60 : stepHeight,
586
+ negativeStepHeight: (_64 = props.negativeStepHeight) !== null && _64 !== void 0 ? _64 : stepHeight,
585
587
  labelsExtraHeight: labelsExtraHeight,
586
588
  yAxisLabelWidth: yAxisLabelWidth,
587
589
  horizontal: horizontal,
588
590
  rtl: rtl,
589
- shiftX: (_61 = props.shiftX) !== null && _61 !== void 0 ? _61 : 0,
590
- shiftY: (_62 = props.shiftY) !== null && _62 !== void 0 ? _62 : 0,
591
+ shiftX: (_65 = props.shiftX) !== null && _65 !== void 0 ? _65 : 0,
592
+ shiftY: (_66 = props.shiftY) !== null && _66 !== void 0 ? _66 : 0,
591
593
  yAxisAtTop: yAxisAtTop,
592
594
  initialSpacing: initialSpacing,
593
595
  data: data,
594
596
  stackData: stackData,
595
597
  // secondaryData,
596
- barWidth: (_63 = props.barWidth) !== null && _63 !== void 0 ? _63 : defaultBarWidth,
598
+ barWidth: (_67 = props.barWidth) !== null && _67 !== void 0 ? _67 : defaultBarWidth,
597
599
  xAxisThickness: xAxisThickness,
598
600
  totalWidth: totalWidth,
599
601
  disableScroll: disableScroll,
@@ -642,7 +644,7 @@ export var useBarChart = function (props) {
642
644
  pointerY: pointerY,
643
645
  onEndReached: props.onEndReached,
644
646
  onStartReached: props.onStartReached,
645
- endReachedOffset: (_64 = props.endReachedOffset) !== null && _64 !== void 0 ? _64 : BarDefaults.endReachedOffset,
647
+ endReachedOffset: (_68 = props.endReachedOffset) !== null && _68 !== void 0 ? _68 : BarDefaults.endReachedOffset,
646
648
  onMomentumScrollEnd: props.onMomentumScrollEnd,
647
649
  customBackground: props.customBackground,
648
650
  highlightEnabled: highlightEnabled,
@@ -1,6 +1,6 @@
1
1
  import { GestureResponderEvent, type ColorValue } from 'react-native';
2
2
  import { type yAxisSides } from '../utils/constants';
3
- import { XAxisConfig, type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType, type Linecap, type IntersectionAreaConfig, CustomBackground } from '../utils/types';
3
+ import { XAxisConfig, type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType, type Linecap, type IntersectionAreaConfig, CustomBackground, SpreadData } from '../utils/types';
4
4
  export interface LineChartPropsType {
5
5
  height?: number;
6
6
  overflowTop?: number;
@@ -335,6 +335,9 @@ export interface LineChartPropsType {
335
335
  renderTooltipSecondary?: Function;
336
336
  dataPointLabelComponent?: Function;
337
337
  focusedDataPointLabelComponent?: Function;
338
+ spreadAreaData?: SpreadData[];
339
+ spreadAreaColor?: ColorValue;
340
+ spreadAreaOpacity?: number;
338
341
  }
339
342
  export interface lineDataItem {
340
343
  value?: number;
package/dist/index.d.ts CHANGED
@@ -42,4 +42,4 @@ export { type StripAndLabelProps } from './components/common/types';
42
42
  /***********************************************************************************************************************/
43
43
  export { getCumulativeWidth, getLighterColor, svgQuadraticCurvePath, svgPath, bezierCommand, getSegmentString, getCurvePathWithSegments, getPreviousSegmentsLastPoint, getPathWithHighlight, getRegionPathObjects, getSegmentedPathObjects, getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getSecondaryDataWithOffsetIncluded, getArrowProperty, getAllArrowProperties, maxAndMinUtil, computeMaxAndMinItems, getLabelTextUtil, getXForLineInBar, getYForLineInBar, clone, getLineConfigForBarChart, adjustToOffset, pointsWithPaddedRepititions } from './utils';
44
44
  export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
45
- export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, type DataSetNullSafe, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps, type Linecap, type IntersectionAreaConfig, type LabelLineConfig, type TooltipProps } from './utils/types';
45
+ export { type RuleType, type RuleTypes, type RulesConfig, CurveType, EdgePosition, type LabelsPosition, type PointerEvents, type secondaryYAxisType, type secondaryLineConfigType, type referenceConfigType, type arrowConfigType, type horizSectionPropTypes, type HorizSectionsType, type BarAndLineChartsWrapperTypes, type Pointer, type HighlightedRange, type LineSegment, type LineSvgProps, type LineProperties, type DataSet, type DataSetNullSafe, Framework, type XAxisConfig, type LineInBarChartPropsType, type DataPointProps, type Linecap, type IntersectionAreaConfig, type LabelLineConfig, type TooltipProps, type SpreadData } from './utils/types';
@@ -332,8 +332,8 @@ export var radarChartDefaults = {
332
332
  hideAsterLines: false,
333
333
  hideGrid: false,
334
334
  hideLabels: false,
335
- labelsPositionOffset: 5,
336
- dataLabelsPositionOffset: 5,
335
+ labelsPositionOffset: 0,
336
+ dataLabelsPositionOffset: 0,
337
337
  gridSection: {
338
338
  stroke: 'lightgray',
339
339
  strokeWidth: 1,
@@ -23,6 +23,10 @@ export interface RuleTypes {
23
23
  DASHED: RuleType;
24
24
  DOTTED: RuleType;
25
25
  }
26
+ export interface SpreadData {
27
+ lower: number;
28
+ upper: number;
29
+ }
26
30
  export declare enum CurveType {
27
31
  CUBIC = 0,
28
32
  QUADRATIC = 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.63",
3
+ "version": "0.1.64",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "./dist/index.js",
6
6
  "files": [