Changed endpoints and db queries, chart now shows suggested mins and maxes
This commit is contained in:
@@ -11,12 +11,13 @@
|
|||||||
<canvas id="myChart"></canvas>
|
<canvas id="myChart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
|
const ROOT_URL = "climate/";
|
||||||
const humidityColor = 'rgb(45,141,45)';
|
const humidityColor = 'rgb(45,141,45)';
|
||||||
const tempColor = 'rgb(0,134,222)';
|
const tempColor = 'rgb(0,134,222)';
|
||||||
const co2Color = 'rgb(194,30,30)';
|
const co2Color = 'rgb(194,30,30)';
|
||||||
|
|
||||||
async function getData() {
|
async function getData() {
|
||||||
let urlEndpoint = "data/";
|
let urlEndpoint = "/" + "ROOT_URL" + "data/";
|
||||||
const pathname = window.location.pathname;
|
const pathname = window.location.pathname;
|
||||||
if (pathname.includes("since")) {
|
if (pathname.includes("since")) {
|
||||||
urlEndpoint += "since/" + pathname.slice(pathname.lastIndexOf("/") + 1);
|
urlEndpoint += "since/" + pathname.slice(pathname.lastIndexOf("/") + 1);
|
||||||
@@ -124,7 +125,7 @@
|
|||||||
|
|
||||||
function startFetchTimeout(chart) {
|
function startFetchTimeout(chart) {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
const newDatum = await fetch("data/last/");
|
const newDatum = await fetch("/" + ROOT_URL + "data/last/");
|
||||||
const snapshot = (await newDatum.json()).snapshots[0];
|
const snapshot = (await newDatum.json()).snapshots[0];
|
||||||
chart.data.datasets[0].data.splice(0, 1);
|
chart.data.datasets[0].data.splice(0, 1);
|
||||||
chart.data.datasets[0].data.push({x: snapshot.time, y: snapshot.humidity});
|
chart.data.datasets[0].data.push({x: snapshot.time, y: snapshot.humidity});
|
||||||
|
|||||||
Reference in New Issue
Block a user