gifted-charts-core 0.1.74 → 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/BubbleChart/index.d.ts +26 -13
- package/dist/BubbleChart/index.js +228 -115
- package/dist/BubbleChart/types.d.ts +73 -74
- package/dist/components/BarAndLineChartsWrapper/index.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/constants.d.ts +17 -1
- package/dist/utils/constants.js +17 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +38 -2
- package/dist/utils/types.d.ts +9 -0
- package/package.json +1 -1
|
@@ -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: (
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
hideDataPoints: boolean;
|
|
38
|
+
showValuesAsBubbleLabels: boolean;
|
|
39
|
+
hideBubbles: boolean;
|
|
41
40
|
xAxisLabelsVerticalShift: number;
|
|
42
41
|
labelsExtraHeight: number;
|
|
43
42
|
xAxisThickness: number;
|
|
@@ -47,4 +46,18 @@ 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;
|
|
50
63
|
};
|
|
@@ -23,106 +23,144 @@ 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 {
|
|
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
|
|
32
|
-
var
|
|
33
|
-
var containerHeight = (_a = props.height) !== null && _a !== void 0 ? _a : (((_b = 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 ||
|
|
34
47
|
AxesAndRulesDefaults.containerHeight);
|
|
35
|
-
var
|
|
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.
|
|
38
|
-
var
|
|
39
|
-
var roundToDigits = (_d = props.
|
|
40
|
-
var
|
|
41
|
-
roundToDigits,
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var onlyPositive = (_f = props.onlyPositive) !== null && _f !== void 0 ? _f :
|
|
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;
|
|
45
58
|
var horizSections = [{ value: '0' }];
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
|
|
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
|
|
51
86
|
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
52
87
|
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
53
88
|
var horizontal = false;
|
|
54
89
|
var yAxisAtTop = false;
|
|
55
|
-
var initialSpacing = (
|
|
56
|
-
var xAxisThickness = (
|
|
57
|
-
var spacing = (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
data.forEach(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var totalWidth = initialSpacing +
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
var
|
|
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;
|
|
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;
|
|
83
115
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
84
|
-
var yAxisOffset = (
|
|
85
|
-
var showXAxisIndices = (
|
|
86
|
-
var xAxisIndicesHeight = (
|
|
87
|
-
var xAxisIndicesWidth = (
|
|
88
|
-
var xAxisIndicesColor = (
|
|
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;
|
|
89
121
|
// const pointerConfig = props.pointerConfig
|
|
90
|
-
var getPointerProps = (
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
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
|
|
94
126
|
? 0
|
|
95
|
-
:
|
|
96
|
-
var xAxisLabelsAtBottom = (
|
|
97
|
-
var allowFontScaling = (
|
|
98
|
-
var animationDuration = (
|
|
99
|
-
var
|
|
100
|
-
var
|
|
101
|
-
var secondaryMinItem = maxValue * -1;
|
|
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;
|
|
102
133
|
var showSecondaryFractionalValues = false;
|
|
103
134
|
var secondaryRoundToDigits = 1;
|
|
104
|
-
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight,
|
|
105
|
-
var fourthQuadrantHeight = noOfSectionsBelowXAxis *
|
|
135
|
+
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, yStepHeight, yStepValue, yNoOfSections, roundToDigits, yNegativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
|
|
136
|
+
var fourthQuadrantHeight = noOfSectionsBelowXAxis * yStepHeight;
|
|
106
137
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
107
138
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + fourthQuadrantHeight;
|
|
108
|
-
var mostNegativeValueOnYAxis =
|
|
109
|
-
var containsNegativeValue = ((
|
|
110
|
-
((
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
|
114
150
|
};
|
|
115
151
|
var getY = function (value) {
|
|
116
|
-
if (containsNegativeValue &&
|
|
152
|
+
if (containsNegativeValue &&
|
|
153
|
+
value < 0 &&
|
|
154
|
+
yStepValue !== yNegativeStepValue) {
|
|
117
155
|
return (extendedContainerHeight +
|
|
118
156
|
(value * fourthQuadrantHeight) / mostNegativeValueOnYAxis);
|
|
119
157
|
}
|
|
120
|
-
return extendedContainerHeight - (value * containerHeight) /
|
|
158
|
+
return extendedContainerHeight - (value * containerHeight) / maxY;
|
|
121
159
|
};
|
|
122
|
-
var showTextOnFocus = (
|
|
123
|
-
var
|
|
124
|
-
var focusTogether = (
|
|
125
|
-
var
|
|
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];
|
|
126
164
|
var lastLineNumber = 1;
|
|
127
165
|
// if (props.secondaryData) {
|
|
128
166
|
// lastLineNumber = 6667 // lastLineNumber is 6667 for a secondary line, so the index or key of the secondary line is 6666
|
|
@@ -133,8 +171,8 @@ export var useBubbleChart = function (props) {
|
|
|
133
171
|
// if (props.data5) lastLineNumber = 5
|
|
134
172
|
// if ((props.dataSet?.length ?? 0) > lastLineNumber)
|
|
135
173
|
// lastLineNumber = props.dataSet?.length ?? 0
|
|
136
|
-
var unFocusOnPressOut = (
|
|
137
|
-
var delayBeforeUnFocus = (
|
|
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;
|
|
138
176
|
var handleFocus = function (index) {
|
|
139
177
|
setSelectedIndex(index);
|
|
140
178
|
};
|
|
@@ -143,29 +181,97 @@ export var useBubbleChart = function (props) {
|
|
|
143
181
|
setTimeout(function () { return setSelectedIndex(-1); }, delayBeforeUnFocus);
|
|
144
182
|
}
|
|
145
183
|
};
|
|
146
|
-
var
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
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
|
|
152
192
|
var startIndex = 0;
|
|
153
193
|
var endIndex = (_28 = (_27 = props.data) === null || _27 === void 0 ? void 0 : _27.length) !== null && _28 !== void 0 ? _28 : 0;
|
|
154
|
-
var
|
|
155
|
-
var
|
|
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
|
|
156
197
|
? fourthQuadrantHeight
|
|
157
198
|
: AxesAndRulesDefaults.xAxisLabelsVerticalShift);
|
|
158
|
-
var xAxisTextNumberOfLines = (
|
|
159
|
-
var rotateLabel = (
|
|
160
|
-
var borderWidth = (
|
|
161
|
-
var borderColor = (
|
|
162
|
-
var opacity = (
|
|
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
|
+
};
|
|
163
269
|
var barAndLineChartsWrapperProps = {
|
|
164
270
|
chartType: chartTypes.BUBBLE,
|
|
165
271
|
containerHeight: containerHeight,
|
|
166
272
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
167
|
-
stepHeight:
|
|
168
|
-
negativeStepHeight:
|
|
273
|
+
stepHeight: yStepHeight,
|
|
274
|
+
negativeStepHeight: yStepHeight,
|
|
169
275
|
labelsExtraHeight: labelsExtraHeight,
|
|
170
276
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
171
277
|
horizontal: horizontal,
|
|
@@ -193,7 +299,7 @@ export var useBubbleChart = function (props) {
|
|
|
193
299
|
showLine: false,
|
|
194
300
|
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
195
301
|
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
196
|
-
maxValue:
|
|
302
|
+
maxValue: maxY,
|
|
197
303
|
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
198
304
|
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
199
305
|
lineBehindBars: false,
|
|
@@ -205,9 +311,9 @@ export var useBubbleChart = function (props) {
|
|
|
205
311
|
horizSections: horizSections,
|
|
206
312
|
endSpacing: endSpacing,
|
|
207
313
|
horizontalRulesStyle: horizontalRulesStyle,
|
|
208
|
-
noOfSections:
|
|
209
|
-
sectionColors: props.
|
|
210
|
-
showFractionalValues:
|
|
314
|
+
noOfSections: yNoOfSections,
|
|
315
|
+
sectionColors: props.ySectionColors,
|
|
316
|
+
showFractionalValues: showFractionalYAxis,
|
|
211
317
|
axesAndRulesProps: axesAndRulesProps,
|
|
212
318
|
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
213
319
|
yAxisOffset: yAxisOffset,
|
|
@@ -223,9 +329,9 @@ export var useBubbleChart = function (props) {
|
|
|
223
329
|
pointerY: pointerY,
|
|
224
330
|
onEndReached: props.onEndReached,
|
|
225
331
|
onStartReached: props.onStartReached,
|
|
226
|
-
endReachedOffset: (
|
|
332
|
+
endReachedOffset: (_49 = props.endReachedOffset) !== null && _49 !== void 0 ? _49 : LineDefaults.endReachedOffset,
|
|
227
333
|
onMomentumScrollEnd: props.onMomentumScrollEnd,
|
|
228
|
-
extraWidthDueToDataPoint:
|
|
334
|
+
extraWidthDueToDataPoint: extraWidthDueToBubble,
|
|
229
335
|
customBackground: props.customBackground,
|
|
230
336
|
onlyPositive: onlyPositive,
|
|
231
337
|
highlightEnabled: LineDefaults.highlightEnabled,
|
|
@@ -233,7 +339,8 @@ export var useBubbleChart = function (props) {
|
|
|
233
339
|
xAxisLabelsAtBottom: xAxisLabelsAtBottom,
|
|
234
340
|
onScrollEndDrag: props.onScrollEndDrag,
|
|
235
341
|
allowFontScaling: allowFontScaling,
|
|
236
|
-
showVerticalLines: props.showVerticalLines
|
|
342
|
+
showVerticalLines: props.showVerticalLines,
|
|
343
|
+
xAxisLabelTexts: xAxisLabelTexts
|
|
237
344
|
};
|
|
238
345
|
return {
|
|
239
346
|
totalWidth: totalWidth,
|
|
@@ -242,7 +349,7 @@ export var useBubbleChart = function (props) {
|
|
|
242
349
|
getY: getY,
|
|
243
350
|
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
244
351
|
getX: getX,
|
|
245
|
-
maxValue:
|
|
352
|
+
maxValue: maxY,
|
|
246
353
|
selectedIndex: selectedIndex,
|
|
247
354
|
setSelectedIndex: setSelectedIndex,
|
|
248
355
|
showTextOnFocus: showTextOnFocus,
|
|
@@ -256,20 +363,19 @@ export var useBubbleChart = function (props) {
|
|
|
256
363
|
handleFocus: handleFocus,
|
|
257
364
|
handleUnFocus: handleUnFocus,
|
|
258
365
|
isAnimated: isAnimated,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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,
|
|
268
375
|
startIndex: startIndex,
|
|
269
376
|
endIndex: endIndex,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
hideDataPoints: hideDataPoints,
|
|
377
|
+
showValuesAsBubbleLabels: showValuesAsBubbleLabels,
|
|
378
|
+
hideBubbles: hideBubbles,
|
|
273
379
|
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
274
380
|
labelsExtraHeight: labelsExtraHeight,
|
|
275
381
|
xAxisThickness: xAxisThickness,
|
|
@@ -278,6 +384,13 @@ export var useBubbleChart = function (props) {
|
|
|
278
384
|
allowFontScaling: allowFontScaling,
|
|
279
385
|
borderWidth: borderWidth,
|
|
280
386
|
borderColor: borderColor,
|
|
281
|
-
opacity: opacity
|
|
387
|
+
opacity: opacity,
|
|
388
|
+
xAxisLabelTexts: xAxisLabelTexts,
|
|
389
|
+
showRegressionLine: showRegressionLine,
|
|
390
|
+
regressionLineConfig: regressionLineConfig,
|
|
391
|
+
regressionLineX1: regressionLineX1,
|
|
392
|
+
regressionLineY1: regressionLineY1,
|
|
393
|
+
regressionLineX2: regressionLineX2,
|
|
394
|
+
regressionLineY2: regressionLineY2
|
|
282
395
|
};
|
|
283
396
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ColorValue, GestureResponderEvent, StyleProp, TextStyle, ViewStyle } from
|
|
2
|
-
import { Linecap } from
|
|
3
|
-
import {
|
|
4
|
-
import { yAxisSides } from
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
55
|
+
showBubbleOnFocus?: boolean;
|
|
47
56
|
showStripOnFocus?: boolean;
|
|
48
|
-
|
|
57
|
+
stripOverBubbles?: boolean;
|
|
49
58
|
showTextOnFocus?: boolean;
|
|
50
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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,7 @@ export interface BubbleChartPropsType {
|
|
|
170
162
|
adjustToWidth?: boolean;
|
|
171
163
|
getPointerProps?: Function;
|
|
172
164
|
formatYLabel?: (label: string) => string;
|
|
165
|
+
formatXLabel?: (label: string) => string;
|
|
173
166
|
lineGradient?: boolean;
|
|
174
167
|
lineGradientComponent?: () => any;
|
|
175
168
|
lineGradientId?: string;
|
|
@@ -184,7 +177,7 @@ export interface BubbleChartPropsType {
|
|
|
184
177
|
bounces?: boolean;
|
|
185
178
|
overScrollMode?: 'auto' | 'always' | 'never';
|
|
186
179
|
onScrollEndDrag?: (event: any, direction: any) => void;
|
|
187
|
-
|
|
180
|
+
showBubblesForMissingValues?: boolean;
|
|
188
181
|
interpolateMissingValues?: boolean;
|
|
189
182
|
extrapolateMissingValues?: boolean;
|
|
190
183
|
onlyPositive?: boolean;
|
|
@@ -194,55 +187,60 @@ export interface BubbleChartPropsType {
|
|
|
194
187
|
secondaryXAxis?: XAxisConfig;
|
|
195
188
|
renderTooltip?: Function;
|
|
196
189
|
renderTooltipSecondary?: Function;
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
labelWidth?: number;
|
|
191
|
+
labelHeight?: number;
|
|
192
|
+
labelFontSize?: number;
|
|
193
|
+
labelShiftX?: number;
|
|
194
|
+
labelShiftY?: number;
|
|
195
|
+
labelComponent?: Function;
|
|
196
|
+
labelTextStyle?: Object;
|
|
197
|
+
focusedLabelComponent?: Function;
|
|
199
198
|
spreadAreaData?: SpreadData[];
|
|
200
199
|
spreadAreaColor?: ColorValue;
|
|
201
200
|
spreadAreaOpacity?: number;
|
|
202
201
|
borderWidth?: number;
|
|
203
202
|
borderColor?: ColorValue;
|
|
203
|
+
borderOpacity?: number;
|
|
204
|
+
showRegressionLine?: boolean;
|
|
205
|
+
regressionLineConfig?: RegressionLineConfig;
|
|
204
206
|
}
|
|
205
207
|
export interface bubbleDataItem {
|
|
206
208
|
y: number;
|
|
207
209
|
label?: string;
|
|
210
|
+
labelWidth?: number;
|
|
211
|
+
labelHeight?: number;
|
|
212
|
+
labelFontSize?: number;
|
|
208
213
|
labelComponent?: Function;
|
|
209
|
-
labelTextStyle?:
|
|
214
|
+
labelTextStyle?: Object;
|
|
215
|
+
labelShiftX?: number;
|
|
216
|
+
labelShiftY?: number;
|
|
210
217
|
secondaryLabel?: string;
|
|
211
218
|
secondaryLabelComponent?: Function;
|
|
212
219
|
secondaryLabelTextStyle?: StyleProp<TextStyle>;
|
|
213
|
-
dataPointText?: string;
|
|
214
|
-
textShiftX?: number;
|
|
215
|
-
textShiftY?: number;
|
|
216
|
-
textColor?: string;
|
|
217
|
-
textFontSize?: number;
|
|
218
220
|
spacing?: number;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
221
|
+
hideBubble?: boolean;
|
|
222
|
+
bubbleHeight?: number;
|
|
223
|
+
bubbleWidth?: number;
|
|
222
224
|
r?: number;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
bubbleColor?: string;
|
|
226
|
+
bubbleShape?: string;
|
|
227
|
+
customBubble?: Function;
|
|
226
228
|
stripHeight?: number;
|
|
227
229
|
stripWidth?: number;
|
|
228
230
|
stripColor?: ColorValue | string | any;
|
|
229
231
|
stripOpacity?: number;
|
|
230
232
|
stripStrokeDashArray?: number[];
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
focusedDataPointLabelComponent?: Function;
|
|
239
|
-
dataPointLabelWidth?: number;
|
|
240
|
-
dataPointLabelShiftX?: number;
|
|
241
|
-
dataPointLabelShiftY?: number;
|
|
233
|
+
focusedBubbleShape?: string;
|
|
234
|
+
focusedBubbleWidth?: number;
|
|
235
|
+
focusedBubbleHeight?: number;
|
|
236
|
+
focusedBubbleColor?: ColorValue | string | any;
|
|
237
|
+
focusedBubbleRadius?: number;
|
|
238
|
+
focusedCustomBubble?: Function;
|
|
239
|
+
focusedLabelComponent?: Function;
|
|
242
240
|
showStrip?: boolean;
|
|
243
241
|
showVerticalLine?: boolean;
|
|
244
242
|
verticalLineHeight?: number;
|
|
245
|
-
|
|
243
|
+
verticalLineUptoBubble?: boolean;
|
|
246
244
|
verticalLineColor?: ColorValue;
|
|
247
245
|
verticalLineThickness?: number;
|
|
248
246
|
verticalLineStrokeDashArray?: number[];
|
|
@@ -261,6 +259,7 @@ export interface bubbleDataItem {
|
|
|
261
259
|
x?: number;
|
|
262
260
|
borderWidth?: number;
|
|
263
261
|
borderColor?: ColorValue;
|
|
262
|
+
borderOpacity?: number;
|
|
264
263
|
opacity?: number;
|
|
265
264
|
}
|
|
266
265
|
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) : (
|
|
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,25 @@ 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
|
-
|
|
192
|
+
bubblesColor: string;
|
|
193
|
+
focusedBubbleColor: string;
|
|
194
|
+
initialSpacing: number;
|
|
195
|
+
regressionLineConfig: {
|
|
196
|
+
thickness: number;
|
|
197
|
+
color: string;
|
|
198
|
+
opacity: number;
|
|
199
|
+
};
|
|
184
200
|
};
|
|
185
201
|
export declare const defaultLineConfig: defaultLineConfigType;
|
|
186
202
|
export declare const defaultPointerConfig: {
|
package/dist/utils/constants.js
CHANGED
|
@@ -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,25 @@ 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
|
-
|
|
205
|
+
bubblesColor: 'skyblue',
|
|
206
|
+
focusedBubbleColor: 'orange',
|
|
207
|
+
initialSpacing: 0,
|
|
208
|
+
regressionLineConfig: {
|
|
209
|
+
thickness: 1,
|
|
210
|
+
color: 'black',
|
|
211
|
+
opacity: 1
|
|
212
|
+
}
|
|
197
213
|
};
|
|
198
214
|
export var defaultLineConfig = {
|
|
199
215
|
initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/utils/index.js
CHANGED
|
@@ -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 :
|
|
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) {
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -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;
|