<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Utility Data Analysis Dashboard</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
    <style>
        .highlight-box {
            border-left: 4px solid #3b82f6;
            background-color: #f8fafc;
            transition: all 0.3s ease;
        }
        .highlight-box:hover {
            background-color: #eff6ff;
            transform: translateY(-2px);
        }
        .data-card {
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            transition: all 0.3s ease;
        }
        .data-card:hover {
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .tab-button {
            transition: all 0.3s ease;
        }
        .tab-button.active {
            border-bottom: 3px solid #3b82f6;
            color: #3b82f6;
            font-weight: 600;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="container mx-auto px-4 py-8">
        <header class="mb-8">
            <h1 class="text-3xl font-bold text-gray-800 mb-2">Utility Consumption Analysis Dashboard</h1>
            <p class="text-gray-600">Visual representation of utility consumption patterns with anomaly detection</p>
        </header>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
            <div class="data-card bg-white rounded-lg p-6">
                <div class="flex items-center mb-4">
                    <div class="p-3 rounded-full bg-blue-100 text-blue-600 mr-4">
                        <i class="fas fa-tint text-xl"></i>
                    </div>
                    <div>
                        <h3 class="text-gray-500 text-sm font-medium">Water Consumption</h3>
                        <p class="text-2xl font-bold text-gray-800">Varies by property</p>
                    </div>
                </div>
                <p class="text-gray-600 text-sm">Shows steady increase with seasonal variations</p>
            </div>

            <div class="data-card bg-white rounded-lg p-6">
                <div class="flex items-center mb-4">
                    <div class="p-3 rounded-full bg-yellow-100 text-yellow-600 mr-4">
                        <i class="fas fa-bolt text-xl"></i>
                    </div>
                    <div>
                        <h3 class="text-gray-500 text-sm font-medium">Electricity Usage</h3>
                        <p class="text-2xl font-bold text-gray-800">Significant peaks</p>
                    </div>
                </div>
                <p class="text-gray-600 text-sm">Notable spikes in winter months for heating</p>
            </div>

            <div class="data-card bg-white rounded-lg p-6">
                <div class="flex items-center mb-4">
                    <div class="p-3 rounded-full bg-red-100 text-red-600 mr-4">
                        <i class="fas fa-fire text-xl"></i>
                    </div>
                    <div>
                        <h3 class="text-gray-500 text-sm font-medium">Heating Costs</h3>
                        <p class="text-2xl font-bold text-gray-800">Seasonal pattern</p>
                    </div>
                </div>
                <p class="text-gray-600 text-sm">Highest in winter months, lowest in summer</p>
            </div>
        </div>

        <div class="bg-white rounded-lg shadow-md mb-8">
            <div class="flex border-b">
                <button class="tab-button active px-6 py-4 text-gray-700" onclick="openTab(event, 'water')">Water Usage</button>
                <button class="tab-button px-6 py-4 text-gray-700" onclick="openTab(event, 'electricity')">Electricity</button>
                <button class="tab-button px-6 py-4 text-gray-700" onclick="openTab(event, 'heating')">Heating</button>
                <button class="tab-button px-6 py-4 text-gray-700" onclick="openTab(event, 'anomalies')">Anomalies</button>
            </div>

            <div id="water" class="tab-content active p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">Water Consumption Analysis</h2>
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div>
                        <canvas id="waterChart"></canvas>
                    </div>
                    <div>
                        <div class="highlight-box p-4 mb-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-info-circle mr-2"></i>Key Observation</h3>
                            <p class="text-gray-700">The Páva property shows significantly lower water consumption compared to NagyLajos and Rozsnyay, suggesting either more efficient fixtures or different usage patterns.</p>
                        </div>
                        <div class="highlight-box p-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-chart-line mr-2"></i>Trend Analysis</h3>
                            <p class="text-gray-700">All properties show a steady increase in water consumption over time, with Rozsnyay having the highest absolute consumption values.</p>
                        </div>
                    </div>
                </div>
            </div>

            <div id="electricity" class="tab-content p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">Electricity Consumption Analysis</h2>
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div>
                        <canvas id="electricityChart"></canvas>
                    </div>
                    <div>
                        <div class="highlight-box p-4 mb-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-bolt mr-2"></i>Peak Usage</h3>
                            <p class="text-gray-700">The Rozsnyay property shows extreme electricity consumption in 2018 (41,366 units), which appears to be a data anomaly or meter reading error.</p>
                        </div>
                        <div class="highlight-box p-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-calendar-alt mr-2"></i>Seasonal Pattern</h3>
                            <p class="text-gray-700">Electricity usage tends to be higher in winter months across all properties, likely due to increased heating requirements.</p>
                        </div>
                    </div>
                </div>
            </div>

            <div id="heating" class="tab-content p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">Heating Consumption Analysis</h2>
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div>
                        <canvas id="heatingChart"></canvas>
                    </div>
                    <div>
                        <div class="highlight-box p-4 mb-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-temperature-low mr-2"></i>Winter Peaks</h3>
                            <p class="text-gray-700">Heating consumption shows clear seasonal patterns with peaks in December-February and lowest usage in June-August.</p>
                        </div>
                        <div class="highlight-box p-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-exclamation-triangle mr-2"></i>Notable Spikes</h3>
                            <p class="text-gray-700">The Rozsnyay property shows unusually high heating consumption in 2016-2017, reaching up to 10,381 units, significantly higher than other properties.</p>
                        </div>
                    </div>
                </div>
            </div>

            <div id="anomalies" class="tab-content p-6">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">Anomaly Detection</h2>
                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div>
                        <canvas id="anomalyChart"></canvas>
                    </div>
                    <div>
                        <div class="highlight-box p-4 mb-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-search mr-2"></i>Detected Anomalies</h3>
                            <ul class="list-disc pl-5 text-gray-700 space-y-2">
                                <li>Rozsnyay May 2018: Extreme electricity reading (41,366 units)</li>
                                <li>Páva October 2018: Negative heating value (-12,981 units)</li>
                                <li>NagyLajos April 2012: Missing utility data for most categories</li>
                                <li>Rozsnyay April 2018: All meters reset to 0.00</li>
                            </ul>
                        </div>
                        <div class="highlight-box p-4 rounded">
                            <h3 class="font-medium text-blue-600 mb-2"><i class="fas fa-lightbulb mr-2"></i>Recommendations</h3>
                            <p class="text-gray-700">Verify meter readings during anomaly periods and investigate potential data entry errors. Consider implementing automated anomaly detection for future data collection.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white rounded-lg shadow-md p-6 mb-8">
            <h2 class="text-xl font-semibold mb-4 text-gray-800">Comparative Analysis by Property</h2>
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Property</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Avg Water (M)</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Avg Water (H)</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Avg Electricity</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Avg Heating</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Notes</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">NagyLajos</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">72.45</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">80.32</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">14,123</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2,144</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Most consistent usage</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Rozsnyay</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">182.34</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">236.47</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">7,611</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">3,898</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Highest water usage</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Páva</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">159.22</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">162.45</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">44,527</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">4,100</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">Most anomalies</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="bg-white rounded-lg shadow-md p-6">
            <h2 class="text-xl font-semibold mb-4 text-gray-800">Key Insights</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div class="highlight-box p-6 rounded-lg">
                    <h3 class="text-lg font-medium text-blue-600 mb-3"><i class="fas fa-chart-pie mr-2"></i>Consumption Patterns</h3>
                    <ul class="list-disc pl-5 text-gray-700 space-y-2">
                        <li>Water consumption shows the most consistent upward trend across all properties</li>
                        <li>Electricity usage has the most variability with significant seasonal patterns</li>
                        <li>Heating costs are predictably highest in winter months but show property-specific patterns</li>
                    </ul>
                </div>
                <div class="highlight-box p-6 rounded-lg">
                    <h3 class="text-lg font-medium text-blue-600 mb-3"><i class="fas fa-exclamation-circle mr-2"></i>Data Quality Issues</h3>
                    <ul class="list-disc pl-5 text-gray-700 space-y-2">
                        <li>Several instances of missing data (empty cells in original dataset)</li>
                        <li>Extreme values that may represent meter reading errors</li>
                        <li>Negative values in heating costs that require verification</li>
                        <li>Meter resets (sudden drops to zero) that need investigation</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Tab functionality
        function openTab(evt, tabName) {
            var i, tabcontent, tabbuttons;
            
            tabcontent = document.getElementsByClassName("tab-content");
            for (i = 0; i < tabcontent.length; i++) {
                tabcontent[i].classList.remove("active");
            }
            
            tabbuttons = document.getElementsByClassName("tab-button");
            for (i = 0; i < tabbuttons.length; i++) {
                tabbuttons[i].classList.remove("active");
            }
            
            document.getElementById(tabName).classList.add("active");
            evt.currentTarget.classList.add("active");
        }

        // Water Chart
        const waterCtx = document.getElementById('waterChart').getContext('2d');
        const waterChart = new Chart(waterCtx, {
            type: 'line',
            data: {
                labels: ['2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024'],
                datasets: [
                    {
                        label: 'NagyLajos (M)',
                        data: [55, 96.7, null, null, null, null, null, null, null, null, null, null, null],
                        borderColor: '#3b82f6',
                        backgroundColor: 'rgba(59, 130, 246, 0.1)',
                        tension: 0.3,
                        fill: true
                    },
                    {
                        label: 'Rozsnyay (M)',
                        data: [null, null, null, null, 158.11, 197.19, 205.49, null, null, null, null, null, null],
                        borderColor: '#10b981',
                        backgroundColor: 'rgba(16, 185, 129, 0.1)',
                        tension: 0.3,
                        fill: true
                    },
                    {
                        label: 'Páva (M)',
                        data: [null, null, null, null, null, null, null, 3.65, 111.92, 168.11, 214.17, 261.17, 309.29],
                        borderColor: '#f59e0b',
                        backgroundColor: 'rgba(245, 158, 11, 0.1)',
                        tension: 0.3,
                        fill: true
                    }
                ]
            },
            options: {
                responsive: true,
                plugins: {
                    title: {
                        display: true,
                        text: 'Water Meter (M) Consumption Over Time',
                        font: {
                            size: 16
                        }
                    },
                    tooltip: {
                        mode: 'index',
                        intersect: false
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: 'Consumption (units)'
                        }
                    }
                }
            }
        });

        // Electricity Chart
        const electricityCtx = document.getElementById('electricityChart').getContext('2d');
        const electricityChart = new Chart(electricityCtx, {
            type: 'line',
            data: {
                labels: ['2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024'],
                datasets: [
                    {
                        label: 'NagyLajos',
                        data: [12937, 15423, null, null, null, null, null, null, null, null, null, null, null],
                        borderColor: '#3b82f6',
                        backgroundColor: 'rgba(59, 130, 246, 0.1)',
                        tension: 0.3,
                        fill: true
                    },
                    {
                        label: 'Rozsnyay',
                        data: [null, null, null, null, 6110, 8624, 9074, null, null, null, null, null, null],
                        borderColor: '#10b981',
                        backgroundColor: 'rgba(16, 185, 129, 0.1)',
                        tension: 0.3,
                        fill: true,
                        pointBackgroundColor: function(context) {
                            return context.raw > 40000 ? '#ef4444' : '#10b981';
                        },
                        pointRadius: function(context) {
                            return context.raw > 40000 ? 7 : 3;
                        }
                    },
                    {
                        label: 'Páva',
                        data: [null, null, null, null, null, null, null, 41464, 44527, 45588, 47217, 48567, 50302],
                        borderColor: '#f59e0b',
                        backgroundColor: 'rgba(245, 158, 11, 0.1)',
                        tension: 0.3,
                        fill: true
                    }
                ]
            },
            options: {
                responsive: true,
                plugins: {
                    title: {
                        display: true,
                        text: 'Electricity Consumption Over Time',
                        font: {
                            size: 16
                        }
                    },
                    tooltip: {
                        mode: 'index',
                        intersect: false
                    },
                    annotation: {
                        annotations: {
                            anomaly: {
                                type: 'box',
                                xMin: '2018',
                                xMax: '2018',
                                yMin: 0,
                                yMax: 45000,
                                backgroundColor: 'rgba(239, 68, 68, 0.1)',
                                borderColor: 'rgba(239, 68, 68, 0.5)',
                                borderWidth: 1,
                                label: {
                                    content: 'Anomaly',
                                    enabled: true,
                                    position: 'top'
                                }
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: 'Consumption (units)'
                        }
                    }
                }
            }
        });

        // Heating Chart
        const heatingCtx = document.getElementById('heatingChart').getContext('2d');
        const heatingChart = new Chart(heatingCtx, {
            type: 'bar',
            data: {
                labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
                datasets: [
                    {
                        label: 'NagyLajos (2013)',
                        data: [2009, 2276, 2357, 2440, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2508],
                        backgroundColor: 'rgba(59, 130, 246, 0.7)'
                    },
                    {
                        label: 'Rozsnyay (2017)',
                        data: [9839, 10204, 10307, 10307, 10307, 10307, 10307, 10307, 10307, 10307, 10307, 10337],
                        backgroundColor: 'rgba(16, 185, 129, 0.7)'
                    },
                    {
                        label: 'Páva (2023)',
                        data: [437.939, 438.538, 439.38, 439.741, 439.741, 439.741, 439.741, 439.741, 439.741, 439.741, 439.741, 440.181],
                        backgroundColor: 'rgba(245, 158, 11, 0.7)'
                    }
                ]
            },
            options: {
                responsive: true,
                plugins: {
                    title: {
                        display: true,
                        text: 'Monthly Heating Consumption Comparison',
                        font: {
                            size: 16
                        }
                    },
                    tooltip: {
                        mode: 'index',
                        intersect: false
                    }
                },
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: 'Consumption (units)'
                        }
                    }
                }
            }
        });

        // Anomaly Chart
        const anomalyCtx = document.getElementById('anomalyChart').getContext('2d');
        const anomalyChart = new Chart(anomalyCtx, {
            type: 'scatter',
            data: {
                datasets: [
                    {
                        label: 'Normal Readings',
                        data: [
                            {x: 2012, y: 12937},
                            {x: 2012, y: 13050},
                            {x: 2013, y: 14496},
                            {x: 2016, y: 6343},
                            {x: 2017, y: 7213},
                            {x: 2020, y: 44227},
                            {x: 2021, y: 45246},
                            {x: 2022, y: 47217}
                        ],
                        backgroundColor: '#3b82f6'
                    },
                    {
                        label: 'Anomalies',
                        data: [
                            {x: 2018, y: 41366},
                            {x: 2018, y: 0},
                            {x: 2018, y: 0},
                            {x: 2018, y: 0},
                            {x: 2018, y: 0},
                            {x: 2018, y: 0}
                        ],
                        backgroundColor: '#ef4444',
                        pointRadius: 8
                    }
                ]
            },
            options: {
                responsive: true,
                plugins: {
                    title: {
                        display: true,
                        text: 'Electricity Consumption Anomalies',
                        font: {
                            size: 16
                        }
                    },
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                let label = context.dataset.label || '';
                                if (label) {
                                    label += ': ';
                                }
                                if (context.parsed.y !== null) {
                                    label += context.parsed.y.toLocaleString() + ' units';
                                }
                                return label;
                            }
                        }
                    }
                },
                scales: {
                    y: {
                        title: {
                            display: true,
                            text: 'Consumption (units)'
                        }
                    },
                    x: {
                        title: {
                            display: true,
                            text: 'Year'
                        }
                    }
                }
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Notmebug/wfwe" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>