pksaheb commited on
Commit
db2a824
·
verified ·
1 Parent(s): 2f2dbac

create a separate line chart and that chart changes livetime - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +217 -2
index.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>ThermoScan AI | Industrial Temperature Monitoring</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
 
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <script>
10
  tailwind.config = {
@@ -313,6 +314,16 @@
313
  </div>
314
  </div>
315
 
 
 
 
 
 
 
 
 
 
 
316
  <!-- System Status -->
317
  <div class="dashboard-grid mb-8">
318
  <div class="industrial-card">
@@ -705,8 +716,9 @@
705
  minTempEl.textContent = `${minTemp}°C`;
706
  }
707
 
708
- // Update history table
709
  updateHistoryTable();
 
710
  }
711
 
712
  // Update gauge display
@@ -802,7 +814,7 @@
802
  <span class="${statusClass} font-medium">${statusText}</span>
803
  </td>
804
  <td class="px-4 py-3 whitespace-nowrap text-sm">
805
- <button class="text-industrial-400 hover:text-industrial-300 mr-2">
806
  <i class="fas fa-chart-line"></i>
807
  </button>
808
  <button class="text-industrial-400 hover:text-industrial-300">
@@ -840,8 +852,184 @@
840
  logDebug("Data exported as CSV");
841
  }
842
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
843
  // Initialize the app when DOM is loaded
844
  document.addEventListener('DOMContentLoaded', () => {
 
845
  init();
846
 
847
  // Start/stop periodic capture
@@ -874,7 +1062,34 @@
874
 
875
  // Export data button
876
  document.getElementById('exportDataBtn').addEventListener('click', exportData);
 
 
 
 
 
 
 
877
  });
878
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  <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=pksaheb/temperature-monitoring" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
880
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>ThermoScan AI | Industrial Temperature Monitoring</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
10
  <script>
11
  tailwind.config = {
 
314
  </div>
315
  </div>
316
 
317
+ <!-- Real-time Chart -->
318
+ <div class="industrial-card mb-8">
319
+ <div class="p-4 border-b border-industrial-700">
320
+ <h2 class="text-xl font-bold text-white">Temperature Trend</h2>
321
+ </div>
322
+ <div class="p-4">
323
+ <canvas id="liveChart" height="300"></canvas>
324
+ </div>
325
+ </div>
326
+
327
  <!-- System Status -->
328
  <div class="dashboard-grid mb-8">
329
  <div class="industrial-card">
 
716
  minTempEl.textContent = `${minTemp}°C`;
717
  }
718
 
719
+ // Update history table and chart
720
  updateHistoryTable();
721
+ updateLiveChart(temp, new Date().toLocaleTimeString());
722
  }
723
 
724
  // Update gauge display
 
814
  <span class="${statusClass} font-medium">${statusText}</span>
815
  </td>
816
  <td class="px-4 py-3 whitespace-nowrap text-sm">
817
+ <button class="text-industrial-400 hover:text-industrial-300 mr-2" onclick="showTemperatureChart()">
818
  <i class="fas fa-chart-line"></i>
819
  </button>
820
  <button class="text-industrial-400 hover:text-industrial-300">
 
852
  logDebug("Data exported as CSV");
853
  }
854
 
