gifted-charts-core 0.1.3 → 0.1.5
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/package.json +1 -1
- package/src/BarChart/index.d.ts +2 -1
- package/src/BarChart/index.js +108 -101
- package/src/BarChart/index.ts +45 -31
- package/src/BarChart/types.d.ts +2 -0
- package/src/BarChart/types.ts +3 -0
- package/src/LineChart/index.js +2 -1
- package/src/LineChart/index.ts +2 -1
- package/src/LineChart/types.d.ts +1 -0
- package/src/LineChart/types.ts +1 -0
- package/src/PieChart/pro.js +1 -1
- package/src/PieChart/pro.ts +1 -1
- package/src/utils/types.d.ts +1 -0
- package/src/utils/types.ts +1 -0
package/package.json
CHANGED
package/src/BarChart/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface extendedBarChartPropsType extends BarChartPropsType {
|
|
|
8
8
|
opacValue?: Animated.Value;
|
|
9
9
|
verticalLinesUptoDataPoint?: boolean;
|
|
10
10
|
secondaryYAxis?: secondaryYAxisType | boolean;
|
|
11
|
+
screenWidth?: number;
|
|
11
12
|
}
|
|
12
13
|
export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
13
14
|
lineConfig: lineConfigType;
|
|
@@ -125,7 +126,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
125
126
|
spacing: any;
|
|
126
127
|
propSpacing: number;
|
|
127
128
|
xAxisThickness: number;
|
|
128
|
-
barWidth: number
|
|
129
|
+
barWidth: number;
|
|
129
130
|
opacity: number;
|
|
130
131
|
disablePress: any;
|
|
131
132
|
rotateLabel: boolean;
|
package/src/BarChart/index.js
CHANGED
|
@@ -29,25 +29,13 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
29
29
|
import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPadding, getLineConfigForBarChart, getMaxValue, getNoOfSections, getSecondaryDataWithOffsetIncluded, getXForLineInBar, getYForLineInBar, maxAndMinUtil, svgPath } from '../utils';
|
|
30
30
|
import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
|
|
31
31
|
export var useBarChart = function (props) {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46;
|
|
33
|
-
var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset;
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47;
|
|
33
|
+
var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, _48 = props.screenWidth, screenWidth = _48 === void 0 ? 300 : _48;
|
|
34
|
+
var _49 = __read(useState(''), 2), points = _49[0], setPoints = _49[1];
|
|
35
|
+
var _50 = __read(useState(''), 2), points2 = _50[0], setPoints2 = _50[1];
|
|
36
|
+
var _51 = __read(useState(''), 2), arrowPoints = _51[0], setArrowPoints = _51[1];
|
|
37
|
+
var _52 = __read(useState(-1), 2), selectedIndex = _52[0], setSelectedIndex = _52[1];
|
|
38
38
|
var showLine = (_a = props.showLine) !== null && _a !== void 0 ? _a : BarDefaults.showLine;
|
|
39
|
-
var spacing = (_b = props.spacing) !== null && _b !== void 0 ? _b : BarDefaults.spacing;
|
|
40
|
-
var initialSpacing = (_c = props.initialSpacing) !== null && _c !== void 0 ? _c : spacing;
|
|
41
|
-
var endSpacing = (_d = props.endSpacing) !== null && _d !== void 0 ? _d : spacing;
|
|
42
|
-
var showFractionalValues = (_e = props.showFractionalValues) !== null && _e !== void 0 ? _e : AxesAndRulesDefaults.showFractionalValues;
|
|
43
|
-
var horizontal = (_f = props.horizontal) !== null && _f !== void 0 ? _f : BarDefaults.horizontal;
|
|
44
|
-
var rtl = (_g = props.rtl) !== null && _g !== void 0 ? _g : BarDefaults.rtl;
|
|
45
|
-
var yAxisAtTop = (_h = props.yAxisAtTop) !== null && _h !== void 0 ? _h : BarDefaults.yAxisAtTop;
|
|
46
|
-
var intactTopLabel = (_j = props.intactTopLabel) !== null && _j !== void 0 ? _j : BarDefaults.intactTopLabel;
|
|
47
|
-
var heightFromProps = horizontal ? props.width : props.height;
|
|
48
|
-
var widthFromProps = horizontal ? props.height : props.width;
|
|
49
|
-
var isAnimated = (_k = props.isAnimated) !== null && _k !== void 0 ? _k : BarDefaults.isAnimated;
|
|
50
|
-
var animationDuration = (_l = props.animationDuration) !== null && _l !== void 0 ? _l : BarDefaults.animationDuration;
|
|
51
39
|
var data = useMemo(function () {
|
|
52
40
|
if (!props.data) {
|
|
53
41
|
return [];
|
|
@@ -60,6 +48,26 @@ export var useBarChart = function (props) {
|
|
|
60
48
|
}
|
|
61
49
|
return props.data;
|
|
62
50
|
}, [yAxisOffset, props.data]);
|
|
51
|
+
var yAxisLabelWidth = (_b = props.yAxisLabelWidth) !== null && _b !== void 0 ? _b : (props.hideYAxisText
|
|
52
|
+
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
53
|
+
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
54
|
+
var autoComputedSectionWidth = (screenWidth - yAxisLabelWidth) / (data.length + 1);
|
|
55
|
+
var autoComputedBarWidth = autoComputedSectionWidth * .6;
|
|
56
|
+
var defaultBarWidth = adjustToWidth ? autoComputedBarWidth : BarDefaults.barWidth;
|
|
57
|
+
var barWidth = (_c = props.barWidth) !== null && _c !== void 0 ? _c : defaultBarWidth;
|
|
58
|
+
var autoComputedSpacing = autoComputedSectionWidth * .4;
|
|
59
|
+
var spacing = (_d = props.spacing) !== null && _d !== void 0 ? _d : (adjustToWidth ? autoComputedSpacing : BarDefaults.spacing);
|
|
60
|
+
var initialSpacing = (_e = props.initialSpacing) !== null && _e !== void 0 ? _e : spacing;
|
|
61
|
+
var endSpacing = (_f = props.endSpacing) !== null && _f !== void 0 ? _f : spacing;
|
|
62
|
+
var showFractionalValues = (_g = props.showFractionalValues) !== null && _g !== void 0 ? _g : AxesAndRulesDefaults.showFractionalValues;
|
|
63
|
+
var horizontal = (_h = props.horizontal) !== null && _h !== void 0 ? _h : BarDefaults.horizontal;
|
|
64
|
+
var rtl = (_j = props.rtl) !== null && _j !== void 0 ? _j : BarDefaults.rtl;
|
|
65
|
+
var yAxisAtTop = (_k = props.yAxisAtTop) !== null && _k !== void 0 ? _k : BarDefaults.yAxisAtTop;
|
|
66
|
+
var intactTopLabel = (_l = props.intactTopLabel) !== null && _l !== void 0 ? _l : BarDefaults.intactTopLabel;
|
|
67
|
+
var heightFromProps = horizontal ? props.width : props.height;
|
|
68
|
+
var widthFromProps = horizontal ? props.height : props.width;
|
|
69
|
+
var isAnimated = (_m = props.isAnimated) !== null && _m !== void 0 ? _m : BarDefaults.isAnimated;
|
|
70
|
+
var animationDuration = (_o = props.animationDuration) !== null && _o !== void 0 ? _o : BarDefaults.animationDuration;
|
|
63
71
|
var secondaryData = getSecondaryDataWithOffsetIncluded(props.secondaryData, props.secondaryYAxis);
|
|
64
72
|
var lineData = useMemo(function () {
|
|
65
73
|
var _a;
|
|
@@ -75,7 +83,7 @@ export var useBarChart = function (props) {
|
|
|
75
83
|
return props.lineData;
|
|
76
84
|
}, [yAxisOffset, props.lineData, data, props.stackData]);
|
|
77
85
|
var lineData2 = props.lineData2;
|
|
78
|
-
var lineBehindBars = (
|
|
86
|
+
var lineBehindBars = (_p = props.lineBehindBars) !== null && _p !== void 0 ? _p : BarDefaults.lineBehindBars;
|
|
79
87
|
defaultLineConfig.initialSpacing = initialSpacing;
|
|
80
88
|
defaultLineConfig.endIndex = lineData.length - 1;
|
|
81
89
|
defaultLineConfig.animationDuration = animationDuration;
|
|
@@ -90,12 +98,12 @@ export var useBarChart = function (props) {
|
|
|
90
98
|
? props.stepHeight * noOfSections
|
|
91
99
|
: AxesAndRulesDefaults.containerHeight);
|
|
92
100
|
var horizSections = [{ value: '0' }];
|
|
93
|
-
var stepHeight = (
|
|
94
|
-
var labelWidth = (
|
|
95
|
-
var scrollToEnd = (
|
|
96
|
-
var scrollAnimation = (
|
|
97
|
-
var scrollEventThrottle = (
|
|
98
|
-
var labelsExtraHeight = (
|
|
101
|
+
var stepHeight = (_q = props.stepHeight) !== null && _q !== void 0 ? _q : containerHeight / noOfSections;
|
|
102
|
+
var labelWidth = (_r = props.labelWidth) !== null && _r !== void 0 ? _r : AxesAndRulesDefaults.labelWidth;
|
|
103
|
+
var scrollToEnd = (_s = props.scrollToEnd) !== null && _s !== void 0 ? _s : BarDefaults.scrollToEnd;
|
|
104
|
+
var scrollAnimation = (_t = props.scrollAnimation) !== null && _t !== void 0 ? _t : BarDefaults.scrollAnimation;
|
|
105
|
+
var scrollEventThrottle = (_u = props.scrollEventThrottle) !== null && _u !== void 0 ? _u : BarDefaults.scrollEventThrottle;
|
|
106
|
+
var labelsExtraHeight = (_v = props.labelsExtraHeight) !== null && _v !== void 0 ? _v : AxesAndRulesDefaults.labelsExtraHeight;
|
|
99
107
|
var totalWidth = initialSpacing;
|
|
100
108
|
var maxItem = 0;
|
|
101
109
|
var minItem = 0;
|
|
@@ -111,7 +119,7 @@ export var useBarChart = function (props) {
|
|
|
111
119
|
minItem = stackSumMin;
|
|
112
120
|
}
|
|
113
121
|
totalWidth +=
|
|
114
|
-
((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b :
|
|
122
|
+
((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) + spacing;
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
else {
|
|
@@ -124,7 +132,7 @@ export var useBarChart = function (props) {
|
|
|
124
132
|
minItem = item.value;
|
|
125
133
|
}
|
|
126
134
|
totalWidth +=
|
|
127
|
-
((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b :
|
|
135
|
+
((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
|
|
128
136
|
((_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
129
137
|
});
|
|
130
138
|
}
|
|
@@ -145,78 +153,76 @@ export var useBarChart = function (props) {
|
|
|
145
153
|
var secondaryMaxAndMin = maxAndMinUtil(secondaryMaxItem, secondaryMinItem, props.roundToDigits, props.showFractionalValues);
|
|
146
154
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxAndMin.maxItem);
|
|
147
155
|
var secondaryMaxValue = lineConfig.isSecondary
|
|
148
|
-
?
|
|
156
|
+
? typeof props.secondaryYAxis !== 'boolean'
|
|
157
|
+
? (_w = props.secondaryYAxis.maxValue) !== null && _w !== void 0 ? _w : secondaryMaxAndMin.maxItem
|
|
158
|
+
: secondaryMaxAndMin.maxItem
|
|
149
159
|
: maxValue;
|
|
150
|
-
var mostNegativeValue = (
|
|
151
|
-
var stepValue = (
|
|
152
|
-
var noOfSectionsBelowXAxis = (
|
|
153
|
-
var showScrollIndicator = (
|
|
154
|
-
var side = (
|
|
155
|
-
var rotateLabel = (
|
|
156
|
-
var opacity = (
|
|
157
|
-
var isThreeD = (
|
|
158
|
-
var showXAxisIndices = (
|
|
159
|
-
var xAxisIndicesHeight = (
|
|
160
|
-
var xAxisIndicesWidth = (
|
|
161
|
-
var xAxisIndicesColor = (
|
|
162
|
-
var xAxisThickness = (
|
|
163
|
-
var xAxisTextNumberOfLines = (
|
|
164
|
-
var xAxisLabelsVerticalShift = (
|
|
160
|
+
var mostNegativeValue = (_x = props.mostNegativeValue) !== null && _x !== void 0 ? _x : maxAndMin.minItem;
|
|
161
|
+
var stepValue = (_y = props.stepValue) !== null && _y !== void 0 ? _y : maxValue / noOfSections;
|
|
162
|
+
var noOfSectionsBelowXAxis = (_z = props.noOfSectionsBelowXAxis) !== null && _z !== void 0 ? _z : -mostNegativeValue / stepValue;
|
|
163
|
+
var showScrollIndicator = (_0 = props.showScrollIndicator) !== null && _0 !== void 0 ? _0 : BarDefaults.showScrollIndicator;
|
|
164
|
+
var side = (_1 = props.side) !== null && _1 !== void 0 ? _1 : BarDefaults.side;
|
|
165
|
+
var rotateLabel = (_2 = props.rotateLabel) !== null && _2 !== void 0 ? _2 : AxesAndRulesDefaults.rotateLabel;
|
|
166
|
+
var opacity = (_3 = props.opacity) !== null && _3 !== void 0 ? _3 : BarDefaults.opacity;
|
|
167
|
+
var isThreeD = (_4 = props.isThreeD) !== null && _4 !== void 0 ? _4 : BarDefaults.isThreeD;
|
|
168
|
+
var showXAxisIndices = (_5 = props.showXAxisIndices) !== null && _5 !== void 0 ? _5 : AxesAndRulesDefaults.showXAxisIndices;
|
|
169
|
+
var xAxisIndicesHeight = (_6 = props.xAxisIndicesHeight) !== null && _6 !== void 0 ? _6 : AxesAndRulesDefaults.xAxisIndicesHeight;
|
|
170
|
+
var xAxisIndicesWidth = (_7 = props.xAxisIndicesWidth) !== null && _7 !== void 0 ? _7 : AxesAndRulesDefaults.xAxisIndicesWidth;
|
|
171
|
+
var xAxisIndicesColor = (_8 = props.xAxisIndicesColor) !== null && _8 !== void 0 ? _8 : AxesAndRulesDefaults.xAxisIndicesColor;
|
|
172
|
+
var xAxisThickness = (_9 = props.xAxisThickness) !== null && _9 !== void 0 ? _9 : AxesAndRulesDefaults.xAxisThickness;
|
|
173
|
+
var xAxisTextNumberOfLines = (_10 = props.xAxisTextNumberOfLines) !== null && _10 !== void 0 ? _10 : AxesAndRulesDefaults.xAxisTextNumberOfLines;
|
|
174
|
+
var xAxisLabelsVerticalShift = (_11 = props.xAxisLabelsVerticalShift) !== null && _11 !== void 0 ? _11 : AxesAndRulesDefaults.xAxisLabelsVerticalShift;
|
|
165
175
|
var horizontalRulesStyle = props.horizontalRulesStyle;
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
: AxesAndRulesDefaults.yAxisLabelWidth);
|
|
169
|
-
var autoShiftLabels = (_10 = props.autoShiftLabels) !== null && _10 !== void 0 ? _10 : false;
|
|
170
|
-
var barWidth = (_11 = props.barWidth) !== null && _11 !== void 0 ? _11 : BarDefaults.barWidth;
|
|
171
|
-
var barBorderColor = (_12 = props.barBorderColor) !== null && _12 !== void 0 ? _12 : BarDefaults.barBorderColor;
|
|
176
|
+
var autoShiftLabels = (_12 = props.autoShiftLabels) !== null && _12 !== void 0 ? _12 : false;
|
|
177
|
+
var barBorderColor = (_13 = props.barBorderColor) !== null && _13 !== void 0 ? _13 : BarDefaults.barBorderColor;
|
|
172
178
|
var extendedContainerHeight = getExtendedContainerHeightWithPadding(containerHeight, 0);
|
|
173
179
|
var containerHeightIncludingBelowXAxis = extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight;
|
|
174
|
-
var
|
|
175
|
-
var
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
+
var _53 = __read(useState(-1), 2), pointerIndex = _53[0], setPointerIndex = _53[1];
|
|
181
|
+
var _54 = __read(useState(0), 2), pointerX = _54[0], setPointerX = _54[1];
|
|
182
|
+
var _55 = __read(useState(0), 2), pointerY = _55[0], setPointerY = _55[1];
|
|
183
|
+
var _56 = __read(useState(), 2), pointerItem = _56[0], setPointerItem = _56[1];
|
|
184
|
+
var _57 = __read(useState(0), 2), responderStartTime = _57[0], setResponderStartTime = _57[1];
|
|
185
|
+
var _58 = __read(useState(false), 2), responderActive = _58[0], setResponderActive = _58[1];
|
|
180
186
|
var pointerConfig = props.pointerConfig;
|
|
181
|
-
var getPointerProps = (
|
|
182
|
-
var pointerHeight = (
|
|
183
|
-
var pointerWidth = (
|
|
184
|
-
var pointerRadius = (
|
|
185
|
-
var pointerColor = (
|
|
186
|
-
var pointerComponent = (
|
|
187
|
+
var getPointerProps = (_14 = props.getPointerProps) !== null && _14 !== void 0 ? _14 : null;
|
|
188
|
+
var pointerHeight = (_15 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.height) !== null && _15 !== void 0 ? _15 : defaultPointerConfig.height;
|
|
189
|
+
var pointerWidth = (_16 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.width) !== null && _16 !== void 0 ? _16 : defaultPointerConfig.width;
|
|
190
|
+
var pointerRadius = (_17 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.radius) !== null && _17 !== void 0 ? _17 : defaultPointerConfig.radius;
|
|
191
|
+
var pointerColor = (_18 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerColor) !== null && _18 !== void 0 ? _18 : defaultPointerConfig.pointerColor;
|
|
192
|
+
var pointerComponent = (_19 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerComponent) !== null && _19 !== void 0 ? _19 : defaultPointerConfig.pointerComponent;
|
|
187
193
|
var showPointerStrip = (pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.showPointerStrip) === false
|
|
188
194
|
? false
|
|
189
195
|
: defaultPointerConfig.showPointerStrip;
|
|
190
|
-
var pointerStripHeight = (
|
|
191
|
-
var pointerStripWidth = (
|
|
192
|
-
var pointerStripColor = (
|
|
193
|
-
var pointerStripUptoDataPoint = (
|
|
194
|
-
var pointerLabelComponent = (
|
|
195
|
-
var stripOverPointer = (
|
|
196
|
-
var shiftPointerLabelX = (
|
|
197
|
-
var shiftPointerLabelY = (
|
|
198
|
-
var pointerLabelWidth = (
|
|
199
|
-
var pointerLabelHeight = (
|
|
200
|
-
var autoAdjustPointerLabelPosition = (
|
|
201
|
-
var pointerVanishDelay = (
|
|
202
|
-
var activatePointersOnLongPress = (
|
|
203
|
-
var activatePointersDelay = (
|
|
204
|
-
var initialPointerIndex = (
|
|
205
|
-
var initialPointerAppearDelay = (
|
|
196
|
+
var pointerStripHeight = (_20 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripHeight) !== null && _20 !== void 0 ? _20 : defaultPointerConfig.pointerStripHeight;
|
|
197
|
+
var pointerStripWidth = (_21 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripWidth) !== null && _21 !== void 0 ? _21 : defaultPointerConfig.pointerStripWidth;
|
|
198
|
+
var pointerStripColor = (_22 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripColor) !== null && _22 !== void 0 ? _22 : defaultPointerConfig.pointerStripColor;
|
|
199
|
+
var pointerStripUptoDataPoint = (_23 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerStripUptoDataPoint) !== null && _23 !== void 0 ? _23 : defaultPointerConfig.pointerStripUptoDataPoint;
|
|
200
|
+
var pointerLabelComponent = (_24 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelComponent) !== null && _24 !== void 0 ? _24 : defaultPointerConfig.pointerLabelComponent;
|
|
201
|
+
var stripOverPointer = (_25 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripOverPointer) !== null && _25 !== void 0 ? _25 : defaultPointerConfig.stripOverPointer;
|
|
202
|
+
var shiftPointerLabelX = (_26 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelX) !== null && _26 !== void 0 ? _26 : defaultPointerConfig.shiftPointerLabelX;
|
|
203
|
+
var shiftPointerLabelY = (_27 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.shiftPointerLabelY) !== null && _27 !== void 0 ? _27 : defaultPointerConfig.shiftPointerLabelY;
|
|
204
|
+
var pointerLabelWidth = (_28 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelWidth) !== null && _28 !== void 0 ? _28 : defaultPointerConfig.pointerLabelWidth;
|
|
205
|
+
var pointerLabelHeight = (_29 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerLabelHeight) !== null && _29 !== void 0 ? _29 : defaultPointerConfig.pointerLabelHeight;
|
|
206
|
+
var autoAdjustPointerLabelPosition = (_30 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.autoAdjustPointerLabelPosition) !== null && _30 !== void 0 ? _30 : defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
207
|
+
var pointerVanishDelay = (_31 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerVanishDelay) !== null && _31 !== void 0 ? _31 : defaultPointerConfig.pointerVanishDelay;
|
|
208
|
+
var activatePointersOnLongPress = (_32 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersOnLongPress) !== null && _32 !== void 0 ? _32 : defaultPointerConfig.activatePointersOnLongPress;
|
|
209
|
+
var activatePointersDelay = (_33 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.activatePointersDelay) !== null && _33 !== void 0 ? _33 : defaultPointerConfig.activatePointersDelay;
|
|
210
|
+
var initialPointerIndex = (_34 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerIndex) !== null && _34 !== void 0 ? _34 : defaultPointerConfig.initialPointerIndex;
|
|
211
|
+
var initialPointerAppearDelay = (_35 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.initialPointerAppearDelay) !== null && _35 !== void 0 ? _35 : (isAnimated
|
|
206
212
|
? animationDuration
|
|
207
213
|
: defaultPointerConfig.initialPointerAppearDelay);
|
|
208
|
-
var persistPointer = (
|
|
209
|
-
var hidePointer1 = (
|
|
214
|
+
var persistPointer = (_36 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.persistPointer) !== null && _36 !== void 0 ? _36 : defaultPointerConfig.persistPointer;
|
|
215
|
+
var hidePointer1 = (_37 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.hidePointer1) !== null && _37 !== void 0 ? _37 : defaultPointerConfig.hidePointer1;
|
|
210
216
|
var pointerEvents = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.pointerEvents;
|
|
211
|
-
var stripBehindBars = (
|
|
212
|
-
var disableScroll = (
|
|
217
|
+
var stripBehindBars = (_38 = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.stripBehindBars) !== null && _38 !== void 0 ? _38 : defaultPointerConfig.stripBehindBars;
|
|
218
|
+
var disableScroll = (_39 = props.disableScroll) !== null && _39 !== void 0 ? _39 : (pointerConfig
|
|
213
219
|
? activatePointersOnLongPress
|
|
214
220
|
? !!responderActive
|
|
215
221
|
: true
|
|
216
222
|
: false);
|
|
217
223
|
var yAxisExtraHeightAtTop = props.trimYAxisAtTop
|
|
218
224
|
? 0
|
|
219
|
-
: (
|
|
225
|
+
: (_40 = props.yAxisExtraHeight) !== null && _40 !== void 0 ? _40 : containerHeight / 20;
|
|
220
226
|
var barInnerComponent = props.barInnerComponent;
|
|
221
227
|
useEffect(function () {
|
|
222
228
|
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;
|
|
@@ -230,7 +236,7 @@ export var useBarChart = function (props) {
|
|
|
230
236
|
i > ((_f = lineConfig.endIndex) !== null && _f !== void 0 ? _f : 0)) {
|
|
231
237
|
continue;
|
|
232
238
|
}
|
|
233
|
-
var currentBarWidth = (_j = (_h = (_g = data === null || data === void 0 ? void 0 : data[i]) === null || _g === void 0 ? void 0 : _g.barWidth) !== null && _h !== void 0 ? _h : props.barWidth) !== null && _j !== void 0 ? _j :
|
|
239
|
+
var currentBarWidth = (_j = (_h = (_g = data === null || data === void 0 ? void 0 : data[i]) === null || _g === void 0 ? void 0 : _g.barWidth) !== null && _h !== void 0 ? _h : props.barWidth) !== null && _j !== void 0 ? _j : defaultBarWidth;
|
|
234
240
|
var currentValue = props.lineData
|
|
235
241
|
? props.lineData[i].value
|
|
236
242
|
: props.stackData
|
|
@@ -261,7 +267,7 @@ export var useBarChart = function (props) {
|
|
|
261
267
|
i > ((_p = lineConfig.endIndex) !== null && _p !== void 0 ? _p : 0)) {
|
|
262
268
|
continue;
|
|
263
269
|
}
|
|
264
|
-
var currentBarWidth = (_s = (_r = (_q = data === null || data === void 0 ? void 0 : data[i]) === null || _q === void 0 ? void 0 : _q.barWidth) !== null && _r !== void 0 ? _r : props.barWidth) !== null && _s !== void 0 ? _s :
|
|
270
|
+
var currentBarWidth = (_s = (_r = (_q = data === null || data === void 0 ? void 0 : data[i]) === null || _q === void 0 ? void 0 : _q.barWidth) !== null && _r !== void 0 ? _r : props.barWidth) !== null && _s !== void 0 ? _s : defaultBarWidth;
|
|
265
271
|
var currentValue = props.lineData
|
|
266
272
|
? props.lineData[i].value
|
|
267
273
|
: props.stackData
|
|
@@ -282,7 +288,7 @@ export var useBarChart = function (props) {
|
|
|
282
288
|
i > ((_u = lineConfig2.endIndex) !== null && _u !== void 0 ? _u : 0)) {
|
|
283
289
|
continue;
|
|
284
290
|
}
|
|
285
|
-
var currentBarWidth = (_x = (_w = (_v = data === null || data === void 0 ? void 0 : data[i]) === null || _v === void 0 ? void 0 : _v.barWidth) !== null && _w !== void 0 ? _w : props.barWidth) !== null && _x !== void 0 ? _x :
|
|
291
|
+
var currentBarWidth = (_x = (_w = (_v = data === null || data === void 0 ? void 0 : data[i]) === null || _v === void 0 ? void 0 : _v.barWidth) !== null && _w !== void 0 ? _w : props.barWidth) !== null && _x !== void 0 ? _x : defaultBarWidth;
|
|
286
292
|
var currentValue = lineData2[i].value;
|
|
287
293
|
pp2 +=
|
|
288
294
|
'L' +
|
|
@@ -300,7 +306,7 @@ export var useBarChart = function (props) {
|
|
|
300
306
|
i > ((_z = lineConfig2.endIndex) !== null && _z !== void 0 ? _z : 0)) {
|
|
301
307
|
continue;
|
|
302
308
|
}
|
|
303
|
-
var currentBarWidth = (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data[i]) === null || _0 === void 0 ? void 0 : _0.barWidth) !== null && _1 !== void 0 ? _1 : props.barWidth) !== null && _2 !== void 0 ? _2 :
|
|
309
|
+
var currentBarWidth = (_2 = (_1 = (_0 = data === null || data === void 0 ? void 0 : data[i]) === null || _0 === void 0 ? void 0 : _0.barWidth) !== null && _1 !== void 0 ? _1 : props.barWidth) !== null && _2 !== void 0 ? _2 : defaultBarWidth;
|
|
304
310
|
var currentValue = lineData2[i].value;
|
|
305
311
|
p2Array.push([
|
|
306
312
|
getXForLineInBar(i, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig2, spacing),
|
|
@@ -332,9 +338,9 @@ export var useBarChart = function (props) {
|
|
|
332
338
|
spacing,
|
|
333
339
|
yAxisLabelWidth,
|
|
334
340
|
lineConfig.showArrow,
|
|
335
|
-
(
|
|
336
|
-
(
|
|
337
|
-
(
|
|
341
|
+
(_41 = lineConfig.arrowConfig) === null || _41 === void 0 ? void 0 : _41.length,
|
|
342
|
+
(_42 = lineConfig.arrowConfig) === null || _42 === void 0 ? void 0 : _42.width,
|
|
343
|
+
(_43 = lineConfig.arrowConfig) === null || _43 === void 0 ? void 0 : _43.showArrowBase
|
|
338
344
|
]);
|
|
339
345
|
useEffect(function () {
|
|
340
346
|
var _a, _b, _c, _d;
|
|
@@ -380,7 +386,7 @@ export var useBarChart = function (props) {
|
|
|
380
386
|
outputRange: [0, initialSpacing + totalWidth + endSpacing]
|
|
381
387
|
});
|
|
382
388
|
var getPropsCommonForBarAndStack = function (item, index) {
|
|
383
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
389
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
384
390
|
return {
|
|
385
391
|
key: index,
|
|
386
392
|
item: item,
|
|
@@ -390,9 +396,9 @@ export var useBarChart = function (props) {
|
|
|
390
396
|
spacing: (_a = item.spacing) !== null && _a !== void 0 ? _a : spacing,
|
|
391
397
|
propSpacing: spacing,
|
|
392
398
|
xAxisThickness: xAxisThickness,
|
|
393
|
-
barWidth: props.barWidth,
|
|
399
|
+
barWidth: (_b = props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth,
|
|
394
400
|
opacity: opacity,
|
|
395
|
-
disablePress: (
|
|
401
|
+
disablePress: (_c = item.disablePress) !== null && _c !== void 0 ? _c : props.disablePress,
|
|
396
402
|
rotateLabel: rotateLabel,
|
|
397
403
|
showXAxisIndices: showXAxisIndices,
|
|
398
404
|
xAxisIndicesHeight: xAxisIndicesHeight,
|
|
@@ -426,15 +432,15 @@ export var useBarChart = function (props) {
|
|
|
426
432
|
xAxisLabelsHeight: props.xAxisLabelsHeight,
|
|
427
433
|
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
428
434
|
renderTooltip: props.renderTooltip,
|
|
429
|
-
leftShiftForTooltip: (
|
|
435
|
+
leftShiftForTooltip: (_d = props.leftShiftForTooltip) !== null && _d !== void 0 ? _d : 0,
|
|
430
436
|
initialSpacing: initialSpacing,
|
|
431
437
|
selectedIndex: selectedIndex,
|
|
432
438
|
setSelectedIndex: setSelectedIndex,
|
|
433
|
-
activeOpacity: (
|
|
439
|
+
activeOpacity: (_e = props.activeOpacity) !== null && _e !== void 0 ? _e : 0.2,
|
|
434
440
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
|
435
|
-
leftShiftForLastIndexTooltip: (
|
|
436
|
-
label: (
|
|
437
|
-
labelTextStyle: (
|
|
441
|
+
leftShiftForLastIndexTooltip: (_f = props.leftShiftForLastIndexTooltip) !== null && _f !== void 0 ? _f : 0,
|
|
442
|
+
label: (_g = item.label) !== null && _g !== void 0 ? _g : (((_h = props.xAxisLabelTexts) === null || _h === void 0 ? void 0 : _h[index]) ? props.xAxisLabelTexts[index] : ''),
|
|
443
|
+
labelTextStyle: (_j = item.labelTextStyle) !== null && _j !== void 0 ? _j : props.xAxisLabelTextStyle,
|
|
438
444
|
pointerConfig: pointerConfig,
|
|
439
445
|
yAxisExtraHeightAtTop: yAxisExtraHeightAtTop,
|
|
440
446
|
yAxisOffset: yAxisOffset !== null && yAxisOffset !== void 0 ? yAxisOffset : 0
|
|
@@ -449,14 +455,14 @@ export var useBarChart = function (props) {
|
|
|
449
455
|
yAxisLabelWidth: yAxisLabelWidth,
|
|
450
456
|
horizontal: horizontal,
|
|
451
457
|
rtl: rtl,
|
|
452
|
-
shiftX: (
|
|
453
|
-
shiftY: (
|
|
458
|
+
shiftX: (_44 = props.shiftX) !== null && _44 !== void 0 ? _44 : 0,
|
|
459
|
+
shiftY: (_45 = props.shiftY) !== null && _45 !== void 0 ? _45 : 0,
|
|
454
460
|
yAxisAtTop: yAxisAtTop,
|
|
455
461
|
initialSpacing: initialSpacing,
|
|
456
462
|
data: data,
|
|
457
463
|
stackData: props.stackData,
|
|
458
464
|
secondaryData: secondaryData,
|
|
459
|
-
barWidth: (
|
|
465
|
+
barWidth: (_46 = props.barWidth) !== null && _46 !== void 0 ? _46 : defaultBarWidth,
|
|
460
466
|
xAxisThickness: xAxisThickness,
|
|
461
467
|
totalWidth: totalWidth,
|
|
462
468
|
disableScroll: disableScroll,
|
|
@@ -503,7 +509,8 @@ export var useBarChart = function (props) {
|
|
|
503
509
|
pointerY: pointerY,
|
|
504
510
|
onEndReached: props.onEndReached,
|
|
505
511
|
onStartReached: props.onStartReached,
|
|
506
|
-
endReachedOffset: (
|
|
512
|
+
endReachedOffset: (_47 = props.endReachedOffset) !== null && _47 !== void 0 ? _47 : BarDefaults.endReachedOffset,
|
|
513
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd
|
|
507
514
|
};
|
|
508
515
|
return {
|
|
509
516
|
lineConfig: lineConfig,
|
package/src/BarChart/index.ts
CHANGED
|
@@ -37,16 +37,45 @@ export interface extendedBarChartPropsType extends BarChartPropsType {
|
|
|
37
37
|
opacValue?: Animated.Value
|
|
38
38
|
verticalLinesUptoDataPoint?: boolean
|
|
39
39
|
secondaryYAxis?: secondaryYAxisType | boolean
|
|
40
|
+
screenWidth?: number
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
43
|
-
const { heightValue, widthValue, opacValue, yAxisOffset } = props
|
|
44
|
+
const { heightValue, widthValue, opacValue, yAxisOffset, adjustToWidth, screenWidth=300 } = props
|
|
44
45
|
const [points, setPoints] = useState('')
|
|
45
46
|
const [points2, setPoints2] = useState('')
|
|
46
47
|
const [arrowPoints, setArrowPoints] = useState('')
|
|
47
48
|
const [selectedIndex, setSelectedIndex] = useState(-1)
|
|
48
49
|
const showLine = props.showLine ?? BarDefaults.showLine
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
const data = useMemo(() => {
|
|
52
|
+
if (!props.data) {
|
|
53
|
+
return []
|
|
54
|
+
}
|
|
55
|
+
if (yAxisOffset) {
|
|
56
|
+
return props.data.map((item) => ({
|
|
57
|
+
...item,
|
|
58
|
+
value: (item.value ?? 0) - (yAxisOffset ?? 0)
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
return props.data
|
|
62
|
+
}, [yAxisOffset, props.data])
|
|
63
|
+
|
|
64
|
+
const yAxisLabelWidth =
|
|
65
|
+
props.yAxisLabelWidth ??
|
|
66
|
+
(props.hideYAxisText
|
|
67
|
+
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
68
|
+
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
69
|
+
|
|
70
|
+
const autoComputedSectionWidth = (screenWidth - yAxisLabelWidth) / (data.length + 1)
|
|
71
|
+
const autoComputedBarWidth = autoComputedSectionWidth * .6
|
|
72
|
+
|
|
73
|
+
const defaultBarWidth = adjustToWidth ? autoComputedBarWidth : BarDefaults.barWidth
|
|
74
|
+
const barWidth = props.barWidth ?? defaultBarWidth
|
|
75
|
+
|
|
76
|
+
const autoComputedSpacing = autoComputedSectionWidth * .4
|
|
77
|
+
|
|
78
|
+
const spacing = props.spacing ?? ( adjustToWidth ? autoComputedSpacing : BarDefaults.spacing)
|
|
50
79
|
const initialSpacing = props.initialSpacing ?? spacing
|
|
51
80
|
const endSpacing = props.endSpacing ?? spacing
|
|
52
81
|
const showFractionalValues =
|
|
@@ -64,18 +93,6 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
64
93
|
const animationDuration =
|
|
65
94
|
props.animationDuration ?? BarDefaults.animationDuration
|
|
66
95
|
|
|
67
|
-
const data = useMemo(() => {
|
|
68
|
-
if (!props.data) {
|
|
69
|
-
return []
|
|
70
|
-
}
|
|
71
|
-
if (yAxisOffset) {
|
|
72
|
-
return props.data.map((item) => ({
|
|
73
|
-
...item,
|
|
74
|
-
value: (item.value ?? 0) - (yAxisOffset ?? 0)
|
|
75
|
-
}))
|
|
76
|
-
}
|
|
77
|
-
return props.data
|
|
78
|
-
}, [yAxisOffset, props.data])
|
|
79
96
|
|
|
80
97
|
const secondaryData = getSecondaryDataWithOffsetIncluded(
|
|
81
98
|
props.secondaryData,
|
|
@@ -153,7 +170,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
153
170
|
totalWidth +=
|
|
154
171
|
(stackItem.stacks[0].barWidth ??
|
|
155
172
|
props.barWidth ??
|
|
156
|
-
|
|
173
|
+
defaultBarWidth) + spacing
|
|
157
174
|
})
|
|
158
175
|
} else {
|
|
159
176
|
data.forEach((item: barDataItem) => {
|
|
@@ -164,7 +181,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
164
181
|
minItem = item.value
|
|
165
182
|
}
|
|
166
183
|
totalWidth +=
|
|
167
|
-
(item.barWidth ?? props.barWidth ??
|
|
184
|
+
(item.barWidth ?? props.barWidth ?? defaultBarWidth) +
|
|
168
185
|
(item.spacing ?? spacing)
|
|
169
186
|
})
|
|
170
187
|
}
|
|
@@ -204,7 +221,10 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
204
221
|
maxAndMin.maxItem
|
|
205
222
|
)
|
|
206
223
|
const secondaryMaxValue = lineConfig.isSecondary
|
|
207
|
-
?
|
|
224
|
+
? typeof props.secondaryYAxis !== 'boolean'
|
|
225
|
+
? (props.secondaryYAxis as secondaryYAxisType).maxValue ??
|
|
226
|
+
secondaryMaxAndMin.maxItem
|
|
227
|
+
: secondaryMaxAndMin.maxItem
|
|
208
228
|
: maxValue
|
|
209
229
|
const mostNegativeValue = props.mostNegativeValue ?? maxAndMin.minItem
|
|
210
230
|
|
|
@@ -236,15 +256,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
236
256
|
props.xAxisLabelsVerticalShift ??
|
|
237
257
|
AxesAndRulesDefaults.xAxisLabelsVerticalShift
|
|
238
258
|
const horizontalRulesStyle = props.horizontalRulesStyle
|
|
239
|
-
const yAxisLabelWidth =
|
|
240
|
-
props.yAxisLabelWidth ??
|
|
241
|
-
(props.hideYAxisText
|
|
242
|
-
? AxesAndRulesDefaults.yAxisEmptyLabelWidth
|
|
243
|
-
: AxesAndRulesDefaults.yAxisLabelWidth)
|
|
244
259
|
|
|
245
260
|
const autoShiftLabels = props.autoShiftLabels ?? false
|
|
246
|
-
|
|
247
|
-
const barWidth = props.barWidth ?? BarDefaults.barWidth
|
|
248
261
|
const barBorderColor = props.barBorderColor ?? BarDefaults.barBorderColor
|
|
249
262
|
|
|
250
263
|
const extendedContainerHeight = getExtendedContainerHeightWithPadding(
|
|
@@ -354,7 +367,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
354
367
|
continue
|
|
355
368
|
}
|
|
356
369
|
const currentBarWidth =
|
|
357
|
-
data?.[i]?.barWidth ?? props.barWidth ??
|
|
370
|
+
data?.[i]?.barWidth ?? props.barWidth ?? defaultBarWidth
|
|
358
371
|
const currentValue = props.lineData
|
|
359
372
|
? props.lineData[i].value
|
|
360
373
|
: props.stackData
|
|
@@ -414,7 +427,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
414
427
|
continue
|
|
415
428
|
}
|
|
416
429
|
const currentBarWidth =
|
|
417
|
-
data?.[i]?.barWidth ?? props.barWidth ??
|
|
430
|
+
data?.[i]?.barWidth ?? props.barWidth ?? defaultBarWidth
|
|
418
431
|
const currentValue = props.lineData
|
|
419
432
|
? props.lineData[i].value
|
|
420
433
|
: props.stackData
|
|
@@ -457,7 +470,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
457
470
|
continue
|
|
458
471
|
}
|
|
459
472
|
const currentBarWidth =
|
|
460
|
-
data?.[i]?.barWidth ?? props.barWidth ??
|
|
473
|
+
data?.[i]?.barWidth ?? props.barWidth ?? defaultBarWidth
|
|
461
474
|
const currentValue = lineData2[i].value
|
|
462
475
|
pp2 +=
|
|
463
476
|
'L' +
|
|
@@ -489,7 +502,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
489
502
|
continue
|
|
490
503
|
}
|
|
491
504
|
const currentBarWidth =
|
|
492
|
-
data?.[i]?.barWidth ?? props.barWidth ??
|
|
505
|
+
data?.[i]?.barWidth ?? props.barWidth ?? defaultBarWidth
|
|
493
506
|
const currentValue = lineData2[i].value
|
|
494
507
|
p2Array.push([
|
|
495
508
|
getXForLineInBar(
|
|
@@ -606,7 +619,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
606
619
|
spacing: item.spacing ?? spacing,
|
|
607
620
|
propSpacing: spacing,
|
|
608
621
|
xAxisThickness,
|
|
609
|
-
barWidth: props.barWidth,
|
|
622
|
+
barWidth: props.barWidth ?? defaultBarWidth,
|
|
610
623
|
opacity,
|
|
611
624
|
disablePress: item.disablePress ?? props.disablePress,
|
|
612
625
|
rotateLabel,
|
|
@@ -676,7 +689,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
676
689
|
data,
|
|
677
690
|
stackData: props.stackData,
|
|
678
691
|
secondaryData,
|
|
679
|
-
barWidth: props.barWidth ??
|
|
692
|
+
barWidth: props.barWidth ?? defaultBarWidth,
|
|
680
693
|
xAxisThickness,
|
|
681
694
|
totalWidth,
|
|
682
695
|
disableScroll,
|
|
@@ -733,7 +746,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
733
746
|
|
|
734
747
|
onEndReached: props.onEndReached,
|
|
735
748
|
onStartReached: props.onStartReached,
|
|
736
|
-
endReachedOffset: props.endReachedOffset ?? BarDefaults.endReachedOffset
|
|
749
|
+
endReachedOffset: props.endReachedOffset ?? BarDefaults.endReachedOffset,
|
|
750
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd
|
|
737
751
|
}
|
|
738
752
|
|
|
739
753
|
return {
|
package/src/BarChart/types.d.ts
CHANGED
|
@@ -275,8 +275,10 @@ export interface BarChartPropsType {
|
|
|
275
275
|
onStartReached?: () => void;
|
|
276
276
|
endReachedOffset?: number;
|
|
277
277
|
onScroll?: Function;
|
|
278
|
+
onMomentumScrollEnd?: Function;
|
|
278
279
|
focusBarOnPress?: boolean;
|
|
279
280
|
focusedBarConfig?: FocusedBarConfig;
|
|
281
|
+
adjustToWidth?: boolean;
|
|
280
282
|
}
|
|
281
283
|
export interface FocusedBarConfig {
|
|
282
284
|
color?: ColorValue;
|
package/src/BarChart/types.ts
CHANGED
|
@@ -309,9 +309,12 @@ export interface BarChartPropsType {
|
|
|
309
309
|
onStartReached?: () => void
|
|
310
310
|
endReachedOffset?: number
|
|
311
311
|
onScroll?: Function
|
|
312
|
+
onMomentumScrollEnd?: Function
|
|
312
313
|
|
|
313
314
|
focusBarOnPress?: boolean
|
|
314
315
|
focusedBarConfig?: FocusedBarConfig
|
|
316
|
+
|
|
317
|
+
adjustToWidth?: boolean
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
export interface FocusedBarConfig {
|
package/src/LineChart/index.js
CHANGED
|
@@ -1076,7 +1076,8 @@ export var useLineChart = function (props) {
|
|
|
1076
1076
|
pointerY: pointerY,
|
|
1077
1077
|
onEndReached: props.onEndReached,
|
|
1078
1078
|
onStartReached: props.onStartReached,
|
|
1079
|
-
endReachedOffset: (_291 = props.endReachedOffset) !== null && _291 !== void 0 ? _291 : LineDefaults.endReachedOffset
|
|
1079
|
+
endReachedOffset: (_291 = props.endReachedOffset) !== null && _291 !== void 0 ? _291 : LineDefaults.endReachedOffset,
|
|
1080
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd
|
|
1080
1081
|
};
|
|
1081
1082
|
return {
|
|
1082
1083
|
curvature: curvature,
|
package/src/LineChart/index.ts
CHANGED
|
@@ -1787,7 +1787,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1787
1787
|
|
|
1788
1788
|
onEndReached: props.onEndReached,
|
|
1789
1789
|
onStartReached: props.onStartReached,
|
|
1790
|
-
endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset
|
|
1790
|
+
endReachedOffset: props.endReachedOffset ?? LineDefaults.endReachedOffset,
|
|
1791
|
+
onMomentumScrollEnd: props.onMomentumScrollEnd
|
|
1791
1792
|
}
|
|
1792
1793
|
|
|
1793
1794
|
return {
|
package/src/LineChart/types.d.ts
CHANGED
|
@@ -288,6 +288,7 @@ export interface LineChartPropsType {
|
|
|
288
288
|
onStartReached?: () => void;
|
|
289
289
|
endReachedOffset?: number;
|
|
290
290
|
onScroll?: Function;
|
|
291
|
+
onMomentumScrollEnd?: Function;
|
|
291
292
|
showDataPointsForMissingValues?: boolean;
|
|
292
293
|
interpolateMissingValues?: boolean;
|
|
293
294
|
onlyPositive?: boolean;
|
package/src/LineChart/types.ts
CHANGED
package/src/PieChart/pro.js
CHANGED
|
@@ -26,7 +26,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
26
26
|
import { defaultAnimationDuration } from '../utils/constants';
|
|
27
27
|
export var usePiePro = function (props) {
|
|
28
28
|
var _a, _b;
|
|
29
|
-
var data = props.data, isAnimated = props.isAnimated, donut = props.donut, semiCircle = props.semiCircle, _c = props.radius, radius = _c === void 0 ? 120 : _c, _d = props.innerRadius, innerRadius = _d === void 0 ? donut ? radius / 2.5 : 0 : _d, _e = props.strokeWidth, strokeWidth = _e === void 0 ? 0 : _e, _f = props.edgesRadius, edgesRadius = _f === void 0 ? 0 : _f, _g = props.startAngle, startAngle = _g === void 0 ? 0 : _g, ring = props.ring;
|
|
29
|
+
var data = props.data, isAnimated = props.isAnimated, donut = props.donut, semiCircle = props.semiCircle, _c = props.radius, radius = _c === void 0 ? 120 : _c, _d = props.innerRadius, innerRadius = _d === void 0 ? donut ? radius / 2.5 : 0 : _d, _e = props.strokeWidth, strokeWidth = _e === void 0 ? props.ring ? 10 : 0 : _e, _f = props.edgesRadius, edgesRadius = _f === void 0 ? 0 : _f, _g = props.startAngle, startAngle = _g === void 0 ? 0 : _g, ring = props.ring;
|
|
30
30
|
var endAngle = (_a = props.endAngle) !== null && _a !== void 0 ? _a : startAngle + Math.PI * (semiCircle ? 1 : 2);
|
|
31
31
|
var total = data.reduce(function (acc, item) { return acc + (item === null || item === void 0 ? void 0 : item.value); }, 0);
|
|
32
32
|
var animationDuration = (_b = props.animationDuration) !== null && _b !== void 0 ? _b : defaultAnimationDuration;
|
package/src/PieChart/pro.ts
CHANGED
package/src/utils/types.d.ts
CHANGED