2018-12-26 12:29:13 +00:00
|
|
|
let addresses = []
|
|
|
|
let date = []
|
|
|
|
let ipv4_v6 = []
|
|
|
|
|
|
|
|
//Fetch call to get data from addresses json file
|
2018-12-26 09:21:29 +00:00
|
|
|
fetch('./address.json').then(response => {
|
|
|
|
return response.json();
|
|
|
|
}).then(data => {
|
|
|
|
data.sort(function(a,b){
|
2018-12-26 12:29:13 +00:00
|
|
|
return new Date(a.date) - new Date(b.date);
|
2018-12-26 09:21:29 +00:00
|
|
|
});
|
2018-12-26 12:29:13 +00:00
|
|
|
data.forEach(element => {
|
|
|
|
date.push(element.date)
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
console.log(date);
|
2018-12-26 09:21:29 +00:00
|
|
|
|
|
|
|
var ctx = document.getElementById("myChart").getContext('2d');
|
|
|
|
var myChart = new Chart(ctx, {
|
|
|
|
type: 'bar',
|
|
|
|
data: {
|
2018-12-26 12:29:13 +00:00
|
|
|
labels:date,
|
2018-12-26 09:21:29 +00:00
|
|
|
datasets: [{
|
2018-12-26 12:29:13 +00:00
|
|
|
label: 'Ipv4 and Ipv6 routin protocols used ',
|
|
|
|
data: [1 , -1 ,1 , -1 ,1 , -1 ,1 , -1 ,1 , -1 ,1 , -1 ,1 , -1 ,1 ,1],
|
2018-12-26 09:21:29 +00:00
|
|
|
borderWidth: 1
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
|
|
|
|
scales: {
|
2018-12-26 12:29:13 +00:00
|
|
|
|
2018-12-26 09:21:29 +00:00
|
|
|
yAxes: [{
|
|
|
|
ticks: {
|
|
|
|
beginAtZero:true
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
2018-12-26 12:29:13 +00:00
|
|
|
},
|
|
|
|
plugins: [{
|
|
|
|
beforeInit: function(chart) {
|
|
|
|
var time = chart.options.scales.xAxes[0].time, // 'time' object reference
|
|
|
|
// difference (in days) between min and max date
|
|
|
|
timeDiff = moment(time.max).diff(moment(time.min), 'd');
|
|
|
|
// populate 'labels' array
|
|
|
|
// (create a date string for each date between min and max, inclusive)
|
|
|
|
for (i = 0; i <= timeDiff; i++) {
|
|
|
|
var _label = moment(time.min).add(i, 'd').format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
chart.data.labels.push(_label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
2018-12-26 09:21:29 +00:00
|
|
|
});
|