2 changed files with 196 additions and 11 deletions
@ -0,0 +1,137 @@ |
|||||||
|
{{ $pages := where .context.Site.RegularPages "Type" "in" (slice "posts") }} |
||||||
|
{{ $count := len $pages }} |
||||||
|
{{ $param_name := .param_name }} |
||||||
|
|
||||||
|
{{ $totalWidth := 200.0 }} |
||||||
|
{{ $totalHeight := 150.0 }} |
||||||
|
{{ $width := div $totalWidth ( len ( $pages.GroupByDate "2006" ) ) }} |
||||||
|
|
||||||
|
{{ $maxCount := 0 }} |
||||||
|
{{ $totalCount := 0 }} |
||||||
|
{{ $actualCount := 0 }} |
||||||
|
|
||||||
|
{{ $maxDistance_km := 0 }} |
||||||
|
{{ $totalDistance_km := 0 }} |
||||||
|
{{ $actualDistance_km := 0 }} |
||||||
|
|
||||||
|
{{ $maxAscent_m := 0 }} |
||||||
|
{{ $totalAscent_m := 0 }} |
||||||
|
{{ $actualAscent_m := 0 }} |
||||||
|
|
||||||
|
{{ $maxMembers := 0 }} |
||||||
|
{{ $totalMembers := 0 }} |
||||||
|
{{ $actualMembers := 0 }} |
||||||
|
|
||||||
|
{{ range sort ( $pages.GroupByDate "2006" ) "Key" }} |
||||||
|
{{ $count := 0 }} |
||||||
|
{{ $distance_km := 0 }} |
||||||
|
{{ $ascent_m := 0 }} |
||||||
|
{{ $members := 0 }} |
||||||
|
|
||||||
|
{{ range .Pages }} |
||||||
|
{{ $count = add 1 $count }} |
||||||
|
|
||||||
|
{{ with .Params.distance_km }} |
||||||
|
{{ $distance_km = add . $distance_km }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ with .Params.ascent_m }} |
||||||
|
{{ $ascent_m = add . $ascent_m }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ with .Params.members }} |
||||||
|
{{ $members = add ( len . ) $members }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if gt $distance_km $maxDistance_km }} |
||||||
|
{{ $maxDistance_km = $distance_km }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if gt $ascent_m $maxAscent_m }} |
||||||
|
{{ $maxAscent_m = $ascent_m }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if gt $count $maxCount }} |
||||||
|
{{ $maxCount = $count }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if gt $members $maxMembers }} |
||||||
|
{{ $maxMembers = $members }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ $totalCount = add $count $totalCount }} |
||||||
|
{{ $totalMembers = add $members $totalMembers }} |
||||||
|
{{ $totalDistance_km = add $distance_km $totalDistance_km }} |
||||||
|
{{ $totalAscent_m = add $ascent_m $totalAscent_m }} |
||||||
|
|
||||||
|
{{ $actualCount = $count }} |
||||||
|
{{ $actualMembers = $members }} |
||||||
|
{{ $actualDistance_km = $distance_km }} |
||||||
|
{{ $actualAscent_m = $ascent_m }} |
||||||
|
|
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ $value := "" }} |
||||||
|
{{ $actualHeight := 0 }} |
||||||
|
|
||||||
|
{{ if eq $param_name "distance_km"}} |
||||||
|
{{ $value = partial "func/NumberFormatter.html" ( dict "number" $totalDistance_km "precision" 0 ) }} |
||||||
|
{{ $actualHeight = mul $actualDistance_km ( div $totalHeight $maxDistance_km ) }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if eq $param_name "ascent_m"}} |
||||||
|
{{ $value = partial "func/NumberFormatter.html" ( dict "number" $totalAscent_m "precision" 0 ) }} |
||||||
|
{{ $actualHeight = mul $actualAscent_m ( div $totalHeight $maxAscent_m ) }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if eq $param_name "count"}} |
||||||
|
{{ $value = $totalCount }} |
||||||
|
{{ $actualHeight = mul $actualCount ( div $totalHeight $maxCount ) }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ if eq $param_name "members"}} |
||||||
|
{{ $value = $totalMembers }} |
||||||
|
{{ $actualHeight = mul $actualMembers ( div $totalHeight $maxMembers ) }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ $color := "#a8c7f0" }} |
||||||
|
{{ $fontcolor := "#123a6d" }} |
||||||
|
{{ $fontstroke := "#e9f1fb" }} |
||||||
|
{{ $actualColor := "#123a6d" }} |
||||||
|
|
||||||
|
<svg width="{{ $totalWidth }}px" height="{{ $totalHeight }}px" 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" }} |
||||||
|
|
||||||
|
{{ $count := 0 }} |
||||||
|
{{ $distance_km := 0 }} |
||||||
|
|
||||||
|
{{ range .Pages }} |
||||||
|
|
||||||
|
{{ with .Params.distance_km }} |
||||||
|
{{ $distance_km = add . $distance_km }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ $count = add 1 $count }} |
||||||
|
|
||||||
|
{{ end }} |
||||||
|
|
||||||
|
{{ $height := 0 }} |
||||||
|
{{ $height = mul (float $totalHeight ) ( div (float $count ) ( float $maxCount ) ) }} |
||||||
|
|
||||||
|
<rect opacity="0.2" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}px" |
||||||
|
width="{{ $width }}px" fill="{{ $color }}" stroke-width="0" /> |
||||||
|
|
||||||
|
{{ $x = add $x $width }} |
||||||
|
{{ end }} |
||||||
|
|
||||||
|
<rect opacity="0.8" height="5px" y="{{ sub $totalHeight $actualHeight }}" x="0px" |
||||||
|
width="{{ $totalWidth }}px" fill="{{ $actualColor }}" stroke-width="0" /> |
||||||
|
|
||||||
|
<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-size="50px" |
||||||
|
font-weight="bold" fill="{{ $fontcolor }}" stroke-width="1px" stroke="{{$fontstroke}}">{{ $value }}</text> |
||||||
|
</svg> |
||||||
Loading…
Reference in new issue