855
+ // Chart functions
856
+ let temperatureChart = null;
857
+
858
+ function showTemperatureChart() {
859
+ const modal = document.getElementById('chartModal');
860
+ modal.classList.remove('hidden');
861
+
862
+ const ctx = document.getElementById('temperatureChart').getContext('2d');
863
+
864
+ // Destroy previous chart if exists
865
+ if (temperatureChart) {
866
+ temperatureChart.destroy();
867
+ }
868
+
869
+ // Prepare chart data
870
+ const labels = temperatureHistory.map(reading => reading.timestamp);
871
+ const data = temperatureHistory.map(reading => reading.temp);
872
+ const statusColors = temperatureHistory.map(reading => {
873
+ switch(reading.status) {
874
+ case 'critical': return '#ef4444';
875
+ case 'warning': return '#f59e0b';
876
+ default: return '#10b981';
877
+ }
878
+ });
879
+
880
+ temperatureChart = new Chart(ctx, {
881
+ type: 'line',
882
+ data: {
883
+ labels: labels,
884
+ datasets: [{
885
+ label: 'Temperature (°C)',
886
+ data: data,
887
+ borderColor: '#38bdf8',
888
+ backgroundColor: 'rgba(56, 189, 248, 0.1)',
889
+ borderWidth: 2,
890
+ pointBackgroundColor: statusColors,
891
+ pointRadius: 5,
892
+ pointHoverRadius: 7,
893
+ tension: 0.1,
894
+ fill: true
895
+ }]
896
+ },
897
+ options: {
898
+ responsive: true,
899
+ maintainAspectRatio: false,
900
+ scales: {
901
+ y: {
902
+ beginAtZero: false,
903
+ grid: {
904
+ color: 'rgba(30, 41, 59, 0.5)'
905
+ },
906
+ ticks: {
907
+ color: '#94a3b8'
908
+ }
909
+ },
910
+ x: {
911
+ grid: {
912
+ color: 'rgba(30, 41, 59, 0.5)'
913
+ },
914
+ ticks: {
915
+ color: '#94a3b8'
916
+ }
917
+ }
918
+ },
919
+ plugins: {
920
+ legend: {
921
+ labels: {
922
+ color: '#e2e8f0'
923
+ }
924
+ },
925
+ tooltip: {
926
+ backgroundColor: '#1e293b',
927
+ titleColor: '#e2e8f0',
928
+ bodyColor: '#e2e8f0',
929
+ borderColor: '#334155',
930
+ borderWidth: 1
931
+ }
932
+ }
933
+ }
934
+ });
935
+ }
936
+
937
+ function exportChartAsImage() {
938
+ if (!temperatureChart) return;
939
+
940
+ const link = document.createElement('a');
941
+ link.download = `temperature_chart_${new Date().toISOString().slice(0,10)}.png`;
942
+ link.href = temperatureChart.toBase64Image();
943
+ link.click();
944
+ }
945
+
946
+ // Chart variables
947
+ let liveChart = null;
948
+ let chartData = {
949
+ labels: [],
950
+ datasets: [{
951
+ label: 'Temperature (°C)',
952
+ data: [],
953
+ borderColor: '#38bdf8',
954
+ backgroundColor: 'rgba(56, 189, 248, 0.1)',
955
+ borderWidth: 2,
956
+ pointRadius: 3,
957
+ tension: 0.1,
958
+ fill: true
959
+ }]
960
+ };
961
+
962
+ // Initialize live chart
963
+ function initLiveChart() {
964
+ const ctx = document.getElementById('liveChart').getContext('2d');
965
+ liveChart = new Chart(ctx, {
966
+ type: 'line',
967
+ data: chartData,
968
+ options: {
969
+ responsive: true,
970
+ maintainAspectRatio: false,
971
+ animation: {
972
+ duration: 1000,
973
+ easing: 'linear'
974
+ },
975
+ scales: {
976
+ y: {
977
+ beginAtZero: false,
978
+ grid: {
979
+ color: 'rgba(30, 41, 59, 0.5)'
980
+ },
981
+ ticks: {
982
+ color: '#94a3b8'
983
+ }
984
+ },
985
+ x: {
986
+ grid: {
987
+ color: 'rgba(30, 41, 59, 0.5)'
988
+ },
989
+ ticks: {
990
+ color: '#94a3b8',
991
+ maxRotation: 45,
992
+ minRotation: 45
993
+ }
994
+ }
995
+ },
996
+ plugins: {
997
+ legend: {
998
+ labels: {
999
+ color: '#e2e8f0'
1000
+ }
1001
+ },
1002
+ tooltip: {
1003
+ backgroundColor: '#1e293b',
1004
+ titleColor: '#e2e8f0',
1005
+ bodyColor: '#e2e8f0',
1006
+ borderColor: '#334155',
1007
+ borderWidth: 1
1008
+ }
1009
+ }
1010
+ }
1011
+ });
1012
+ }
1013
+
1014
+ // Update live chart with new data
1015
+ function updateLiveChart(temp, timestamp) {
1016
+ // Add new data point
1017
+ chartData.labels.push(timestamp);
1018
+ chartData.datasets[0].data.push(temp);
1019
+
1020
+ // Keep only last 20 points
1021
+ if (chartData.labels.length > 20) {
1022
+ chartData.labels.shift();
1023
+ chartData.datasets[0].data.shift();
1024
+ }
1025
+
1026
+ // Update chart
1027
+ liveChart.update();
1028
+ }
1029
+
1030
  // Initialize the app when DOM is loaded
1031
  document.addEventListener('DOMContentLoaded', () => {
1032
+ initLiveChart();
1033
  init();
1034
 
1035
  // Start/stop periodic capture
 
1062
 
1063
  // Export data button
1064
  document.getElementById('exportDataBtn').addEventListener('click', exportData);
1065
+
1066
+ // Chart modal events
1067
+ document.getElementById('closeChartModal').addEventListener('click', () => {
1068
+ document.getElementById('chartModal').classList.add('hidden');
1069
+ });
1070
+
1071
+ document.getElementById('exportChartBtn').addEventListener('click', exportChartAsImage);
1072
  });
1073
  </script>
1074
+
1075
+ <!-- Chart Modal -->
1076
+ <div id="chartModal" class="modal-overlay hidden">
1077
+ <div class="modal-content">
1078
+ <div class="flex justify-between items-center mb-4">
1079
+ <h3 class="text-xl font-bold">Temperature History Chart</h3>
1080
+ <button id="closeChartModal" class="text-industrial-400 hover:text-industrial-300">
1081
+ <i class="fas fa-times"></i>
1082
+ </button>
1083
+ </div>
1084
+ <div class="bg-industrial-800 p-4 rounded-lg">
1085
+ <canvas id="temperatureChart" height="300"></canvas>
1086
+ </div>
1087
+ <div class="modal-actions">
1088
+ <button id="exportChartBtn" class="bg-industrial-600 hover:bg-industrial-500 text-white px-4 py-2 rounded-lg">
1089
+ <i class="fas fa-download mr-2"></i> Export as Image
1090
+ </button>
1091
+ </div>
1092
+ </div>
1093
+ </div>
1094
  <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=pksaheb/temperature-monitoring" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
1095
  </html>