Browse Source

added months tx/day evolution chart

master
arnaucode 7 years ago
parent
commit
ad29e362d5
17 changed files with 85 additions and 13 deletions
  1. +1
    -10
      README.md
  2. +4
    -1
      mongoModels.go
  3. BIN
      screenshots/goBlockchainDataAnalysis00.png
  4. BIN
      screenshots/goBlockchainDataAnalysis00_new.png
  5. BIN
      screenshots/goBlockchainDataAnalysis01.png
  6. BIN
      screenshots/goBlockchainDataAnalysis02.png
  7. BIN
      screenshots/goBlockchainDataAnalysis03.gif
  8. BIN
      screenshots/goBlockchainDataAnalysis04.png
  9. BIN
      screenshots/goBlockchainDataAnalysis05.png
  10. BIN
      screenshots/goBlockchainDataAnalysis06.gif
  11. BIN
      screenshots/new/goBlockchainDataAnalysis00.png
  12. BIN
      screenshots/new/goBlockchainDataAnalysis01png
  13. BIN
      screenshots/new/goBlockchainDataAnalysis02.png
  14. +50
    -0
      serverRoutes.go
  15. +2
    -2
      web/views/addressNetwork/addressNetwork.html
  16. +12
    -0
      web/views/dateAnalysis/dateAnalysis.html
  17. +16
    -0
      web/views/dateAnalysis/dateAnalysis.js

+ 1
- 10
README.md

@ -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")

+ 4
- 1
mongoModels.go

@ -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"`

BIN
screenshots/goBlockchainDataAnalysis00.png

Before After
Width: 1258  |  Height: 851  |  Size: 186 KiB Width: 1344  |  Height: 615  |  Size: 166 KiB

BIN
screenshots/goBlockchainDataAnalysis00_new.png

Before After
Width: 1362  |  Height: 647  |  Size: 180 KiB

BIN
screenshots/goBlockchainDataAnalysis01.png

Before After
Width: 858  |  Height: 861  |  Size: 298 KiB Width: 1345  |  Height: 643  |  Size: 262 KiB

BIN
screenshots/goBlockchainDataAnalysis02.png

Before After
Width: 847  |  Height: 869  |  Size: 298 KiB Width: 1344  |  Height: 646  |  Size: 192 KiB

BIN
screenshots/goBlockchainDataAnalysis03.gif

Before After
Width: 600  |  Height: 325  |  Size: 3.2 MiB

BIN
screenshots/goBlockchainDataAnalysis04.png

Before After
Width: 1264  |  Height: 910  |  Size: 146 KiB

BIN
screenshots/goBlockchainDataAnalysis05.png

Before After
Width: 1179  |  Height: 557  |  Size: 127 KiB

BIN
screenshots/goBlockchainDataAnalysis06.gif

Before After
Width: 600  |  Height: 338  |  Size: 2.5 MiB

BIN
screenshots/new/goBlockchainDataAnalysis00.png

Before After
Width: 1344  |  Height: 615  |  Size: 166 KiB

BIN
screenshots/new/goBlockchainDataAnalysis01png

Before After
Width: 1344  |  Height: 646  |  Size: 192 KiB

BIN
screenshots/new/goBlockchainDataAnalysis02.png

Before After
Width: 1345  |  Height: 643  |  Size: 262 KiB

+ 50
- 0
serverRoutes.go

@ -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)

+ 2
- 2
web/views/addressNetwork/addressNetwork.html

@ -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">

+ 12
- 0
web/views/dateAnalysis/dateAnalysis.html

@ -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>

+ 16
- 0
web/views/dateAnalysis/dateAnalysis.js

@ -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');
});
});

Loading…
Cancel
Save