gifted-charts-core 0.1.74 → 0.1.76

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.
@@ -9,7 +9,7 @@ export declare const useBubbleChart: (props: extendedBubbleChartPropsType) => {
9
9
  containerHeightIncludingBelowXAxis: number;
10
10
  getY: (value: number) => number;
11
11
  barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
12
- getX: (spacingArray: number[], index: number) => number;
12
+ getX: (index: number) => number;
13
13
  maxValue: number;
14
14
  selectedIndex: number;
15
15
  setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
@@ -24,20 +24,19 @@ export declare const useBubbleChart: (props: extendedBubbleChartPropsType) => {
24
24
  handleFocus: (index: number) => void;
25
25
  handleUnFocus: () => void;
26
26
  isAnimated: boolean;
27
- showDataPointOnFocus: boolean;
28
- showDataPointLabelOnFocus: boolean;
29
- dataPointsShape: string;
30
- dataPointsWidth: number;
31
- dataPointsHeight: number;
32
- dataPointsColor: string;
33
- dataPointsRadius: number;
34
- textColor: string;
35
- textFontSize: number;
27
+ showBubbleOnFocus: boolean;
28
+ showBubbleLabelOnFocus: boolean;
29
+ bubblesShape: string;
30
+ bubblesWidth: number;
31
+ bubblesHeight: number;
32
+ bubblesColor: string;
33
+ bubblesRadius: number;
34
+ labelFontSize: number;
35
+ labelTextStyle: Object | undefined;
36
36
  startIndex: number;
37
37
  endIndex: number;
38
- showValuesAsDataPointsText: boolean;
39
- cumulativeSpacing: number[];
40
- hideDataPoints: boolean;
38
+ showValuesAsBubbleLabels: boolean;
39
+ hideBubbles: boolean;
41
40
  xAxisLabelsVerticalShift: number;
42
41
  labelsExtraHeight: number;
43
42
  xAxisThickness: number;
@@ -47,4 +46,19 @@ export declare const useBubbleChart: (props: extendedBubbleChartPropsType) => {
47
46
  borderWidth: number;
48
47
  borderColor: import("react-native").ColorValue;
49
48
  opacity: number;
49
+ xAxisLabelTexts: string[];
50
+ showRegressionLine: boolean;
51
+ regressionLineConfig: {
52
+ thickness: number;
53
+ color: import("react-native").ColorValue;
54
+ opacity: number;
55
+ strokeDashArray: number[] | undefined;
56
+ isAnimated: boolean;
57
+ animationDuration: number;
58
+ };
59
+ regressionLineX1: number;
60
+ regressionLineY1: number;
61
+ regressionLineX2: number;
62
+ regressionLineY2: number;
63
+ scatterChart: boolean;
50
64
  };
@@ -23,118 +23,192 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
23
23
  }
24
24
  return to.concat(ar || Array.prototype.slice.call(from));
25
25
  };
26
+ var __values = (this && this.__values) || function(o) {
27
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28
+ if (m) return m.call(o);
29
+ if (o && typeof o.length === "number") return {
30
+ next: function () {
31
+ if (o && i >= o.length) o = void 0;
32
+ return { value: o && o[i++], done: !o };
33
+ }
34
+ };
35
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
36
+ };
26
37
  import { useState } from 'react';
27
- import { computeMaxAndMinItems, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getMaxValue, getNoOfSections, indexOfFirstNonZeroDigit } from '../utils';
38
+ import { computeMaxAndMinXForBubble, computeMaxAndMinYForBubble, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getMaxValue, getNoOfSections, indexOfFirstNonZeroDigit
39
+ // weightedRegression
40
+ } from '../utils';
28
41
  import { AxesAndRulesDefaults, BubbleDefaults, chartTypes, LineDefaults } from '../utils/constants';
29
42
  export var useBubbleChart = function (props) {
30
- 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;
31
- var _37 = props.data, data = _37 === void 0 ? [] : _37;
32
- var noOfSections = getNoOfSections(props.noOfSections, props.maxValue, props.stepValue);
33
- var containerHeight = (_a = props.height) !== null && _a !== void 0 ? _a : (((_b = props.stepHeight) !== null && _b !== void 0 ? _b : 0) * noOfSections ||
43
+ 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;
44
+ var _55 = props.data, data = _55 === void 0 ? [] : _55, formatXLabel = props.formatXLabel;
45
+ var yNoOfSections = getNoOfSections(props.yNoOfSections, props.maxY, props.yStepValue);
46
+ var containerHeight = (_a = props.height) !== null && _a !== void 0 ? _a : (((_b = props.yStepHeight) !== null && _b !== void 0 ? _b : 0) * yNoOfSections ||
34
47
  AxesAndRulesDefaults.containerHeight);
35
- var valuesRange = Math.max.apply(Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.value, 0); })), false)) - // find the largest +ve number
48
+ var yRange = Math.max.apply(Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.y, 0); })), false)) - // find the largest +ve number
36
49
  Math.min.apply(// find the largest +ve number
37
- Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.value, 0); })), false)); // find the smallest +ve number
38
- var showFractionalValues = (_c = props.showFractionalValues) !== null && _c !== void 0 ? _c : (isFinite(valuesRange) && valuesRange <= 1);
39
- var roundToDigits = (_d = props.roundToDigits) !== null && _d !== void 0 ? _d : (showFractionalValues ? indexOfFirstNonZeroDigit(valuesRange) + 1 : 0);
40
- var _38 = computeMaxAndMinItems(data, false, // extrapolateMissingValues
41
- roundToDigits, showFractionalValues, data), maxItem = _38.maxItem, minItem = _38.minItem;
42
- var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem) || 10;
43
- var mostNegativeValue = (_e = props.mostNegativeValue) !== null && _e !== void 0 ? _e : minItem;
44
- var onlyPositive = (_f = props.onlyPositive) !== null && _f !== void 0 ? _f : mostNegativeValue >= 0;
50
+ Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.y, 0); })), false)); // find the smallest +ve number
51
+ var showFractionalYAxis = (_c = props.showFractionalYAxis) !== null && _c !== void 0 ? _c : (isFinite(yRange) && yRange <= 1);
52
+ var roundToDigits = (_d = props.yRoundToDigits) !== null && _d !== void 0 ? _d : (showFractionalYAxis ? indexOfFirstNonZeroDigit(yRange) + 1 : 0);
53
+ var bubblesRadius = (_e = props.bubblesRadius) !== null && _e !== void 0 ? _e : BubbleDefaults.bubblesRadius;
54
+ var _56 = computeMaxAndMinYForBubble(data, false, // extrapolateMissingValues
55
+ roundToDigits, showFractionalYAxis, data), yMaxItem = _56.maxItem, yMinItem = _56.minItem;
56
+ // Find the maximum radius across all bubbles to account for bubble size in chart bounds
57
+ var maxBubbleRadius = props.hideBubbles
58
+ ? 0
59
+ : data.length > 0
60
+ ? Math.max.apply(Math, __spreadArray([bubblesRadius], __read(data.map(function (item) { var _a; return (_a = item.r) !== null && _a !== void 0 ? _a : bubblesRadius; })), false)) : bubblesRadius;
61
+ var maxYInitial = getMaxValue(props.maxY, props.yStepValue, yNoOfSections, yMaxItem) || 10;
62
+ var mostNegativeYInitial = (_f = props.mostNegativeY) !== null && _f !== void 0 ? _f : yMinItem;
63
+ var onlyPositive = (_g = props.onlyPositive) !== null && _g !== void 0 ? _g : mostNegativeYInitial >= 0;
45
64
  var horizSections = [{ value: '0' }];
