@dhiraj0720/report1chart 2.2.1 → 2.2.3

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,134 +0,0 @@
1
- import React from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- StyleSheet,
7
- } from 'react-native';
8
-
9
- const LineChart = ({ data, title }) => {
10
- const formatNumber = (num) => {
11
- return num.toLocaleString();
12
- };
13
-
14
- if (!data || (!Array.isArray(data) && !data.values)) {
15
- return (
16
- <View style={styles.noDataContainer}>
17
- <Text style={styles.noDataText}>No data available</Text>
18
- </View>
19
- );
20
- }
21
-
22
- let values, labels;
23
-
24
- if (Array.isArray(data)) {
25
- values = data.map(d => d.value || 0);
26
- labels = data.map(d => d.label || '');
27
- } else {
28
- values = data.values || [];
29
- labels = data.labels || [];
30
- }
31
-
32
- if (values.length === 0) {
33
- return (
34
- <View style={styles.noDataContainer}>
35
- <Text style={styles.noDataText}>No data available</Text>
36
- </View>
37
- );
38
- }
39
-
40
- const maxValue = Math.max(...values, 1);
41
- const chartHeight = 200;
42
-
43
- return (
44
- <View style={styles.container}>
45
- {title && <Text style={styles.title}>{title}</Text>}
46
- <ScrollView
47
- horizontal
48
- showsHorizontalScrollIndicator={true}
49
- >
50
- <View style={[styles.chart, { height: chartHeight }]}>
51
- {values.map((value, index) => {
52
- const height = (value / maxValue) * chartHeight;
53
- const label = labels[index] || `M${index + 1}`;
54
-
55
- return (
56
- <View key={index} style={styles.pointWrapper}>
57
- <View style={[styles.point, {
58
- height: Math.max(height, 2),
59
- }]} />
60
- <View style={styles.connector} />
61
- <Text style={styles.pointLabel} numberOfLines={1}>{label}</Text>
62
- <Text style={styles.valueText}>{formatNumber(value)}</Text>
63
- </View>
64
- );
65
- })}
66
- </View>
67
- </ScrollView>
68
- </View>
69
- );
70
- };
71
-
72
- const styles = StyleSheet.create({
73
- container: {
74
- backgroundColor: '#fff',
75
- borderRadius: 12,
76
- padding: 16,
77
- marginBottom: 16,
78
- borderWidth: 1,
79
- borderColor: '#e8e8e8',
80
- },
81
- title: {
82
- fontSize: 18,
83
- fontWeight: '700',
84
- color: '#000',
85
- marginBottom: 20,
86
- textAlign: 'center',
87
- },
88
- chart: {
89
- flexDirection: 'row',
90
- alignItems: 'flex-end',
91
- paddingHorizontal: 8,
92
- minWidth: 400,
93
- },
94
- pointWrapper: {
95
- alignItems: 'center',
96
- marginHorizontal: 12,
97
- },
98
- point: {
99
- width: 30,
100
- backgroundColor: '#2196F3',
101
- borderRadius: 2,
102
- },
103
- connector: {
104
- width: 2,
105
- backgroundColor: '#2196F3',
106
- opacity: 0.3,
107
- marginVertical: 2,
108
- flex: 1,
109
- },
110
- pointLabel: {
111
- marginTop: 8,
112
- fontSize: 12,
113
- color: '#666',
114
- textAlign: 'center',
115
- width: 60,
116
- },
117
- valueText: {
118
- fontSize: 11,
119
- color: '#999',
120
- marginTop: 4,
121
- fontWeight: '500',
122
- },
123
- noDataContainer: {
124
- padding: 40,
125
- alignItems: 'center',
126
- },
127
- noDataText: {
128
- fontSize: 16,
129
- color: '#999',
130
- textAlign: 'center',
131
- },
132
- });
133
-
134
- export default LineChart;
@@ -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;