update show graph

This commit is contained in:
2025-07-13 01:20:43 -04:00
parent ef35a36512
commit 8dd57d4b16
4 changed files with 50 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
let timer = 0;
let isRunning = false;
let log: Array<{ time: string, event: string, temp?: number }> = [];
@@ -5,6 +7,7 @@ let targets: number[] = [];
let currentTargetIndex = 0;
let interval: NodeJS.Timeout | null = null;
interface Window {
startTimer?: Function; // function to start the timer
stopTimer?: Function; // function to stop the timer
@@ -14,9 +17,10 @@ interface Window {
navigateTemp?: Function; //function to navigate forward/back between events in the setPlan() temp plan
logTemp?: Function; //function to log a temputure event
exportCSV?: Function; //function to export the events to CSV
showGraph?: Function; //function to show the graph on screen
showGraph?: Function; // function to render or display graphs using libraries like Chart.js for visual representation of logged events
}
function startTimer(): void {
if (isRunning) {
alert("Timer is already running. Click again to reset.");
@@ -156,6 +160,14 @@ function exportCSV(): void {
document.body.removeChild(link);
}
function showGraph(): void {
const graphContainer = document.getElementById("graph-container");
if (graphContainer) {
graphContainer.classList.remove("hidden");
graphContainer.classList.add("graph-display-flex");
}
}
// Expose functions to the global scope (allowing html direct access)
if (typeof window !== 'undefined') {
window.startTimer = startTimer;
@@ -166,4 +178,5 @@ if (typeof window !== 'undefined') {
window.navigateTemp = navigateTemp;
window.logTemp = logTemp;
window.exportCSV = exportCSV;
window.showGraph = showGraph;
}