diff --git a/app.js b/app.js index 7735729..28b099d 100644 --- a/app.js +++ b/app.js @@ -6,39 +6,41 @@ var date = [] var ipv4_v6 = [] function Ip4OrIp6(ipAddress){ - console.log(ipAddress) - console.log(regex.test(ipAddress)); + if(ipAddress.length == 39){ + ipv4_v6.push(1); + }else{ + ipv4_v6.push(-1); + } } + // Refactor getStudents and getScores to return Promise for their response bodies function getData(){ return fetch(`address.json`, { headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json' + 'Accept': 'application/json', } }).then((response) => response.json()) }; getData().then((data)=>{ data.forEach(element => { - date.push(element.date) + date.push(element.date); + Ip4OrIp6(element.ip); }); - - console.log(date); - data.forEach(element => { - Ip4OrIp6(element.ip) - }) - console.log(ipv4_v6) + console.log(date); + console.log(ipv4_v6); + var ctx = document.getElementById("myChart").getContext('2d'); var chart = new Chart(ctx, { - type: 'line', + type: 'bar', data: { labels:date , datasets: [{ label: "Statistics for IPV4 and IPV6", - data: [1 , -1 , 1 , 1 , -1 , 1,1 , -1 , 1 , 1 , -1 ], + data:ipv4_v6, } ] },