gifted-charts-core 0.1.12 → 0.1.14
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/README.md +1 -1
- package/package.json +1 -1
- package/src/BarChart/index.d.ts +1 -1
- package/src/BarChart/index.js +9 -9
- package/src/BarChart/index.ts +9 -8
- package/src/BarChart/types.d.ts +5 -0
- package/src/BarChart/types.ts +5 -0
- package/src/LineChart/LineChartBiColor.js +3 -3
- package/src/LineChart/LineChartBiColor.ts +3 -3
- package/src/LineChart/index.js +5 -1
- package/src/LineChart/index.ts +6 -2
- package/src/LineChart/types.d.ts +6 -1
- package/src/LineChart/types.ts +7 -1
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.js +1 -1
- package/src/components/BarAndLineChartsWrapper/getHorizSectionsVals.ts +1 -1
- package/src/components/BarAndLineChartsWrapper/index.js +1 -0
- package/src/components/BarAndLineChartsWrapper/index.ts +1 -0
- package/src/utils/index.js +1 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/types.d.ts +2 -0
- package/src/utils/types.ts +2 -0
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
This library contains the common code used by [react-native-gifted-charts](https://
|
|
1
|
+
This library contains the common code used by [react-native-gifted-charts](https://www.npmjs.com/package/react-native-gifted-charts) and [react-gifted-charts](https://www.npmjs.com/package/react-gifted-charts).
|
package/package.json
CHANGED
package/src/BarChart/index.d.ts
CHANGED
|
@@ -119,7 +119,6 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
119
119
|
getPointerProps: Function | null;
|
|
120
120
|
pointerIndex: number;
|
|
121
121
|
getPropsCommonForBarAndStack: (item: any, index: number) => {
|
|
122
|
-
key: number;
|
|
123
122
|
item: any;
|
|
124
123
|
index: number;
|
|
125
124
|
containerHeight: number;
|
|
@@ -165,6 +164,7 @@ export declare const useBarChart: (props: extendedBarChartPropsType) => {
|
|
|
165
164
|
xAxisLabelsVerticalShift: number;
|
|
166
165
|
renderTooltip: Function | undefined;
|
|
167
166
|
leftShiftForTooltip: number;
|
|
167
|
+
autoCenterTooltip: boolean | undefined;
|
|
168
168
|
initialSpacing: number;
|
|
169
169
|
selectedIndex: number;
|
|
170
170
|
setSelectedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
package/src/BarChart/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import { getArrowPoints, getAxesAndRulesProps, getExtendedContainerHeightWithPad
|
|
|
30
30
|
import { AxesAndRulesDefaults, BarDefaults, chartTypes, defaultLineConfig, defaultPointerConfig } from '../utils/constants';
|
|
31
31
|
export var useBarChart = function (props) {
|
|
32
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, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue;
|
|
33
|
+
var heightValue = props.heightValue, widthValue = props.widthValue, opacValue = props.opacValue, yAxisOffset = props.yAxisOffset, adjustToWidth = props.adjustToWidth, parentWidth = props.parentWidth, labelsDistanceFromXaxis = props.labelsDistanceFromXaxis, autoShiftLabelsForNegativeStacks = props.autoShiftLabelsForNegativeStacks, focusedBarIndex = props.focusedBarIndex, negativeStepValue = props.negativeStepValue, autoCenterTooltip = props.autoCenterTooltip;
|
|
34
34
|
var _48 = __read(useState(''), 2), points = _48[0], setPoints = _48[1];
|
|
35
35
|
var _49 = __read(useState(''), 2), points2 = _49[0], setPoints2 = _49[1];
|
|
36
36
|
var _50 = __read(useState(''), 2), arrowPoints = _50[0], setArrowPoints = _50[1];
|
|
@@ -111,12 +111,12 @@ export var useBarChart = function (props) {
|
|
|
111
111
|
var scrollAnimation = (_t = props.scrollAnimation) !== null && _t !== void 0 ? _t : BarDefaults.scrollAnimation;
|
|
112
112
|
var scrollEventThrottle = (_u = props.scrollEventThrottle) !== null && _u !== void 0 ? _u : BarDefaults.scrollEventThrottle;
|
|
113
113
|
var labelsExtraHeight = (_v = props.labelsExtraHeight) !== null && _v !== void 0 ? _v : AxesAndRulesDefaults.labelsExtraHeight;
|
|
114
|
-
var totalWidth = initialSpacing;
|
|
114
|
+
var totalWidth = initialSpacing + endSpacing;
|
|
115
115
|
var maxItem = 0;
|
|
116
116
|
var minItem = 0;
|
|
117
117
|
if (props.stackData) {
|
|
118
|
-
props.stackData.forEach(function (stackItem) {
|
|
119
|
-
var _a, _b;
|
|
118
|
+
props.stackData.forEach(function (stackItem, index) {
|
|
119
|
+
var _a, _b, _c;
|
|
120
120
|
var stackSumMax = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value >= 0 ? stack.value : 0); }, 0);
|
|
121
121
|
var stackSumMin = stackItem.stacks.reduce(function (acc, stack) { return acc + (stack.value < 0 ? stack.value : 0); }, 0);
|
|
122
122
|
if (stackSumMax > maxItem) {
|
|
@@ -127,11 +127,11 @@ export var useBarChart = function (props) {
|
|
|
127
127
|
}
|
|
128
128
|
totalWidth +=
|
|
129
129
|
((_b = (_a = stackItem.stacks[0].barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
|
|
130
|
-
spacing;
|
|
130
|
+
(index === data.length - 1 ? 0 : (_c = stackItem.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
data.forEach(function (item) {
|
|
134
|
+
data.forEach(function (item, index) {
|
|
135
135
|
var _a, _b, _c;
|
|
136
136
|
if (item.value > maxItem) {
|
|
137
137
|
maxItem = item.value;
|
|
@@ -141,7 +141,7 @@ export var useBarChart = function (props) {
|
|
|
141
141
|
}
|
|
142
142
|
totalWidth +=
|
|
143
143
|
((_b = (_a = item.barWidth) !== null && _a !== void 0 ? _a : props.barWidth) !== null && _b !== void 0 ? _b : defaultBarWidth) +
|
|
144
|
-
((_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
144
|
+
(index === data.length - 1 ? spacing : (_c = item.spacing) !== null && _c !== void 0 ? _c : spacing);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
var secondaryMaxItem = 0;
|
|
@@ -391,12 +391,11 @@ export var useBarChart = function (props) {
|
|
|
391
391
|
});
|
|
392
392
|
var animatedWidth = widthValue === null || widthValue === void 0 ? void 0 : widthValue.interpolate({
|
|
393
393
|
inputRange: [0, 1],
|
|
394
|
-
outputRange: [0, initialSpacing + totalWidth
|
|
394
|
+
outputRange: [0, initialSpacing + totalWidth]
|
|
395
395
|
});
|
|
396
396
|
var getPropsCommonForBarAndStack = function (item, index) {
|
|
397
397
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
398
398
|
return {
|
|
399
|
-
key: index,
|
|
400
399
|
item: item,
|
|
401
400
|
index: index,
|
|
402
401
|
containerHeight: containerHeight,
|
|
@@ -442,6 +441,7 @@ export var useBarChart = function (props) {
|
|
|
442
441
|
xAxisLabelsVerticalShift: xAxisLabelsVerticalShift,
|
|
443
442
|
renderTooltip: props.renderTooltip,
|
|
444
443
|
leftShiftForTooltip: (_e = props.leftShiftForTooltip) !== null && _e !== void 0 ? _e : 0,
|
|
444
|
+
autoCenterTooltip: autoCenterTooltip,
|
|
445
445
|
initialSpacing: initialSpacing,
|
|
446
446
|
selectedIndex: selectedIndex,
|
|
447
447
|
setSelectedIndex: setSelectedIndex,
|
package/src/BarChart/index.ts
CHANGED
|
@@ -52,7 +52,8 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
52
52
|
labelsDistanceFromXaxis,
|
|
53
53
|
autoShiftLabelsForNegativeStacks,
|
|
54
54
|
focusedBarIndex,
|
|
55
|
-
negativeStepValue
|
|
55
|
+
negativeStepValue,
|
|
56
|
+
autoCenterTooltip
|
|
56
57
|
} = props
|
|
57
58
|
const [points, setPoints] = useState('')
|
|
58
59
|
const [points2, setPoints2] = useState('')
|
|
@@ -167,11 +168,11 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
167
168
|
const labelsExtraHeight =
|
|
168
169
|
props.labelsExtraHeight ?? AxesAndRulesDefaults.labelsExtraHeight
|
|
169
170
|
|
|
170
|
-
let totalWidth = initialSpacing
|
|
171
|
+
let totalWidth = initialSpacing + endSpacing
|
|
171
172
|
let maxItem = 0
|
|
172
173
|
let minItem = 0
|
|
173
174
|
if (props.stackData) {
|
|
174
|
-
props.stackData.forEach((stackItem) => {
|
|
175
|
+
props.stackData.forEach((stackItem, index) => {
|
|
175
176
|
const stackSumMax = stackItem.stacks.reduce(
|
|
176
177
|
(acc, stack) => acc + (stack.value >= 0 ? stack.value : 0),
|
|
177
178
|
0
|
|
@@ -190,10 +191,10 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
190
191
|
}
|
|
191
192
|
totalWidth +=
|
|
192
193
|
(stackItem.stacks[0].barWidth ?? props.barWidth ?? defaultBarWidth) +
|
|
193
|
-
spacing
|
|
194
|
+
(index === data.length - 1 ? 0 : stackItem.spacing ?? spacing)
|
|
194
195
|
})
|
|
195
196
|
} else {
|
|
196
|
-
data.forEach((item: barDataItem) => {
|
|
197
|
+
data.forEach((item: barDataItem, index) => {
|
|
197
198
|
if (item.value > maxItem) {
|
|
198
199
|
maxItem = item.value
|
|
199
200
|
}
|
|
@@ -202,7 +203,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
202
203
|
}
|
|
203
204
|
totalWidth +=
|
|
204
205
|
(item.barWidth ?? props.barWidth ?? defaultBarWidth) +
|
|
205
|
-
(item.spacing ?? spacing)
|
|
206
|
+
(index === data.length - 1 ? spacing : item.spacing ?? spacing)
|
|
206
207
|
})
|
|
207
208
|
}
|
|
208
209
|
|
|
@@ -632,12 +633,11 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
632
633
|
|
|
633
634
|
const animatedWidth = widthValue?.interpolate({
|
|
634
635
|
inputRange: [0, 1],
|
|
635
|
-
outputRange: [0, initialSpacing + totalWidth
|
|
636
|
+
outputRange: [0, initialSpacing + totalWidth]
|
|
636
637
|
})
|
|
637
638
|
|
|
638
639
|
const getPropsCommonForBarAndStack = (item: any, index: number) => {
|
|
639
640
|
return {
|
|
640
|
-
key: index,
|
|
641
641
|
item,
|
|
642
642
|
index,
|
|
643
643
|
containerHeight,
|
|
@@ -684,6 +684,7 @@ export const useBarChart = (props: extendedBarChartPropsType) => {
|
|
|
684
684
|
xAxisLabelsVerticalShift,
|
|
685
685
|
renderTooltip: props.renderTooltip,
|
|
686
686
|
leftShiftForTooltip: props.leftShiftForTooltip ?? 0,
|
|
687
|
+
autoCenterTooltip,
|
|
687
688
|
initialSpacing,
|
|
688
689
|
selectedIndex,
|
|
689
690
|
setSelectedIndex,
|
package/src/BarChart/types.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ export interface BarChartPropsType {
|
|
|
215
215
|
disableScroll?: boolean;
|
|
216
216
|
showScrollIndicator?: boolean;
|
|
217
217
|
indicatorColor?: 'black' | 'default' | 'white';
|
|
218
|
+
nestedScrollEnabled?: boolean;
|
|
218
219
|
roundedTop?: boolean;
|
|
219
220
|
roundedBottom?: boolean;
|
|
220
221
|
disablePress?: boolean;
|
|
@@ -271,6 +272,7 @@ export interface BarChartPropsType {
|
|
|
271
272
|
onPressOut?: Function;
|
|
272
273
|
renderTooltip?: Function;
|
|
273
274
|
leftShiftForTooltip?: number;
|
|
275
|
+
autoCenterTooltip?: boolean;
|
|
274
276
|
leftShiftForLastIndexTooltip?: number;
|
|
275
277
|
barStyle?: object;
|
|
276
278
|
barInnerComponent?: (item?: stackDataItem | barDataItem, index?: number) => ReactNode;
|
|
@@ -406,9 +408,11 @@ export interface barDataItem {
|
|
|
406
408
|
patternId?: string;
|
|
407
409
|
barMarginBottom?: number;
|
|
408
410
|
leftShiftForTooltip?: number;
|
|
411
|
+
autoCenterTooltip?: boolean;
|
|
409
412
|
barStyle?: object;
|
|
410
413
|
barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode;
|
|
411
414
|
showXAxisIndex?: boolean;
|
|
415
|
+
isSecondary?: boolean;
|
|
412
416
|
}
|
|
413
417
|
export interface Animated2DWithGradientPropsType {
|
|
414
418
|
item: barDataItem;
|
|
@@ -522,6 +526,7 @@ export interface RenderBarsPropsType {
|
|
|
522
526
|
xAxisLabelsVerticalShift: number;
|
|
523
527
|
renderTooltip: Function | undefined;
|
|
524
528
|
leftShiftForTooltip?: number;
|
|
529
|
+
autoCenterTooltip?: boolean;
|
|
525
530
|
leftShiftForLastIndexTooltip: number;
|
|
526
531
|
initialSpacing: number;
|
|
527
532
|
selectedIndex: number;
|
package/src/BarChart/types.ts
CHANGED
|
@@ -240,6 +240,7 @@ export interface BarChartPropsType {
|
|
|
240
240
|
disableScroll?: boolean
|
|
241
241
|
showScrollIndicator?: boolean
|
|
242
242
|
indicatorColor?: 'black' | 'default' | 'white'
|
|
243
|
+
nestedScrollEnabled?: boolean
|
|
243
244
|
roundedTop?: boolean
|
|
244
245
|
roundedBottom?: boolean
|
|
245
246
|
disablePress?: boolean
|
|
@@ -300,6 +301,7 @@ export interface BarChartPropsType {
|
|
|
300
301
|
onPressOut?: Function
|
|
301
302
|
renderTooltip?: Function
|
|
302
303
|
leftShiftForTooltip?: number
|
|
304
|
+
autoCenterTooltip?: boolean
|
|
303
305
|
leftShiftForLastIndexTooltip?: number
|
|
304
306
|
barStyle?: object
|
|
305
307
|
barInnerComponent?: (
|
|
@@ -446,9 +448,11 @@ export interface barDataItem {
|
|
|
446
448
|
patternId?: string
|
|
447
449
|
barMarginBottom?: number
|
|
448
450
|
leftShiftForTooltip?: number
|
|
451
|
+
autoCenterTooltip?: boolean
|
|
449
452
|
barStyle?: object
|
|
450
453
|
barInnerComponent?: (item?: barDataItem, index?: number) => ReactNode
|
|
451
454
|
showXAxisIndex?: boolean
|
|
455
|
+
isSecondary?: boolean
|
|
452
456
|
}
|
|
453
457
|
|
|
454
458
|
export interface Animated2DWithGradientPropsType {
|
|
@@ -569,6 +573,7 @@ export interface RenderBarsPropsType {
|
|
|
569
573
|
xAxisLabelsVerticalShift: number
|
|
570
574
|
renderTooltip: Function | undefined
|
|
571
575
|
leftShiftForTooltip?: number
|
|
576
|
+
autoCenterTooltip?: boolean
|
|
572
577
|
leftShiftForLastIndexTooltip: number
|
|
573
578
|
initialSpacing: number
|
|
574
579
|
selectedIndex: number
|
|
@@ -81,17 +81,17 @@ export var useLineChartBiColor = function (props) {
|
|
|
81
81
|
var areaChart = (_w = props.areaChart) !== null && _w !== void 0 ? _w : false;
|
|
82
82
|
var textFontSize1 = (_x = props.textFontSize) !== null && _x !== void 0 ? _x : LineDefaults.textFontSize;
|
|
83
83
|
var textColor1 = (_y = props.textColor) !== null && _y !== void 0 ? _y : LineDefaults.textColor;
|
|
84
|
-
var totalWidth = initialSpacing;
|
|
84
|
+
var totalWidth = initialSpacing + endSpacing;
|
|
85
85
|
var maxItem = 0;
|
|
86
86
|
var minItem = 0;
|
|
87
|
-
data.forEach(function (item) {
|
|
87
|
+
data.forEach(function (item, index) {
|
|
88
88
|
if (item.value > maxItem) {
|
|
89
89
|
maxItem = item.value;
|
|
90
90
|
}
|
|
91
91
|
if (item.value < minItem) {
|
|
92
92
|
minItem = item.value;
|
|
93
93
|
}
|
|
94
|
-
totalWidth += spacing;
|
|
94
|
+
totalWidth += index === data.length - 1 ? 0 : spacing;
|
|
95
95
|
});
|
|
96
96
|
if ((_z = props.showFractionalValues) !== null && _z !== void 0 ? _z : props.roundToDigits) {
|
|
97
97
|
maxItem *= 10 * ((_0 = props.roundToDigits) !== null && _0 !== void 0 ? _0 : 1);
|
|
@@ -99,17 +99,17 @@ export const useLineChartBiColor = (
|
|
|
99
99
|
const textFontSize1 = props.textFontSize ?? LineDefaults.textFontSize
|
|
100
100
|
const textColor1 = props.textColor ?? LineDefaults.textColor
|
|
101
101
|
|
|
102
|
-
let totalWidth = initialSpacing
|
|
102
|
+
let totalWidth = initialSpacing + endSpacing
|
|
103
103
|
let maxItem = 0
|
|
104
104
|
let minItem = 0
|
|
105
|
-
data.forEach((item: bicolorLineDataItem) => {
|
|
105
|
+
data.forEach((item: bicolorLineDataItem, index) => {
|
|
106
106
|
if (item.value > maxItem) {
|
|
107
107
|
maxItem = item.value
|
|
108
108
|
}
|
|
109
109
|
if (item.value < minItem) {
|
|
110
110
|
minItem = item.value
|
|
111
111
|
}
|
|
112
|
-
totalWidth += spacing
|
|
112
|
+
totalWidth += index === data.length - 1 ? 0 : spacing
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
if (props.showFractionalValues ?? props.roundToDigits) {
|
package/src/LineChart/index.js
CHANGED
|
@@ -233,7 +233,7 @@ export var useLineChart = function (props) {
|
|
|
233
233
|
var textColor3 = (_93 = (_92 = props.textColor3) !== null && _92 !== void 0 ? _92 : props.textColor) !== null && _93 !== void 0 ? _93 : LineDefaults.textColor;
|
|
234
234
|
var textColor4 = (_95 = (_94 = props.textColor4) !== null && _94 !== void 0 ? _94 : props.textColor) !== null && _95 !== void 0 ? _95 : LineDefaults.textColor;
|
|
235
235
|
var textColor5 = (_97 = (_96 = props.textColor5) !== null && _96 !== void 0 ? _96 : props.textColor) !== null && _97 !== void 0 ? _97 : LineDefaults.textColor;
|
|
236
|
-
var totalWidth = initialSpacing + spacing * (data0 !== null && data0 !== void 0 ? data0 : data).length;
|
|
236
|
+
var totalWidth = initialSpacing + spacing * (data0 !== null && data0 !== void 0 ? data0 : data).length - 1 + endSpacing;
|
|
237
237
|
var _339 = computeMaxAndMinItems(data0 !== null && data0 !== void 0 ? data0 : data, props.roundToDigits, props.showFractionalValues), maxItem = _339.maxItem, minItem = _339.minItem;
|
|
238
238
|
var maxValue = getMaxValue(props.maxValue, props.stepValue, noOfSections, maxItem);
|
|
239
239
|
var mostNegativeValue = (_98 = props.mostNegativeValue) !== null && _98 !== void 0 ? _98 : minItem;
|
|
@@ -253,6 +253,9 @@ export var useLineChart = function (props) {
|
|
|
253
253
|
animations.forEach(function (item, index) {
|
|
254
254
|
item.addListener(function (val) {
|
|
255
255
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
256
|
+
if (typeof data[index] === 'undefined') {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
256
259
|
var temp = (_b = (_a = data[index]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
257
260
|
data[index].value = (_c = val === null || val === void 0 ? void 0 : val.value) !== null && _c !== void 0 ? _c : 0;
|
|
258
261
|
var pp = '';
|
|
@@ -1093,6 +1096,7 @@ export var useLineChart = function (props) {
|
|
|
1093
1096
|
endSpacing: endSpacing,
|
|
1094
1097
|
horizontalRulesStyle: horizontalRulesStyle,
|
|
1095
1098
|
noOfSections: noOfSections,
|
|
1099
|
+
sectionColors: props.sectionColors,
|
|
1096
1100
|
showFractionalValues: showFractionalValues,
|
|
1097
1101
|
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
|
1098
1102
|
yAxisLabelTexts: props.yAxisLabelTexts,
|
package/src/LineChart/index.ts
CHANGED
|
@@ -428,7 +428,8 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
428
428
|
const textColor5 =
|
|
429
429
|
props.textColor5 ?? props.textColor ?? LineDefaults.textColor
|
|
430
430
|
|
|
431
|
-
const totalWidth =
|
|
431
|
+
const totalWidth =
|
|
432
|
+
initialSpacing + spacing * (data0 ?? data).length - 1 + endSpacing
|
|
432
433
|
|
|
433
434
|
const { maxItem, minItem } = computeMaxAndMinItems(
|
|
434
435
|
data0 ?? data,
|
|
@@ -469,7 +470,9 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
469
470
|
if (animateOnDataChange && animations) {
|
|
470
471
|
animations.forEach((item, index) => {
|
|
471
472
|
item.addListener((val) => {
|
|
472
|
-
if (typeof data[index] === 'undefined') {
|
|
473
|
+
if (typeof data[index] === 'undefined') {
|
|
474
|
+
return
|
|
475
|
+
}
|
|
473
476
|
|
|
474
477
|
const temp = data[index]?.value ?? 0
|
|
475
478
|
data[index].value = val?.value ?? 0
|
|
@@ -1819,6 +1822,7 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
|
|
|
1819
1822
|
endSpacing,
|
|
1820
1823
|
horizontalRulesStyle,
|
|
1821
1824
|
noOfSections,
|
|
1825
|
+
sectionColors: props.sectionColors,
|
|
1822
1826
|
showFractionalValues,
|
|
1823
1827
|
|
|
1824
1828
|
axesAndRulesProps: getAxesAndRulesProps(props, stepValue, undefined),
|
package/src/LineChart/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ColorValue } from 'react-native';
|
|
1
|
+
import { GestureResponderEvent, type ColorValue } from 'react-native';
|
|
2
2
|
import { type yAxisSides } from '../utils/constants';
|
|
3
3
|
import { type CurveType, type DataSet, type EdgePosition, type HighlightedRange, type LineSegment, type Pointer, type RuleType, type RulesConfig, type arrowConfigType, type referenceConfigType, type secondaryLineConfigType, type secondaryYAxisType } from '../utils/types';
|
|
4
4
|
export interface LineChartPropsType {
|
|
@@ -6,6 +6,7 @@ export interface LineChartPropsType {
|
|
|
6
6
|
overflowTop?: number;
|
|
7
7
|
overflowBottom?: number;
|
|
8
8
|
noOfSections?: number;
|
|
9
|
+
sectionColors?: ColorValue[];
|
|
9
10
|
maxValue?: number;
|
|
10
11
|
mostNegativeValue?: number;
|
|
11
12
|
stepHeight?: number;
|
|
@@ -107,6 +108,7 @@ export interface LineChartPropsType {
|
|
|
107
108
|
pointerConfig?: Pointer;
|
|
108
109
|
showScrollIndicator?: boolean;
|
|
109
110
|
indicatorColor?: 'black' | 'default' | 'white';
|
|
111
|
+
nestedScrollEnabled?: boolean;
|
|
110
112
|
showYAxisIndices?: boolean;
|
|
111
113
|
showXAxisIndices?: boolean;
|
|
112
114
|
yAxisIndicesHeight?: number;
|
|
@@ -295,6 +297,8 @@ export interface LineChartPropsType {
|
|
|
295
297
|
interpolateMissingValues?: boolean;
|
|
296
298
|
onlyPositive?: boolean;
|
|
297
299
|
parentWidth?: number;
|
|
300
|
+
onChartAreaPress?: (event: GestureResponderEvent) => void;
|
|
301
|
+
onBackgroundPress?: (event: GestureResponderEvent) => void;
|
|
298
302
|
}
|
|
299
303
|
export interface lineDataItem {
|
|
300
304
|
value: number;
|
|
@@ -451,6 +455,7 @@ export interface LineChartBicolorPropsType {
|
|
|
451
455
|
disableScroll?: boolean;
|
|
452
456
|
showScrollIndicator?: boolean;
|
|
453
457
|
indicatorColor?: 'black' | 'default' | 'white';
|
|
458
|
+
nestedScrollEnabled?: boolean;
|
|
454
459
|
showYAxisIndices?: boolean;
|
|
455
460
|
showXAxisIndices?: boolean;
|
|
456
461
|
yAxisIndicesHeight?: number;
|
package/src/LineChart/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ColorValue } from 'react-native'
|
|
1
|
+
import { GestureResponderEvent, type ColorValue } from 'react-native'
|
|
2
2
|
import { type yAxisSides } from '../utils/constants'
|
|
3
3
|
import {
|
|
4
4
|
type CurveType,
|
|
@@ -20,6 +20,7 @@ export interface LineChartPropsType {
|
|
|
20
20
|
overflowTop?: number
|
|
21
21
|
overflowBottom?: number
|
|
22
22
|
noOfSections?: number
|
|
23
|
+
sectionColors?: ColorValue[]
|
|
23
24
|
maxValue?: number
|
|
24
25
|
mostNegativeValue?: number
|
|
25
26
|
stepHeight?: number
|
|
@@ -125,6 +126,7 @@ export interface LineChartPropsType {
|
|
|
125
126
|
pointerConfig?: Pointer
|
|
126
127
|
showScrollIndicator?: boolean
|
|
127
128
|
indicatorColor?: 'black' | 'default' | 'white'
|
|
129
|
+
nestedScrollEnabled?: boolean
|
|
128
130
|
|
|
129
131
|
// Indices
|
|
130
132
|
|
|
@@ -329,6 +331,9 @@ export interface LineChartPropsType {
|
|
|
329
331
|
interpolateMissingValues?: boolean
|
|
330
332
|
onlyPositive?: boolean
|
|
331
333
|
parentWidth?: number
|
|
334
|
+
|
|
335
|
+
onChartAreaPress?: (event: GestureResponderEvent) => void
|
|
336
|
+
onBackgroundPress?: (event: GestureResponderEvent) => void
|
|
332
337
|
}
|
|
333
338
|
|
|
334
339
|
export interface lineDataItem {
|
|
@@ -502,6 +507,7 @@ export interface LineChartBicolorPropsType {
|
|
|
502
507
|
disableScroll?: boolean
|
|
503
508
|
showScrollIndicator?: boolean
|
|
504
509
|
indicatorColor?: 'black' | 'default' | 'white'
|
|
510
|
+
nestedScrollEnabled?: boolean
|
|
505
511
|
|
|
506
512
|
// Indices
|
|
507
513
|
|
|
@@ -112,7 +112,7 @@ export var getHorizSectionVals = function (props) {
|
|
|
112
112
|
var showReferenceLine1 = referenceLinesConfig.showReferenceLine1, referenceLine1Position = referenceLinesConfig.referenceLine1Position, referenceLine1Config = referenceLinesConfig.referenceLine1Config, showReferenceLine2 = referenceLinesConfig.showReferenceLine2, referenceLine2Position = referenceLinesConfig.referenceLine2Position, referenceLine2Config = referenceLinesConfig.referenceLine2Config, showReferenceLine3 = referenceLinesConfig.showReferenceLine3, referenceLine3Position = referenceLinesConfig.referenceLine3Position, referenceLine3Config = referenceLinesConfig.referenceLine3Config;
|
|
113
113
|
var defaultReferenceConfig = {
|
|
114
114
|
thickness: rulesThickness,
|
|
115
|
-
width: (width || totalWidth -
|
|
115
|
+
width: (width || totalWidth - endSpacing) + endSpacing,
|
|
116
116
|
color: 'black',
|
|
117
117
|
type: rulesType,
|
|
118
118
|
dashWidth: dashWidth,
|
|
@@ -228,7 +228,7 @@ export const getHorizSectionVals = (props: horizSectionPropTypes) => {
|
|
|
228
228
|
|
|
229
229
|
const defaultReferenceConfig = {
|
|
230
230
|
thickness: rulesThickness,
|
|
231
|
-
width: (width || totalWidth -
|
|
231
|
+
width: (width || totalWidth - endSpacing) + endSpacing,
|
|
232
232
|
color: 'black',
|
|
233
233
|
type: rulesType,
|
|
234
234
|
dashWidth,
|
|
@@ -91,6 +91,7 @@ export var useBarAndLineChartsWrapper = function (props) {
|
|
|
91
91
|
var verticalLinesAr = noOfVerticalLines
|
|
92
92
|
? __spreadArray([], __read(Array(noOfVerticalLines).keys()), false) : __spreadArray([], __read(Array(stackData ? stackData.length : data.length).keys()), false);
|
|
93
93
|
var horizSectionProps = {
|
|
94
|
+
chartType: chartType,
|
|
94
95
|
width: width,
|
|
95
96
|
horizSections: horizSections,
|
|
96
97
|
noOfSectionsBelowXAxis: noOfSectionsBelowXAxis,
|
package/src/utils/index.js
CHANGED
|
@@ -545,7 +545,7 @@ export var getAxesAndRulesProps = function (props, stepValue, negativeStepValue,
|
|
|
545
545
|
};
|
|
546
546
|
if (((_c = props.secondaryYAxis) !== null && _c !== void 0 ? _c : (_d = props.lineConfig) === null || _d === void 0 ? void 0 : _d.isSecondary) &&
|
|
547
547
|
maxValue !== undefined &&
|
|
548
|
-
secondaryYAxis.maxValue === undefined) {
|
|
548
|
+
secondaryYAxis && secondaryYAxis.maxValue === undefined) {
|
|
549
549
|
axesAndRulesProps.secondaryYAxis = __assign(__assign({}, secondaryYAxis), { maxValue: maxValue });
|
|
550
550
|
}
|
|
551
551
|
return axesAndRulesProps;
|
package/src/utils/index.ts
CHANGED
|
@@ -744,7 +744,7 @@ export const getAxesAndRulesProps = (
|
|
|
744
744
|
if (
|
|
745
745
|
(props.secondaryYAxis ?? props.lineConfig?.isSecondary) &&
|
|
746
746
|
maxValue !== undefined &&
|
|
747
|
-
secondaryYAxis.maxValue === undefined
|
|
747
|
+
secondaryYAxis && secondaryYAxis.maxValue === undefined
|
|
748
748
|
) {
|
|
749
749
|
axesAndRulesProps.secondaryYAxis = { ...secondaryYAxis, maxValue }
|
|
750
750
|
}
|
package/src/utils/types.d.ts
CHANGED
|
@@ -110,6 +110,7 @@ export interface arrowConfigType {
|
|
|
110
110
|
showArrowBase: boolean;
|
|
111
111
|
}
|
|
112
112
|
export interface horizSectionPropTypes {
|
|
113
|
+
chartType: chartTypes;
|
|
113
114
|
width: number | undefined;
|
|
114
115
|
horizSections: any[];
|
|
115
116
|
noOfSectionsBelowXAxis: number;
|
|
@@ -245,6 +246,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
245
246
|
endReachedOffset: number;
|
|
246
247
|
isRTL?: boolean;
|
|
247
248
|
extraWidthDueToDataPoint?: number;
|
|
249
|
+
nestedScrollEnabled?: boolean;
|
|
248
250
|
}
|
|
249
251
|
export interface Pointer {
|
|
250
252
|
height?: number;
|
package/src/utils/types.ts
CHANGED
|
@@ -125,6 +125,7 @@ export interface arrowConfigType {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export interface horizSectionPropTypes {
|
|
128
|
+
chartType: chartTypes
|
|
128
129
|
width: number | undefined
|
|
129
130
|
horizSections: any[]
|
|
130
131
|
noOfSectionsBelowXAxis: number
|
|
@@ -276,6 +277,7 @@ export interface BarAndLineChartsWrapperTypes {
|
|
|
276
277
|
endReachedOffset: number
|
|
277
278
|
isRTL?: boolean
|
|
278
279
|
extraWidthDueToDataPoint?: number
|
|
280
|
+
nestedScrollEnabled?: boolean
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
export interface Pointer {
|