fresh design for years

This commit is contained in:
2020-11-28 19:16:23 +01:00
parent 846e7132a4
commit 65791c68cb
4 changed files with 53 additions and 39 deletions
+25 -10
View File
@@ -6,14 +6,16 @@
{{ $totalWidth := 100.0 }}
{{ $totalHeight := 50.0 }}
{{ $width := div $totalWidth 12 }}
{{ $month_map := .page.Site.Data.month }}
{{ $color := "#a8c7f0" }}
{{ $strokecolor := "#d3e3f8" }}
<script>
function onyearover(year, key, count){
function onyearover(key, month, text){
// alert( year + key + "!")
document.getElementById( key ).innerHTML = year + ": " + count;
document.getElementById( key ).innerHTML = month + ": " + text;
}
function onyearout(key){
@@ -24,7 +26,6 @@ document.getElementById( key ).innerHTML = "<div style='color: transparent'>:</d
<svg width="{{ $totalWidth }}%" height="{{ $totalHeight }}"
xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" opacity="0.1" fill="{{ $color }}"/>
{{ $month := 0 }}
{{ $actMonth := 0 }}
{{ $maxCount := 0 }}
@@ -48,23 +49,37 @@ xmlns="http://www.w3.org/2000/svg">
{{ $x := 0 }}
{{ $month := 0 }}
{{ range $i, $sequence := (seq 12) }}
{{ $i }}: {{ $sequence }}
{{ $x = mul ( sub ( float $sequence ) 1 ) $width }}
{{ $m:= printf "%02d" $sequence }}
{{ $d:= (print "2006-" $m "-01")}}
<rect height="100%" y="0" x="{{ $x }}%" opacity="0.8"
width="{{ $width }}%" fill="transparent" stroke-width="2" stroke="{{ $color }}"/>
<text y="{{ mul $totalHeight 0.7 }}" x="{{ sub (mul $width $sequence) (div $width 2) }}%" text-anchor="middle" fill="{{ $color }}" font-size="25" font-weight="bold" opacity="0.8">{{ substr (dateFormat "Jan" $d) 0 1 }} </text>
{{ end }}
{{ $adate := "" }}
{{ range sort ( $pages.GroupByDate "2006-01" ) "Key" }}
{{ range first 1 .Pages }}
{{ $month = .Params.Date.Format "01" }}
{{ $month = .Params.Date.Format "1" }}
{{ end }}
{{ $height := 0 }}
{{ $height = mul (float $totalHeight ) ( div (float ( len .Pages ) ) ( float $maxCount ) ) }}
{{ $x = mul ( sub ( float $month ) 1 ) $width }}
<rect onmouseover="onyearover({{ $month }}, {{ $param_title }}, {{ len .Pages }} )" onmouseout="onyearout({{ $param_title }})" height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$strokecolor}}"
class="dim"/>
<rect height="{{ $height }}" y="{{ sub $totalHeight $height }}" x="{{ $x }}%"
opacity="0.6"
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$strokecolor}}"/>
<rect onmouseover="onyearover( {{ $param_title }}, {{index $month_map ($month)}}, {{ i18n "tours" ( len .Pages ) }} )"
onmouseout="onyearout({{ $param_title }})"
height="100%" y="0" x="{{ $x }}%"
width="{{ $width }}%" fill="{{ $color }}" stroke-width="1.5" stroke="{{$strokecolor}}"
class="o-10"/>
{{$x }}
{{ end }}
</svg>