react-native-gifted-charts 1.4.13 → 1.4.15
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 +2 -2
- package/src/BarChart/Animated2DWithGradient.tsx +1 -1
- package/src/BarChart/RenderBars.tsx +18 -11
- package/src/BarChart/RenderStackBars.tsx +6 -4
- package/src/BarChart/index.tsx +9 -1
- package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +15 -10
- package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +1 -1
- package/src/todos.md +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.15",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"gifted-charts-core": "^0.1.
|
|
28
|
+
"gifted-charts-core": "^0.1.11"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/core": "^7.22.5",
|
|
@@ -52,12 +52,21 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
52
52
|
noOfSectionsBelowXAxis,
|
|
53
53
|
yAxisOffset,
|
|
54
54
|
barWidth,
|
|
55
|
+
labelsDistanceFromXaxis = 0,
|
|
56
|
+
stepHeight,
|
|
57
|
+
stepValue,
|
|
58
|
+
negativeStepHeight,
|
|
59
|
+
negativeStepValue,
|
|
55
60
|
} = props;
|
|
56
61
|
|
|
62
|
+
const heightFactor =
|
|
63
|
+
item.value < 0
|
|
64
|
+
? negativeStepHeight / negativeStepValue
|
|
65
|
+
: stepHeight / stepValue;
|
|
66
|
+
|
|
57
67
|
const barHeight = Math.max(
|
|
58
68
|
minHeight,
|
|
59
|
-
|
|
60
|
-
xAxisThickness,
|
|
69
|
+
Math.abs(item.value) * heightFactor - xAxisThickness,
|
|
61
70
|
);
|
|
62
71
|
|
|
63
72
|
const {
|
|
@@ -97,7 +106,8 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
97
106
|
(rotateLabel
|
|
98
107
|
? -40
|
|
99
108
|
: -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
|
|
100
|
-
barMarginBottom
|
|
109
|
+
barMarginBottom -
|
|
110
|
+
labelsDistanceFromXaxis,
|
|
101
111
|
},
|
|
102
112
|
rotateLabel
|
|
103
113
|
? horizontal
|
|
@@ -293,10 +303,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
293
303
|
translateY:
|
|
294
304
|
(containerHeight || 200) -
|
|
295
305
|
(barHeight - 10 + xAxisLabelsVerticalShift) +
|
|
296
|
-
(item.value < 0
|
|
297
|
-
? (Math.abs(item.value) * (containerHeight || 200)) /
|
|
298
|
-
(maxValue || 200)
|
|
299
|
-
: 0),
|
|
306
|
+
(item.value < 0 ? Math.abs(item.value) * heightFactor : 0),
|
|
300
307
|
},
|
|
301
308
|
],
|
|
302
309
|
}
|
|
@@ -304,9 +311,7 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
304
311
|
? {
|
|
305
312
|
transform: [
|
|
306
313
|
{
|
|
307
|
-
translateY:
|
|
308
|
-
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
309
|
-
(maxValue || 200),
|
|
314
|
+
translateY: Math.abs(item.value) * heightFactor,
|
|
310
315
|
},
|
|
311
316
|
{rotateZ: '180deg'},
|
|
312
317
|
],
|
|
@@ -406,7 +411,9 @@ const RenderBars = (props: RenderBarsPropsType) => {
|
|
|
406
411
|
activeOpacity={props.activeOpacity || 0.2}
|
|
407
412
|
onPress={() => {
|
|
408
413
|
if (renderTooltip || props.focusBarOnPress) {
|
|
409
|
-
|
|
414
|
+
if (props.focusedBarIndex === undefined || !props.onPress) {
|
|
415
|
+
setSelectedIndex(index);
|
|
416
|
+
}
|
|
410
417
|
}
|
|
411
418
|
item.onPress
|
|
412
419
|
? item.onPress()
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
UIManager,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import Svg, {Defs, Rect} from 'react-native-svg';
|
|
11
|
-
import LinearGradient from
|
|
11
|
+
import LinearGradient from '../Components/common/LinearGradient';
|
|
12
12
|
import {
|
|
13
13
|
useRenderStackBars,
|
|
14
14
|
BarDefaults,
|
|
@@ -49,6 +49,8 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
|
|
|
49
49
|
stackBorderBottomLeftRadius,
|
|
50
50
|
stackBorderBottomRightRadius,
|
|
51
51
|
showValuesAsTopLabel,
|
|
52
|
+
autoShiftLabelsForNegativeStacks = true,
|
|
53
|
+
labelsDistanceFromXaxis = 0,
|
|
52
54
|
} = props;
|
|
53
55
|
const {
|
|
54
56
|
cotainsNegative,
|
|
@@ -78,9 +80,9 @@ const RenderStackBars = (props: StackedBarChartPropsType) => {
|
|
|
78
80
|
width:
|
|
79
81
|
(item.stacks[0].barWidth || props.barWidth || 30) + spacing / 2,
|
|
80
82
|
position: 'absolute',
|
|
81
|
-
bottom:
|
|
82
|
-
? -
|
|
83
|
-
: -
|
|
83
|
+
bottom: autoShiftLabelsForNegativeStacks
|
|
84
|
+
? -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition
|
|
85
|
+
: -labelsDistanceFromXaxis,
|
|
84
86
|
},
|
|
85
87
|
rotateLabel
|
|
86
88
|
? props.horizontal
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -86,7 +86,14 @@ export const BarChart = (props: BarChartPropsType) => {
|
|
|
86
86
|
autoShiftLabels,
|
|
87
87
|
getPropsCommonForBarAndStack,
|
|
88
88
|
barAndLineChartsWrapperProps,
|
|
89
|
-
|
|
89
|
+
autoShiftLabelsForNegativeStacks,
|
|
90
|
+
} = useBarChart({
|
|
91
|
+
...props,
|
|
92
|
+
heightValue,
|
|
93
|
+
widthValue,
|
|
94
|
+
opacValue,
|
|
95
|
+
parentWidth: props.parentWidth ?? screenWidth,
|
|
96
|
+
});
|
|
90
97
|
|
|
91
98
|
const labelsAppear = useCallback(() => {
|
|
92
99
|
opacValue.setValue(0);
|
|
@@ -327,6 +334,7 @@ export const BarChart = (props: BarChartPropsType) => {
|
|
|
327
334
|
stackBorderTopRightRadius={props.stackBorderTopRightRadius}
|
|
328
335
|
stackBorderBottomLeftRadius={props.stackBorderBottomLeftRadius}
|
|
329
336
|
stackBorderBottomRightRadius={props.stackBorderBottomRightRadius}
|
|
337
|
+
autoShiftLabelsForNegativeStacks={autoShiftLabelsForNegativeStacks}
|
|
330
338
|
{...getPropsCommonForBarAndStack(item, index)}
|
|
331
339
|
/>
|
|
332
340
|
);
|
|
@@ -18,7 +18,9 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
18
18
|
yAxisSide,
|
|
19
19
|
horizontalRulesStyle,
|
|
20
20
|
noOfSections,
|
|
21
|
+
sectionColors,
|
|
21
22
|
stepHeight,
|
|
23
|
+
negativeStepHeight,
|
|
22
24
|
yAxisLabelWidth,
|
|
23
25
|
yAxisLabelContainerStyle,
|
|
24
26
|
yAxisThickness,
|
|
@@ -92,7 +94,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
92
94
|
: styles.leftPart,
|
|
93
95
|
{
|
|
94
96
|
borderColor: yAxisColor,
|
|
95
|
-
backgroundColor: backgroundColor,
|
|
97
|
+
backgroundColor: sectionColors?.[invertedIndex] ?? backgroundColor,
|
|
96
98
|
width: (props.width || totalWidth - spacing) + endSpacing,
|
|
97
99
|
},
|
|
98
100
|
!index ? {height: stepHeight / 2, marginTop: stepHeight / 2} : null,
|
|
@@ -458,7 +460,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
458
460
|
{
|
|
459
461
|
width: (width ?? totalWidth) + 15,
|
|
460
462
|
},
|
|
461
|
-
index === 0 && {marginTop:
|
|
463
|
+
index === 0 && {marginTop: negativeStepHeight / 2},
|
|
462
464
|
]}>
|
|
463
465
|
<View
|
|
464
466
|
style={[
|
|
@@ -469,11 +471,14 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
469
471
|
marginLeft: yAxisThickness,
|
|
470
472
|
},
|
|
471
473
|
{
|
|
472
|
-
height:
|
|
474
|
+
height:
|
|
475
|
+
index === 0
|
|
476
|
+
? negativeStepHeight * 1.5
|
|
477
|
+
: negativeStepHeight,
|
|
473
478
|
width:
|
|
474
479
|
yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
|
|
475
480
|
},
|
|
476
|
-
index === 0 && {marginTop: -
|
|
481
|
+
index === 0 && {marginTop: -negativeStepHeight / 2},
|
|
477
482
|
]}
|
|
478
483
|
/>
|
|
479
484
|
<View
|
|
@@ -521,12 +526,12 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
521
526
|
{
|
|
522
527
|
position: 'absolute',
|
|
523
528
|
zIndex: 1,
|
|
524
|
-
bottom:
|
|
529
|
+
bottom: negativeStepHeight * index,
|
|
525
530
|
width: yAxisLabelWidth,
|
|
526
531
|
height:
|
|
527
|
-
index ===
|
|
528
|
-
?
|
|
529
|
-
:
|
|
532
|
+
index === noOfSectionsBelowXAxis
|
|
533
|
+
? negativeStepHeight / 2
|
|
534
|
+
: negativeStepHeight,
|
|
530
535
|
},
|
|
531
536
|
yAxisSide === yAxisSides.RIGHT && {
|
|
532
537
|
left: (width ?? totalWidth) + yAxisLabelWidth,
|
|
@@ -538,8 +543,8 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
|
|
|
538
543
|
ellipsizeMode={'clip'}
|
|
539
544
|
style={[
|
|
540
545
|
yAxisTextStyle,
|
|
541
|
-
index ===
|
|
542
|
-
marginBottom:
|
|
546
|
+
index === noOfSectionsBelowXAxis && {
|
|
547
|
+
marginBottom: negativeStepHeight / -2,
|
|
543
548
|
},
|
|
544
549
|
]}>
|
|
545
550
|
{label}
|
|
@@ -16,7 +16,7 @@ export const renderDataPoints = props => {
|
|
|
16
16
|
spacing,
|
|
17
17
|
} = props;
|
|
18
18
|
return data.map((item: any, index: number) => {
|
|
19
|
-
if (index < lineConfig.startIndex || index > lineConfig.endIndex) {
|
|
19
|
+
if (index < lineConfig.startIndex || index > lineConfig.endIndex || item.hideDataPoint) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
const currentBarWidth = item.barWidth || barWidth || 30;
|
package/src/todos.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
## Features
|
|
2
2
|
|
|
3
|
-
1.
|
|
3
|
+
1. Scatter Chart - https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/518
|
|
4
|
+
2. Issue with eslint - tsc https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/222
|
|
4
5
|
|
|
5
6
|
## To-dos in documentation-
|
|
6
7
|
|