File size: 3,257 Bytes
f0bb158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export class ChartManager {
    constructor() {
        this.charts = {};
    }

    formatDate(dateStr) {
        return new Date(dateStr).toLocaleDateString('en-US', {
            year: 'numeric', month: 'short', day: 'numeric'
        });
    }

    createProgressChart(repoData) {
        const maxCount = Math.max(...repoData.map(row => row.xet_repos));
        const dataPoints = repoData.map(row => ({
            date: row.date, 
            value: row.xet_repos
        }));
        
        const lineChartCtx = document.getElementById('progressChart').getContext('2d');
        this.charts.lineChart = new Chart(lineChartCtx, {
            type: 'line',
            data: {
                labels: dataPoints.map(point => this.formatDate(point.date)),
                datasets: [{
                    label: 'Repos Migrated',
                    data: dataPoints.map(point => point.value),
                    borderColor: '#7875FF',
                    backgroundColor: 'rgba(255, 127, 65, 1)',
                    tension: 0.4 
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                animation: { duration: 2000 }, 
                scales: {
                    y: {
                        min: 0,
                        ticks: { stepSize: 100000 } 
                    },
                    x: {
                        ticks: {
                            maxTicksLimit: 20
                        }
                    },
                },
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                return `Repos Migrated: ${context.parsed.y.toLocaleString()}`;
                            }
                        }
                    }
                }
            }
        });
    }

    createDonutChart(fileData) {
        const lfs_file_count = fileData[fileData.length - 1].lfs_files;
        const xet_file_count = fileData[fileData.length - 1].xet_files;

        const donutChartCtx = document.getElementById('largeFilesChart').getContext('2d');
        this.charts.donutChart = new Chart(donutChartCtx, {
            type: 'doughnut',
            data: {
                labels: [
                    'LFS Files',
                    'Xet Files',
                ],
                datasets: [{
                    label: 'My First Dataset',
                    data: [lfs_file_count, xet_file_count],
                    backgroundColor: [
                        'oklch(0.577 0.245 27.325 / 75.56%)',
                        'oklch(0.6361 0.1994 280.07 / 71.37%)',
                    ],
                    hoverOffset: 4
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                animation: { duration: 2000 }, 
                plugins: {
                    legend: {
                        position: 'top',
                    },
                }
            }
        });
    }

    init(repoData, fileData) {
        this.createProgressChart(repoData);
        this.createDonutChart(fileData);
    }
}