Almost there
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user