46
- var stepHeight = (_g = props.stepHeight) !== null && _g !== void 0 ? _g : containerHeight / noOfSections;
47
- var stepValue = (_h = props.stepValue) !== null && _h !== void 0 ? _h : maxValue / noOfSections;
48
- var noOfSectionsBelowXAxis = (_j = props.noOfSectionsBelowXAxis) !== null && _j !== void 0 ? _j : Math.round(Math.ceil(-mostNegativeValue / stepValue));
49
- var labelsExtraHeight = (_k = props.labelsExtraHeight) !== null && _k !== void 0 ? _k : 0;
50
- var yAxisLabelWidth = (_l = props.yAxisLabelWidth) !== null && _l !== void 0 ? _l : (props.hideYAxisText
65
+ var yStepHeight = (_h = props.yStepHeight) !== null && _h !== void 0 ? _h : containerHeight / yNoOfSections;
66
+ // Adjust maxY to account for bubble radius at the top of the chart
67
+ // Convert max bubble radius from screen pixels to Y value space
68
+ var maxYRadiusPadding = containerHeight > 0 ? (maxBubbleRadius * maxYInitial) / containerHeight : 0;
69
+ var maxY = (_j = props.maxY) !== null && _j !== void 0 ? _j : maxYInitial + maxYRadiusPadding;
70
+ var yStepValue = (_k = props.yStepValue) !== null && _k !== void 0 ? _k : maxY / yNoOfSections;
71
+ var yNegativeStepValue = (_l = props.yNegativeStepValue) !== null && _l !== void 0 ? _l : yStepValue;
72
+ // Adjust mostNegativeY to account for bubble radius at the bottom of the chart
73
+ // Convert max bubble radius from screen pixels to Y value space for negative values
74
+ // Use an approximation: assume the negative quadrant height is roughly proportional to the absolute value
75
+ var mostNegativeYRadiusPadding = containerHeight > 0 && mostNegativeYInitial < 0
76
+ ? (maxBubbleRadius * Math.abs(mostNegativeYInitial)) / containerHeight
77
+ : 0;
78
+ var mostNegativeY = mostNegativeYInitial < 0
79
+ ? mostNegativeYInitial - mostNegativeYRadiusPadding
80
+ : mostNegativeYInitial;
81
+ var xRange = Math.max.apply(Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.x, 0); })), false)) - // find the largest +ve number
82
+ Math.min.apply(// find the largest +ve number
83
+ Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.x, 0); })), false)); // find the smallest +ve number
84
+ var showFractionalXAxis = (_m = props.showFractionalXAxis) !== null && _m !== void 0 ? _m : (isFinite(xRange) && xRange <= 1);
85
+ var xRoundToDigits = (_o = props.xRoundToDigits) !== null && _o !== void 0 ? _o : (showFractionalXAxis ? indexOfFirstNonZeroDigit(xRange) + 1 : 0);
86
+ var _57 = computeMaxAndMinXForBubble(data, false, // extrapolateMissingValues
87
+ xRoundToDigits, showFractionalXAxis, data), xMaxItem = _57.maxItem, xMinItem = _57.minItem;
88
+ var xNoOfSections = getNoOfSections(props.xNoOfSections, props.maxX, props.xStepValue, true);
89
+ var maxXInitial = getMaxValue(props.maxX, props.xStepValue, xNoOfSections, xMaxItem) || 10;
90
+ var minXInitial = xMinItem;
91
+ // Adjust minX and maxX to account for bubble radius on left and right sides
92
+ // Convert max bubble radius from screen pixels to X value space
93
+ // We'll need spacing and totalWidth for accurate conversion, but we can use an approximation first
94
+ // For now, we'll adjust after we have spacing calculated
95
+ var xRangeInitial = maxXInitial - minXInitial;
96
+ // const xStepHeight = props.xStepHeight ?? containerHeight / yNoOfSections
97
+ // Calculate xStepValue based on the range instead of just maxX
98
+ var xStepValue = (_p = props.xStepValue) !== null && _p !== void 0 ? _p : (xRangeInitial > 0
99
+ ? xRangeInitial / xNoOfSections
100
+ : maxXInitial / xNoOfSections);
101
+ var initialSpacing = (_q = props.initialSpacing) !== null && _q !== void 0 ? _q : BubbleDefaults.initialSpacing;
102
+ var endSpacing = (_r = props.endSpacing) !== null && _r !== void 0 ? _r : BubbleDefaults.endSpacing;
103
+ // Calculate initial spacing estimate for radius conversion
104
+ // We'll refine this after adjusting minX/maxX
105
+ var estimatedSpacing = (_s = props.spacing) !== null && _s !== void 0 ? _s : (props.width
106
+ ? (props.width - initialSpacing - endSpacing) / xNoOfSections
107
+ : BubbleDefaults.spacing);
108
+ // Adjust minX and maxX to account for bubble radius on left and right sides
109
+ // Convert max bubble radius from screen pixels to X value space
110
+ var estimatedXRange = maxXInitial - minXInitial;
111
+ // Calculate scale: pixels per unit in data space
112
+ // estimatedSpacing is pixels per section, so scale = (pixels/section) / (dataUnits/section)
113
+ var estimatedXScale = estimatedXRange > 0 && estimatedSpacing > 0
114
+ ? (estimatedSpacing * xNoOfSections) / estimatedXRange
115
+ : 1;
116
+ var maxXRadiusPadding = estimatedXScale > 0 ? maxBubbleRadius / estimatedXScale : 0;
117
+ var minXRadiusPadding = estimatedXScale > 0 ? maxBubbleRadius / estimatedXScale : 0;
118
+ var minX = minXInitial - minXRadiusPadding;
119
+ var maxX = (_t = props.maxX) !== null && _t !== void 0 ? _t : maxXInitial + maxXRadiusPadding;
120
+ var xRangeAdjusted = maxX - minX;
121
+ // Recalculate xStepValue based on adjusted range
122
+ var xStepValueAdjusted = (_u = props.xStepValue) !== null && _u !== void 0 ? _u : (xRangeAdjusted > 0 ? xRangeAdjusted / xNoOfSections : xStepValue);
123
+ var xAxisLabelTexts = (_v = props.xAxisLabelTexts) !== null && _v !== void 0 ? _v : Array.from({ length: xNoOfSections + 1 }, function (_, i) {
124
+ if (i === 0 && initialSpacing === 0)
125
+ return '';
126
+ var labelText = (minX + xStepValueAdjusted * i)
127
+ .toFixed(xRoundToDigits)
128
+ .toString();
129
+ if (formatXLabel) {
130
+ return formatXLabel(labelText);
131
+ }
132
+ return labelText;
133
+ });
134
+ var noOfSectionsBelowXAxis = (_w = props.noOfSectionsBelowXAxis) !== null && _w !== void 0 ? _w : Math.round(Math.ceil(-mostNegativeY / yNegativeStepValue));
135
+ var labelsExtraHeight = (_x = props.labelsExtraHeight) !== null && _x !== void 0 ? _x : 0;
136
+ var yAxisLabelWidth = (_y = props.yAxisLabelWidth) !== null && _y !== void 0 ? _y : (props.hideYAxisText
51
137
  ? AxesAndRulesDefaults.yAxisEmptyLabelWidth
52
138
  : AxesAndRulesDefaults.yAxisLabelWidth);
53
139
  var horizontal = false;
54
140
  var yAxisAtTop = false;
55
- var initialSpacing = (_m = props.initialSpacing) !== null && _m !== void 0 ? _m : LineDefaults.initialSpacing;
56
- var xAxisThickness = (_o = props.xAxisThickness) !== null && _o !== void 0 ? _o : AxesAndRulesDefaults.xAxisThickness;
57
- var spacing = (_p = props.spacing) !== null && _p !== void 0 ? _p : LineDefaults.spacing;
58
- var cumulativeSpacing = [];
59
- var spacingSum = 0;
60
- var space = (_q = props.spacing) !== null && _q !== void 0 ? _q : spacing;
61
- data.forEach(function (item) {
62
- var _a;
63
- spacingSum += (_a = item.spacing) !== null && _a !== void 0 ? _a : space;
64
- cumulativeSpacing.push(spacingSum);
65
- });
66
- var totalWidth = initialSpacing +
67
- spacing * (data.length - 1) +
68
- ((_r = props.endSpacing) !== null && _r !== void 0 ? _r : LineDefaults.endSpacing);
69
- var endSpacing = (_s = props.endSpacing) !== null && _s !== void 0 ? _s : LineDefaults.endSpacing;
70
- var disableScroll = (_t = props.disableScroll) !== null && _t !== void 0 ? _t : false;
71
- var showScrollIndicator = (_u = props.showScrollIndicator) !== null && _u !== void 0 ? _u : false;
72
- var scrollToEnd = (_v = props.scrollToEnd) !== null && _v !== void 0 ? _v : false;
73
- var scrollAnimation = (_w = props.scrollAnimation) !== null && _w !== void 0 ? _w : false;
74
- var scrollEventThrottle = (_x = props.scrollEventThrottle) !== null && _x !== void 0 ? _x : 16;
75
- var focusEnabled = (_y = props.focusEnabled) !== null && _y !== void 0 ? _y : LineDefaults.focusEnabled;
76
- var showDataPointOnFocus = (_z = props.showDataPointOnFocus) !== null && _z !== void 0 ? _z : LineDefaults.showDataPointOnFocus;
77
- var _39 = __read(useState((_0 = props.focusedDataPointIndex) !== null && _0 !== void 0 ? _0 : -1), 2), selectedIndex = _39[0], setSelectedIndex = _39[1];
78
- var _40 = __read(useState(''), 2), points = _40[0], setPoints = _40[1];
79
- var _41 = __read(useState(-1), 2), pointerIndex = _41[0], setPointerIndex = _41[1];
80
- var _42 = __read(useState(0), 2), pointerX = _42[0], setPointerX = _42[1];
81
- var _43 = __read(useState(0), 2), pointerY = _43[0], setPointerY = _43[1];
82
- var isAnimated = (_1 = props.isAnimated) !== null && _1 !== void 0 ? _1 : false;
141
+ var xAxisThickness = (_z = props.xAxisThickness) !== null && _z !== void 0 ? _z : AxesAndRulesDefaults.xAxisThickness;
142
+ var spacing = (_0 = props.spacing) !== null && _0 !== void 0 ? _0 : (props.width
143
+ ? (props.width - initialSpacing - endSpacing) /
144
+ (xAxisLabelTexts.length - 1)
145
+ : BubbleDefaults.spacing);
146
+ var totalWidth = initialSpacing + spacing * (xAxisLabelTexts.length - 1) + endSpacing;
147
+ var disableScroll = (_1 = props.disableScroll) !== null && _1 !== void 0 ? _1 : false;
148
+ var showScrollIndicator = (_2 = props.showScrollIndicator) !== null && _2 !== void 0 ? _2 : false;
149
+ var scrollToEnd = (_3 = props.scrollToEnd) !== null && _3 !== void 0 ? _3 : false;
150
+ var scrollAnimation = (_4 = props.scrollAnimation) !== null && _4 !== void 0 ? _4 : false;
151
+ var scrollEventThrottle = (_5 = props.scrollEventThrottle) !== null && _5 !== void 0 ? _5 : 16;
152
+ var focusEnabled = (_6 = props.focusEnabled) !== null && _6 !== void 0 ? _6 : LineDefaults.focusEnabled;
153
+ var showBubbleOnFocus = (_7 = props.showBubbleOnFocus) !== null && _7 !== void 0 ? _7 : BubbleDefaults.showBubbleOnFocus;
154
+ var _58 = __read(useState((_8 = props.focusedBubbleIndex) !== null && _8 !== void 0 ? _8 : -1), 2), selectedIndex = _58[0], setSelectedIndex = _58[1];
155
+ var _59 = __read(useState(''), 2), points = _59[0], setPoints = _59[1];
156
+ var _60 = __read(useState(-1), 2), pointerIndex = _60[0], setPointerIndex = _60[1];
157
+ var _61 = __read(useState(0), 2), pointerX = _61[0], setPointerX = _61[1];
158
+ var _62 = __read(useState(0), 2), pointerY = _62[0], setPointerY = _62[1];
159
+ var isAnimated = (_9 = props.isAnimated) !== null && _9 !== void 0 ? _9 : false;
83
160
  var horizontalRulesStyle = props.horizontalRulesStyle;
