react-native-gifted-charts 1.2.27 → 1.2.30
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.tsx +15 -5
- package/src/LineChart/index.tsx +13 -5
- package/src/PieChart/index.tsx +41 -37
- package/src/PieChart/main.tsx +14 -7
- package/src/todos.md +9 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -44,6 +44,7 @@ type PropTypes = {
|
|
|
44
44
|
xAxisColor?: ColorValue;
|
|
45
45
|
yAxisThickness?: number;
|
|
46
46
|
yAxisColor?: ColorValue;
|
|
47
|
+
xAxisType?: String;
|
|
47
48
|
yAxisLabelContainerStyle?: any;
|
|
48
49
|
horizontalRulesStyle?: any;
|
|
49
50
|
yAxisTextStyle?: any;
|
|
@@ -103,6 +104,7 @@ type PropTypes = {
|
|
|
103
104
|
|
|
104
105
|
disableScroll?: Boolean;
|
|
105
106
|
showScrollIndicator?: Boolean;
|
|
107
|
+
indicatorColor?: 'black' | 'default' | 'white';
|
|
106
108
|
roundedTop?: Boolean;
|
|
107
109
|
roundedBottom?: Boolean;
|
|
108
110
|
disablePress?: boolean;
|
|
@@ -402,6 +404,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
402
404
|
const hideOrigin = props.hideOrigin || false;
|
|
403
405
|
|
|
404
406
|
const rulesType = props.rulesType || 'line';
|
|
407
|
+
const xAxisType = props.xAxisType || 'solid';
|
|
405
408
|
const dashWidth = props.dashWidth === 0 ? 0 : props.dashWidth || 4;
|
|
406
409
|
const dashGap = props.dashGap === 0 ? 0 : props.dashGap || 8;
|
|
407
410
|
|
|
@@ -715,11 +718,17 @@ export const BarChart = (props: PropTypes) => {
|
|
|
715
718
|
{backgroundColor: backgroundColor},
|
|
716
719
|
]}>
|
|
717
720
|
{index === noOfSections ? (
|
|
718
|
-
<
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
721
|
+
<Rule
|
|
722
|
+
config={{
|
|
723
|
+
thickness: xAxisThickness,
|
|
724
|
+
color: xAxisColor,
|
|
725
|
+
width: horizontal
|
|
726
|
+
? props.width || Math.min(300, totalWidth)
|
|
727
|
+
: (props.width || totalWidth) + 11,
|
|
728
|
+
dashWidth: dashWidth,
|
|
729
|
+
dashGap: dashGap,
|
|
730
|
+
type: xAxisType,
|
|
731
|
+
}}
|
|
723
732
|
/>
|
|
724
733
|
) : hideRules ? null : (
|
|
725
734
|
<Rule
|
|
@@ -1379,6 +1388,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1379
1388
|
!props.width && {width: totalWidth},
|
|
1380
1389
|
]}
|
|
1381
1390
|
showsHorizontalScrollIndicator={showScrollIndicator}
|
|
1391
|
+
indicatorStyle={props.indicatorColor}
|
|
1382
1392
|
horizontal
|
|
1383
1393
|
// data={props.stackData || data}
|
|
1384
1394
|
keyExtractor={(item, index) => index.toString()}>
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -71,6 +71,7 @@ type propTypes = {
|
|
|
71
71
|
animateTogether?: boolean;
|
|
72
72
|
xAxisThickness?: number;
|
|
73
73
|
xAxisColor?: ColorValue;
|
|
74
|
+
xAxisType?: String;
|
|
74
75
|
hideRules?: Boolean;
|
|
75
76
|
rulesColor?: ColorValue;
|
|
76
77
|
rulesThickness?: number;
|
|
@@ -119,6 +120,7 @@ type propTypes = {
|
|
|
119
120
|
disableScroll?: Boolean;
|
|
120
121
|
pointerConfig?: Pointer;
|
|
121
122
|
showScrollIndicator?: Boolean;
|
|
123
|
+
indicatorColor?: 'black' | 'default' | 'white';
|
|
122
124
|
|
|
123
125
|
//Indices
|
|
124
126
|
|
|
@@ -1554,6 +1556,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1554
1556
|
const hideOrigin = props.hideOrigin || false;
|
|
1555
1557
|
|
|
1556
1558
|
const rulesType = props.rulesType || 'line';
|
|
1559
|
+
const xAxisType = props.xAxisType || 'solid';
|
|
1557
1560
|
const dashWidth = props.dashWidth === 0 ? 0 : props.dashWidth || 4;
|
|
1558
1561
|
const dashGap = props.dashGap === 0 ? 0 : props.dashGap || 8;
|
|
1559
1562
|
|
|
@@ -1855,11 +1858,15 @@ export const LineChart = (props: propTypes) => {
|
|
|
1855
1858
|
},
|
|
1856
1859
|
]}>
|
|
1857
1860
|
{index === noOfSections ? (
|
|
1858
|
-
<
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1861
|
+
<Rule
|
|
1862
|
+
config={{
|
|
1863
|
+
thickness: xAxisThickness,
|
|
1864
|
+
color: xAxisColor,
|
|
1865
|
+
width: (props.width || totalWidth) + 11,
|
|
1866
|
+
dashWidth: dashWidth,
|
|
1867
|
+
dashGap: dashGap,
|
|
1868
|
+
type: xAxisType,
|
|
1869
|
+
}}
|
|
1863
1870
|
/>
|
|
1864
1871
|
) : hideRules ? null : (
|
|
1865
1872
|
<Rule
|
|
@@ -3287,6 +3294,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
3287
3294
|
}
|
|
3288
3295
|
}}
|
|
3289
3296
|
showsHorizontalScrollIndicator={showScrollIndicator}
|
|
3297
|
+
indicatorStyle={props.indicatorColor}
|
|
3290
3298
|
style={[
|
|
3291
3299
|
{
|
|
3292
3300
|
marginLeft:
|
package/src/PieChart/index.tsx
CHANGED
|
@@ -67,6 +67,8 @@ type itemType = {
|
|
|
67
67
|
labelPosition?: 'onBorder' | 'outward' | 'inward' | 'mid';
|
|
68
68
|
onPress?: Function;
|
|
69
69
|
onLabelPress?: Function;
|
|
70
|
+
strokeWidth?: number;
|
|
71
|
+
strokeColor?: string;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
export const PieChart = (props: propTypes) => {
|
|
@@ -74,32 +76,29 @@ export const PieChart = (props: propTypes) => {
|
|
|
74
76
|
const extraRadiusForFocused = props.extraRadiusForFocused || radius / 10;
|
|
75
77
|
const pi = props.semiCircle ? Math.PI / 2 : Math.PI;
|
|
76
78
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
} else {
|
|
88
|
-
let startAngle = props.initialAngle || (props.semiCircle ? -pi : 0);
|
|
89
|
-
// let startColor;
|
|
90
|
-
let total = 0;
|
|
91
|
-
props.data.forEach(item => {
|
|
92
|
-
total += item.value;
|
|
93
|
-
});
|
|
94
|
-
if (selectedIndex !== 0) {
|
|
95
|
-
let start = 0;
|
|
96
|
-
for (let i = 0; i < selectedIndex; i++) {
|
|
97
|
-
start += props.data[i].value;
|
|
98
|
-
}
|
|
99
|
-
startAngle += (2 * pi * start) / total;
|
|
79
|
+
let startAngle = props.initialAngle || (props.semiCircle ? -pi : 0);
|
|
80
|
+
let total = 0;
|
|
81
|
+
props.data.forEach(item => {
|
|
82
|
+
total += item.value;
|
|
83
|
+
});
|
|
84
|
+
if (selectedIndex !== 0) {
|
|
85
|
+
let start = 0;
|
|
86
|
+
for (let i = 0; i < selectedIndex; i++) {
|
|
87
|
+
start += props.data[i].value;
|
|
100
88
|
}
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
startAngle += (2 * pi * start) / total;
|
|
90
|
+
}
|
|
91
|
+
return (
|
|
92
|
+
<View
|
|
93
|
+
style={{
|
|
94
|
+
height: (radius + extraRadiusForFocused) * 2,
|
|
95
|
+
width: (radius + extraRadiusForFocused) * 2,
|
|
96
|
+
}}>
|
|
97
|
+
{!(
|
|
98
|
+
props.data.length <= 1 ||
|
|
99
|
+
!props.focusOnPress ||
|
|
100
|
+
selectedIndex === -1
|
|
101
|
+
) && (
|
|
103
102
|
<View
|
|
104
103
|
style={{
|
|
105
104
|
position: 'absolute',
|
|
@@ -113,26 +112,31 @@ export const PieChart = (props: propTypes) => {
|
|
|
113
112
|
value: props.data[selectedIndex].value,
|
|
114
113
|
color:
|
|
115
114
|
props.data[selectedIndex].color || colors[selectedIndex % 9],
|
|
115
|
+
strokeColor: props.data[selectedIndex].strokeColor || null,
|
|
116
|
+
strokeWidth: props.data[selectedIndex].strokeWidth || null,
|
|
117
|
+
gradientCenterColor:
|
|
118
|
+
props.data[selectedIndex].gradientCenterColor || null,
|
|
116
119
|
},
|
|
117
120
|
{
|
|
118
121
|
value: total - props.data[selectedIndex].value,
|
|
119
|
-
|
|
122
|
+
peripheral: true,
|
|
123
|
+
strokeWidth: 0,
|
|
120
124
|
},
|
|
121
125
|
]}
|
|
122
|
-
key="pie"
|
|
123
126
|
radius={radius + extraRadiusForFocused}
|
|
124
127
|
initialAngle={startAngle}
|
|
128
|
+
showText={false}
|
|
129
|
+
innerRadius={props.innerRadius || radius / 2.5}
|
|
125
130
|
/>
|
|
126
131
|
</View>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
</View>
|
|
132
|
+
)}
|
|
133
|
+
<View style={{position: 'absolute'}}>
|
|
134
|
+
<PieChartMain
|
|
135
|
+
{...props}
|
|
136
|
+
selectedIndex={selectedIndex}
|
|
137
|
+
setSelectedIndex={setSelectedIndex}
|
|
138
|
+
/>
|
|
135
139
|
</View>
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
</View>
|
|
141
|
+
);
|
|
138
142
|
};
|
package/src/PieChart/main.tsx
CHANGED
|
@@ -73,6 +73,9 @@ type itemType = {
|
|
|
73
73
|
labelPosition?: 'onBorder' | 'outward' | 'inward' | 'mid';
|
|
74
74
|
onPress?: Function;
|
|
75
75
|
onLabelPress?: Function;
|
|
76
|
+
strokeWidth?: number;
|
|
77
|
+
strokeColor?: string;
|
|
78
|
+
peripheral?: boolean;
|
|
76
79
|
};
|
|
77
80
|
|
|
78
81
|
export const PieChartMain = (props: propTypes) => {
|
|
@@ -266,10 +269,6 @@ export const PieChartMain = (props: propTypes) => {
|
|
|
266
269
|
cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
|
|
267
270
|
(item.shiftY || 0);
|
|
268
271
|
|
|
269
|
-
// console.log('sx', sx);
|
|
270
|
-
// console.log('sy', sy);
|
|
271
|
-
// console.log('ax', ax);
|
|
272
|
-
// console.log('ay', ay);
|
|
273
272
|
return (
|
|
274
273
|
<Path
|
|
275
274
|
key={index + 'a'}
|
|
@@ -280,10 +279,18 @@ export const PieChartMain = (props: propTypes) => {
|
|
|
280
279
|
} 1 ${ax} ${ay} L ${cx + (item.shiftX || 0)} ${
|
|
281
280
|
cy + (item.shiftY || 0)
|
|
282
281
|
}`}
|
|
283
|
-
stroke={strokeColor}
|
|
284
|
-
strokeWidth={
|
|
282
|
+
stroke={item.strokeColor || strokeColor}
|
|
283
|
+
strokeWidth={
|
|
284
|
+
props.focusOnPress && props.selectedIndex === index
|
|
285
|
+
? 0
|
|
286
|
+
: item.strokeWidth === 0
|
|
287
|
+
? 0
|
|
288
|
+
: item.strokeWidth || strokeWidth
|
|
289
|
+
}
|
|
285
290
|
fill={
|
|
286
|
-
|
|
291
|
+
props.selectedIndex === index || item.peripheral
|
|
292
|
+
? 'transparent'
|
|
293
|
+
: showGradient
|
|
287
294
|
? `url(#grad${index})`
|
|
288
295
|
: item.color || colors[index % 9]
|
|
289
296
|
}
|
package/src/todos.md
CHANGED
|
@@ -4,19 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
## To-dos in documentation-
|
|
6
6
|
|
|
7
|
-
1. Prepare a doc for
|
|
8
|
-
2. Prepare a doc for Line chart with
|
|
9
|
-
3. Prepare a doc for Bar chart with
|
|
10
|
-
4. Prepare a doc for Line chart with
|
|
11
|
-
5. Prepare a doc for
|
|
12
|
-
6. Prepare a doc for
|
|
13
|
-
7. Prepare a doc for Bar
|
|
14
|
-
8. Prepare a doc for
|
|
15
|
-
9. Prepare a doc for
|
|
16
|
-
8. Prepare a doc for adjustToWidth in Line and Area charts
|
|
17
|
-
9. Prepare a doc for xAxisLabelTexts and xAxisLabelTextStyle in Bar, Line And Area Charts
|
|
18
|
-
10. Prepare a doc for vertical lines to explain noOfVerticalLines and verticalLinesSpacing props. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/205
|
|
19
|
-
11. Prepare a doc for negative marginBottom instead of marginTop for x axis labels. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/190
|
|
7
|
+
1. Prepare a doc for Line chart with negative values
|
|
8
|
+
2. Prepare a doc for Line chart with y axis on right side
|
|
9
|
+
3. Prepare a doc for Bar chart combined with Line chart having a separate data for the Line chart
|
|
10
|
+
4. Prepare a doc for Line chart with smoothly scrolling data pointer and strip (along with pointerShiftX)
|
|
11
|
+
5. Prepare a doc for labelsPosition in Pie and Donut charts
|
|
12
|
+
6. Prepare a doc for adjustToWidth in Line and Area charts
|
|
13
|
+
7. Prepare a doc for xAxisLabelTexts and xAxisLabelTextStyle in Bar, Line And Area Charts
|
|
14
|
+
8. Prepare a doc for vertical lines to explain noOfVerticalLines and verticalLinesSpacing props. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/205
|
|
15
|
+
9. Prepare a doc for negative marginBottom instead of marginTop for x axis labels. https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/190
|
|
20
16
|
|
|
21
17
|
|
|
22
18
|
## Architecture Enhancement
|