added months tx/day evolution chart

This commit is contained in:
arnaucode
2017-09-15 09:41:50 +02:00
parent 47b647f010
commit ad29e362d5
17 changed files with 85 additions and 13 deletions

View File

@@ -102,19 +102,10 @@ Webapp will run on 127.0.0.1:8080
### Some screenshots
Some screenshots can be old, and can contain errors.
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00_new.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis06.gif "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis05.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis01.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis02.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis04.png "goBlockchainDataAnalysis")
![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis03.gif "goBlockchainDataAnalysis")

View File

@@ -98,7 +98,10 @@ type SankeyModel struct {
Nodes []SankeyNodeModel `json:"nodes"`
Links []SankeyLinkModel `json:"links"`
}
type ChartCountFloat64Model struct {
Elem float64 `json:"elem"`
Count int `json:"count"`
}
type ChartCountModel struct {
Elem int `json:"elem"`
Count int `json:"count"`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

View File

@@ -124,6 +124,12 @@ var routes = Routes{
"/last7dayhour",
GetLast7DayHourAnalysis,
},
Route{
"GetLastMonthsAnalysis",
"Get",
"/lastmonths/{count}",
GetLastMonthsAnalysis,
},
Route{
"GetAddressTimeChart",
"GET",
@@ -672,6 +678,50 @@ func GetLast7DayHourAnalysis(w http.ResponseWriter, r *http.Request) {
check(err)
fmt.Fprintln(w, string(jsonResp))
}
func GetLastMonthsAnalysis(w http.ResponseWriter, r *http.Request) {
ipFilter(w, r)
vars := mux.Vars(r)
count, err := strconv.Atoi(vars["count"])
check(err)
fmt.Println(count)
fromDate := time.Now().AddDate(0, -count, 0)
toDate := time.Now()
txs := []TxModel{}
err = txCollection.Find(bson.M{
"datet": bson.M{
"$gt": fromDate,
"$lt": toDate,
},
}).Sort("-$natural").All(&txs)
check(err)
//generate map with 24 hours
//hourFrequencies := map24hours()
dayFrequencies := make(map[float64]int)
for _, tx := range txs {
dayFrequencies[float64(tx.Date.Month) + float64(tx.Date.Day)/100]++
}
var dayCount []ChartCountFloat64Model
for day, frequency := range dayFrequencies {
dayCount = append(dayCount, ChartCountFloat64Model{day, frequency})
}
//sort by hour
sort.Slice(dayCount, func(i, j int) bool {
return dayCount[i].Elem < dayCount[j].Elem
})
var resp ChartAnalysisResp
for _, d := range dayCount {
resp.Labels = append(resp.Labels, strconv.FormatFloat(d.Elem, 'f', -1, 64))
resp.Data = append(resp.Data, d.Count)
}
//convert []resp struct to json
jsonResp, err := json.Marshal(resp)
check(err)
fmt.Fprintln(w, string(jsonResp))
}
func GetAddressTimeChart(w http.ResponseWriter, r *http.Request) {
ipFilter(w, r)

View File

@@ -1,6 +1,6 @@
<div class="row">
<div class="col-sm-3">
<div class="panel-heading c_blueGrey300">
<div class="panel-heading c_deepPurpleG300to500">
<h3 class="panel-title">All addresses ({{addresses.length}})</h3>
</div>
<div class="panel-body" style="max-height: 500px;overflow-y: scroll;">
@@ -17,7 +17,7 @@
</div>
</div>
<div class="col-sm-9">
<div class="panel-heading c_blueGrey300">
<div class="panel-heading c_deepPurpleG300to500">
<h3 class="panel-title">Address history Network Map {{selectedAddress.id}}, BlockHeight: {{selectedAddress.group}}</h3>
</div>
<div class="panel-body">

View File

@@ -30,3 +30,15 @@
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12">
<div class="panel-heading c_deepPurpleG300to500">
<h3 class="panel-title">Last {{monthsCount}} Months Tx/Hour</h3>
</div>
<div class="panel-body">
<canvas id="line" class="chart chart-line" chart-data="lastmonths.data" chart-labels="lastmonths.labels" chart-series="lastmonths.series">
</canvas>
</div>
</div>
</div>

View File

@@ -57,4 +57,20 @@ angular.module('app.dateAnalysis', ['ngRoute', 'chart.js'])
}, function(data, status, headers, config) {
console.log('data error');
});
$scope.lastmonths={
data: [],
labels: []
};
$scope.monthsCount = 3;
$http.get(urlapi + 'lastmonths/' + $scope.monthsCount)
.then(function(data, status, headers, config) {
console.log('data success');
console.log(data);
$scope.lastmonths.data = data.data.data;
$scope.lastmonths.labels=data.data.labels;
}, function(data, status, headers, config) {
console.log('data error');
});
});