84
- var yAxisOffset = (_2 = props.yAxisOffset) !== null && _2 !== void 0 ? _2 : 0;
85
- var showXAxisIndices = (_3 = props.showXAxisIndices) !== null && _3 !== void 0 ? _3 : AxesAndRulesDefaults.showXAxisIndices;
86
- var xAxisIndicesHeight = (_4 = props.xAxisIndicesHeight) !== null && _4 !== void 0 ? _4 : AxesAndRulesDefaults.xAxisIndicesHeight;
87
- var xAxisIndicesWidth = (_5 = props.xAxisIndicesWidth) !== null && _5 !== void 0 ? _5 : AxesAndRulesDefaults.xAxisIndicesWidth;
88
- var xAxisIndicesColor = (_6 = props.xAxisIndicesColor) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.xAxisIndicesColor;
161
+ var yAxisOffset = (_10 = props.yAxisOffset) !== null && _10 !== void 0 ? _10 : 0;
162
+ var showXAxisIndices = (_11 = props.showXAxisIndices) !== null && _11 !== void 0 ? _11 : AxesAndRulesDefaults.showXAxisIndices;
163
+ var xAxisIndicesHeight = (_12 = props.xAxisIndicesHeight) !== null && _12 !== void 0 ? _12 : AxesAndRulesDefaults.xAxisIndicesHeight;
164
+ var xAxisIndicesWidth = (_13 = props.xAxisIndicesWidth) !== null && _13 !== void 0 ? _13 : AxesAndRulesDefaults.xAxisIndicesWidth;
165
+ var xAxisIndicesColor = (_14 = props.xAxisIndicesColor) !== null && _14 !== void 0 ? _14 : AxesAndRulesDefaults.xAxisIndicesColor;
89
166
  // const pointerConfig = props.pointerConfig
90
- var getPointerProps = (_7 = props.getPointerProps) !== null && _7 !== void 0 ? _7 : null;
91
- var dataPointsRadius = (_8 = props.dataPointsRadius) !== null && _8 !== void 0 ? _8 : LineDefaults.dataPointsRadius;
92
- var dataPointsWidth = (_9 = props.dataPointsWidth) !== null && _9 !== void 0 ? _9 : LineDefaults.dataPointsWidth;
93
- var extraWidthDueToDataPoint = props.hideDataPoints
167
+ var getPointerProps = (_15 = props.getPointerProps) !== null && _15 !== void 0 ? _15 : null;
168
+ var bubblesWidth = (_16 = props.bubblesWidth) !== null && _16 !== void 0 ? _16 : BubbleDefaults.bubblesWidth;
169
+ var extraWidthDueToBubble = props.hideBubbles
94
170
  ? 0
95
- : dataPointsRadius !== null && dataPointsRadius !== void 0 ? dataPointsRadius : dataPointsWidth;
96
- var xAxisLabelsAtBottom = (_10 = props.xAxisLabelsAtBottom) !== null && _10 !== void 0 ? _10 : false;
97
- var allowFontScaling = (_11 = props.allowFontScaling) !== null && _11 !== void 0 ? _11 : AxesAndRulesDefaults.allowFontScaling;
98
- var animationDuration = (_12 = props.animationDuration) !== null && _12 !== void 0 ? _12 : LineDefaults.animationDuration;
99
- var negativeStepValue = (_13 = props.negativeStepValue) !== null && _13 !== void 0 ? _13 : stepValue;
100
- var secondaryMaxValue = maxValue;
101
- var secondaryMinItem = maxValue * -1;
171
+ : bubblesRadius !== null && bubblesRadius !== void 0 ? bubblesRadius : bubblesWidth;
172
+ var xAxisLabelsAtBottom = (_17 = props.xAxisLabelsAtBottom) !== null && _17 !== void 0 ? _17 : false;
173
+ var allowFontScaling = (_18 = props.allowFontScaling) !== null && _18 !== void 0 ? _18 : AxesAndRulesDefaults.allowFontScaling;
174
+ var animationDuration = (_19 = props.animationDuration) !== null && _19 !== void 0 ? _19 : LineDefaults.animationDuration;
175
+ var secondaryMaxValue = maxY;
176
+ var secondaryMinItem = maxY * -1;
102
177
  var showSecondaryFractionalValues = false;
103
178
  var secondaryRoundToDigits = 1;
104
- var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
105
- var fourthQuadrantHeight = noOfSectionsBelowXAxis * stepHeight;
179
+ var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, yStepHeight, yStepValue, yNoOfSections, roundToDigits, yNegativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
180
+ var fourthQuadrantHeight = noOfSectionsBelowXAxis * yStepHeight;
106
181
  var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
107
182
  var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
