add hourly graph
This commit is contained in:
parent
0331de8b8a
commit
1a7734b620
20 changed files with 358 additions and 22 deletions
|
|
@ -29,7 +29,7 @@ class Hourly extends WeatherDisplay {
|
|||
|
||||
async getData(weatherParameters) {
|
||||
// super checks for enabled
|
||||
if (!super.getData(weatherParameters)) return;
|
||||
const superResponse = super.getData(weatherParameters);
|
||||
let forecast;
|
||||
try {
|
||||
// get the forecast
|
||||
|
|
@ -43,6 +43,9 @@ class Hourly extends WeatherDisplay {
|
|||
|
||||
this.data = await Hourly.parseForecast(forecast.properties);
|
||||
|
||||
this.getDataCallback();
|
||||
if (!superResponse) return;
|
||||
|
||||
this.setStatus(STATUS.loaded);
|
||||
this.drawLongCanvas();
|
||||
}
|
||||
|
|
@ -66,6 +69,8 @@ class Hourly extends WeatherDisplay {
|
|||
apparentTemperature: celsiusToFahrenheit(apparentTemperature[idx]),
|
||||
windSpeed: kilometersToMiles(windSpeed[idx]),
|
||||
windDirection: directionToNSEW(windDirection[idx]),
|
||||
probabilityOfPrecipitation: probabilityOfPrecipitation[idx],
|
||||
skyCover: skyCover[idx],
|
||||
icon: icons[idx],
|
||||
}));
|
||||
}
|
||||
|
|
@ -184,7 +189,20 @@ class Hourly extends WeatherDisplay {
|
|||
return dayName;
|
||||
}, '');
|
||||
}
|
||||
|
||||
// make data available outside this class
|
||||
// promise allows for data to be requested before it is available
|
||||
async getCurrentData() {
|
||||
return new Promise((resolve) => {
|
||||
if (this.data) resolve(this.data);
|
||||
// data not available, put it into the data callback queue
|
||||
this.getDataCallbacks.push(() => resolve(this.data));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// register display
|
||||
registerDisplay(new Hourly(2, 'hourly'));
|
||||
const display = new Hourly(2, 'hourly', false);
|
||||
registerDisplay(display);
|
||||
|
||||
export default display.getCurrentData.bind(display);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue