Hi,
I would like to show data from the first date and the last selected from the list :
Here is my code
var listx = [];
var listy = [];
var frst = end = 0;
fetch('http://api.openweathermap.org/data/2.5/forecast?lat=59.9199&lon=10.6341&units=metric&APPID=e8e9c42c251d963d12895024279a2bb8')
.then(res => res.json())
.then((out) => {
//console.log('Output: ', out.list);
var myMessage = out.list;
for (var i = 0; i < myMessage.length; i++) {
//console.log('Output: ', myMessage[i]);
frst= Date.parse(myMessage[0].dt_txt)/1000;
end=Date.parse(myMessage[myMessage.length -1].dt_txt)/1000;
listx.push( myMessage[i].dt_txt);
listy.push( myMessage[i].main.temp);
}
alert(st);
alert(end);
console.log(listx);
console.log(listy);
}).catch(err => console.error(err));
var layout = {
title: 'Custom Range',
xaxis: {
range: [frst, end],
type: 'date'
},
yaxis: {
autorange: true,
range: [-10, 10],
type: 'linear'
}
};
var data = [
{
x: listx,
y: listy, //[1, 3, 6],
type: 'scatter'
}
];
console.log(data);
Plotly.plot('myDiv', data, layout);
I have tried also this
document.querySelector(’[data-title=“Autoscale”]’).click()
but doesn’t work …
Even unix time in range not working … where is the prob ?