Added relative statistics to tracking page.

This commit is contained in:
Marvin Blum
2020-08-28 16:39:02 +02:00
committed by Marvin Blum
parent 1961c962c4
commit 743ec348db
3 changed files with 27 additions and 3 deletions

2
go.mod
View File

@@ -7,7 +7,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emvi/api-go v0.2.2
github.com/emvi/logbuch v1.1.1
github.com/emvi/pirsch v1.4.0
github.com/emvi/pirsch v1.4.1
github.com/go-sql-driver/mysql v1.5.0 // indirect
github.com/gorilla/mux v1.8.0
github.com/gosimple/slug v1.9.0

2
go.sum
View File

@@ -19,6 +19,8 @@ github.com/emvi/pirsch v1.3.3 h1:TSiyXye77511/Xrjqd6ro87uodBzSDcxkZ0GzVU/YFg=
github.com/emvi/pirsch v1.3.3/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
github.com/emvi/pirsch v1.4.0 h1:UuP/4jmkURySUH6DpR+igRsW5GKTb7axyPoMz0qz+8A=
github.com/emvi/pirsch v1.4.0/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
github.com/emvi/pirsch v1.4.1 h1:YQi54C9bVcCW0UeE6eebZrYlQPMbkbY4SIQr15MV240=
github.com/emvi/pirsch v1.4.1/go.mod h1:GDijqLHM331iWtmDmc7th19RxDrZadRkKoNvd9/kDX8=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=

View File

@@ -143,7 +143,8 @@
<thead>
<tr>
<th>Browser</th>
<th>Visitors</th>
<th>Absolute</th>
<th>Relative</th>
</tr>
</thead>
<tbody>
@@ -151,6 +152,7 @@
<tr>
<td>{{if $data.Browser.Valid}}{{$data.Browser.String}}{{else}}(unknown){{end}}</td>
<td>{{$data.Visitors}}</td>
<td>{{round (multiply $data.RelativeVisitors 100)}} %</td>
</tr>
{{end}}
</tbody>
@@ -162,7 +164,8 @@
<thead>
<tr>
<th>OS</th>
<th>Visitors</th>
<th>Absolute</th>
<th>Relative</th>
</tr>
</thead>
<tbody>
@@ -170,6 +173,7 @@
<tr>
<td>{{if $data.OS.Valid}}{{$data.OS.String}}{{else}}(unknown){{end}}</td>
<td>{{$data.Visitors}}</td>
<td>{{round (multiply $data.RelativeVisitors 100)}} %</td>
</tr>
{{end}}
</tbody>
@@ -177,6 +181,9 @@
</section>
<section>
<h2>Platform</h2>
<canvas id="platform" class="tracking"></canvas>
</section>
<section>
<table>
<thead>
<tr>
@@ -256,6 +263,21 @@
}
});
new Chart(document.getElementById('platform').getContext('2d'), {
type: "doughnut",
data: {
labels: ["Desktop", "Mobile", "(unknown)"],
datasets: [{
backgroundColor: ["#515151", "#7f7f7f", "#dbdbdb"],
borderColor: ["#515151", "#7f7f7f", "#dbdbdb"],
data: [
{{round (multiply .Platform.PlatformDesktopRelative 100)}},
{{round (multiply .Platform.PlatformMobileRelative 100)}},
{{round (multiply .Platform.PlatformUnknownRelative 100)}}]
}]
}
});
{{range $i, $data := .PageVisits}}
new Chart(document.getElementById('pageVisits{{$i}}').getContext('2d'), {
type: "line",