challenge = "ELECTRICITY"
Electricity availability statistics are a key part of the system of energy statistics in the EU and have a long history of data collection. For this indicator, the benchmark will be the official figures on Electricity availability in each European country.
Next forecast for a given country
viewof country = Inputs. select (Object . values (country_map), {
label : html `<b>Select a country:</b>` ,
placeholder : "Enter a country name" ,
unique : true
})
Plot. plot ({
grid : true ,
y : {
label : "↑ Electricity availability" ,
},
x : {
label : "Year" ,
domain : range
},
marks : [
Plot. line (historical, {
tip : true ,
x : "date" ,
y : "values" ,
stroke : "black" ,
title : (d) =>
` ${ d. date . toLocaleString ("en-UK" , {
month : "long" ,
year : "numeric"
})}\n ${ d. values } `
}),
Plot. dot (predictions, {
tip : true ,
x : "date" ,
y : "values" ,
fill : "model" ,
title : (d) =>
` ${ d. model }\n ${ d. date . toLocaleString ("en-UK" , {
month : "long" ,
year : "numeric"
})} : ${ d. values } `
})
],
color : {legend : true }
})
dates = {
const data = historical. map (d => d. date )
data. push (predictions. map (d => d. date )[0 ])
return data
}
viewof range = offsetInterval (dates, {
value : [ dates[dates. length - 90 ], dates[dates. length - 1 ] ],
format : ([a, b]) => htl. html `<span ${ {
style : "display: flex; justify-content: space-between"
}} >
${ a. toISOString ("en-UK" ). slice (0 , 10 )}
${ b. toISOString ("en-UK" ). slice (0 , 10 )}
</span>`
})
Country-specific forecast summary by model
viewof form = Inputs. form ({
model : Inputs. checkbox (models, {value : models}),
countries : Inputs. select (["All" , ... Object . values (country_map)], {multiple : true , value : ["All" ], width : 50 , size : 1 })
})
viewof rows = Inputs. table (summary_table, {
rows : 25 ,
maxWidth : 840 ,
multiple : false ,
layout : "fixed"
})
historical = format_historical_data (data, country_iso)
predictions = format_pred_data (pred, country_iso)
summary_table = format_summary_table_data (pred, form. countries , form. model , country_map)
country_map = get_countries_per_challenge (mapping_countries_weights, challenge)
country_iso = Object . keys (country_map). find (key => country_map[key] === country);
models = ["REG-ARIMA" , "DFM" , "ETS" , "XGBOOST" , "LSTM" ]
import {
format_historical_data,
format_pred_data,
format_summary_table_data,
get_countries_per_challenge,
mapping_countries_weights,
} from "./utils/utils.qmd"
import {offsetInterval} from '@mootari/offset-slider'
Plot = require ("https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.8/dist/plot.umd.min.js" )