summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/index.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/js/index.js b/js/index.js
index 415518f..2e6345b 100644
--- a/js/index.js
+++ b/js/index.js
@@ -114,7 +114,6 @@ function weather2description(weather){
}
function processDaily( response_obj ) {
- console.log(response_obj);
let data = response_obj.daily;
// Our variables are here:
@@ -173,8 +172,8 @@ function processHourly(data){
let xsize = 300;
let xmargin = 15;
- let ysize = 90;
- let ymargin = 10;
+ let ysize = 120;
+ let ymargin = 30;
for( let i in temperature ){
points.push( [project(i, 0, temperature.length, xmargin, xsize-xmargin),
@@ -200,6 +199,17 @@ function processHourly(data){
`${WEATHER2ICON[WMO_CONVERTER[weathercode[i]]]}</text>`;
}
+ let times = ""
+ for( let i in points){
+ let t = new Date(time[i]);
+ let hours = t.getHours();
+ let mins = t.getMinutes();
+ if (hours < 10) { hours = `0${hours}` } else { hours = `${hours}` }
+ if (mins < 10) { mins = `0${mins}` } else { mins = `${mins}` }
+ labels += `<text transform="translate(${points[i][0]}, ${ysize-ymargin/2}) rotate(-90)"
+ class="time-label" dy="0.4em">${hours}:${mins}</text>`;
+ }
+
let hourly_element = document.createElement("article");
hourly_element.setAttribute("class", "hourly-forecast");
@@ -209,6 +219,7 @@ function processHourly(data){
${dots}
${labels}
${icons}
+ ${times}
</svg>
`;
return hourly_element;