gifted-charts-core 0.1.71 → 0.1.74
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/index.d.ts +3 -3
- package/dist/BarChart/index.js +85 -82
- package/dist/BarChart/types.d.ts +5 -0
- package/dist/BubbleChart/index.d.ts +50 -0
- package/dist/BubbleChart/index.js +283 -0
- package/dist/BubbleChart/types.d.ts +266 -0
- package/dist/BubbleChart/types.js +1 -0
- package/dist/PieChart/index.d.ts +1 -0
- package/dist/PieChart/index.js +28 -26
- package/dist/PieChart/pro.js +5 -5
- package/dist/PieChart/types.d.ts +1 -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 +47 -47
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/utils/constants.d.ts +13 -1
- package/dist/utils/constants.js +23 -9
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +15 -10
- package/dist/utils/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
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
|
+
import { useState } from 'react';
|
|
27
|
+
import { computeMaxAndMinItems, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getMaxValue, getNoOfSections, indexOfFirstNonZeroDigit } from '../utils';
|
|
28
|
+
import { AxesAndRulesDefaults, BubbleDefaults, chartTypes, LineDefaults } from '../utils/constants';
|
|
29
|
+
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 ||
|
|
34
|
+
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
|
|
36
|
+
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;
|
|
45
|
+
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
|
|
51
|
+
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
52
|
+
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
53
|
+
var horizontal = false;
|
|
54
|
+
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;
|
|
83
|
+
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;
|
|
89
|
+
// 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
|
|
94
|
+
? 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;
|
|
102
|
+
var showSecondaryFractionalValues = false;
|
|
103
|
+
var secondaryRoundToDigits = 1;
|
|
104
|
+
var axesAndRulesProps = getAxesAndRulesProps(props, containerHeight, stepHeight, stepValue, noOfSections, roundToDigits, negativeStepValue, secondaryMaxValue, secondaryMinItem, showSecondaryFractionalValues, secondaryRoundToDigits);
|
|
105
|
+
var fourthQuadrantHeight = noOfSectionsBelowXAxis * stepHeight;
|
|
106
|
+
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
107
|
+
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);
|
|
114
|
+
};
|
|
115
|
+
var getY = function (value) {
|
|
116
|
+
if (containsNegativeValue && value < 0 && stepValue !== negativeStepValue) {
|
|
117
|
+
return (extendedContainerHeight +
|
|
118
|
+
(value * fourthQuadrantHeight) / mostNegativeValueOnYAxis);
|
|
119
|
+
}
|
|
120
|
+
return extendedContainerHeight - (value * containerHeight) / maxValue;
|
|
121
|
+
};
|
|
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];
|
|
126
|
+
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;
|
|
138
|
+
var handleFocus = function (index) {
|
|
139
|
+
setSelectedIndex(index);
|
|
140
|
+
};
|
|
141
|
+
var handleUnFocus = function () {
|
|
142
|
+
if (unFocusOnPressOut) {
|
|
143
|
+
setTimeout(function () { return setSelectedIndex(-1); }, delayBeforeUnFocus);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
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;
|
|
152
|
+
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
|
|
156
|
+
? fourthQuadrantHeight
|
|
157
|
+
: 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;
|
|
163
|
+
var barAndLineChartsWrapperProps = {
|
|
164
|
+
chartType: chartTypes.BUBBLE,
|
|
165
|
+
containerHeight: containerHeight,
|
|
166
|
+
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
167
|
+
stepHeight: stepHeight,
|
|
168
|
+
negativeStepHeight: stepHeight,
|
|
169
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
170
|
+
yAxisLabelWidth: yAxisLabelWidth,
|
|
171
|
+
horizontal: horizontal,
|
|
172
|
+
rtl: false,
|
|
173
|
+
shiftX: 0,
|
|
174
|
+
shiftY: 0,
|
|
175
|
+
yAxisAtTop: yAxisAtTop,
|
|
176
|
+
initialSpacing: initialSpacing,
|
|
177
|
+
data: data,
|
|
178
|
+
stackData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
179
|
+
secondaryData: undefined, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
180
|
+
barWidth: 0, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
181
|
+
xAxisThickness: xAxisThickness,
|
|
182
|
+
totalWidth: totalWidth,
|
|
183
|
+
disableScroll: disableScroll,
|
|
184
|
+
showScrollIndicator: showScrollIndicator,
|
|
185
|
+
scrollToEnd: scrollToEnd,
|
|
186
|
+
scrollToIndex: props.scrollToIndex,
|
|
187
|
+
scrollAnimation: scrollAnimation,
|
|
188
|
+
scrollEventThrottle: scrollEventThrottle,
|
|
189
|
+
indicatorColor: props.indicatorColor,
|
|
190
|
+
selectedIndex: [selectedIndex],
|
|
191
|
+
setSelectedIndex: setSelectedIndex,
|
|
192
|
+
spacing: spacing,
|
|
193
|
+
showLine: false,
|
|
194
|
+
lineConfig: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
195
|
+
lineConfig2: null, // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
196
|
+
maxValue: maxValue,
|
|
197
|
+
lineData: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
198
|
+
lineData2: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
199
|
+
lineBehindBars: false,
|
|
200
|
+
points: points,
|
|
201
|
+
points2: '', // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
202
|
+
arrowPoints: [], // Not needed but passing this prop to maintain consistency (between LineChart and BarChart props)
|
|
203
|
+
// horizSectionProps-
|
|
204
|
+
width: props.width,
|
|
205
|
+
horizSections: horizSections,
|
|
206
|
+
endSpacing: endSpacing,
|
|
207
|
+
horizontalRulesStyle: horizontalRulesStyle,
|
|
208
|
+
noOfSections: noOfSections,
|
|
209
|
+
sectionColors: props.sectionColors,
|
|
210
|
+
showFractionalValues: showFractionalValues,
|
|
211
|
+
axesAndRulesProps: axesAndRulesProps,
|
|
212
|
+
yAxisLabelTexts: props.yAxisLabelTexts,
|
|
213
|
+
yAxisOffset: yAxisOffset,
|
|
214
|
+
rotateYAxisTexts: 0,
|
|
215
|
+
hideAxesAndRules: props.hideAxesAndRules,
|
|
216
|
+
showXAxisIndices: showXAxisIndices,
|
|
217
|
+
xAxisIndicesHeight: xAxisIndicesHeight,
|
|
218
|
+
xAxisIndicesWidth: xAxisIndicesWidth,
|
|
219
|
+
xAxisIndicesColor: xAxisIndicesColor,
|
|
220
|
+
getPointerProps: getPointerProps,
|
|
221
|
+
pointerIndex: pointerIndex,
|
|
222
|
+
pointerX: pointerX,
|
|
223
|
+
pointerY: pointerY,
|
|
224
|
+
onEndReached: props.onEndReached,
|
|
225
|
+
onStartReached: props.onStartReached,
|
|
226
|
+
endReachedOffset: (_36 = props.endReachedOffset) !== null && _36 !== void 0 ? _36 : LineDefaults.endReachedOffset,
|
|
227
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd,
|
|
228
|
+
extraWidthDueToDataPoint: extraWidthDueToDataPoint,
|
|
229
|
+
customBackground: props.customBackground,
|
|
230
|
+
onlyPositive: onlyPositive,
|
|
231
|
+
highlightEnabled: LineDefaults.highlightEnabled,
|
|
232
|
+
lowlightOpacity: LineDefaults.lowlightOpacity,
|
|
233
|
+
xAxisLabelsAtBottom: xAxisLabelsAtBottom,
|
|
234
|
+
onScrollEndDrag: props.onScrollEndDrag,
|
|
235
|
+
allowFontScaling: allowFontScaling,
|
|
236
|
+
showVerticalLines: props.showVerticalLines
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
totalWidth: totalWidth,
|
|
240
|
+
animationDuration: animationDuration,
|
|
241
|
+
containerHeightIncludingBelowXAxis: containerHeightIncludingBelowXAxis,
|
|
242
|
+
getY: getY,
|
|
243
|
+
barAndLineChartsWrapperProps: barAndLineChartsWrapperProps,
|
|
244
|
+
getX: getX,
|
|
245
|
+
maxValue: maxValue,
|
|
246
|
+
selectedIndex: selectedIndex,
|
|
247
|
+
setSelectedIndex: setSelectedIndex,
|
|
248
|
+
showTextOnFocus: showTextOnFocus,
|
|
249
|
+
focusEnabled: focusEnabled,
|
|
250
|
+
focusTogether: focusTogether,
|
|
251
|
+
selectedLineNumber: selectedLineNumber,
|
|
252
|
+
lastLineNumber: lastLineNumber,
|
|
253
|
+
initialSpacing: initialSpacing,
|
|
254
|
+
spacing: spacing,
|
|
255
|
+
containerHeight: containerHeight,
|
|
256
|
+
handleFocus: handleFocus,
|
|
257
|
+
handleUnFocus: handleUnFocus,
|
|
258
|
+
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,
|
|
268
|
+
startIndex: startIndex,
|
|
269
|
+
endIndex: endIndex,
|
|
270
|
+
showValuesAsDataPointsText: showValuesAsDataPointsText,
|
|
271
|
+
cumulativeSpacing: cumulativeSpacing,
|
|
272
|
+
hideDataPoints: hideDataPoints,
|
|
273
|
+
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
274
|
+
labelsExtraHeight: labelsExtraHeight,
|
|
275
|
+
xAxisThickness: xAxisThickness,
|
|
276
|
+
xAxisTextNumberOfLines: xAxisTextNumberOfLines,
|
|
277
|
+
rotateLabel: rotateLabel,
|
|
278
|
+
allowFontScaling: allowFontScaling,
|
|
279
|
+
borderWidth: borderWidth,
|
|
280
|
+
borderColor: borderColor,
|
|
281
|
+
opacity: opacity
|
|
282
|
+
};
|
|
283
|
+
};
|
|
@@ -0,0 +1,266 @@
|
|
|
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";
|
|
5
|
+
interface sectionType {
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BubbleChartPropsType {
|
|
9
|
+
opacity?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
overflowTop?: number;
|
|
12
|
+
overflowBottom?: number;
|
|
13
|
+
noOfSections?: number;
|
|
14
|
+
sectionColors?: ColorValue[];
|
|
15
|
+
maxValue?: number;
|
|
16
|
+
mostNegativeValue?: number;
|
|
17
|
+
stepHeight?: number;
|
|
18
|
+
stepValue?: number;
|
|
19
|
+
negativeStepValue?: number;
|
|
20
|
+
spacing?: number;
|
|
21
|
+
initialSpacing?: number;
|
|
22
|
+
endSpacing?: number;
|
|
23
|
+
data?: bubbleDataItem[];
|
|
24
|
+
zIndex?: number;
|
|
25
|
+
thickness?: number;
|
|
26
|
+
strokeDashArray?: number[];
|
|
27
|
+
strokeLinecap?: Linecap;
|
|
28
|
+
rotateLabel?: boolean;
|
|
29
|
+
isAnimated?: boolean;
|
|
30
|
+
animateOnDataChange?: boolean;
|
|
31
|
+
animationDuration?: number;
|
|
32
|
+
onDataChangeAnimationDuration?: number;
|
|
33
|
+
animationEasing?: any;
|
|
34
|
+
animateTogether?: boolean;
|
|
35
|
+
renderDataPointsAfterAnimationEnds?: boolean;
|
|
36
|
+
xAxisLength?: number;
|
|
37
|
+
xAxisThickness?: number;
|
|
38
|
+
xAxisColor?: ColorValue;
|
|
39
|
+
xAxisType?: RuleType;
|
|
40
|
+
hideRules?: boolean;
|
|
41
|
+
rulesLength?: number;
|
|
42
|
+
rulesColor?: ColorValue;
|
|
43
|
+
rulesThickness?: number;
|
|
44
|
+
focusEnabled?: boolean;
|
|
45
|
+
onFocus?: Function;
|
|
46
|
+
showDataPointOnFocus?: boolean;
|
|
47
|
+
showStripOnFocus?: boolean;
|
|
48
|
+
stripOverDataPoints?: boolean;
|
|
49
|
+
showTextOnFocus?: boolean;
|
|
50
|
+
showDataPointLabelOnFocus?: boolean;
|
|
51
|
+
stripHeight?: number;
|
|
52
|
+
stripWidth?: number;
|
|
53
|
+
stripColor?: ColorValue | string | any;
|
|
54
|
+
stripOpacity?: number;
|
|
55
|
+
stripStrokeDashArray?: number[];
|
|
56
|
+
onPress?: Function;
|
|
57
|
+
unFocusOnPressOut?: boolean;
|
|
58
|
+
delayBeforeUnFocus?: number;
|
|
59
|
+
focusedDataPointIndex?: number;
|
|
60
|
+
showValuesAsDataPointsText?: boolean;
|
|
61
|
+
rulesType?: RuleType;
|
|
62
|
+
dashWidth?: number;
|
|
63
|
+
dashGap?: number;
|
|
64
|
+
rulesConfigArray?: RulesConfig[];
|
|
65
|
+
showReferenceLine1?: boolean;
|
|
66
|
+
referenceLine1Config?: referenceConfigType;
|
|
67
|
+
referenceLine1Position?: number;
|
|
68
|
+
showReferenceLine2?: boolean;
|
|
69
|
+
referenceLine2Config?: referenceConfigType;
|
|
70
|
+
referenceLine2Position?: number;
|
|
71
|
+
showReferenceLine3?: boolean;
|
|
72
|
+
referenceLine3Config?: referenceConfigType;
|
|
73
|
+
referenceLine3Position?: number;
|
|
74
|
+
referenceLinesOverChartContent?: boolean;
|
|
75
|
+
showVerticalLines?: boolean;
|
|
76
|
+
verticalLinesUptoDataPoint?: boolean;
|
|
77
|
+
verticalLinesThickness?: number;
|
|
78
|
+
verticalLinesHeight?: number;
|
|
79
|
+
verticalLinesColor?: ColorValue;
|
|
80
|
+
verticalLinesStrokeDashArray?: number[];
|
|
81
|
+
verticalLinesShift?: number;
|
|
82
|
+
verticalLinesZIndex?: number;
|
|
83
|
+
noOfVerticalLines?: number;
|
|
84
|
+
verticalLinesSpacing?: number;
|
|
85
|
+
verticalLinesStrokeLinecap?: Linecap;
|
|
86
|
+
hideAxesAndRules?: boolean;
|
|
87
|
+
areaChart?: boolean;
|
|
88
|
+
disableScroll?: boolean;
|
|
89
|
+
showScrollIndicator?: boolean;
|
|
90
|
+
indicatorColor?: 'black' | 'default' | 'white';
|
|
91
|
+
nestedScrollEnabled?: boolean;
|
|
92
|
+
showYAxisIndices?: boolean;
|
|
93
|
+
showXAxisIndices?: boolean;
|
|
94
|
+
yAxisIndicesHeight?: number;
|
|
95
|
+
xAxisIndicesHeight?: number;
|
|
96
|
+
yAxisIndicesWidth?: number;
|
|
97
|
+
xAxisIndicesWidth?: number;
|
|
98
|
+
xAxisIndicesColor?: ColorValue;
|
|
99
|
+
yAxisIndicesColor?: ColorValue;
|
|
100
|
+
yAxisSide?: yAxisSides;
|
|
101
|
+
yAxisOffset?: number;
|
|
102
|
+
startIndex?: number;
|
|
103
|
+
endIndex?: number;
|
|
104
|
+
color?: string;
|
|
105
|
+
colors?: ColorFromToY[];
|
|
106
|
+
yAxisThickness?: number;
|
|
107
|
+
yAxisColor?: ColorValue;
|
|
108
|
+
yAxisExtraHeight?: number;
|
|
109
|
+
trimYAxisAtTop?: boolean;
|
|
110
|
+
yAxisLabelContainerStyle?: StyleProp<ViewStyle>;
|
|
111
|
+
horizontalRulesStyle?: any;
|
|
112
|
+
yAxisTextStyle?: StyleProp<TextStyle>;
|
|
113
|
+
yAxisTextNumberOfLines?: number;
|
|
114
|
+
xAxisTextNumberOfLines?: number;
|
|
115
|
+
showFractionalValues?: boolean;
|
|
116
|
+
roundToDigits?: number;
|
|
117
|
+
yAxisLabelWidth?: number;
|
|
118
|
+
hideYAxisText?: boolean;
|
|
119
|
+
floatingYAxisLabels?: boolean;
|
|
120
|
+
allowFontScaling?: boolean;
|
|
121
|
+
backgroundColor?: ColorValue;
|
|
122
|
+
customBackground?: CustomBackground;
|
|
123
|
+
horizSections?: sectionType[];
|
|
124
|
+
focusTogether?: boolean;
|
|
125
|
+
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;
|
|
146
|
+
gradientDirection?: string;
|
|
147
|
+
areaGradientComponent?: () => any;
|
|
148
|
+
areaGradientId?: string;
|
|
149
|
+
textFontSize?: number;
|
|
150
|
+
textColor?: string;
|
|
151
|
+
hideOrigin?: boolean;
|
|
152
|
+
textShiftX?: number;
|
|
153
|
+
textShiftY?: number;
|
|
154
|
+
yAxisLabelTexts?: string[];
|
|
155
|
+
xAxisLabelTexts?: string[];
|
|
156
|
+
xAxisLabelTextStyle?: StyleProp<TextStyle>;
|
|
157
|
+
xAxisLabelsHeight?: number;
|
|
158
|
+
xAxisLabelsVerticalShift?: number;
|
|
159
|
+
xAxisLabelsAtBottom?: boolean;
|
|
160
|
+
width?: number;
|
|
161
|
+
yAxisLabelPrefix?: string;
|
|
162
|
+
yAxisLabelSuffix?: string;
|
|
163
|
+
scrollRef?: any;
|
|
164
|
+
scrollToEnd?: boolean;
|
|
165
|
+
scrollToIndex?: number;
|
|
166
|
+
scrollAnimation?: boolean;
|
|
167
|
+
scrollEventThrottle?: number;
|
|
168
|
+
noOfSectionsBelowXAxis?: number;
|
|
169
|
+
labelsExtraHeight?: number;
|
|
170
|
+
adjustToWidth?: boolean;
|
|
171
|
+
getPointerProps?: Function;
|
|
172
|
+
formatYLabel?: (label: string) => string;
|
|
173
|
+
lineGradient?: boolean;
|
|
174
|
+
lineGradientComponent?: () => any;
|
|
175
|
+
lineGradientId?: string;
|
|
176
|
+
lineGradientDirection?: string;
|
|
177
|
+
lineGradientStartColor?: string;
|
|
178
|
+
lineGradientEndColor?: string;
|
|
179
|
+
onEndReached?: () => void;
|
|
180
|
+
onStartReached?: () => void;
|
|
181
|
+
endReachedOffset?: number;
|
|
182
|
+
onScroll?: Function;
|
|
183
|
+
onMomentumScrollEnd?: Function;
|
|
184
|
+
bounces?: boolean;
|
|
185
|
+
overScrollMode?: 'auto' | 'always' | 'never';
|
|
186
|
+
onScrollEndDrag?: (event: any, direction: any) => void;
|
|
187
|
+
showDataPointsForMissingValues?: boolean;
|
|
188
|
+
interpolateMissingValues?: boolean;
|
|
189
|
+
extrapolateMissingValues?: boolean;
|
|
190
|
+
onlyPositive?: boolean;
|
|
191
|
+
parentWidth?: number;
|
|
192
|
+
onChartAreaPress?: (event: GestureResponderEvent) => void;
|
|
193
|
+
onBackgroundPress?: (event: GestureResponderEvent) => void;
|
|
194
|
+
secondaryXAxis?: XAxisConfig;
|
|
195
|
+
renderTooltip?: Function;
|
|
196
|
+
renderTooltipSecondary?: Function;
|
|
197
|
+
dataPointLabelComponent?: Function;
|
|
198
|
+
focusedDataPointLabelComponent?: Function;
|
|
199
|
+
spreadAreaData?: SpreadData[];
|
|
200
|
+
spreadAreaColor?: ColorValue;
|
|
201
|
+
spreadAreaOpacity?: number;
|
|
202
|
+
borderWidth?: number;
|
|
203
|
+
borderColor?: ColorValue;
|
|
204
|
+
}
|
|
205
|
+
export interface bubbleDataItem {
|
|
206
|
+
y: number;
|
|
207
|
+
label?: string;
|
|
208
|
+
labelComponent?: Function;
|
|
209
|
+
labelTextStyle?: StyleProp<TextStyle>;
|
|
210
|
+
secondaryLabel?: string;
|
|
211
|
+
secondaryLabelComponent?: Function;
|
|
212
|
+
secondaryLabelTextStyle?: StyleProp<TextStyle>;
|
|
213
|
+
dataPointText?: string;
|
|
214
|
+
textShiftX?: number;
|
|
215
|
+
textShiftY?: number;
|
|
216
|
+
textColor?: string;
|
|
217
|
+
textFontSize?: number;
|
|
218
|
+
spacing?: number;
|
|
219
|
+
hideDataPoint?: boolean;
|
|
220
|
+
dataPointHeight?: number;
|
|
221
|
+
dataPointWidth?: number;
|
|
222
|
+
r?: number;
|
|
223
|
+
dataPointColor?: string;
|
|
224
|
+
dataPointShape?: string;
|
|
225
|
+
customDataPoint?: Function;
|
|
226
|
+
stripHeight?: number;
|
|
227
|
+
stripWidth?: number;
|
|
228
|
+
stripColor?: ColorValue | string | any;
|
|
229
|
+
stripOpacity?: number;
|
|
230
|
+
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;
|
|
242
|
+
showStrip?: boolean;
|
|
243
|
+
showVerticalLine?: boolean;
|
|
244
|
+
verticalLineHeight?: number;
|
|
245
|
+
verticalLineUptoDataPoint?: boolean;
|
|
246
|
+
verticalLineColor?: ColorValue;
|
|
247
|
+
verticalLineThickness?: number;
|
|
248
|
+
verticalLineStrokeDashArray?: number[];
|
|
249
|
+
verticalLineShift?: number;
|
|
250
|
+
verticalLineZIndex?: number;
|
|
251
|
+
verticalLineSpacing?: number;
|
|
252
|
+
verticalLineStrokeLinecap?: Linecap;
|
|
253
|
+
pointerShiftX?: number;
|
|
254
|
+
pointerShiftY?: number;
|
|
255
|
+
onPress?: Function;
|
|
256
|
+
onContextMenu?: Function;
|
|
257
|
+
onMouseEnter?: Function;
|
|
258
|
+
onMouseLeave?: Function;
|
|
259
|
+
showXAxisIndex?: boolean;
|
|
260
|
+
hidePointer?: boolean;
|
|
261
|
+
x?: number;
|
|
262
|
+
borderWidth?: number;
|
|
263
|
+
borderColor?: ColorValue;
|
|
264
|
+
opacity?: number;
|
|
265
|
+
}
|
|
266
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|