From 4f04823a817ad18e9af08a7b5731a5b2e22f9f3d Mon Sep 17 00:00:00 2001 From: Redaloukil Date: Wed, 26 Dec 2018 10:21:29 +0100 Subject: [PATCH] change json file name , get json data and sort ip addresses by date --- address.json | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ adresses.json | 20 --------------- app.js | 37 ++++++++++++++++++++++++++++ index.htm | 17 ++++++++++--- 4 files changed, 119 insertions(+), 23 deletions(-) create mode 100644 address.json delete mode 100644 adresses.json diff --git a/address.json b/address.json new file mode 100644 index 0000000..352927d --- /dev/null +++ b/address.json @@ -0,0 +1,68 @@ +[ + { + "ip": "94.198.99.82" , + "date": "2018-12-25" + }, + { + "ip":"123.125.67.160" , + "date":"2018-12-26" + }, + { + "ip":"123.125.67.165", + "date":"2018-12-27" + }, + { + "ip":"123.125.67.121", + "date":"2018-12-28" + }, + { + "ip": "94.198.99.82" , + "date": "2018-12-29" + }, + { + "ip":"123.125.67.160" , + "date":"2018-12-30" + }, + { + "ip":"123.125.67.165", + "date":"2018-12-31" + }, + { + "ip":"123.125.67.121", + "date":"2018-01-01" + }, + { + "ip": "94.198.99.82" , + "date": "2018-01-01" + }, + { + "ip":"123.125.67.160" , + "date":"2018-01-02" + }, + { + "ip":"123.125.67.165", + "date":"2018-01-03" + }, + { + "ip":"123.125.67.121", + "date":"2018-01-04" + },{ + "ip": "94.198.99.82" , + "date": "2018-12-16" + }, + { + "ip":"123.125.67.160" , + "date":"2018-12-18" + }, + { + "ip":"123.125.67.165", + "date":"2018-12-01" + }, + { + "ip":"123.125.67.121", + "date":"2018-12-02" + } +] + + + \ No newline at end of file diff --git a/adresses.json b/adresses.json deleted file mode 100644 index 5412706..0000000 --- a/adresses.json +++ /dev/null @@ -1,20 +0,0 @@ -[ { - "ip": "94.198.99.82" , - "date": "2018-12-25" - }, - { - "ip":"123.125.67.160" , - "date":"2018-12-26" - }, - { - "ip":"123.125.67.165", - "date":"2018-12-27" - }, - { - "ip":"123.125.67.121", - "date":"2018-12-28" - } -] - - - \ No newline at end of file diff --git a/app.js b/app.js index e69de29..7f26240 100644 --- a/app.js +++ b/app.js @@ -0,0 +1,37 @@ +let labels = [] +let data = [] +fetch('./address.json').then(response => { + return response.json(); + }).then(data => { + data.sort(function(a,b){ + console.log(a.date) + console.log(b.date) + return new Date(a.date) - new Date(b.date) ; + }); + console.log(data); + }).catch(err => { + + }); + +var ctx = document.getElementById("myChart").getContext('2d'); +var myChart = new Chart(ctx, { + type: 'bar', + data: { + labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], + datasets: [{ + label: '# of Votes', + data: [1, -1, 1, -1, 1, -1], + borderWidth: 1 + }] + }, + options: { + + scales: { + yAxes: [{ + ticks: { + beginAtZero:true + } + }] + } + } +}); diff --git a/index.htm b/index.htm index 129e0fc..cba306c 100644 --- a/index.htm +++ b/index.htm @@ -5,13 +5,24 @@ + Test -
+
+ + + + + + + + +
- + \ No newline at end of file