add new ip array
This commit is contained in:
parent
692291bb04
commit
eaf8822510
2 changed files with 37 additions and 28 deletions
60
app.js
60
app.js
|
@ -3,7 +3,7 @@ const regex = RegExp(/^((([0–9A-Fa-f]{1,4}:){7}[0–9A-Fa-f]{1,4})|(([0–9A-F
|
|||
|
||||
var addresses = []
|
||||
var date = []
|
||||
var ipv4_v6 = []
|
||||
var ipv4_v6 = [[], [] , []]
|
||||
|
||||
//colors object for different graphs
|
||||
var chartColors = {
|
||||
|
@ -19,12 +19,15 @@ var chartColors = {
|
|||
//test function for ip addresses
|
||||
function Ip4OrIp6(ipAddress){
|
||||
if(ipAddress.length == 39){
|
||||
ipv4_v6.push(1);
|
||||
return 1;
|
||||
}else{
|
||||
ipv4_v6.push(-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
var randomScalingFactor = function() {
|
||||
return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100);
|
||||
}
|
||||
|
||||
// Refactor getStudents and getScores to return Promise for their response bodies
|
||||
function getData(){
|
||||
|
@ -37,10 +40,24 @@ function getData(){
|
|||
};
|
||||
|
||||
getData().then((data)=>{
|
||||
data.forEach(element => {
|
||||
date.push(element.date);
|
||||
//pushing the dates
|
||||
data[0].forEach(element => {
|
||||
date.push(element.date)
|
||||
|
||||
// Ip4OrIp6(element.ip);
|
||||
// });
|
||||
});
|
||||
data.forEach((element ,i) =>{
|
||||
element.map((e) =>{
|
||||
ipv4_v6[i].push(Ip4OrIp6(e.ip));
|
||||
})
|
||||
})
|
||||
|
||||
// data[1].forEach(element =>{
|
||||
// ipv4_v6[1].push(Ip4OrIp6(element.ip))
|
||||
// })
|
||||
// data[2].forEach(element =>{
|
||||
// ipv4_v6[2].push(Ip4OrIp6(element.ip))
|
||||
// })
|
||||
|
||||
// console.log(date);
|
||||
// console.log(ipv4_v6);
|
||||
|
@ -59,32 +76,23 @@ getData().then((data)=>{
|
|||
datasets: [
|
||||
{
|
||||
label: "My First dataset",
|
||||
backgroundColor: chartColors.red,
|
||||
// backgroundColor: chartColors.red,
|
||||
borderColor: chartColors.red,
|
||||
data: [
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor()
|
||||
],
|
||||
data:ipv4_v6[0],
|
||||
fill: false,
|
||||
}, {
|
||||
label: "My Second dataset",
|
||||
fill: false,
|
||||
backgroundColor: chartColors.blue,
|
||||
// backgroundColor: chartColors.blue,
|
||||
borderColor: chartColors.blue,
|
||||
data: [
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor(),
|
||||
randomScalingFactor()
|
||||
],
|
||||
data:ipv4_v6[1],
|
||||
},
|
||||
{
|
||||
label: "My Second dataset",
|
||||
fill: false,
|
||||
// backgroundColor: chartColors.orange,
|
||||
borderColor: chartColors.orange,
|
||||
data: ipv4_v6[2],
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#myChart {
|
||||
height: 85vh!important;
|
||||
margin:10% 0;
|
||||
height: 60vh!important;
|
||||
}
|
Loading…
Reference in a new issue