108
- var mostNegativeValueOnYAxis = negativeStepValue * noOfSectionsBelowXAxis;
109
- var containsNegativeValue = ((_14 = props.mostNegativeValue) !== null && _14 !== void 0 ? _14 : 0) < 0 ||
110
- ((_15 = props.data) === null || _15 === void 0 ? void 0 : _15.some(function (item) { var _a; return ((_a = item.y) !== null && _a !== void 0 ? _a : 0) < 0; }));
111
- var getX = function (spacingArray, index) {
112
- var _a, _b;
113
- return (_b = (_a = props.data) === null || _a === void 0 ? void 0 : _a[index].x) !== null && _b !== void 0 ? _b : initialSpacing + (index ? spacingArray[index - 1] : 0);
183
+ var mostNegativeValueOnYAxis = yNegativeStepValue * noOfSectionsBelowXAxis;
184
+ var containsNegativeValue = ((_20 = props.mostNegativeY) !== null && _20 !== void 0 ? _20 : 0) < 0 ||
185
+ ((_21 = props.data) === null || _21 === void 0 ? void 0 : _21.some(function (item) { var _a; return ((_a = item.y) !== null && _a !== void 0 ? _a : 0) < 0; }));
186
+ // Use adjusted xStepValue for scale calculation
187
+ var xScale = spacing / xStepValueAdjusted;
188
+ var getX = function (index) {
189
+ var _a, _b, _c, _d, _e, _f, _g;
190
+ var val = ((_a = props.data) === null || _a === void 0 ? void 0 : _a[index].x) !== undefined
191
+ ? (((_c = (_b = props.data) === null || _b === void 0 ? void 0 : _b[index].x) !== null && _c !== void 0 ? _c : 0) - minX) * xScale // redundant ?? just to avoid lint highlighting
192
+ : Math.min(totalWidth -
193
+ ((_e = (_d = props.data) === null || _d === void 0 ? void 0 : _d[index].r) !== null && _e !== void 0 ? _e : BubbleDefaults.bubblesRadius), ((index + 1) * totalWidth) / ((_g = (_f = props.data) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 1));
194
+ return val + initialSpacing;
114
195
  };
115
196
  var getY = function (value) {
116
- if (containsNegativeValue && value < 0 && stepValue !== negativeStepValue) {
197
+ if (containsNegativeValue &&
198
+ value < 0 &&
199
+ yStepValue !== yNegativeStepValue) {
117
200
  return (extendedContainerHeight +
118
201
  (value * fourthQuadrantHeight) / mostNegativeValueOnYAxis);
119
202
  }
120
- return extendedContainerHeight - (value * containerHeight) / maxValue;
203
+ return extendedContainerHeight - (value * containerHeight) / maxY;
121
204
  };
122
- var showTextOnFocus = (_16 = props.showTextOnFocus) !== null && _16 !== void 0 ? _16 : LineDefaults.showTextOnFocus;
123
- var showDataPointLabelOnFocus = (_17 = props.showDataPointLabelOnFocus) !== null && _17 !== void 0 ? _17 : LineDefaults.showDataPointLabelOnFocus;
124
- var focusTogether = (_18 = props.focusTogether) !== null && _18 !== void 0 ? _18 : true;
125
- var _44 = __read(useState(-1), 2), selectedLineNumber = _44[0], setSelectedLineNumber = _44[1];
205
+ var showTextOnFocus = (_22 = props.showTextOnFocus) !== null && _22 !== void 0 ? _22 : LineDefaults.showTextOnFocus;
206
+ var showBubbleLabelOnFocus = (_23 = props.showBubbleLabelOnFocus) !== null && _23 !== void 0 ? _23 : BubbleDefaults.showBubbleLabelOnFocus;
207
+ var focusTogether = (_24 = props.focusTogether) !== null && _24 !== void 0 ? _24 : true;
208
+ var _63 = __read(useState(-1), 2), selectedLineNumber = _63[0], setSelectedLineNumber = _63[1];
126
209
  var lastLineNumber = 1;
127
- // if (props.secondaryData) {
128
- // lastLineNumber = 6667 // lastLineNumber is 6667 for a secondary line, so the index or key of the secondary line is 6666
129
- // }
130
- // if (props.data2) lastLineNumber = 2
131
- // if (props.data3) lastLineNumber = 3
132
- // if (props.data4) lastLineNumber = 4
133
- // if (props.data5) lastLineNumber = 5
134
- // if ((props.dataSet?.length ?? 0) > lastLineNumber)
135
- // lastLineNumber = props.dataSet?.length ?? 0
136
- var unFocusOnPressOut = (_19 = props.unFocusOnPressOut) !== null && _19 !== void 0 ? _19 : LineDefaults.unFocusOnPressOut;
137
- var delayBeforeUnFocus = (_20 = props.delayBeforeUnFocus) !== null && _20 !== void 0 ? _20 : LineDefaults.delayBeforeUnFocus;
210
+ var unFocusOnPressOut = (_25 = props.unFocusOnPressOut) !== null && _25 !== void 0 ? _25 : LineDefaults.unFocusOnPressOut;
211
+ var delayBeforeUnFocus = (_26 = props.delayBeforeUnFocus) !== null && _26 !== void 0 ? _26 : LineDefaults.delayBeforeUnFocus;
138
212
  var handleFocus = function (index) {
139
213
  setSelectedIndex(index);
140
214
  };
@@ -143,29 +217,94 @@ export var useBubbleChart = function (props) {
143
217
  setTimeout(function () { return setSelectedIndex(-1); }, delayBeforeUnFocus);
144
218
  }
145
219
  };
146
- var hideDataPoints = (_21 = props.hideDataPoints) !== null && _21 !== void 0 ? _21 : false;
147
- var dataPointsShape = (_22 = props.dataPointsShape) !== null && _22 !== void 0 ? _22 : LineDefaults.dataPointsShape;
148
- var dataPointsHeight = (_23 = props.dataPointsHeight) !== null && _23 !== void 0 ? _23 : LineDefaults.dataPointsHeight;
149
- var dataPointsColor = (_24 = props.dataPointsColor) !== null && _24 !== void 0 ? _24 : BubbleDefaults.dataPointsColor;
150
- var textFontSize = (_25 = props.textFontSize) !== null && _25 !== void 0 ? _25 : LineDefaults.textFontSize;
151
- var textColor = (_26 = props.textColor) !== null && _26 !== void 0 ? _26 : LineDefaults.textColor;
220
+ var hideBubbles = (_27 = props.hideBubbles) !== null && _27 !== void 0 ? _27 : false;
221
+ var bubblesShape = (_28 = props.bubblesShape) !== null && _28 !== void 0 ? _28 : BubbleDefaults.bubblesShape;
222
+ var bubblesHeight = (_29 = props.bubblesHeight) !== null && _29 !== void 0 ? _29 : BubbleDefaults.bubblesHeight;
223
+ var bubblesColor = (_30 = props.bubblesColor) !== null && _30 !== void 0 ? _30 : BubbleDefaults.bubblesColor;
152
224
  var startIndex = 0;
153
- var endIndex = (_28 = (_27 = props.data) === null || _27 === void 0 ? void 0 : _27.length) !== null && _28 !== void 0 ? _28 : 0;
154
- var showValuesAsDataPointsText = (_29 = props.showValuesAsDataPointsText) !== null && _29 !== void 0 ? _29 : LineDefaults.showValuesAsDataPointsText;
155
- var xAxisLabelsVerticalShift = (_30 = props.xAxisLabelsVerticalShift) !== null && _30 !== void 0 ? _30 : (xAxisLabelsAtBottom
225
+ var endIndex = (_32 = (_31 = props.data) === null || _31 === void 0 ? void 0 : _31.length) !== null && _32 !== void 0 ? _32 : 0;
226
+ var labelFontSize = (_33 = props.labelFontSize) !== null && _33 !== void 0 ? _33 : BubbleDefaults.labelFontSize;
227
+ var showValuesAsBubbleLabels = (_34 = props.showValuesAsBubbleLabels) !== null && _34 !== void 0 ? _34 : BubbleDefaults.showValuesAsBubbleLabels;
228
+ var xAxisLabelsVerticalShift = (_35 = props.xAxisLabelsVerticalShift) !== null && _35 !== void 0 ? _35 : (xAxisLabelsAtBottom
156
229
  ? fourthQuadrantHeight
157
230
  : AxesAndRulesDefaults.xAxisLabelsVerticalShift);
158
- var xAxisTextNumberOfLines = (_31 = props.xAxisTextNumberOfLines) !== null && _31 !== void 0 ? _31 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
159
- var rotateLabel = (_32 = props.rotateLabel) !== null && _32 !== void 0 ? _32 : false;
160
- var borderWidth = (_33 = props.borderWidth) !== null && _33 !== void 0 ? _33 : BubbleDefaults.borderWidth;
161
- var borderColor = (_34 = props.borderColor) !== null && _34 !== void 0 ? _34 : BubbleDefaults.borderColor;
162
- var opacity = (_35 = props.opacity) !== null && _35 !== void 0 ? _35 : BubbleDefaults.opacity;
231
+ var xAxisTextNumberOfLines = (_36 = props.xAxisTextNumberOfLines) !== null && _36 !== void 0 ? _36 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
232
+ var rotateLabel = (_37 = props.rotateLabel) !== null && _37 !== void 0 ? _37 : false;
233
+ var borderWidth = (_38 = props.borderWidth) !== null && _38 !== void 0 ? _38 : BubbleDefaults.borderWidth;
234
+ var borderColor = (_39 = props.borderColor) !== null && _39 !== void 0 ? _39 : BubbleDefaults.borderColor;
235
+ var opacity = (_40 = props.opacity) !== null && _40 !== void 0 ? _40 : BubbleDefaults.opacity;
236
+ var showRegressionLine = (_41 = props.showRegressionLine) !== null && _41 !== void 0 ? _41 : false;
237
+ var weightedRegression = function () {
238
+ var e_1, _a;
239
+ if (!data)
240
+ return { slope: 0, intercept: 0 };
241
+ var sumW = 0;
242
+ var sumWX = 0;
243
+ var sumWY = 0;
244
+ var sumWXX = 0;
245
+ var sumWXY = 0;
246
+ var i = -1;
247
+ try {
248
+ for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
249
+ var _b = data_1_1.value, y = _b.y, _c = _b.r, r = _c === void 0 ? 1 : _c;
250
+ ++i;
251
+ var w = r * r;
252
+ if (w <= 0)
253
+ continue; // ignore zero/negative weights
254
+ var x = getX(i);
255
+ sumW += w;
256
+ sumWX += w * x;
257
+ sumWY += w * y;
258
+ sumWXX += w * x * x;
259
+ sumWXY += w * x * y;
260
+ }
261
+ }
262
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
263
+ finally {
264
+ try {
265
+ if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
266
+ }
267
+ finally { if (e_1) throw e_1.error; }
268
+ }
269
+ var denominator = sumW * sumWXX - sumWX * sumWX;
270
+ if (denominator === 0) {
271
+ throw new Error('Regression not defined (degenerate data)');
272
+ }
273
+ var slope = (sumW * sumWXY - sumWX * sumWY) / denominator;
274
+ var intercept = (sumWY - slope * sumWX) / sumW;
275
+ return { slope: slope, intercept: intercept };
276
+ };
277
+ var regressionLineX1 = 0, regressionLineY1 = 0, regressionLineX2 = 0, regressionLineY2 = 0;
278
+ if (showRegressionLine) {
279
+ var slope = 0, intercept = 0;
280
+ var slopeIntercept = weightedRegression();
281
+ slope = slopeIntercept.slope;
282
+ intercept = slopeIntercept.intercept;
283
+ // Calculate Y values in data space first
284
+ var y1_data = slope * minX + intercept;
285
+ var y2_data = slope * maxX + intercept;
286
+ // Convert X coordinates to screen space (matching getX formula)
287
+ regressionLineX1 = initialSpacing;
288
+ regressionLineX2 = (maxX - minX) * xScale + initialSpacing;
289
+ // Convert Y coordinates to screen space using getY function
290
+ regressionLineY1 = getY(y1_data);
291
+ regressionLineY2 = getY(y2_data);
292
+ }
293
+ var regressionLineConfig = {
294
+ thickness: (_43 = (_42 = props.regressionLineConfig) === null || _42 === void 0 ? void 0 : _42.thickness) !== null && _43 !== void 0 ? _43 : BubbleDefaults.regressionLineConfig.thickness,
295
+ color: (_45 = (_44 = props.regressionLineConfig) === null || _44 === void 0 ? void 0 : _44.color) !== null && _45 !== void 0 ? _45 : BubbleDefaults.regressionLineConfig.color,
296
+ opacity: (_47 = (_46 = props.regressionLineConfig) === null || _46 === void 0 ? void 0 : _46.opacity) !== null && _47 !== void 0 ? _47 : BubbleDefaults.regressionLineConfig.opacity,
297
+ strokeDashArray: (_48 = props.regressionLineConfig) === null || _48 === void 0 ? void 0 : _48.strokeDashArray,
298
+ isAnimated: (_50 = (_49 = props.regressionLineConfig) === null || _49 === void 0 ? void 0 : _49.isAnimated) !== null && _50 !== void 0 ? _50 : isAnimated,
299
+ animationDuration: (_52 = (_51 = props.regressionLineConfig) === null || _51 === void 0 ? void 0 : _51.animationDuration) !== null && _52 !== void 0 ? _52 : animationDuration
300
+ };
301
+ var scatterChart = (_53 = props.scatterChart) !== null && _53 !== void 0 ? _53 : BubbleDefaults.scatterChart;
163
302
  var barAndLineChartsWrapperProps = {
164
303
  chartType: chartTypes.BUBBLE,
165
304
  containerHeight: containerHeight,
166
305
  noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
167
- stepHeight: stepHeight,
168
- negativeStepHeight: stepHeight,
306
+ stepHeight: yStepHeight,
307
+ negativeStepHeight: yStepHeight,
169
308
  labelsExtraHeight: labelsExtraHeight,
170
309
  yAxisLabelWidth: yAxisLabelWidth,
171
310
  horizontal: horizontal,
@@ -193,7 +332,7 @@ export var useBubbleChart = function (props) {
193
332
  showLine: false,
194
333
  lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
195
334
  lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
196
- maxValue: maxValue,
335
+ maxValue: maxY,
197
336
  lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
198
337
  lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
199
338
  lineBehindBars: false,
@@ -205,9 +344,9 @@ export var useBubbleChart = function (props) {
205
344
  horizSections: horizSections,
206
345
  endSpacing: endSpacing,
207
346
  horizontalRulesStyle: horizontalRulesStyle,
208
- noOfSections: noOfSections,
209
- sectionColors: props.sectionColors,
210
- showFractionalValues: showFractionalValues,
347
+ noOfSections: yNoOfSections,
348
+ sectionColors: props.ySectionColors,
349
+ showFractionalValues: showFractionalYAxis,
211
350
  axesAndRulesProps: axesAndRulesProps,
212
351
  yAxisLabelTexts: props.yAxisLabelTexts,
213
352
  yAxisOffset: yAxisOffset,
@@ -223,9 +362,9 @@ export var useBubbleChart = function (props) {
223
362
  pointerY: pointerY,
224
363
  onEndReached: props.onEndReached,
225
364
  onStartReached: props.onStartReached,
226
- endReachedOffset: (_36 = props.endReachedOffset) !== null && _36 !== void 0 ? _36 : LineDefaults.endReachedOffset,
365
+ endReachedOffset: (_54 = props.endReachedOffset) !== null && _54 !== void 0 ? _54 : LineDefaults.endReachedOffset,
227
366
  onMomentumScrollEnd: props.onMomentumScrollEnd,
228
- extraWidthDueToDataPoint: extraWidthDueToDataPoint,
367
+ extraWidthDueToDataPoint: extraWidthDueToBubble,
229
368
  customBackground: props.customBackground,
230
369
  onlyPositive: onlyPositive,
231
370
  highlightEnabled: LineDefaults.highlightEnabled,
@@ -233,7 +372,8 @@ export var useBubbleChart = function (props) {
233
372
  xAxisLabelsAtBottom: xAxisLabelsAtBottom,
234
373
  onScrollEndDrag: props.onScrollEndDrag,
235
374
  allowFontScaling: allowFontScaling,
236
- showVerticalLines: props.showVerticalLines
375
+ showVerticalLines: props.showVerticalLines,
376
+ xAxisLabelTexts: xAxisLabelTexts
237
377
  };
238
378
  return {
239
379
  totalWidth: totalWidth,
@@ -242,7 +382,7 @@ export var useBubbleChart = function (props) {
242
382
  getY: getY,
243
383
  barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
244
384
  getX: getX,
245
- maxValue: maxValue,
385
+ maxValue: maxY,
246
386
  selectedIndex: selectedIndex,
247
387
  setSelectedIndex: setSelectedIndex,
248
388
  showTextOnFocus: showTextOnFocus,
@@ -256,20 +396,19 @@ export var useBubbleChart = function (props) {
256
396
  handleFocus: handleFocus,
257
397
  handleUnFocus: handleUnFocus,
258
398
  isAnimated: isAnimated,
259
- showDataPointOnFocus: showDataPointOnFocus,
260
- showDataPointLabelOnFocus: showDataPointLabelOnFocus,
261
- dataPointsShape: dataPointsShape,
262
- dataPointsWidth: dataPointsWidth,
263
- dataPointsHeight: dataPointsHeight,
264
- dataPointsColor: dataPointsColor,
265
- dataPointsRadius: dataPointsRadius,
266
- textColor: textColor,
267
- textFontSize: textFontSize,
399
+ showBubbleOnFocus: showBubbleOnFocus,
400
+ showBubbleLabelOnFocus: showBubbleLabelOnFocus,
401
+ bubblesShape: bubblesShape,
402
+ bubblesWidth: bubblesWidth,
403
+ bubblesHeight: bubblesHeight,
404
+ bubblesColor: bubblesColor,
405
+ bubblesRadius: bubblesRadius,
406
+ labelFontSize: labelFontSize,
407
+ labelTextStyle: props.labelTextStyle,
268
408
  startIndex: startIndex,
269
409
  endIndex: endIndex,
270
- showValuesAsDataPointsText: showValuesAsDataPointsText,
271
- cumulativeSpacing: cumulativeSpacing,
272
- hideDataPoints: hideDataPoints,
410
+ showValuesAsBubbleLabels: showValuesAsBubbleLabels,
411
+ hideBubbles: hideBubbles,
273
412
  xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
274
413
  labelsExtraHeight: labelsExtraHeight,
275
414
  xAxisThickness: xAxisThickness,
@@ -278,6 +417,14 @@ export var useBubbleChart = function (props) {
278
417
  allowFontScaling: allowFontScaling,
279
418
  borderWidth: borderWidth,
280
419
  borderColor: borderColor,
281
- opacity: opacity
420
+ opacity: opacity,
421
+ xAxisLabelTexts: xAxisLabelTexts,
422
+ showRegressionLine: showRegressionLine,
423
+ regressionLineConfig: regressionLineConfig,
424
+ regressionLineX1: regressionLineX1,
425
+ regressionLineY1: regressionLineY1,
426
+ regressionLineX2: regressionLineX2,
427
+ regressionLineY2: regressionLineY2,
428
+ scatterChart: scatterChart
282
429
  };
283
430
  };
@@ -1,7 +1,7 @@
1
- import { ColorValue, GestureResponderEvent, StyleProp, TextStyle, ViewStyle } from "react-native";
2
- import { Linecap } from "react-native-svg";
3
- import { ColorFromToY, CustomBackground, RuleType, RulesConfig, SpreadData, XAxisConfig, referenceConfigType } from "../utils/types";
4
- import { yAxisSides } from "../utils/constants";
1
+ import { ColorValue, GestureResponderEvent, StyleProp, TextStyle, ViewStyle } from 'react-native';
2
+ import { Linecap } from 'react-native-svg';
3
+ import { CustomBackground, RegressionLineConfig, RuleType, RulesConfig, SpreadData, XAxisConfig, referenceConfigType } from '../utils/types';
4
+ import { yAxisSides } from '../utils/constants';
5
5
  interface sectionType {
6
6
  value: string;
7
7
  }
@@ -10,13 +10,22 @@ export interface BubbleChartPropsType {
10
10
  height?: number;
11
11
  overflowTop?: number;
12
12
  overflowBottom?: number;
13
- noOfSections?: number;
14
- sectionColors?: ColorValue[];
15
- maxValue?: number;
16
- mostNegativeValue?: number;
17
- stepHeight?: number;
18
- stepValue?: number;
19
- negativeStepValue?: number;
13
+ yNoOfSections?: number;
14
+ ySectionColors?: ColorValue[];
15
+ maxY?: number;
16
+ mostNegativeY?: number;
17
+ yStepHeight?: number;
18
+ yStepValue?: number;
19
+ yNegativeStepValue?: number;
20
+ showFractionalYAxis?: boolean;
21
+ yRoundToDigits?: number;
22
+ xNoOfSections?: number;
23
+ maxX?: number;
24
+ mostNegativeX?: number;
25
+ xStepHeight?: number;
26
+ xStepValue?: number;
27
+ showFractionalXAxis?: boolean;
28
+ xRoundToDigits?: number;
20
29
  spacing?: number;
21
30
  initialSpacing?: number;
22
31
  endSpacing?: number;
@@ -32,7 +41,7 @@ export interface BubbleChartPropsType {
32
41
  onDataChangeAnimationDuration?: number;
33
42
  animationEasing?: any;
34
43
  animateTogether?: boolean;
35
- renderDataPointsAfterAnimationEnds?: boolean;
44
+ renderBubblesAfterAnimationEnds?: boolean;
36
45
  xAxisLength?: number;
37
46
  xAxisThickness?: number;
38
47
  xAxisColor?: ColorValue;
@@ -43,11 +52,11 @@ export interface BubbleChartPropsType {
43
52
  rulesThickness?: number;
44
53
  focusEnabled?: boolean;
45
54
  onFocus?: Function;
46
- showDataPointOnFocus?: boolean;
55
+ showBubbleOnFocus?: boolean;
47
56
  showStripOnFocus?: boolean;
48
- stripOverDataPoints?: boolean;
57
+ stripOverBubbles?: boolean;
49
58
  showTextOnFocus?: boolean;
50
- showDataPointLabelOnFocus?: boolean;
59
+ showBubbleLabelOnFocus?: boolean;
51
60
  stripHeight?: number;
52
61
  stripWidth?: number;
53
62
  stripColor?: ColorValue | string | any;
@@ -56,8 +65,8 @@ export interface BubbleChartPropsType {
56
65
  onPress?: Function;
57
66
  unFocusOnPressOut?: boolean;
58
67
  delayBeforeUnFocus?: number;
59
- focusedDataPointIndex?: number;
60
- showValuesAsDataPointsText?: boolean;
68
+ focusedBubbleIndex?: number;
69
+ showValuesAsBubbleLabels?: boolean;
61
70
  rulesType?: RuleType;
62
71
  dashWidth?: number;
63
72
  dashGap?: number;
@@ -99,10 +108,6 @@ export interface BubbleChartPropsType {
99
108
  yAxisIndicesColor?: ColorValue;
100
109
  yAxisSide?: yAxisSides;
101
110
  yAxisOffset?: number;
102
- startIndex?: number;
103
- endIndex?: number;
104
- color?: string;
105
- colors?: ColorFromToY[];
106
111
  yAxisThickness?: number;
107
112
  yAxisColor?: ColorValue;
108
113
  yAxisExtraHeight?: number;
@@ -112,8 +117,6 @@ export interface BubbleChartPropsType {
112
117
  yAxisTextStyle?: StyleProp<TextStyle>;
113
118
  yAxisTextNumberOfLines?: number;
114
119
  xAxisTextNumberOfLines?: number;
115
- showFractionalValues?: boolean;
116
- roundToDigits?: number;
117
120
  yAxisLabelWidth?: number;
118
121
  hideYAxisText?: boolean;
119
122
  floatingYAxisLabels?: boolean;
@@ -123,34 +126,23 @@ export interface BubbleChartPropsType {
123
126
  horizSections?: sectionType[];
124
127
  focusTogether?: boolean;
125
128
  focusProximity?: number;
126
- hideDataPoints?: boolean;
127
- dataPointsHeight?: number;
128
- dataPointsWidth?: number;
129
- dataPointsRadius?: number;
130
- dataPointsColor?: string;
131
- dataPointsShape?: string;
132
- customDataPoint?: Function;
133
- focusedDataPointShape?: string;
134
- focusedDataPointWidth?: number;
135
- focusedDataPointHeight?: number;
136
- focusedDataPointColor?: ColorValue | string | any;
137
- focusedDataPointRadius?: number;
138
- focusedCustomDataPoint?: Function;
139
- dataPointLabelWidth?: number;
140
- dataPointLabelShiftX?: number;
141
- dataPointLabelShiftY?: number;
142
- startFillColor?: string;
143
- endFillColor?: string;
144
- startOpacity?: number;
145
- endOpacity?: number;
129
+ hideBubbles?: boolean;
130
+ bubblesHeight?: number;
131
+ bubblesWidth?: number;
132
+ bubblesRadius?: number;
133
+ bubblesColor?: string;
134
+ bubblesShape?: string;
135
+ customBubble?: Function;
136
+ focusedBubbleShape?: string;
137
+ focusedBubbleWidth?: number;
138
+ focusedBubbleHeight?: number;
139
+ focusedBubbleColor?: ColorValue | string | any;
140
+ focusedBubbleRadius?: number;
141
+ focusedCustomBubble?: Function;
146
142
  gradientDirection?: string;
147
143
  areaGradientComponent?: () => any;
148
144
  areaGradientId?: string;
149
- textFontSize?: number;
150
- textColor?: string;
151
145
  hideOrigin?: boolean;
152
- textShiftX?: number;
153
- textShiftY?: number;
154
146
  yAxisLabelTexts?: string[];
155
147
  xAxisLabelTexts?: string[];
156
148
  xAxisLabelTextStyle?: StyleProp<TextStyle>;
@@ -170,6 +162,8 @@ export interface BubbleChartPropsType {
170
162
  adjustToWidth?: boolean;
171
163
  getPointerProps?: Function;
172
164
  formatYLabel?: (label: string) => string;
165
+ formatXLabel?: (label: string) => string;
166
+ formatBubbleLabel?: (label: string) => string;
173
167
  lineGradient?: boolean;
174
168
  lineGradientComponent?: () => any;
175
169
  lineGradientId?: string;
@@ -184,7 +178,7 @@ export interface BubbleChartPropsType {
184
178
  bounces?: boolean;
185
179
  overScrollMode?: 'auto' | 'always' | 'never';
186
180
  onScrollEndDrag?: (event: any, direction: any) => void;
187
- showDataPointsForMissingValues?: boolean;
181
+ showBubblesForMissingValues?: boolean;
188
182
  interpolateMissingValues?: boolean;
189
183
  extrapolateMissingValues?: boolean;
190
184
  onlyPositive?: boolean;
@@ -194,55 +188,61 @@ export interface BubbleChartPropsType {
194
188
  secondaryXAxis?: XAxisConfig;
195
189
  renderTooltip?: Function;
196
190
  renderTooltipSecondary?: Function;
197
- dataPointLabelComponent?: Function;
198
- focusedDataPointLabelComponent?: Function;
191
+ labelWidth?: number;
192
+ labelHeight?: number;
193
+ labelFontSize?: number;
194
+ labelShiftX?: number;
195
+ labelShiftY?: number;
196
+ labelComponent?: Function;
197
+ labelTextStyle?: Object;
198
+ focusedLabelComponent?: Function;
199
199
  spreadAreaData?: SpreadData[];
200
200
  spreadAreaColor?: ColorValue;
201
201
  spreadAreaOpacity?: number;
202
202
  borderWidth?: number;
203
203
  borderColor?: ColorValue;
204
+ borderOpacity?: number;
205
+ showRegressionLine?: boolean;
206
+ regressionLineConfig?: RegressionLineConfig;
207
+ scatterChart?: boolean;
204
208
  }
205
209
  export interface bubbleDataItem {
206
210
  y: number;
207
211
  label?: string;
212
+ labelWidth?: number;
213
+ labelHeight?: number;
214
+ labelFontSize?: number;
208
215
  labelComponent?: Function;
209
- labelTextStyle?: StyleProp<TextStyle>;
216
+ labelTextStyle?: Object;
217
+ labelShiftX?: number;
218
+ labelShiftY?: number;
210
219
  secondaryLabel?: string;
211
220
  secondaryLabelComponent?: Function;
212
221
  secondaryLabelTextStyle?: StyleProp<TextStyle>;
213
- dataPointText?: string;
214
- textShiftX?: number;
215
- textShiftY?: number;
216
- textColor?: string;
217
- textFontSize?: number;
218
222
  spacing?: number;
219
- hideDataPoint?: boolean;
220
- dataPointHeight?: number;
221
- dataPointWidth?: number;
223
+ hideBubble?: boolean;
224
+ bubbleHeight?: number;
225
+ bubbleWidth?: number;
222
226
  r?: number;
223
- dataPointColor?: string;
224
- dataPointShape?: string;
225
- customDataPoint?: Function;
227
+ bubbleColor?: string;
228
+ bubbleShape?: string;
229
+ customBubble?: Function;
226
230
  stripHeight?: number;
227
231
  stripWidth?: number;
228
232
  stripColor?: ColorValue | string | any;
229
233
  stripOpacity?: number;
230
234
  stripStrokeDashArray?: number[];
231
- focusedDataPointShape?: string;
232
- focusedDataPointWidth?: number;
233
- focusedDataPointHeight?: number;
234
- focusedDataPointColor?: ColorValue | string | any;
235
- focusedDataPointRadius?: number;
236
- focusedCustomDataPoint?: Function;
237
- dataPointLabelComponent?: Function;
238
- focusedDataPointLabelComponent?: Function;
239
- dataPointLabelWidth?: number;
240
- dataPointLabelShiftX?: number;
241
- dataPointLabelShiftY?: number;
235
+ focusedBubbleShape?: string;
236
+ focusedBubbleWidth?: number;
237
+ focusedBubbleHeight?: number;
238
+ focusedBubbleColor?: ColorValue | string | any;
239
+ focusedBubbleRadius?: number;
240
+ focusedCustomBubble?: Function;
241
+ focusedLabelComponent?: Function;
242
242
  showStrip?: boolean;
243
243
  showVerticalLine?: boolean;
244
244
  verticalLineHeight?: number;
245
- verticalLineUptoDataPoint?: boolean;
245
+ verticalLineUptoBubble?: boolean;
246
246
  verticalLineColor?: ColorValue;
247
247
  verticalLineThickness?: number;
248
248
  verticalLineStrokeDashArray?: number[];
@@ -261,6 +261,7 @@ export interface bubbleDataItem {
261
261
  x?: number;
262
262
  borderWidth?: number;
263
263
  borderColor?: ColorValue;
264
+ borderOpacity?: number;
264
265
  opacity?: number;
265
266
  }
266
267
  export {};
@@ -39,7 +39,7 @@ import { AxesAndRulesDefaults, BarDefaults, chartTypes } from '../../utils/const
39
39
  import { computeMaxAndMinItems } from '../../utils';
40
40
  export var useBarAndLineChartsWrapper = function (props) {
41
41
  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;
42
- var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex, onlyPositive = props.onlyPositive, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity, xAxisLabelsAtBottom = props.xAxisLabelsAtBottom, floatingYAxisLabels = props.floatingYAxisLabels, allowFontScaling = props.allowFontScaling;
42
+ var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, sectionColors = props.sectionColors, stepHeight = props.stepHeight, negativeStepHeight = props.negativeStepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, rtl = props.rtl, shiftX = props.shiftX, shiftY = props.shiftY, initialSpacing = props.initialSpacing, data = props.data, dataSet = props.dataSet, stackData = props.stackData, secondaryData = props.secondaryData, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, spacing = props.spacing, lineConfig = props.lineConfig, lineConfig2 = props.lineConfig2, maxValue = props.maxValue, lineData = props.lineData, lineData2 = props.lineData2, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, points2 = props.points2, arrowPoints = props.arrowPoints, width = props.width, horizSections = props.horizSections, endSpacing = props.endSpacing, horizontalRulesStyle = props.horizontalRulesStyle, noOfSections = props.noOfSections, showFractionalValues = props.showFractionalValues, axesAndRulesProps = props.axesAndRulesProps, yAxisLabelTexts = props.yAxisLabelTexts, yAxisOffset = props.yAxisOffset, rotateYAxisTexts = props.rotateYAxisTexts, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, scrollEventThrottle = props.scrollEventThrottle, endReachedOffset = props.endReachedOffset, isRTL = props.isRTL, selectedIndex = props.selectedIndex, onlyPositive = props.onlyPositive, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity, xAxisLabelsAtBottom = props.xAxisLabelsAtBottom, floatingYAxisLabels = props.floatingYAxisLabels, allowFontScaling = props.allowFontScaling, xAxisLabelTexts = props.xAxisLabelTexts;
43
43
  var _22 = (_a = axesAndRulesProps.secondaryYAxisConfig) !== null && _a !== void 0 ? _a : {}, secondaryStepValue = _22.stepValue, secondaryNegativeStepValue = _22.negativeStepValue, secondaryNoOfSectionsBelowXAxis = _22.noOfSectionsBelowXAxis, showSecondaryFractionalValues = _22.showFractionalValues, secondaryRoundToDigits = _22.roundToDigits, secondaryStepHeight = _22.stepHeight, secondaryNegativeStepHeight = _22.negativeStepHeight;
44
44
  var primaryYAxisHeightBelowOrigin = noOfSectionsBelowXAxis * negativeStepHeight;
45
45
  var secondaryYAxisHeightBelowOrigin = secondaryNoOfSectionsBelowXAxis * secondaryNegativeStepHeight;
@@ -98,7 +98,9 @@ export var useBarAndLineChartsWrapper = function (props) {
98
98
  var noOfVerticalLines = axesAndRulesProps.noOfVerticalLines;
99
99
  var secondaryXAxis = axesAndRulesProps.secondaryXAxis;
100
100
  var verticalLinesAr = noOfVerticalLines
101
- ? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : (stackData !== null && stackData !== void 0 ? stackData : data).map(function (item) {
101
+ ? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : (chartType === chartTypes.BUBBLE
102
+ ? xAxisLabelTexts !== null && xAxisLabelTexts !== void 0 ? xAxisLabelTexts : []
103
+ : stackData !== null && stackData !== void 0 ? stackData : data).map(function (item) {
102
104
  var showVerticalLine = item.showVerticalLine, verticalLineThickness = item.verticalLineThickness, verticalLineHeight = item.verticalLineHeight, verticalLineColor = item.verticalLineColor, verticalLineStrokeDashArray = item.verticalLineStrokeDashArray, verticalLineShift = item.verticalLineShift, verticalLineZIndex = item.verticalLineZIndex, verticalLineSpacing = item.verticalLineSpacing, verticalLineStrokeLinecap = item.verticalLineStrokeLinecap;
103
105
  return {
104
106
  showVerticalLine: showVerticalLine,
package/dist/index.d.ts CHANGED
@@ -46,5 +46,5 @@ export { type StripAndLabelProps } from './components/common/types';
46
46
  /********************************* common utils, constants and types ********************************
47
47
  /***********************************************************************************************************************/
48
48
  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';
49
- 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';
49
+ export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, BubbleDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
50
50
  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, type ColorFromToY } from './utils/types';
package/dist/index.js CHANGED
@@ -39,5 +39,5 @@ export { getTopAndLeftForStripAndLabel } from './components/common/StripAndLabel
39
39
  /********************************* common utils, constants and types ********************************
40
40
  /***********************************************************************************************************************/
41
41
  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';
42
- 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';
42
+ export { chartTypes, yAxisSides, loc, SEGMENT_START, SEGMENT_END, RANGE_ENTER, RANGE_EXIT, STOP, ruleTypes, AxesAndRulesDefaults, defaultArrowConfig, BarDefaults, defaultLineConfig, LineDefaults, BubbleDefaults, defaultPointerConfig, pieColors, populationDefaults, defaultAnimationDuration } from './utils/constants';
43
43
  export { CurveType, EdgePosition, Framework } from './utils/types';
@@ -67,6 +67,7 @@ export declare const AxesAndRulesDefaults: {
67
67
  verticalLinesUptoDataPoint: boolean;
68
68
  verticalLinesStrokeLinecap: string;
69
69
  noOfSections: number;
70
+ xNoOfSections: number;
70
71
  containerHeight: number;
71
72
  width: number;
72
73
  labelWidth: number;
@@ -177,10 +178,28 @@ export declare const LineDefaults: {
177
178
  lowlightOpacity: number;
178
179
  };
179
180
  export declare const BubbleDefaults: {
181
+ bubblesRadius: number;
182
+ bubblesWidth: number;
183
+ bubblesHeight: number;
184
+ bubblesShape: string;
185
+ showValuesAsBubbleLabels: boolean;
186
+ showBubbleOnFocus: boolean;
187
+ showBubbleLabelOnFocus: boolean;
188
+ labelFontSize: number;
180
189
  borderWidth: number;
181
190
  borderColor: string;
182
191
  opacity: number;
183
- dataPointsColor: string;
192
+ bubblesColor: string;
193
+ focusedBubbleColor: string;
194
+ initialSpacing: number;
195
+ endSpacing: number;
196
+ spacing: number;
197
+ regressionLineConfig: {
198
+ thickness: number;
199
+ color: string;
200
+ opacity: number;
201
+ };
202
+ scatterChart: boolean;
184
203
  };
185
204
  export declare const defaultLineConfig: defaultLineConfigType;
186
205
  export declare const defaultPointerConfig: {
@@ -77,6 +77,7 @@ export var AxesAndRulesDefaults = {
77
77
  verticalLinesUptoDataPoint: false,
78
78
  verticalLinesStrokeLinecap: 'butt',
79
79
  noOfSections: 10,
80
+ xNoOfSections: 5,
80
81
  containerHeight: 200,
81
82
  width: 200,
82
83
  labelWidth: 0,
@@ -190,10 +191,28 @@ export var LineDefaults = {
190
191
  };
191
192
  // Bubble chart specific
192
193
  export var BubbleDefaults = {
194
+ bubblesRadius: 10,
195
+ bubblesWidth: 20,
196
+ bubblesHeight: 20,
197
+ bubblesShape: 'circular',
198
+ showValuesAsBubbleLabels: false,
199
+ showBubbleOnFocus: false,
200
+ showBubbleLabelOnFocus: false,
201
+ labelFontSize: 10,
193
202
  borderWidth: 0,
194
203
  borderColor: '#333',
195
204
  opacity: 0.8,
196
- dataPointsColor: 'skyblue'
205
+ bubblesColor: 'skyblue',
206
+ focusedBubbleColor: 'orange',
207
+ initialSpacing: 0,
208
+ endSpacing: 20,
209
+ spacing: 50,
210
+ regressionLineConfig: {
211
+ thickness: 1,
212
+ color: 'black',
213
+ opacity: 1
214
+ },
215
+ scatterChart: false
197
216
  };
198
217
  export var defaultLineConfig = {
199
218
  initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
@@ -89,12 +89,14 @@ interface MaxAndMin {
89
89
  export declare const indexOfFirstNonZeroDigit: (num: number) => number;
90
90
  export declare const maxAndMinUtil: (maxItem: number, minItem: number, roundToDigits?: number, showFractionalValues?: boolean) => MaxAndMin;
91
91
  export declare const computeMaxAndMinItems: (data: any[] | undefined, extrapolateMissingValues: boolean, roundToDigits?: number, showFractionalValues?: boolean, propsData?: any[]) => MaxAndMin;
92
+ export declare const computeMaxAndMinYForBubble: (data: any[] | undefined, extrapolateMissingValues: boolean, roundToDigits?: number, showFractionalValues?: boolean, propsData?: any[]) => MaxAndMin;
93
+ export declare const computeMaxAndMinXForBubble: (data: any[] | undefined, extrapolateMissingValues: boolean, roundToDigits?: number, showFractionalValues?: boolean, propsData?: any[]) => MaxAndMin;
92
94
  export declare const getLabelTextUtil: (val: string, index: number, showFractionalValues?: boolean, yAxisLabelTexts?: string[], yAxisOffset?: number, yAxisLabelPrefix?: string, yAxisLabelSuffix?: string, roundToDigits?: number, formatYLabel?: (label: string) => string) => string;
93
95
  export declare const getXForLineInBar: (index: number, firstBarWidth: number, currentBarWidth: number, yAxisLabelWidth: number, lineConfig: any, spacing: number) => number;
94
96
  export declare const getYForLineInBar: (value: number | undefined, shiftY: number | undefined, containerHeight: number, maxValue: number, yAxisOffset: number) => number;
95
97
  export declare const clone: (obj: any) => any;
96
98
  export declare const getLineConfigForBarChart: (lineConfig: lineConfigType, barInitialSpacing: number, focusedDataPointIndex: number, setFocusedDataPointIndex: (i: number) => void) => lineConfigWithSetFocusedDataPointIndexType;
97
- export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined) => number;
99
+ export declare const getNoOfSections: (noOfSections: number | undefined, maxValue: number | undefined, stepValue: number | undefined, isX?: boolean) => number;
98
100
  export declare const getMaxValue: (maxValue: number | undefined, stepValue: number | undefined, noOfSections: number, maxItem: number) => number;
99
101
  export declare const getMostNegativeValue: (minValue: number | undefined, stepValue: number | undefined, noOfSections: number | undefined, minItem: number) => number;
100
102
  export declare const getBarFrontColor: (isFocused?: boolean, focusedBarConfig?: FocusedBarConfig, itemFrontColor?: ColorValue, frontColor?: ColorValue, isThreeD?: boolean) => ColorValue;
@@ -738,6 +738,40 @@ export var computeMaxAndMinItems = function (data, extrapolateMissingValues, rou
738
738
  });
739
739
  return maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
740
740
  };
741
+ export var computeMaxAndMinYForBubble = function (data, extrapolateMissingValues, roundToDigits, showFractionalValues, propsData) {
742
+ if (!(data === null || data === void 0 ? void 0 : data.length)) {
743
+ return { maxItem: 0, minItem: 0 };
744
+ }
745
+ var maxItem = 0;
746
+ var minItem = 0;
747
+ data.forEach(function (item, index) {
748
+ if (item.y > maxItem) {
749
+ maxItem = item.y;
750
+ }
751
+ if (item.y < minItem &&
752
+ (extrapolateMissingValues || (propsData === null || propsData === void 0 ? void 0 : propsData[index].y))) {
753
+ minItem = item.y;
754
+ }
755
+ });
756
+ return maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
757
+ };
758
+ export var computeMaxAndMinXForBubble = function (data, extrapolateMissingValues, roundToDigits, showFractionalValues, propsData) {
759
+ if (!(data === null || data === void 0 ? void 0 : data.length)) {
760
+ return { maxItem: 0, minItem: 0 };
761
+ }
762
+ var maxItem = 0;
763
+ var minItem = 0;
764
+ data.forEach(function (item, index) {
765
+ if (item.x > maxItem) {
766
+ maxItem = item.x;
767
+ }
768
+ if (item.x < minItem &&
769
+ (extrapolateMissingValues || (propsData === null || propsData === void 0 ? void 0 : propsData[index].x))) {
770
+ minItem = item.x;
771
+ }
772
+ });
773
+ return maxAndMinUtil(maxItem, minItem, roundToDigits, showFractionalValues);
774
+ };
741
775
  export var getLabelTextUtil = function (val, index, showFractionalValues, yAxisLabelTexts, yAxisOffset, yAxisLabelPrefix, yAxisLabelSuffix, roundToDigits, formatYLabel) {
742
776
  var _a, _b;
743
777
  var label = '';
@@ -849,10 +883,12 @@ export var getLineConfigForBarChart = function (lineConfig, barInitialSpacing, f
849
883
  showDataPointLabelOnFocus: (_24 = lineConfig.showDataPointLabelOnFocus) !== null && _24 !== void 0 ? _24 : defaultLineConfig.showDataPointLabelOnFocus
850
884
  };
851
885
  };
852
- export var getNoOfSections = function (noOfSections, maxValue, stepValue) {
886
+ export var getNoOfSections = function (noOfSections, maxValue, stepValue, isX) {
853
887
  return maxValue && stepValue
854
888
  ? maxValue / stepValue
855
- : noOfSections !== null && noOfSections !== void 0 ? noOfSections : AxesAndRulesDefaults.noOfSections;
889
+ : noOfSections !== null && noOfSections !== void 0 ? noOfSections : (isX
890
+ ? AxesAndRulesDefaults.xNoOfSections
891
+ : AxesAndRulesDefaults.noOfSections);
856
892
  };
857
893
  export var getMaxValue = function (maxValue, stepValue, noOfSections, maxItem) { return maxValue !== null && maxValue !== void 0 ? maxValue : (stepValue ? stepValue * noOfSections : maxItem); };
858
894
  export var getMostNegativeValue = function (minValue, stepValue, noOfSections, minItem) {
@@ -355,6 +355,7 @@ export interface BarAndLineChartsWrapperTypes {
355
355
  xAxisLabelsAtBottom: boolean;
356
356
  onScrollEndDrag?: (event: any, direction: any) => void;
357
357
  showVerticalLines?: boolean;
358
+ xAxisLabelTexts?: string[];
358
359
  }
359
360
  export interface HorizontalStripConfig {
360
361
  thickness?: number;
@@ -366,6 +367,14 @@ export interface HorizontalStripConfig {
366
367
  labelComponentHeight?: number;
367
368
  labelComponentWidth?: number;
368
369
  }
370
+ export interface RegressionLineConfig {
371
+ thickness?: number;
372
+ color?: ColorValue;
373
+ opacity?: number;
374
+ strokeDashArray?: number[];
375
+ isAnimated?: boolean;
376
+ animationDuration?: number;
377
+ }
369
378
  export interface Pointer {
370
379
  height?: number;
371
380
  width?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
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": [