added members mouseover info

This commit is contained in:
2020-10-29 17:56:20 +01:00
parent b3e3ffbf8c
commit 10941c4f5e
4 changed files with 29 additions and 13 deletions
+22 -11
View File
@@ -1,6 +1,7 @@
{{ $key := .Title }}
{{ $pages := where .Site.RegularPages "Type" "in" (slice "posts") }}
{{ $key := .page.Title }}
{{ $pages := where .page.Site.RegularPages "Type" "in" (slice "posts") }}
{{ $count := len $pages }}
{{ $param_title := .param_title }}
{{ $totalWidth := 100.0 }}
{{ $totalHeight := 50.0 }}
@@ -9,13 +10,22 @@
{{ $color := "#357edd" }}
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}"
xmlns="http://www.w3.org/2000/svg">
<script>
function onyearover(year, key, count){
document.getElementById( key ).innerHTML = year + ": " + count + " km";
}
function onyearout(key){
document.getElementById( key ).innerHTML = "<br>";
}
</script>
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}" xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/>
{{ $x := 0 }}
{{ $year := 0 }}
{{ range sort ( $pages.GroupByDate "2006" ) "Key" }}
{{ $maxDist := 0.00 }}
{{ $maxCount := 0 }}
{{ $dist := 0.00 }}
@@ -23,6 +33,7 @@ xmlns="http://www.w3.org/2000/svg">
{{ range .Pages }}
{{ $maxCount = add 1 $maxCount }}
{{ $year = dateFormat "2006" .Date }}
{{ $isMember := false }}
@@ -47,13 +58,13 @@ xmlns="http://www.w3.org/2000/svg">
{{ else }}
{{ $height = mul (float $totalHeight ) ( div (float $count ) ( float $maxCount ) ) }}
{{ end }}
{{/* {{ $maxDist }} */}}
{{/* {{ $dist }} */}}
{{/* {{ $x }} */}}
{{/* {{ $height }} */}}
<rect opacity="0.2" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
{{/* $maxDist */}}
{{/* $dist */}}
{{/* $x */}}
{{/* $height */}}
<rect onmouseover="onyearover({{ $year }}, {{ $param_title }}, {{ math.Round $dist }} )" onmouseout="onyearout({{ $param_title }})" opacity="0.2" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$color}}"/>
{{ $x = add $x $width }}
{{ end }}
</svg>
</svg>
+2
View File
@@ -22,6 +22,8 @@ document.getElementById( key ).innerHTML = "<br>";
}
</script>
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}"
xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/>