Weather dashboard
https://natronics.org/weather/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
var d3 = require('d3')
|
|
import {readxml} from './data.js'
|
|
import {render_calendar, render_nights, render_astronomy, render_temperature} from './render.js'
|
|
|
|
const canvas = d3.select('svg')
|
|
|
|
//const url = 'https://forecast.weather.gov/MapClick.php?lat=39.9243509&lon=-75.1696126&FcstType=digitalDWML'
|
|
const url = '/forcast.xml'
|
|
|
|
const render = function (data) {
|
|
data.beginTime = new Date(
|
|
data.startTimes[0].getFullYear(),
|
|
data.startTimes[0].getMonth(),
|
|
data.startTimes[0].getDate(),
|
|
0,0,0
|
|
)
|
|
data.endTime = new Date(
|
|
data.endTimes[data.endTimes.length - 1].getFullYear(),
|
|
data.endTimes[data.endTimes.length - 1].getMonth(),
|
|
data.endTimes[data.endTimes.length - 1].getDate(),
|
|
23,59,59
|
|
)
|
|
|
|
const width = canvas.node().getBoundingClientRect().width
|
|
const height = canvas.node().getBoundingClientRect().height
|
|
|
|
render_calendar(canvas, width, 20, 0, data)
|
|
render_nights(canvas, width, height - 20, 20, data)
|
|
render_astronomy(canvas, width, 70, 20, data)
|
|
render_temperature(canvas, width, 350, 70, data)
|
|
}
|
|
|
|
d3.xml(url).then(function(xmldoc) {
|
|
let data = readxml(xmldoc)
|
|
render(data)
|
|
})
|