gifted-charts-core 0.1.72 → 0.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BarChart/types.d.ts +1 -0
- package/dist/BubbleChart/index.d.ts +63 -0
- package/dist/BubbleChart/index.js +396 -0
- package/dist/BubbleChart/types.d.ts +265 -0
- package/dist/BubbleChart/types.js +1 -0
- package/dist/PieChart/index.js +2 -1
- package/dist/RadarChart/index.d.ts +7 -0
- package/dist/RadarChart/index.js +48 -40
- package/dist/RadarChart/types.d.ts +2 -0
- package/dist/components/BarAndLineChartsWrapper/index.js +51 -49
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/utils/constants.d.ts +29 -1
- package/dist/utils/constants.js +29 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +50 -10
- package/dist/utils/types.d.ts +16 -0
- package/package.json +1 -1
package/dist/BarChart/types.d.ts
CHANGED
|
@@ -157,6 +157,7 @@ export interface StackedBarChartPropsType {
|
|
|
157
157
|
bounces?: boolean;
|
|
158
158
|
overScrollMode?: 'auto' | 'always' | 'never';
|
|
159
159
|
onScrollEndDrag?: (event: any, direction: any) => void;
|
|
160
|
+
rtl?: boolean;
|
|
160
161
|
}
|
|
161
162
|
export interface StackedBarChartPropsTypeForWeb extends StackedBarChartPropsType {
|
|
162
163
|
onContextMenu?: Function;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BarAndLineChartsWrapperTypes } from '../utils/types';
|
|
2
|
+
import { BubbleChartPropsType } from './types';
|
|
3
|
+
export interface extendedBubbleChartPropsType extends BubbleChartPropsType {
|
|
4
|
+
parentWidth: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const useBubbleChart: (props: extendedBubbleChartPropsType) => {
|
|
7
|
+
totalWidth: number;
|
|
8
|
+
animationDuration: number;
|
|
9
|
+
containerHeightIncludingBelowXAxis: number;
|
|
10
|
+
getY: (value: number) => number;
|
|
11
|
+
barAndLineChartsWrapperProps: BarAndLineChartsWrapperTypes;
|
|
12
|
+
getX: (index: number) => number;
|
|
13
|
+
maxValue: number;
|
|
14
|
+
selectedIndex: number;
|
|
15
|
+
setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
16
|
+
showTextOnFocus: boolean;
|
|
17
|
+
focusEnabled: boolean;
|
|
18
|
+
focusTogether: boolean;
|
|
19
|
+
selectedLineNumber: number;
|
|
20
|
+
lastLineNumber: number;
|
|
21
|
+
initialSpacing: number;
|
|
22
|
+
spacing: number;
|
|
23
|
+
containerHeight: number;
|
|
24
|
+
handleFocus: (index: number) => void;
|
|
25
|
+
handleUnFocus: () => void;
|
|
26
|
+
isAnimated: boolean;
|
|
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
|
+
startIndex: number;
|
|
37
|
+
endIndex: number;
|
|
38
|
+
showValuesAsBubbleLabels: boolean;
|
|
39
|
+
hideBubbles: boolean;
|
|
40
|
+
xAxisLabelsVerticalShift: number;
|
|
41
|
+
labelsExtraHeight: number;
|
|
42
|
+
xAxisThickness: number;
|
|
43
|
+
xAxisTextNumberOfLines: number;
|
|
44
|
+
rotateLabel: boolean;
|
|
45
|
+
allowFontScaling: boolean;
|
|
46
|
+
borderWidth: number;
|
|
47
|
+
borderColor: import("react-native").ColorValue;
|
|
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
|
+
};
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
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
|
+
};
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
import { computeMaxAndMinXForBubble, computeMaxAndMinYForBubble, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getMaxValue, getNoOfSections, indexOfFirstNonZeroDigit
|
|
39
|
+
// weightedRegression
|
|
40
|
+
} from '../utils';
|
|
41
|
+
import { AxesAndRulesDefaults, BubbleDefaults, chartTypes, LineDefaults } from '../utils/constants';
|
|
42
|
+
export var useBubbleChart = function (props) {
|
|
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;
|
|
44
|
+
var _50 = props.data, data = _50 === void 0 ? [] : _50, 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 ||
|
|
47
|
+
AxesAndRulesDefaults.containerHeight);
|
|
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
|
|
49
|
+
Math.min.apply(// find the largest +ve number
|
|
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 _51 = computeMaxAndMinYForBubble(data, false, // extrapolateMissingValues
|
|
54
|
+
roundToDigits, showFractionalYAxis, data), yMaxItem = _51.maxItem, yMinItem = _51.minItem;
|
|
55
|
+
var maxY = getMaxValue(props.maxY, props.yStepValue, yNoOfSections, yMaxItem) || 10;
|
|
56
|
+
var mostNegativeY = (_e = props.mostNegativeY) !== null && _e !== void 0 ? _e : yMinItem;
|
|
57
|
+
var onlyPositive = (_f = props.onlyPositive) !== null && _f !== void 0 ? _f : mostNegativeY >= 0;
|
|
58
|
+
var horizSections = [{ value: '0' }];
|
|
59
|
+
var yStepHeight = (_g = props.yStepHeight) !== null && _g !== void 0 ? _g : containerHeight / yNoOfSections;
|
|
60
|
+
var yStepValue = (_h = props.yStepValue) !== null && _h !== void 0 ? _h : maxY / yNoOfSections;
|
|
61
|
+
var yNegativeStepValue = (_j = props.yNegativeStepValue) !== null && _j !== void 0 ? _j : yStepValue;
|
|
62
|
+
var xRange = Math.max.apply(Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.x, 0); })), false)) - // find the largest +ve number
|
|
63
|
+
Math.min.apply(// find the largest +ve number
|
|
64
|
+
Math, __spreadArray([], __read(data.map(function (i) { return Math.max(i.x, 0); })), false)); // find the smallest +ve number
|
|
65
|
+
var showFractionalXAxis = (_k = props.showFractionalXAxis) !== null && _k !== void 0 ? _k : (isFinite(xRange) && xRange <= 1);
|
|
66
|
+
var xRoundToDigits = (_l = props.xRoundToDigits) !== null && _l !== void 0 ? _l : (showFractionalXAxis ? indexOfFirstNonZeroDigit(xRange) + 1 : 0);
|
|
67
|
+
var _52 = computeMaxAndMinXForBubble(data, false, // extrapolateMissingValues
|
|
68
|
+
xRoundToDigits, showFractionalXAxis, data), xMaxItem = _52.maxItem, xMinItem = _52.minItem;
|
|
69
|
+
var xNoOfSections = getNoOfSections(props.xNoOfSections, props.maxX, props.xStepValue, true);
|
|
70
|
+
var maxX = getMaxValue(props.maxX, props.xStepValue, xNoOfSections, xMaxItem) || 10;
|
|
71
|
+
var minX = xMinItem;
|
|
72
|
+
// const xStepHeight = props.xStepHeight ?? containerHeight / yNoOfSections
|
|
73
|
+
var xStepValue = (_m = props.xStepValue) !== null && _m !== void 0 ? _m : maxX / xNoOfSections;
|
|
74
|
+
var xAxisLabelTexts = (_o = props.xAxisLabelTexts) !== null && _o !== void 0 ? _o : Array.from({ length: xNoOfSections + 1 }, function (_, i) {
|
|
75
|
+
if (i == 0)
|
|
76
|
+
return '';
|
|
77
|
+
var labelText = (xStepValue * i).toString();
|
|
78
|
+
if (formatXLabel) {
|
|
79
|
+
return formatXLabel(labelText);
|
|
80
|
+
}
|
|
81
|
+
return labelText;
|
|
82
|
+
});
|
|
83
|
+
var noOfSectionsBelowXAxis = (_p = props.noOfSectionsBelowXAxis) !== null && _p !== void 0 ? _p : Math.round(Math.ceil(-mostNegativeY / yNegativeStepValue));
|
|
84
|
+
var labelsExtraHeight = (_q = props.labelsExtraHeight) !== null && _q !== void 0 ? _q : 0;
|
|
85
|
+
var yAxisLabelWidth = (_r = props.yAxisLabelWidth) !== null && _r !== void 0 ? _r : (props.hideYAxisText
|
|
86
|
+
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
87
|
+
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
88
|
+
var horizontal = false;
|
|
89
|
+
var yAxisAtTop = false;
|
|
90
|
+
var initialSpacing = (_s = props.initialSpacing) !== null && _s !== void 0 ? _s : BubbleDefaults.initialSpacing;
|
|
91
|
+
var xAxisThickness = (_t = props.xAxisThickness) !== null && _t !== void 0 ? _t : AxesAndRulesDefaults.xAxisThickness;
|
|
92
|
+
var spacing = (_u = props.spacing) !== null && _u !== void 0 ? _u : LineDefaults.spacing;
|
|
93
|
+
// let cumulativeSpacing: number[] = []
|
|
94
|
+
// let spacingSum = 0
|
|
95
|
+
// let space = props.spacing ?? spacing
|
|
96
|
+
// data.forEach((item) => {
|
|
97
|
+
// spacingSum += item.spacing ?? space
|
|
98
|
+
// cumulativeSpacing.push(spacingSum)
|
|
99
|
+
// })
|
|
100
|
+
var endSpacing = (_v = props.endSpacing) !== null && _v !== void 0 ? _v : LineDefaults.endSpacing;
|
|
101
|
+
var totalWidth = initialSpacing + spacing * (xAxisLabelTexts.length - 1) + endSpacing;
|
|
102
|
+
var disableScroll = (_w = props.disableScroll) !== null && _w !== void 0 ? _w : false;
|
|
103
|
+
var showScrollIndicator = (_x = props.showScrollIndicator) !== null && _x !== void 0 ? _x : false;
|
|
104
|
+
var scrollToEnd = (_y = props.scrollToEnd) !== null && _y !== void 0 ? _y : false;
|
|
105
|
+
var scrollAnimation = (_z = props.scrollAnimation) !== null && _z !== void 0 ? _z : false;
|
|
106
|
+
var scrollEventThrottle = (_0 = props.scrollEventThrottle) !== null && _0 !== void 0 ? _0 : 16;
|
|
107
|
+
var focusEnabled = (_1 = props.focusEnabled) !== null && _1 !== void 0 ? _1 : LineDefaults.focusEnabled;
|
|
108
|
+
var showBubbleOnFocus = (_2 = props.showBubbleOnFocus) !== null && _2 !== void 0 ? _2 : BubbleDefaults.showBubbleOnFocus;
|
|
109
|
+
var _53 = __read(useState((_3 = props.focusedBubbleIndex) !== null && _3 !== void 0 ? _3 : -1), 2), selectedIndex = _53[0], setSelectedIndex = _53[1];
|
|
110
|
+
var _54 = __read(useState(''), 2), points = _54[0], setPoints = _54[1];
|
|
111
|
+
var _55 = __read(useState(-1), 2), pointerIndex = _55[0], setPointerIndex = _55[1];
|
|
112
|
+
var _56 = __read(useState(0), 2), pointerX = _56[0], setPointerX = _56[1];
|
|
113
|
+
var _57 = __read(useState(0), 2), pointerY = _57[0], setPointerY = _57[1];
|
|
114
|
+
var isAnimated = (_4 = props.isAnimated) !== null && _4 !== void 0 ? _4 : false;
|
|
115
|
+
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
116
|
+
var yAxisOffset = (_5 = props.yAxisOffset) !== null && _5 !== void 0 ? _5 : 0;
|
|
117
|
+
var showXAxisIndices = (_6 = props.showXAxisIndices) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.showXAxisIndices;
|
|
118
|
+
var xAxisIndicesHeight = (_7 = props.xAxisIndicesHeight) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
119
|
+
var xAxisIndicesWidth = (_8 = props.xAxisIndicesWidth) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
120
|
+
var xAxisIndicesColor = (_9 = props.xAxisIndicesColor) !== null && _9 !== void 0 ? _9 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
121
|
+
// const pointerConfig = props.pointerConfig
|
|
122
|
+
var getPointerProps = (_10 = props.getPointerProps) !== null && _10 !== void 0 ? _10 : null;
|
|
123
|
+
var bubblesRadius = (_11 = props.bubblesRadius) !== null && _11 !== void 0 ? _11 : BubbleDefaults.bubblesRadius;
|
|
124
|
+
var bubblesWidth = (_12 = props.bubblesWidth) !== null && _12 !== void 0 ? _12 : BubbleDefaults.bubblesWidth;
|
|
125
|
+
var extraWidthDueToBubble = props.hideBubbles
|
|
126
|
+
? 0
|
|
127
|
+
: bubblesRadius !== null && bubblesRadius !== void 0 ? bubblesRadius : bubblesWidth;
|
|
128
|
+
var xAxisLabelsAtBottom = (_13 = props.xAxisLabelsAtBottom) !== null && _13 !== void 0 ? _13 : false;
|
|
129
|
+
var allowFontScaling = (_14 = props.allowFontScaling) !== null && _14 !== void 0 ? _14 : AxesAndRulesDefaults.allowFontScaling;
|
|
130
|
+
var animationDuration = (_15 = props.animationDuration) !== null && _15 !== void 0 ? _15 : LineDefaults.animationDuration;
|
|
131
|
+
var secondaryMaxValue = maxY;
|
|
132
|
+
var secondaryMinItem = maxY * -1;
|
|
133
|
+
var showSecondaryFractionalValues = false;
|
|
134
|
+
var secondaryRoundToDigits = 1;
|
|
135
|
+
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, yStepHeight, yStepValue, yNoOfSections, roundToDigits, yNegativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
|
|
136
|
+
var fourthQuadrantHeight = noOfSectionsBelowXAxis * yStepHeight;
|
|
137
|
+
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
138
|
+
var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
|
|
139
|
+
var mostNegativeValueOnYAxis = yNegativeStepValue * noOfSectionsBelowXAxis;
|
|
140
|
+
var containsNegativeValue = ((_16 = props.mostNegativeY) !== null && _16 !== void 0 ? _16 : 0) < 0 ||
|
|
141
|
+
((_17 = props.data) === null || _17 === void 0 ? void 0 : _17.some(function (item) { var _a; return ((_a = item.y) !== null && _a !== void 0 ? _a : 0) < 0; }));
|
|
142
|
+
var xScale = spacing / xStepValue;
|
|
143
|
+
var getX = function (index) {
|
|
144
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
145
|
+
var val = ((_a = props.data) === null || _a === void 0 ? void 0 : _a[index].x) !== undefined
|
|
146
|
+
? ((_c = (_b = props.data) === null || _b === void 0 ? void 0 : _b[index].x) !== null && _c !== void 0 ? _c : 0) * xScale
|
|
147
|
+
: Math.min(totalWidth -
|
|
148
|
+
((_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));
|
|
149
|
+
return val;
|
|
150
|
+
};
|
|
151
|
+
var getY = function (value) {
|
|
152
|
+
if (containsNegativeValue &&
|
|
153
|
+
value < 0 &&
|
|
154
|
+
yStepValue !== yNegativeStepValue) {
|
|
155
|
+
return (extendedContainerHeight +
|
|
156
|
+
(value * fourthQuadrantHeight) / mostNegativeValueOnYAxis);
|
|
157
|
+
}
|
|
158
|
+
return extendedContainerHeight - (value * containerHeight) / maxY;
|
|
159
|
+
};
|
|
160
|
+
var showTextOnFocus = (_18 = props.showTextOnFocus) !== null && _18 !== void 0 ? _18 : LineDefaults.showTextOnFocus;
|
|
161
|
+
var showBubbleLabelOnFocus = (_19 = props.showBubbleLabelOnFocus) !== null && _19 !== void 0 ? _19 : BubbleDefaults.showBubbleLabelOnFocus;
|
|
162
|
+
var focusTogether = (_20 = props.focusTogether) !== null && _20 !== void 0 ? _20 : true;
|
|
163
|
+
var _58 = __read(useState(-1), 2), selectedLineNumber = _58[0], setSelectedLineNumber = _58[1];
|
|
164
|
+
var lastLineNumber = 1;
|
|
165
|
+
// if (props.secondaryData) {
|
|
166
|
+
// lastLineNumber = 6667 // lastLineNumber is 6667 for a secondary line, so the index or key of the secondary line is 6666
|
|
167
|
+
// }
|
|
168
|
+
// if (props.data2) lastLineNumber = 2
|
|
169
|
+
// if (props.data3) lastLineNumber = 3
|
|
170
|
+
// if (props.data4) lastLineNumber = 4
|
|
171
|
+
// if (props.data5) lastLineNumber = 5
|
|
172
|
+
// if ((props.dataSet?.length ?? 0) > lastLineNumber)
|
|
173
|
+
// lastLineNumber = props.dataSet?.length ?? 0
|
|
174
|
+
var unFocusOnPressOut = (_21 = props.unFocusOnPressOut) !== null && _21 !== void 0 ? _21 : LineDefaults.unFocusOnPressOut;
|
|
175
|
+
var delayBeforeUnFocus = (_22 = props.delayBeforeUnFocus) !== null && _22 !== void 0 ? _22 : LineDefaults.delayBeforeUnFocus;
|
|
176
|
+
var handleFocus = function (index) {
|
|
177
|
+
setSelectedIndex(index);
|
|
178
|
+
};
|
|
179
|
+
var handleUnFocus = function () {
|
|
180
|
+
if (unFocusOnPressOut) {
|
|
181
|
+
setTimeout(function () { return setSelectedIndex(-1); }, delayBeforeUnFocus);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var hideBubbles = (_23 = props.hideBubbles) !== null && _23 !== void 0 ? _23 : false;
|
|
185
|
+
var bubblesShape = (_24 = props.bubblesShape) !== null && _24 !== void 0 ? _24 : BubbleDefaults.bubblesShape;
|
|
186
|
+
var bubblesHeight = (_25 = props.bubblesHeight) !== null && _25 !== void 0 ? _25 : BubbleDefaults.bubblesHeight;
|
|
187
|
+
var bubblesColor = (_26 = props.bubblesColor) !== null && _26 !== void 0 ? _26 : BubbleDefaults.bubblesColor;
|
|
188
|
+
// const textFontSize = props.textFontSize ?? LineDefaults.textFontSize
|
|
189
|
+
// const textColor = props.textColor ?? LineDefaults.textColor
|
|
190
|
+
// const textFontFamily = props.textFontFamily
|
|
191
|
+
// const textFontWeight = props.textFontWeight
|
|
192
|
+
var startIndex = 0;
|
|
193
|
+
var endIndex = (_28 = (_27 = props.data) === null || _27 === void 0 ? void 0 : _27.length) !== null && _28 !== void 0 ? _28 : 0;
|
|
194
|
+
var labelFontSize = (_29 = props.labelFontSize) !== null && _29 !== void 0 ? _29 : BubbleDefaults.labelFontSize;
|
|
195
|
+
var showValuesAsBubbleLabels = (_30 = props.showValuesAsBubbleLabels) !== null && _30 !== void 0 ? _30 : BubbleDefaults.showValuesAsBubbleLabels;
|
|
196
|
+
var xAxisLabelsVerticalShift = (_31 = props.xAxisLabelsVerticalShift) !== null && _31 !== void 0 ? _31 : (xAxisLabelsAtBottom
|
|
197
|
+
? fourthQuadrantHeight
|
|
198
|
+
: AxesAndRulesDefaults.xAxisLabelsVerticalShift);
|
|
199
|
+
var xAxisTextNumberOfLines = (_32 = props.xAxisTextNumberOfLines) !== null && _32 !== void 0 ? _32 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
200
|
+
var rotateLabel = (_33 = props.rotateLabel) !== null && _33 !== void 0 ? _33 : false;
|
|
201
|
+
var borderWidth = (_34 = props.borderWidth) !== null && _34 !== void 0 ? _34 : BubbleDefaults.borderWidth;
|
|
202
|
+
var borderColor = (_35 = props.borderColor) !== null && _35 !== void 0 ? _35 : BubbleDefaults.borderColor;
|
|
203
|
+
var opacity = (_36 = props.opacity) !== null && _36 !== void 0 ? _36 : BubbleDefaults.opacity;
|
|
204
|
+
var showRegressionLine = (_37 = props.showRegressionLine) !== null && _37 !== void 0 ? _37 : false;
|
|
205
|
+
var weightedRegression = function () {
|
|
206
|
+
var e_1, _a;
|
|
207
|
+
if (!data)
|
|
208
|
+
return { slope: 0, intercept: 0 };
|
|
209
|
+
var sumW = 0;
|
|
210
|
+
var sumWX = 0;
|
|
211
|
+
var sumWY = 0;
|
|
212
|
+
var sumWXX = 0;
|
|
213
|
+
var sumWXY = 0;
|
|
214
|
+
var i = -1;
|
|
215
|
+
try {
|
|
216
|
+
for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
|
|
217
|
+
var _b = data_1_1.value, y = _b.y, _c = _b.r, r = _c === void 0 ? 1 : _c;
|
|
218
|
+
++i;
|
|
219
|
+
var w = r * r;
|
|
220
|
+
if (w <= 0)
|
|
221
|
+
continue; // ignore zero/negative weights
|
|
222
|
+
var x = getX(i);
|
|
223
|
+
sumW += w;
|
|
224
|
+
sumWX += w * x;
|
|
225
|
+
sumWY += w * y;
|
|
226
|
+
sumWXX += w * x * x;
|
|
227
|
+
sumWXY += w * x * y;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
231
|
+
finally {
|
|
232
|
+
try {
|
|
233
|
+
if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
|
|
234
|
+
}
|
|
235
|
+
finally { if (e_1) throw e_1.error; }
|
|
236
|
+
}
|
|
237
|
+
var denominator = sumW * sumWXX - sumWX * sumWX;
|
|
238
|
+
if (denominator === 0) {
|
|
239
|
+
throw new Error('Regression not defined (degenerate data)');
|
|
240
|
+
}
|
|
241
|
+
var slope = (sumW * sumWXY - sumWX * sumWY) / denominator;
|
|
242
|
+
var intercept = (sumWY - slope * sumWX) / sumW;
|
|
243
|
+
return { slope: slope, intercept: intercept };
|
|
244
|
+
};
|
|
245
|
+
var regressionLineX1 = 0, regressionLineY1 = 0, regressionLineX2 = 0, regressionLineY2 = 0;
|
|
246
|
+
if (showRegressionLine) {
|
|
247
|
+
var slope = 0, intercept = 0;
|
|
248
|
+
var slopeIntercept = weightedRegression();
|
|
249
|
+
slope = slopeIntercept.slope;
|
|
250
|
+
intercept = slopeIntercept.intercept;
|
|
251
|
+
// Calculate Y values in data space first
|
|
252
|
+
var y1_data = slope * minX + intercept;
|
|
253
|
+
var y2_data = slope * maxX + intercept;
|
|
254
|
+
// Convert X coordinates to screen space
|
|
255
|
+
regressionLineX1 = minX * xScale;
|
|
256
|
+
regressionLineX2 = maxX * xScale;
|
|
257
|
+
// Convert Y coordinates to screen space using getY function
|
|
258
|
+
regressionLineY1 = getY(y1_data);
|
|
259
|
+
regressionLineY2 = getY(y2_data);
|
|
260
|
+
}
|
|
261
|
+
var regressionLineConfig = {
|
|
262
|
+
thickness: (_39 = (_38 = props.regressionLineConfig) === null || _38 === void 0 ? void 0 : _38.thickness) !== null && _39 !== void 0 ? _39 : BubbleDefaults.regressionLineConfig.thickness,
|
|
263
|
+
color: (_41 = (_40 = props.regressionLineConfig) === null || _40 === void 0 ? void 0 : _40.color) !== null && _41 !== void 0 ? _41 : BubbleDefaults.regressionLineConfig.color,
|
|
264
|
+
opacity: (_43 = (_42 = props.regressionLineConfig) === null || _42 === void 0 ? void 0 : _42.opacity) !== null && _43 !== void 0 ? _43 : BubbleDefaults.regressionLineConfig.opacity,
|
|
265
|
+
strokeDashArray: (_44 = props.regressionLineConfig) === null || _44 === void 0 ? void 0 : _44.strokeDashArray,
|
|
266
|
+
isAnimated: (_46 = (_45 = props.regressionLineConfig) === null || _45 === void 0 ? void 0 : _45.isAnimated) !== null && _46 !== void 0 ? _46 : isAnimated,
|
|
267
|
+
animationDuration: (_48 = (_47 = props.regressionLineConfig) === null || _47 === void 0 ? void 0 : _47.animationDuration) !== null && _48 !== void 0 ? _48 : animationDuration
|
|
268
|
+
};
|
|
269
|
+
var barAndLineChartsWrapperProps = {
|
|
270
|
+
chartType: chartTypes.BUBBLE,
|
|
271
|
+
containerHeight: containerHeight,
|
|
272
|
+
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
273
|
+
stepHeight: yStepHeight,
|
|
274
|
+
negativeStepHeight: yStepHeight,
|
|
275
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
276
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
277
|
+
horizontal: horizontal,
|
|
278
|
+
rtl: false,
|
|
279
|
+
shiftX: 0,
|
|
280
|
+
shiftY: 0,
|
|
281
|
+
yAxisAtTop: yAxisAtTop,
|
|
282
|
+
initialSpacing: initialSpacing,
|
|
283
|
+
data: data,
|
|
284
|
+
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
285
|
+
secondaryData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
286
|
+
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
287
|
+
xAxisThickness: xAxisThickness,
|
|
288
|
+
totalWidth: totalWidth,
|
|
289
|
+
disableScroll: disableScroll,
|
|
290
|
+
showScrollIndicator: showScrollIndicator,
|
|
291
|
+
scrollToEnd: scrollToEnd,
|
|
292
|
+
scrollToIndex: props.scrollToIndex,
|
|
293
|
+
scrollAnimation: scrollAnimation,
|
|
294
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
295
|
+
indicatorColor: props.indicatorColor,
|
|
296
|
+
selectedIndex: [selectedIndex],
|
|
297
|
+
setSelectedIndex: setSelectedIndex,
|
|
298
|
+
spacing: spacing,
|
|
299
|
+
showLine: false,
|
|
300
|
+
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
301
|
+
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
302
|
+
maxValue: maxY,
|
|
303
|
+
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
304
|
+
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
305
|
+
lineBehindBars: false,
|
|
306
|
+
points: points,
|
|
307
|
+
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
308
|
+
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
309
|
+
// horizSectionProps-
|
|
310
|
+
width: props.width,
|
|
311
|
+
horizSections: horizSections,
|
|
312
|
+
endSpacing: endSpacing,
|
|
313
|
+
horizontalRulesStyle: horizontalRulesStyle,
|
|
314
|
+
noOfSections: yNoOfSections,
|
|
315
|
+
sectionColors: props.ySectionColors,
|
|
316
|
+
showFractionalValues: showFractionalYAxis,
|
|
317
|
+
axesAndRulesProps: axesAndRulesProps,
|
|
318
|
+
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
319
|
+
yAxisOffset: yAxisOffset,
|
|
320
|
+
rotateYAxisTexts: 0,
|
|
321
|
+
hideAxesAndRules: props.hideAxesAndRules,
|
|
322
|
+
showXAxisIndices: showXAxisIndices,
|
|
323
|
+
xAxisIndicesHeight: xAxisIndicesHeight,
|
|
324
|
+
xAxisIndicesWidth: xAxisIndicesWidth,
|
|
325
|
+
xAxisIndicesColor: xAxisIndicesColor,
|
|
326
|
+
getPointerProps: getPointerProps,
|
|
327
|
+
pointerIndex: pointerIndex,
|
|
328
|
+
pointerX: pointerX,
|
|
329
|
+
pointerY: pointerY,
|
|
330
|
+
onEndReached: props.onEndReached,
|
|
331
|
+
onStartReached: props.onStartReached,
|
|
332
|
+
endReachedOffset: (_49 = props.endReachedOffset) !== null && _49 !== void 0 ? _49 : LineDefaults.endReachedOffset,
|
|
333
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd,
|
|
334
|
+
extraWidthDueToDataPoint: extraWidthDueToBubble,
|
|
335
|
+
customBackground: props.customBackground,
|
|
336
|
+
onlyPositive: onlyPositive,
|
|
337
|
+
highlightEnabled: LineDefaults.highlightEnabled,
|
|
338
|
+
lowlightOpacity: LineDefaults.lowlightOpacity,
|
|
339
|
+
xAxisLabelsAtBottom: xAxisLabelsAtBottom,
|
|
340
|
+
onScrollEndDrag: props.onScrollEndDrag,
|
|
341
|
+
allowFontScaling: allowFontScaling,
|
|
342
|
+
showVerticalLines: props.showVerticalLines,
|
|
343
|
+
xAxisLabelTexts: xAxisLabelTexts
|
|
344
|
+
};
|
|
345
|
+
return {
|
|
346
|
+
totalWidth: totalWidth,
|
|
347
|
+
animationDuration: animationDuration,
|
|
348
|
+
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
349
|
+
getY: getY,
|
|
350
|
+
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
351
|
+
getX: getX,
|
|
352
|
+
maxValue: maxY,
|
|
353
|
+
selectedIndex: selectedIndex,
|
|
354
|
+
setSelectedIndex: setSelectedIndex,
|
|
355
|
+
showTextOnFocus: showTextOnFocus,
|
|
356
|
+
focusEnabled: focusEnabled,
|
|
357
|
+
focusTogether: focusTogether,
|
|
358
|
+
selectedLineNumber: selectedLineNumber,
|
|
359
|
+
lastLineNumber: lastLineNumber,
|
|
360
|
+
initialSpacing: initialSpacing,
|
|
361
|
+
spacing: spacing,
|
|
362
|
+
containerHeight: containerHeight,
|
|
363
|
+
handleFocus: handleFocus,
|
|
364
|
+
handleUnFocus: handleUnFocus,
|
|
365
|
+
isAnimated: isAnimated,
|
|
366
|
+
showBubbleOnFocus: showBubbleOnFocus,
|
|
367
|
+
showBubbleLabelOnFocus: showBubbleLabelOnFocus,
|
|
368
|
+
bubblesShape: bubblesShape,
|
|
369
|
+
bubblesWidth: bubblesWidth,
|
|
370
|
+
bubblesHeight: bubblesHeight,
|
|
371
|
+
bubblesColor: bubblesColor,
|
|
372
|
+
bubblesRadius: bubblesRadius,
|
|
373
|
+
labelFontSize: labelFontSize,
|
|
374
|
+
labelTextStyle: props.labelTextStyle,
|
|
375
|
+
startIndex: startIndex,
|
|
376
|
+
endIndex: endIndex,
|
|
377
|
+
showValuesAsBubbleLabels: showValuesAsBubbleLabels,
|
|
378
|
+
hideBubbles: hideBubbles,
|
|
379
|
+
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
380
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
381
|
+
xAxisThickness: xAxisThickness,
|
|
382
|
+
xAxisTextNumberOfLines: xAxisTextNumberOfLines,
|
|
383
|
+
rotateLabel: rotateLabel,
|
|
384
|
+
allowFontScaling: allowFontScaling,
|
|
385
|
+
borderWidth: borderWidth,
|
|
386
|
+
borderColor: borderColor,
|
|
387
|
+
opacity: opacity,
|
|
388
|
+
xAxisLabelTexts: xAxisLabelTexts,
|
|
389
|
+
showRegressionLine: showRegressionLine,
|
|
390
|
+
regressionLineConfig: regressionLineConfig,
|
|
391
|
+
regressionLineX1: regressionLineX1,
|
|
392
|
+
regressionLineY1: regressionLineY1,
|
|
393
|
+
regressionLineX2: regressionLineX2,
|
|
394
|
+
regressionLineY2: regressionLineY2
|
|
395
|
+
};
|
|
396
|
+
};
|