@dhiraj0720/report1chart 1.0.6 → 2.1.0

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.
@@ -0,0 +1,264 @@
1
+ import React from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ ScrollView,
6
+ StyleSheet,
7
+ } from 'react-native';
8
+
9
+ const FreezeTable = ({ 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
+ <View style={styles.container}>
32
+ {/* Fixed First Column */}
33
+ <View style={styles.fixedColumn}>
34
+ <View style={[styles.fixedHeader, styles.fixedFirstCell]}>
35
+ <Text style={styles.fixedHeaderText}>FALİYET KAR/ZARAR</Text>
36
+ </View>
37
+ {data.map((item, index) => (
38
+ <View
39
+ key={index}
40
+ style={[
41
+ styles.fixedRow,
42
+ item.isTotal && styles.fixedTotalRow,
43
+ index % 2 === 0 ? styles.evenRow : styles.oddRow
44
+ ]}
45
+ >
46
+ <Text style={[
47
+ styles.fixedCellText,
48
+ item.isTotal && styles.fixedTotalText
49
+ ]}>
50
+ {item.name}
51
+ </Text>
52
+ </View>
53
+ ))}
54
+ </View>
55
+
56
+ {/* Scrollable Data Columns */}
57
+ <ScrollView horizontal showsHorizontalScrollIndicator={true}>
58
+ <View style={styles.scrollableColumns}>
59
+ {/* Headers for scrollable columns */}
60
+ <View style={styles.scrollableHeaderRow}>
61
+ {['2024 Fiili', '2025 Fiili', 'Fiili Artış %', '2025 Bütçe', 'Sapma %', 'BRÜT KAR %'].map((header, idx) => (
62
+ <View key={idx} style={styles.scrollableHeader}>
63
+ <Text style={styles.scrollableHeaderText}>{header}</Text>
64
+ </View>
65
+ ))}
66
+ </View>
67
+
68
+ {/* Data rows for scrollable columns */}
69
+ {data.map((item, rowIndex) => (
70
+ <View
71
+ key={rowIndex}
72
+ style={[
73
+ styles.scrollableDataRow,
74
+ item.isTotal && styles.scrollableTotalDataRow,
75
+ rowIndex % 2 === 0 ? styles.evenRow : styles.oddRow
76
+ ]}
77
+ >
78
+ <View style={styles.scrollableDataCell}>
79
+ <Text style={styles.scrollableDataText}>
80
+ {formatCurrency(item.actual2024)}
81
+ </Text>
82
+ </View>
83
+
84
+ <View style={styles.scrollableDataCell}>
85
+ <Text style={styles.scrollableDataText}>
86
+ {formatCurrency(item.actual2025)}
87
+ </Text>
88
+ </View>
89
+
90
+ <View style={styles.scrollableDataCell}>
91
+ <Text style={[
92
+ styles.scrollablePercent,
93
+ item.yoYChangePercent >= 0 ? styles.positive : styles.negative
94
+ ]}>
95
+ {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent).toFixed(1)}%
96
+ </Text>
97
+ </View>
98
+
99
+ <View style={styles.scrollableDataCell}>
100
+ <Text style={styles.scrollableDataText}>
101
+ {formatCurrency(item.budget2025)}
102
+ </Text>
103
+ </View>
104
+
105
+ <View style={styles.scrollableDataCell}>
106
+ <Text style={[
107
+ styles.scrollablePercent,
108
+ item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
109
+ ]}>
110
+ {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent).toFixed(1)}%
111
+ </Text>
112
+ </View>
113
+
114
+ <View style={styles.scrollableDataCell}>
115
+ <Text style={[
116
+ styles.scrollablePercent,
117
+ styles.grossMargin
118
+ ]}>
119
+ {item.grossMarginPercent}%
120
+ </Text>
121
+ </View>
122
+ </View>
123
+ ))}
124
+ </View>
125
+ </ScrollView>
126
+ </View>
127
+ );
128
+ };
129
+
130
+ const styles = StyleSheet.create({
131
+ container: {
132
+ flex: 1,
133
+ flexDirection: 'row',
134
+ },
135
+ fixedColumn: {
136
+ width: 180,
137
+ borderRightWidth: 2,
138
+ borderRightColor: '#ddd',
139
+ backgroundColor: '#fff',
140
+ },
141
+ fixedFirstCell: {
142
+ backgroundColor: '#2c3e50',
143
+ justifyContent: 'center',
144
+ alignItems: 'center',
145
+ },
146
+ fixedHeader: {
147
+ height: 50,
148
+ justifyContent: 'center',
149
+ alignItems: 'center',
150
+ backgroundColor: '#2c3e50',
151
+ borderBottomWidth: 1,
152
+ borderBottomColor: '#444',
153
+ borderRightWidth: 1,
154
+ borderRightColor: '#444',
155
+ minWidth: 120,
156
+ },
157
+ fixedHeaderText: {
158
+ color: '#fff',
159
+ fontWeight: '600',
160
+ fontSize: 12,
161
+ textAlign: 'center',
162
+ },
163
+ fixedRow: {
164
+ height: 45,
165
+ justifyContent: 'center',
166
+ paddingHorizontal: 10,
167
+ borderBottomWidth: 1,
168
+ borderBottomColor: '#eee',
169
+ },
170
+ fixedTotalRow: {
171
+ backgroundColor: '#e8f5e9',
172
+ borderTopWidth: 2,
173
+ borderTopColor: '#4CAF50',
174
+ borderBottomWidth: 2,
175
+ borderBottomColor: '#4CAF50',
176
+ },
177
+ fixedCellText: {
178
+ fontSize: 12,
179
+ color: '#333',
180
+ fontWeight: '500',
181
+ },
182
+ fixedTotalText: {
183
+ fontWeight: '700',
184
+ color: '#2c3e50',
185
+ },
186
+ scrollableColumns: {
187
+ flex: 1,
188
+ },
189
+ scrollableHeaderRow: {
190
+ flexDirection: 'row',
191
+ },
192
+ scrollableHeader: {
193
+ height: 50,
194
+ justifyContent: 'center',
195
+ alignItems: 'center',
196
+ backgroundColor: '#2c3e50',
197
+ borderBottomWidth: 1,
198
+ borderBottomColor: '#444',
199
+ borderRightWidth: 1,
200
+ borderRightColor: '#444',
201
+ minWidth: 120,
202
+ },
203
+ scrollableHeaderText: {
204
+ color: '#fff',
205
+ fontWeight: '600',
206
+ fontSize: 12,
207
+ textAlign: 'center',
208
+ },
209
+ scrollableDataRow: {
210
+ flexDirection: 'row',
211
+ height: 45,
212
+ borderBottomWidth: 1,
213
+ borderBottomColor: '#eee',
214
+ },
215
+ scrollableTotalDataRow: {
216
+ backgroundColor: '#e8f5e9',
217
+ },
218
+ scrollableDataCell: {
219
+ minWidth: 120,
220
+ justifyContent: 'center',
221
+ alignItems: 'center',
222
+ borderRightWidth: 1,
223
+ borderRightColor: '#eee',
224
+ paddingHorizontal: 8,
225
+ },
226
+ scrollableDataText: {
227
+ fontSize: 12,
228
+ fontWeight: '500',
229
+ fontFamily: 'monospace',
230
+ color: '#333',
231
+ },
232
+ scrollablePercent: {
233
+ fontSize: 12,
234
+ fontWeight: '600',
235
+ fontFamily: 'monospace',
236
+ },
237
+ positive: {
238
+ color: '#27ae60',
239
+ },
240
+ negative: {
241
+ color: '#e74c3c',
242
+ },
243
+ grossMargin: {
244
+ color: '#2c3e50',
245
+ fontWeight: '700',
246
+ },
247
+ evenRow: {
248
+ backgroundColor: '#fff',
249
+ },
250
+ oddRow: {
251
+ backgroundColor: '#f9f9f9',
252
+ },
253
+ noDataContainer: {
254
+ padding: 40,
255
+ alignItems: 'center',
256
+ },
257
+ noDataText: {
258
+ fontSize: 16,
259
+ color: '#999',
260
+ textAlign: 'center',
261
+ },
262
+ });
263
+
264
+ export default FreezeTable;
@@ -0,0 +1,47 @@
1
+ import { Dimensions } from 'react-native';
2
+
3
+ export const formatCurrency = (value) => {
4
+ const num = Number(value);
5
+ if (isNaN(num)) return '0';
6
+
7
+ if (num >= 1000000) {
8
+ return `${(num / 1000000).toFixed(1)}M`;
9
+ } else if (num >= 1000) {
10
+ return `${(num / 1000).toFixed(1)}K`;
11
+ }
12
+ return num.toLocaleString();
13
+ };
14
+
15
+ export const formatNumber = (num) => {
16
+ return num.toLocaleString();
17
+ };
18
+
19
+ export const calculatePercentageChange = (oldValue, newValue) => {
20
+ if (!oldValue || oldValue === 0) return 0;
21
+ return ((newValue - oldValue) / Math.abs(oldValue)) * 100;
22
+ };
23
+
24
+ export const getTableWidth = (columns) => {
25
+ const { width: screenWidth } = Dimensions.get('window');
26
+ return Math.max(screenWidth, columns * 120);
27
+ };
28
+
29
+ export const getStatusColor = (yoYChange, budgetVariance) => {
30
+ if (yoYChange >= 0 && budgetVariance >= 0) {
31
+ return '#4CAF50'; // Good
32
+ } else if (yoYChange >= 0 || budgetVariance >= 0) {
33
+ return '#FF9800'; // Warning
34
+ } else {
35
+ return '#F44336'; // Critical
36
+ }
37
+ };
38
+
39
+ export const getStatusText = (yoYChange, budgetVariance) => {
40
+ if (yoYChange >= 0 && budgetVariance >= 0) {
41
+ return 'Performans İyi';
42
+ } else if (yoYChange >= 0 || budgetVariance >= 0) {
43
+ return 'Kısmen İyi';
44
+ } else {
45
+ return 'İnceleme Gerekli';
46
+ }
47
+ };