@dhiraj0720/report1chart 2.2.2 → 2.2.4

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.
@@ -1,120 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- } from 'react-native';
7
-
8
- const PieChart = ({ data, title }) => {
9
- const formatNumber = (num) => {
10
- return num.toLocaleString();
11
- };
12
-
13
- const getColor = (index) => {
14
- const colors = ['#4CAF50', '#2196F3', '#FF9800', '#E91E63', '#9C27B0'];
15
- return colors[index % colors.length];
16
- };
17
-
18
- if (!Array.isArray(data) || data.length === 0) {
19
- return (
20
- <View style={styles.noDataContainer}>
21
- <Text style={styles.noDataText}>No data available</Text>
22
- </View>
23
- );
24
- }
25
-
26
- const total = data.reduce((sum, item) => sum + (item.shipments || item.value || 0), 0);
27
-
28
- return (
29
- <View style={styles.container}>
30
- {title && <Text style={styles.title}>{title}</Text>}
31
- <View style={styles.pieContainer}>
32
- {data.map((item, index) => {
33
- const value = item.shipments || item.value || 0;
34
- const label = item.direction || item.label || `Item ${index + 1}`;
35
- const percentage = total > 0 ? ((value / total) * 100).toFixed(1) : '0';
36
-
37
- return (
38
- <View key={index} style={styles.pieItem}>
39
- <View style={[styles.pieColor, { backgroundColor: getColor(index) }]} />
40
- <Text style={styles.pieLabel}>{label}:</Text>
41
- <Text style={styles.pieValue}>
42
- {formatNumber(value)} ({percentage}%)
43
- </Text>
44
- </View>
45
- );
46
- })}
47
- </View>
48
- {total > 0 && (
49
- <Text style={styles.totalText}>Total: {formatNumber(total)}</Text>
50
- )}
51
- </View>
52
- );
53
- };
54
-
55
- const styles = StyleSheet.create({
56
- container: {
57
- backgroundColor: '#fff',
58
- borderRadius: 12,
59
- padding: 16,
60
- marginBottom: 16,
61
- borderWidth: 1,
62
- borderColor: '#e8e8e8',
63
- },
64
- title: {
65
- fontSize: 18,
66
- fontWeight: '700',
67
- color: '#000',
68
- marginBottom: 20,
69
- textAlign: 'center',
70
- },
71
- pieContainer: {
72
- padding: 10,
73
- },
74
- pieItem: {
75
- flexDirection: 'row',
76
- alignItems: 'center',
77
- marginBottom: 12,
78
- padding: 8,
79
- backgroundColor: '#f9f9f9',
80
- borderRadius: 8,
81
- },
82
- pieColor: {
83
- width: 16,
84
- height: 16,
85
- borderRadius: 8,
86
- marginRight: 12,
87
- },
88
- pieLabel: {
89
- fontSize: 15,
90
- fontWeight: '600',
91
- color: '#000',
92
- flex: 1,
93
- },
94
- pieValue: {
95
- fontSize: 14,
96
- color: '#666',
97
- fontWeight: '500',
98
- },
99
- totalText: {
100
- fontSize: 16,
101
- fontWeight: '700',
102
- color: '#4CAF50',
103
- textAlign: 'center',
104
- marginTop: 16,
105
- paddingTop: 16,
106
- borderTopWidth: 1,
107
- borderTopColor: '#eee',
108
- },
109
- noDataContainer: {
110
- padding: 40,
111
- alignItems: 'center',
112
- },
113
- noDataText: {
114
- fontSize: 16,
115
- color: '#999',
116
- textAlign: 'center',
117
- },
118
- });
119
-
120
- export default PieChart;
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const ErrorDisplay = ({ error, onRetry }) => {
10
- return (
11
- <View style={styles.container}>
12
- <Text style={styles.errorText}>Error: {error}</Text>
13
- {onRetry && (
14
- <TouchableOpacity
15
- style={styles.retryButton}
16
- onPress={onRetry}
17
- >
18
- <Text style={styles.retryText}>Retry</Text>
19
- </TouchableOpacity>
20
- )}
21
- </View>
22
- );
23
- };
24
-
25
- const styles = StyleSheet.create({
26
- container: {
27
- flex: 1,
28
- justifyContent: 'center',
29
- alignItems: 'center',
30
- padding: 40,
31
- },
32
- errorText: {
33
- fontSize: 16,
34
- color: '#d32f2f',
35
- textAlign: 'center',
36
- marginBottom: 20,
37
- },
38
- retryButton: {
39
- backgroundColor: '#4CAF50',
40
- paddingHorizontal: 24,
41
- paddingVertical: 12,
42
- borderRadius: 8,
43
- },
44
- retryText: {
45
- color: '#fff',
46
- fontSize: 16,
47
- fontWeight: '600',
48
- },
49
- });
50
-
51
- export default ErrorDisplay;
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ActivityIndicator,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const LoadingSpinner = ({ message = 'Loading...' }) => {
10
- return (
11
- <View style={styles.container}>
12
- <ActivityIndicator size="large" color="#4CAF50" />
13
- <Text style={styles.message}>{message}</Text>
14
- </View>
15
- );
16
- };
17
-
18
- const styles = StyleSheet.create({
19
- container: {
20
- flex: 1,
21
- justifyContent: 'center',
22
- alignItems: 'center',
23
- padding: 40,
24
- },
25
- message: {
26
- marginTop: 16,
27
- fontSize: 16,
28
- color: '#666',
29
- },
30
- });
31
-
32
- export default LoadingSpinner;
@@ -1,84 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const ReportCard = ({ report, onPress }) => {
10
- const getColor = (id) => {
11
- const colors = ['#4CAF50', '#2196F3', '#FF9800', '#E91E63', '#9C27B0'];
12
- return colors[Math.floor(id) % colors.length];
13
- };
14
-
15
- return (
16
- <TouchableOpacity
17
- style={styles.card}
18
- onPress={onPress}
19
- >
20
- <View style={[styles.icon, { backgroundColor: getColor(report.id) }]}>
21
- <Text style={styles.iconText}>{Math.floor(report.id)}</Text>
22
- </View>
23
- <View style={styles.info}>
24
- <Text style={styles.name}>{report.name}</Text>
25
- <Text style={styles.title}>{report.title}</Text>
26
- <Text style={styles.desc}>{report.description}</Text>
27
- </View>
28
- <Text style={styles.arrow}>›</Text>
29
- </TouchableOpacity>
30
- );
31
- };
32
-
33
- const styles = StyleSheet.create({
34
- card: {
35
- flexDirection: 'row',
36
- alignItems: 'center',
37
- backgroundColor: '#fff',
38
- borderRadius: 12,
39
- padding: 16,
40
- marginBottom: 12,
41
- borderWidth: 1,
42
- borderColor: '#e8e8e8',
43
- },
44
- icon: {
45
- width: 44,
46
- height: 44,
47
- borderRadius: 22,
48
- justifyContent: 'center',
49
- alignItems: 'center',
50
- marginRight: 12,
51
- },
52
- iconText: {
53
- fontSize: 18,
54
- fontWeight: '700',
55
- color: '#fff',
56
- },
57
- info: {
58
- flex: 1,
59
- },
60
- name: {
61
- fontSize: 16,
62
- fontWeight: '600',
63
- color: '#000',
64
- marginBottom: 2,
65
- },
66
- title: {
67
- fontSize: 14,
68
- fontWeight: '500',
69
- color: '#4CAF50',
70
- marginBottom: 4,
71
- },
72
- desc: {
73
- fontSize: 13,
74
- color: '#666',
75
- lineHeight: 18,
76
- },
77
- arrow: {
78
- fontSize: 24,
79
- color: '#ccc',
80
- fontWeight: '300',
81
- },
82
- });
83
-
84
- export default ReportCard;
@@ -1,194 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const CompactTable = ({ data }) => {
10
- const formatCurrency = (value) => {
11
- const num = Number(value);
12
- if (isNaN(num)) return '0';
13
-
14
- if (num >= 1000000) {
15
- return `${(num / 1000000).toFixed(1)}M`;
16
- } else if (num >= 1000) {
17
- return `${(num / 1000).toFixed(1)}K`;
18
- }
19
- return num.toLocaleString();
20
- };
21
-
22
- if (!Array.isArray(data) || data.length === 0) {
23
- return (
24
- <View style={styles.noDataContainer}>
25
- <Text style={styles.noDataText}>No data available</Text>
26
- </View>
27
- );
28
- }
29
-
30
- return (
31
- <ScrollView style={styles.container}>
32
- {data.map((item, index) => (
33
- <View
34
- key={index}
35
- style={[
36
- styles.card,
37
- item.isTotal && styles.totalCard,
38
- ]}
39
- >
40
- <View style={styles.header}>
41
- <Text style={[
42
- styles.title,
43
- item.isTotal && styles.totalTitle
44
- ]}>
45
- {item.name}
46
- </Text>
47
- <Text style={[
48
- styles.grossMargin,
49
- ]}>
50
- Gross Margin: {item.grossMarginPercent}%
51
- </Text>
52
- </View>
53
-
54
- <View style={styles.grid}>
55
- <View style={styles.column}>
56
- <Text style={styles.label}>2024 Actual</Text>
57
- <Text style={styles.value}>
58
- {formatCurrency(item.actual2024)}
59
- </Text>
60
- </View>
61
-
62
- <View style={styles.column}>
63
- <Text style={styles.label}>2025 Actual</Text>
64
- <Text style={styles.value}>
65
- {formatCurrency(item.actual2025)}
66
- </Text>
67
- </View>
68
-
69
- <View style={styles.column}>
70
- <Text style={styles.label}>YoY Change</Text>
71
- <Text style={[
72
- styles.percentText,
73
- item.yoYChangePercent >= 0 ? styles.positive : styles.negative
74
- ]}>
75
- {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
76
- </Text>
77
- </View>
78
-
79
- <View style={styles.column}>
80
- <Text style={styles.label}>2025 Budget</Text>
81
- <Text style={styles.value}>
82
- {formatCurrency(item.budget2025)}
83
- </Text>
84
- </View>
85
-
86
- <View style={styles.column}>
87
- <Text style={styles.label}>Variance</Text>
88
- <Text style={[
89
- styles.percentText,
90
- item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
91
- ]}>
92
- {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
93
- </Text>
94
- </View>
95
- </View>
96
- </View>
97
- ))}
98
- </ScrollView>
99
- );
100
- };
101
-
102
- const styles = StyleSheet.create({
103
- container: {
104
- flex: 1,
105
- paddingHorizontal: 8,
106
- },
107
- card: {
108
- backgroundColor: '#fff',
109
- borderRadius: 12,
110
- marginBottom: 12,
111
- padding: 16,
112
- borderWidth: 1,
113
- borderColor: '#e8e8e8',
114
- },
115
- totalCard: {
116
- backgroundColor: '#e8f5e9',
117
- borderColor: '#4CAF50',
118
- borderWidth: 2,
119
- },
120
- header: {
121
- flexDirection: 'row',
122
- justifyContent: 'space-between',
123
- alignItems: 'center',
124
- marginBottom: 12,
125
- paddingBottom: 12,
126
- borderBottomWidth: 1,
127
- borderBottomColor: '#eee',
128
- },
129
- title: {
130
- fontSize: 14,
131
- fontWeight: '600',
132
- color: '#2c3e50',
133
- flex: 1,
134
- },
135
- totalTitle: {
136
- fontWeight: '700',
137
- color: '#2c3e50',
138
- fontSize: 15,
139
- },
140
- grossMargin: {
141
- fontSize: 13,
142
- fontWeight: '600',
143
- paddingHorizontal: 8,
144
- paddingVertical: 4,
145
- borderRadius: 6,
146
- backgroundColor: '#f0f0f0',
147
- color: '#2c3e50',
148
- },
149
- grid: {
150
- flexDirection: 'row',
151
- flexWrap: 'wrap',
152
- justifyContent: 'space-between',
153
- },
154
- column: {
155
- width: '48%',
156
- marginBottom: 12,
157
- backgroundColor: '#f8f9fa',
158
- padding: 10,
159
- borderRadius: 8,
160
- alignItems: 'center',
161
- },
162
- label: {
163
- fontSize: 11,
164
- color: '#666',
165
- marginBottom: 4,
166
- textAlign: 'center',
167
- },
168
- value: {
169
- fontSize: 13,
170
- fontWeight: '600',
171
- color: '#2c3e50',
172
- },
173
- percentText: {
174
- fontSize: 12,
175
- fontWeight: '600',
176
- },
177
- positive: {
178
- color: '#27ae60',
179
- },
180
- negative: {
181
- color: '#e74c3c',
182
- },
183
- noDataContainer: {
184
- padding: 40,
185
- alignItems: 'center',
186
- },
187
- noDataText: {
188
- fontSize: 16,
189
- color: '#999',
190
- textAlign: 'center',
191
- },
192
- });
193
-
194
- export default CompactTable;
@@ -1,221 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const DefaultTable = ({ data }) => {
10
- const formatCurrency = (value) => {
11
- const num = Number(value);
12
- if (isNaN(num)) return '0';
13
-
14
- if (num >= 1000000) {
15
- return `${(num / 1000000).toFixed(1)}M`;
16
- } else if (num >= 1000) {
17
- return `${(num / 1000).toFixed(1)}K`;
18
- }
19
- return num.toLocaleString();
20
- };
21
-
22
- if (!Array.isArray(data) || data.length === 0) {
23
- return (
24
- <View style={styles.noDataContainer}>
25
- <Text style={styles.noDataText}>No data available</Text>
26
- </View>
27
- );
28
- }
29
-
30
- return (
31
- <ScrollView horizontal showsHorizontalScrollIndicator={true}>
32
- <View style={styles.table}>
33
- <View style={styles.tableHeader}>
34
- <View style={[styles.headerCell, styles.firstColumn]}>
35
- <Text style={styles.headerText}>ACTIVITY</Text>
36
- </View>
37
- <View style={styles.headerCell}>
38
- <Text style={styles.headerText}>2024 Actual</Text>
39
- </View>
40
- <View style={styles.headerCell}>
41
- <Text style={styles.headerText}>2025 Actual</Text>
42
- </View>
43
- <View style={styles.headerCell}>
44
- <Text style={styles.headerText}>YoY Change %</Text>
45
- </View>
46
- <View style={styles.headerCell}>
47
- <Text style={styles.headerText}>2025 Budget</Text>
48
- </View>
49
- <View style={styles.headerCell}>
50
- <Text style={styles.headerText}>Variance %</Text>
51
- </View>
52
- <View style={styles.headerCell}>
53
- <Text style={styles.headerText}>GROSS MARGIN %</Text>
54
- </View>
55
- </View>
56
-
57
- {data.map((item, index) => (
58
- <View
59
- key={index}
60
- style={[
61
- styles.tableRow,
62
- item.isTotal ? styles.totalRow : (index % 2 === 0 ? styles.evenRow : styles.oddRow)
63
- ]}
64
- >
65
- <View style={[styles.cell, styles.firstColumn]}>
66
- <Text style={item.isTotal ? styles.totalText : styles.cellText}>
67
- {item.name}
68
- </Text>
69
- </View>
70
-
71
- <View style={styles.cell}>
72
- <Text style={styles.numberText}>
73
- {formatCurrency(item.actual2024)}
74
- </Text>
75
- </View>
76
-
77
- <View style={styles.cell}>
78
- <Text style={styles.numberText}>
79
- {formatCurrency(item.actual2025)}
80
- </Text>
81
- </View>
82
-
83
- <View style={styles.cell}>
84
- <Text style={[
85
- styles.percentText,
86
- item.yoYChangePercent >= 0 ? styles.positive : styles.negative
87
- ]}>
88
- {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
89
- </Text>
90
- </View>
91
-
92
- <View style={styles.cell}>
93
- <Text style={styles.numberText}>
94
- {formatCurrency(item.budget2025)}
95
- </Text>
96
- </View>
97
-
98
- <View style={styles.cell}>
99
- <Text style={[
100
- styles.percentText,
101
- item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
102
- ]}>
103
- {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
104
- </Text>
105
- </View>
106
-
107
- <View style={styles.cell}>
108
- <Text style={[
109
- styles.percentText,
110
- styles.grossMargin
111
- ]}>
112
- {item.grossMarginPercent}%
113
- </Text>
114
- </View>
115
- </View>
116
- ))}
117
- </View>
118
- </ScrollView>
119
- );
120
- };
121
-
122
- const styles = StyleSheet.create({
123
- table: {
124
- minWidth: 700,
125
- marginBottom: 20,
126
- },
127
- tableHeader: {
128
- flexDirection: 'row',
129
- backgroundColor: '#2c3e50',
130
- borderBottomWidth: 1,
131
- borderBottomColor: '#ddd',
132
- },
133
- headerCell: {
134
- flex: 1,
135
- padding: 10,
136
- minWidth: 100,
137
- justifyContent: 'center',
138
- alignItems: 'center',
139
- borderRightWidth: 1,
140
- borderRightColor: '#444',
141
- },
142
- firstColumn: {
143
- flex: 1.5,
144
- minWidth: 180,
145
- },
146
- headerText: {
147
- color: '#fff',
148
- fontWeight: '600',
149
- fontSize: 11,
150
- textAlign: 'center',
151
- },
152
- tableRow: {
153
- flexDirection: 'row',
154
- borderBottomWidth: 1,
155
- borderBottomColor: '#eee',
156
- minHeight: 40,
157
- },
158
- evenRow: {
159
- backgroundColor: '#fff',
160
- },
161
- oddRow: {
162
- backgroundColor: '#f9f9f9',
163
- },
164
- totalRow: {
165
- backgroundColor: '#e8f5e9',
166
- borderTopWidth: 2,
167
- borderTopColor: '#4CAF50',
168
- borderBottomWidth: 2,
169
- borderBottomColor: '#4CAF50',
170
- },
171
- cell: {
172
- flex: 1,
173
- padding: 8,
174
- minWidth: 100,
175
- justifyContent: 'center',
176
- alignItems: 'center',
177
- borderRightWidth: 1,
178
- borderRightColor: '#eee',
179
- },
180
- cellText: {
181
- fontSize: 12,
182
- color: '#333',
183
- textAlign: 'center',
184
- },
185
- totalText: {
186
- fontSize: 12,
187
- fontWeight: '700',
188
- color: '#2c3e50',
189
- textAlign: 'center',
190
- },
191
- numberText: {
192
- fontSize: 11,
193
- fontWeight: '500',
194
- color: '#333',
195
- },
196
- percentText: {
197
- fontSize: 12,
198
- fontWeight: '600',
199
- },
200
- positive: {
201
- color: '#27ae60',
202
- },
203
- negative: {
204
- color: '#e74c3c',
205
- },
206
- grossMargin: {
207
- color: '#2c3e50',
208
- fontWeight: '700',
209
- },
210
- noDataContainer: {
211
- padding: 40,
212
- alignItems: 'center',
213
- },
214
- noDataText: {
215
- fontSize: 16,
216
- color: '#999',
217
- textAlign: 'center',
218
- },
219
- });
220
-
221
- export default DefaultTable;