gotemptracker/index.gohtml
2022-09-26 23:25:10 +03:00

49 lines
893 B
Plaintext

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>gotemptracker</title>
</head>
<body>
<h1>This is the first step to quantified selt, brought in by Golang app with PostgreSQL database</h1>
<form method="post">
<label>Temperature:</label><br />
<input type="number" step="0.1" name="value">
<input type="submit">
</form>
<canvas id="tempChart" style="width:100%;max-width:700px"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js">
</script>
<script>
const vals = [
{{range .}}
{{.Value}},
{{end}}
];
const dates = [
{{range .}}
{{.CreatedAt.Format "2006-01-02"}},
{{end}}
];
new Chart("tempChart", {
type: "line",
data: {
labels: dates,
datasets: [{
data: vals
}]
}
});
</script>
</body>
</html>