59 lines
1.7 KiB
HTML
59 lines
1.7 KiB
HTML
{{ $key := .Title }}
|
|
{{ $pages := where .Site.RegularPages "Type" "in" (slice "posts") }}
|
|
{{ $count := len $pages }}
|
|
|
|
{{ $totalWidth := 100.0 }}
|
|
{{ $totalHeight := 50.0 }}
|
|
{{/* {{ $width := div $totalWidth ( len ( $pages.GroupByDate "2006" ) ) }} */}}
|
|
{{ $width := div $totalWidth ( len ( $pages.GroupByDate "2006" ) ) }}
|
|
|
|
{{ $color := "#357edd" }}
|
|
|
|
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}"
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
<rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/>
|
|
|
|
{{ $x := 0 }}
|
|
{{ range sort ( $pages.GroupByDate "2006" ) "Key" }}
|
|
|
|
{{ $maxDist := 0.00 }}
|
|
{{ $maxCount := 0 }}
|
|
{{ $dist := 0.00 }}
|
|
{{ $count := 0 }}
|
|
|
|
{{ range .Pages }}
|
|
{{ $maxCount = add 1 $maxCount }}
|
|
|
|
{{ $isMember := false }}
|
|
|
|
{{ range .Params.members }}
|
|
{{ if eq . $key }}
|
|
{{ $isMember = true }}
|
|
{{ $count = add 1 $count }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ with .Params.distance_km }}
|
|
{{ $maxDist = add . $maxDist }}
|
|
{{ if $isMember }}
|
|
{{ $dist = add . $dist }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ $height := 0 }}
|
|
{{ if gt $maxDist 0 }}
|
|
{{ $height = mul (float $totalHeight ) ( div (float $dist ) ( float $maxDist ) ) }}
|
|
{{ 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 }}%"
|
|
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$color}}"/>
|
|
|
|
{{ $x = add $x $width }}
|
|
{{ end }}
|
|
</svg> |