@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.
@@ -0,0 +1,647 @@
1
+ import React from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ ScrollView,
6
+ StyleSheet,
7
+ Dimensions,
8
+ } from 'react-native';
9
+
10
+ export 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
+ export const formatNumber = (num) => {
23
+ return num.toLocaleString();
24
+ };
25
+
26
+ export const renderTable = (data) => {
27
+ if (!Array.isArray(data) || data.length === 0) {
28
+ return (
29
+ <View style={styles.noDataContainer}>
30
+ <Text style={styles.noDataText}>No data available for this report</Text>
31
+ </View>
32
+ );
33
+ }
34
+
35
+ return (
36
+ <ScrollView horizontal showsHorizontalScrollIndicator={true}>
37
+ <View style={styles.table}>
38
+ {/* Table Header */}
39
+ <View style={styles.tableHeader}>
40
+ <View style={[styles.headerCell, styles.firstColumn]}>
41
+ <Text style={styles.headerText}>FALİYET KAR/ZARAR</Text>
42
+ </View>
43
+ <View style={styles.headerCell}>
44
+ <Text style={styles.headerText}>2024 Fiili</Text>
45
+ </View>
46
+ <View style={styles.headerCell}>
47
+ <Text style={styles.headerText}>2025 Fiili</Text>
48
+ </View>
49
+ <View style={styles.headerCell}>
50
+ <Text style={styles.headerText}>Fiili Artış %</Text>
51
+ </View>
52
+ <View style={styles.headerCell}>
53
+ <Text style={styles.headerText}>2025 Bütçe</Text>
54
+ </View>
55
+ <View style={styles.headerCell}>
56
+ <Text style={styles.headerText}>Sapma %</Text>
57
+ </View>
58
+ <View style={styles.headerCell}>
59
+ <Text style={styles.headerText}>BRÜT KAR %</Text>
60
+ </View>
61
+ </View>
62
+
63
+ {/* Table Rows */}
64
+ {data.map((item, index) => (
65
+ <View
66
+ key={index}
67
+ style={[
68
+ styles.tableRow,
69
+ item.isTotal ? styles.totalRow : (index % 2 === 0 ? styles.evenRow : styles.oddRow)
70
+ ]}
71
+ >
72
+ <View style={[styles.cell, styles.firstColumn]}>
73
+ <Text style={item.isTotal ? styles.totalText : styles.cellText}>
74
+ {item.name}
75
+ </Text>
76
+ </View>
77
+
78
+ <View style={styles.cell}>
79
+ <Text style={styles.numberText}>
80
+ {formatCurrency(item.actual2024)}
81
+ </Text>
82
+ </View>
83
+
84
+ <View style={styles.cell}>
85
+ <Text style={styles.numberText}>
86
+ {formatCurrency(item.actual2025)}
87
+ </Text>
88
+ </View>
89
+
90
+ <View style={styles.cell}>
91
+ <Text style={[
92
+ styles.percentText,
93
+ item.yoYChangePercent >= 0 ? styles.positive : styles.negative
94
+ ]}>
95
+ {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
96
+ </Text>
97
+ </View>
98
+
99
+ <View style={styles.cell}>
100
+ <Text style={styles.numberText}>
101
+ {formatCurrency(item.budget2025)}
102
+ </Text>
103
+ </View>
104
+
105
+ <View style={styles.cell}>
106
+ <Text style={[
107
+ styles.percentText,
108
+ item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
109
+ ]}>
110
+ {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
111
+ </Text>
112
+ </View>
113
+
114
+ <View style={styles.cell}>
115
+ <Text style={[
116
+ styles.percentText,
117
+ styles.grossMargin
118
+ ]}>
119
+ {item.grossMarginPercent}%
120
+ </Text>
121
+ </View>
122
+ </View>
123
+ ))}
124
+ </View>
125
+ </ScrollView>
126
+ );
127
+ };
128
+
129
+ export const renderCompactTable = (data) => {
130
+ if (!Array.isArray(data) || data.length === 0) {
131
+ return (
132
+ <View style={styles.noDataContainer}>
133
+ <Text style={styles.noDataText}>No data available for this report</Text>
134
+ </View>
135
+ );
136
+ }
137
+
138
+ return (
139
+ <ScrollView style={styles.compactContainer}>
140
+ {data.map((item, index) => (
141
+ <View
142
+ key={index}
143
+ style={[
144
+ styles.compactCard,
145
+ item.isTotal && styles.compactTotalCard,
146
+ index % 2 === 0 ? styles.evenCard : styles.oddCard
147
+ ]}
148
+ >
149
+ {/* Card Header */}
150
+ <View style={styles.compactHeader}>
151
+ <Text style={[
152
+ styles.compactTitle,
153
+ item.isTotal && styles.totalTitle
154
+ ]}>
155
+ {item.name}
156
+ </Text>
157
+ <Text style={[
158
+ styles.compactGrossMargin,
159
+ styles.grossMargin
160
+ ]}>
161
+ Brüt Kar: {item.grossMarginPercent}%
162
+ </Text>
163
+ </View>
164
+
165
+ {/* Card Body - Grid Layout */}
166
+ <View style={styles.compactGrid}>
167
+ {/* Column 1 */}
168
+ <View style={styles.compactColumn}>
169
+ <Text style={styles.compactLabel}>2024 Fiili</Text>
170
+ <Text style={styles.compactValue}>
171
+ {formatCurrency(item.actual2024)}
172
+ </Text>
173
+ </View>
174
+
175
+ {/* Column 2 */}
176
+ <View style={styles.compactColumn}>
177
+ <Text style={styles.compactLabel}>2025 Fiili</Text>
178
+ <Text style={styles.compactValue}>
179
+ {formatCurrency(item.actual2025)}
180
+ </Text>
181
+ </View>
182
+
183
+ {/* Column 3 */}
184
+ <View style={styles.compactColumn}>
185
+ <Text style={styles.compactLabel}>Fiili Artış</Text>
186
+ <View style={styles.percentBadge}>
187
+ <Text style={[
188
+ styles.percentText,
189
+ item.yoYChangePercent >= 0 ? styles.positive : styles.negative
190
+ ]}>
191
+ {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
192
+ </Text>
193
+ </View>
194
+ </View>
195
+
196
+ {/* Column 4 */}
197
+ <View style={styles.compactColumn}>
198
+ <Text style={styles.compactLabel}>2025 Bütçe</Text>
199
+ <Text style={styles.compactValue}>
200
+ {formatCurrency(item.budget2025)}
201
+ </Text>
202
+ </View>
203
+
204
+ {/* Column 5 */}
205
+ <View style={styles.compactColumn}>
206
+ <Text style={styles.compactLabel}>Sapma</Text>
207
+ <View style={styles.percentBadge}>
208
+ <Text style={[
209
+ styles.percentText,
210
+ item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
211
+ ]}>
212
+ {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
213
+ </Text>
214
+ </View>
215
+ </View>
216
+ </View>
217
+
218
+ {/* Status Indicator */}
219
+ <View style={styles.statusIndicator}>
220
+ <View style={[
221
+ styles.statusDot,
222
+ (item.yoYChangePercent >= 0 && item.budgetVariancePercent >= 0)
223
+ ? styles.statusGood
224
+ : styles.statusWarning
225
+ ]} />
226
+ <Text style={styles.statusText}>
227
+ {item.yoYChangePercent >= 0 && item.budgetVariancePercent >= 0
228
+ ? 'Performans İyi'
229
+ : 'İnceleme Gerekli'}
230
+ </Text>
231
+ </View>
232
+ </View>
233
+ ))}
234
+ </ScrollView>
235
+ );
236
+ };
237
+
238
+ export const renderFreezeTable = (data) => {
239
+ if (!Array.isArray(data) || data.length === 0) {
240
+ return (
241
+ <View style={styles.noDataContainer}>
242
+ <Text style={styles.noDataText}>No data available for this report</Text>
243
+ </View>
244
+ );
245
+ }
246
+
247
+ return (
248
+ <View style={styles.freezeContainer}>
249
+ {/* Fixed First Column */}
250
+ <View style={styles.freezeColumn}>
251
+ <View style={[styles.freezeHeader, styles.freezeFirstCell]}>
252
+ <Text style={styles.freezeHeaderText}>FALİYET KAR/ZARAR</Text>
253
+ </View>
254
+ {data.map((item, index) => (
255
+ <View
256
+ key={index}
257
+ style={[
258
+ styles.freezeRow,
259
+ item.isTotal && styles.freezeTotalRow,
260
+ index % 2 === 0 ? styles.evenRow : styles.oddRow
261
+ ]}
262
+ >
263
+ <Text style={[
264
+ styles.freezeCellText,
265
+ item.isTotal && styles.freezeTotalText
266
+ ]}>
267
+ {item.name}
268
+ </Text>
269
+ </View>
270
+ ))}
271
+ </View>
272
+
273
+ {/* Scrollable Data Columns */}
274
+ <ScrollView horizontal showsHorizontalScrollIndicator={true}>
275
+ <View style={styles.scrollableColumns}>
276
+ {/* Headers for scrollable columns */}
277
+ <View style={styles.freezeHeaderRow}>
278
+ {['2024 Fiili', '2025 Fiili', 'Fiili Artış %', '2025 Bütçe', 'Sapma %', 'BRÜT KAR %'].map((header, idx) => (
279
+ <View key={idx} style={styles.freezeHeader}>
280
+ <Text style={styles.freezeHeaderText}>{header}</Text>
281
+ </View>
282
+ ))}
283
+ </View>
284
+
285
+ {/* Data rows for scrollable columns */}
286
+ {data.map((item, rowIndex) => (
287
+ <View
288
+ key={rowIndex}
289
+ style={[
290
+ styles.freezeDataRow,
291
+ item.isTotal && styles.freezeTotalDataRow,
292
+ rowIndex % 2 === 0 ? styles.evenRow : styles.oddRow
293
+ ]}
294
+ >
295
+ <View style={styles.freezeDataCell}>
296
+ <Text style={styles.freezeDataText}>
297
+ {formatCurrency(item.actual2024)}
298
+ </Text>
299
+ </View>
300
+
301
+ <View style={styles.freezeDataCell}>
302
+ <Text style={styles.freezeDataText}>
303
+ {formatCurrency(item.actual2025)}
304
+ </Text>
305
+ </View>
306
+
307
+ <View style={styles.freezeDataCell}>
308
+ <Text style={[
309
+ styles.freezePercent,
310
+ item.yoYChangePercent >= 0 ? styles.positive : styles.negative
311
+ ]}>
312
+ {item.yoYChangePercent >= 0 ? '↑' : '↓'} {Math.abs(item.yoYChangePercent)}%
313
+ </Text>
314
+ </View>
315
+
316
+ <View style={styles.freezeDataCell}>
317
+ <Text style={styles.freezeDataText}>
318
+ {formatCurrency(item.budget2025)}
319
+ </Text>
320
+ </View>
321
+
322
+ <View style={styles.freezeDataCell}>
323
+ <Text style={[
324
+ styles.freezePercent,
325
+ item.budgetVariancePercent >= 0 ? styles.positive : styles.negative
326
+ ]}>
327
+ {item.budgetVariancePercent >= 0 ? '↑' : '↓'} {Math.abs(item.budgetVariancePercent)}%
328
+ </Text>
329
+ </View>
330
+
331
+ <View style={styles.freezeDataCell}>
332
+ <Text style={[
333
+ styles.freezePercent,
334
+ styles.grossMargin
335
+ ]}>
336
+ {item.grossMarginPercent}%
337
+ </Text>
338
+ </View>
339
+ </View>
340
+ ))}
341
+ </View>
342
+ </ScrollView>
343
+ </View>
344
+ );
345
+ };
346
+
347
+ const styles = StyleSheet.create({
348
+ noDataContainer: {
349
+ padding: 40,
350
+ alignItems: 'center',
351
+ },
352
+ noDataText: {
353
+ fontSize: 16,
354
+ color: '#999',
355
+ textAlign: 'center',
356
+ },
357
+ table: {
358
+ minWidth: 700,
359
+ marginBottom: 20,
360
+ },
361
+ tableHeader: {
362
+ flexDirection: 'row',
363
+ backgroundColor: '#2c3e50',
364
+ borderBottomWidth: 1,
365
+ borderBottomColor: '#ddd',
366
+ },
367
+ headerCell: {
368
+ flex: 1,
369
+ padding: 10,
370
+ minWidth: 100,
371
+ justifyContent: 'center',
372
+ alignItems: 'center',
373
+ borderRightWidth: 1,
374
+ borderRightColor: '#444',
375
+ },
376
+ firstColumn: {
377
+ flex: 1.5,
378
+ minWidth: 180,
379
+ },
380
+ headerText: {
381
+ color: '#fff',
382
+ fontWeight: '600',
383
+ fontSize: 11,
384
+ textAlign: 'center',
385
+ },
386
+ tableRow: {
387
+ flexDirection: 'row',
388
+ borderBottomWidth: 1,
389
+ borderBottomColor: '#eee',
390
+ minHeight: 40,
391
+ },
392
+ evenRow: {
393
+ backgroundColor: '#fff',
394
+ },
395
+ oddRow: {
396
+ backgroundColor: '#f9f9f9',
397
+ },
398
+ totalRow: {
399
+ backgroundColor: '#e8f5e9',
400
+ borderTopWidth: 2,
401
+ borderTopColor: '#4CAF50',
402
+ borderBottomWidth: 2,
403
+ borderBottomColor: '#4CAF50',
404
+ },
405
+ cell: {
406
+ flex: 1,
407
+ padding: 8,
408
+ minWidth: 100,
409
+ justifyContent: 'center',
410
+ alignItems: 'center',
411
+ borderRightWidth: 1,
412
+ borderRightColor: '#eee',
413
+ },
414
+ cellText: {
415
+ fontSize: 12,
416
+ color: '#333',
417
+ textAlign: 'center',
418
+ },
419
+ totalText: {
420
+ fontSize: 13,
421
+ fontWeight: '700',
422
+ color: '#2c3e50',
423
+ },
424
+ numberText: {
425
+ fontSize: 11,
426
+ fontWeight: '500',
427
+ fontFamily: 'monospace',
428
+ color: '#333',
429
+ },
430
+ percentText: {
431
+ fontSize: 12,
432
+ fontWeight: '600',
433
+ fontFamily: 'monospace',
434
+ },
435
+ positive: {
436
+ color: '#27ae60',
437
+ },
438
+ negative: {
439
+ color: '#e74c3c',
440
+ },
441
+ grossMargin: {
442
+ color: '#2c3e50',
443
+ fontWeight: '700',
444
+ },
445
+ compactContainer: {
446
+ flex: 1,
447
+ paddingHorizontal: 8,
448
+ },
449
+ compactCard: {
450
+ backgroundColor: '#fff',
451
+ borderRadius: 12,
452
+ marginBottom: 12,
453
+ padding: 16,
454
+ borderWidth: 1,
455
+ borderColor: '#e8e8e8',
456
+ shadowColor: '#000',
457
+ shadowOffset: { width: 0, height: 2 },
458
+ shadowOpacity: 0.1,
459
+ shadowRadius: 3,
460
+ elevation: 2,
461
+ },
462
+ compactTotalCard: {
463
+ backgroundColor: '#e8f5e9',
464
+ borderColor: '#4CAF50',
465
+ borderWidth: 2,
466
+ },
467
+ evenCard: {
468
+ backgroundColor: '#fff',
469
+ },
470
+ oddCard: {
471
+ backgroundColor: '#f9f9f9',
472
+ },
473
+ compactHeader: {
474
+ flexDirection: 'row',
475
+ justifyContent: 'space-between',
476
+ alignItems: 'center',
477
+ marginBottom: 12,
478
+ paddingBottom: 12,
479
+ borderBottomWidth: 1,
480
+ borderBottomColor: '#eee',
481
+ },
482
+ compactTitle: {
483
+ fontSize: 14,
484
+ fontWeight: '600',
485
+ color: '#2c3e50',
486
+ flex: 1,
487
+ },
488
+ totalTitle: {
489
+ fontWeight: '700',
490
+ color: '#2c3e50',
491
+ fontSize: 15,
492
+ },
493
+ compactGrossMargin: {
494
+ fontSize: 13,
495
+ fontWeight: '600',
496
+ paddingHorizontal: 8,
497
+ paddingVertical: 4,
498
+ borderRadius: 6,
499
+ backgroundColor: '#f0f0f0',
500
+ },
501
+ compactGrid: {
502
+ flexDirection: 'row',
503
+ flexWrap: 'wrap',
504
+ justifyContent: 'space-between',
505
+ },
506
+ compactColumn: {
507
+ width: '48%',
508
+ marginBottom: 12,
509
+ backgroundColor: '#f8f9fa',
510
+ padding: 10,
511
+ borderRadius: 8,
512
+ alignItems: 'center',
513
+ },
514
+ compactLabel: {
515
+ fontSize: 11,
516
+ color: '#666',
517
+ marginBottom: 4,
518
+ textAlign: 'center',
519
+ },
520
+ compactValue: {
521
+ fontSize: 13,
522
+ fontWeight: '600',
523
+ color: '#2c3e50',
524
+ fontFamily: 'monospace',
525
+ },
526
+ percentBadge: {
527
+ backgroundColor: '#fff',
528
+ paddingHorizontal: 10,
529
+ paddingVertical: 4,
530
+ borderRadius: 12,
531
+ borderWidth: 1,
532
+ borderColor: '#e0e0e0',
533
+ },
534
+ statusIndicator: {
535
+ flexDirection: 'row',
536
+ alignItems: 'center',
537
+ marginTop: 12,
538
+ paddingTop: 12,
539
+ borderTopWidth: 1,
540
+ borderTopColor: '#eee',
541
+ },
542
+ statusDot: {
543
+ width: 8,
544
+ height: 8,
545
+ borderRadius: 4,
546
+ marginRight: 8,
547
+ },
548
+ statusGood: {
549
+ backgroundColor: '#4CAF50',
550
+ },
551
+ statusWarning: {
552
+ backgroundColor: '#FF9800',
553
+ },
554
+ statusText: {
555
+ fontSize: 12,
556
+ color: '#666',
557
+ },
558
+ freezeContainer: {
559
+ flex: 1,
560
+ flexDirection: 'row',
561
+ },
562
+ freezeColumn: {
563
+ width: 180,
564
+ borderRightWidth: 2,
565
+ borderRightColor: '#ddd',
566
+ backgroundColor: '#fff',
567
+ },
568
+ freezeFirstCell: {
569
+ backgroundColor: '#2c3e50',
570
+ justifyContent: 'center',
571
+ alignItems: 'center',
572
+ },
573
+ freezeHeader: {
574
+ height: 50,
575
+ justifyContent: 'center',
576
+ alignItems: 'center',
577
+ backgroundColor: '#2c3e50',
578
+ borderBottomWidth: 1,
579
+ borderBottomColor: '#444',
580
+ borderRightWidth: 1,
581
+ borderRightColor: '#444',
582
+ minWidth: 120,
583
+ },
584
+ freezeHeaderRow: {
585
+ flexDirection: 'row',
586
+ },
587
+ freezeHeaderText: {
588
+ color: '#fff',
589
+ fontWeight: '600',
590
+ fontSize: 12,
591
+ textAlign: 'center',
592
+ },
593
+ freezeRow: {
594
+ height: 45,
595
+ justifyContent: 'center',
596
+ paddingHorizontal: 10,
597
+ borderBottomWidth: 1,
598
+ borderBottomColor: '#eee',
599
+ },
600
+ freezeTotalRow: {
601
+ backgroundColor: '#e8f5e9',
602
+ borderTopWidth: 2,
603
+ borderTopColor: '#4CAF50',
604
+ borderBottomWidth: 2,
605
+ borderBottomColor: '#4CAF50',
606
+ },
607
+ freezeCellText: {
608
+ fontSize: 12,
609
+ color: '#333',
610
+ fontWeight: '500',
611
+ },
612
+ freezeTotalText: {
613
+ fontWeight: '700',
614
+ color: '#2c3e50',
615
+ },
616
+ scrollableColumns: {
617
+ flex: 1,
618
+ },
619
+ freezeDataRow: {
620
+ flexDirection: 'row',
621
+ height: 45,
622
+ borderBottomWidth: 1,
623
+ borderBottomColor: '#eee',
624
+ },
625
+ freezeTotalDataRow: {
626
+ backgroundColor: '#e8f5e9',
627
+ },
628
+ freezeDataCell: {
629
+ minWidth: 120,
630
+ justifyContent: 'center',
631
+ alignItems: 'center',
632
+ borderRightWidth: 1,
633
+ borderRightColor: '#eee',
634
+ paddingHorizontal: 8,
635
+ },
636
+ freezeDataText: {
637
+ fontSize: 12,
638
+ fontWeight: '500',
639
+ fontFamily: 'monospace',
640
+ color: '#333',
641
+ },
642
+ freezePercent: {
643
+ fontSize: 12,
644
+ fontWeight: '600',
645
+ fontFamily: 'monospace',
646
+ },
647
+ });
package/src/index.jsx CHANGED
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
- import ReportDashboard from './screens/ReportDashboard';
2
+ import ReportScreen from './screens/ReportScreen';
3
3
 
4
4
  const ReportChart = ({
5
- reports = [],
6
5
  onReportSelect,
7
- onClose
6
+ onClose,
7
+ reports = []
8
8
  }) => {
9
9
  return (
10
- <ReportDashboard
10
+ <ReportScreen
11
11
  reports={reports}
12
12
  onReportSelect={onReportSelect}
13
13
  onClose={onClose}