added months tx/day evolution chart
11
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.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -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"`
|
||||
|
||||
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 298 KiB After Width: | Height: | Size: 262 KiB |
|
Before Width: | Height: | Size: 298 KiB After Width: | Height: | Size: 192 KiB |
BIN
screenshots/goBlockchainDataAnalysis03.gif
Normal file
|
After Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 262 KiB |
@@ -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)
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||