Almost there

This commit is contained in:
Daniel Ledda
2020-11-14 15:16:50 +01:00
parent c4a121cbd2
commit b027434827
3 changed files with 6 additions and 1946 deletions

View File

@@ -1,4 +1,5 @@
import Chart, {ChartPoint} from "chart.js";
//@ts-ignore
import Chart, {ChartPoint} from "chart.js/dist/Chart.bundle.min";
import {generateClimateChartConfig} from "./climateChartConfig";
interface Snapshot {
@@ -14,7 +15,6 @@ interface SnapshotRecords {
}
class ClimateChart {
private readonly urlEndpoint: string;
private chart: Chart | null;
private latestSnapshot: Snapshot | null;
private onLoadedCallback: () => void = () => {};
@@ -29,8 +29,6 @@ class ClimateChart {
} else {
throw new Error(`invalid minutes passed to display in chart: ${minutesDisplayed}`);
}
this.urlEndpoint = this.rootUrl + "data/";
this.urlEndpoint += "since/" + this.minutesDisplayed;
this.initChart().catch((e) => {this.onErrorCallback(e);});
}
@@ -48,7 +46,7 @@ class ClimateChart {
private async getInitialDataBlob(): Promise<SnapshotRecords> {
try {
const data = await fetch(this.urlEndpoint);
const data = await fetch(this.rootUrl + "/data?since" + (new Date().getTime() - this.minutesDisplayed * 60 * 1000));
return await data.json();
}
catch (e) {