ファイル

18 行
1.4 KiB
HTML

{{- $c := .chart -}}{{- $id := .id -}}
<figure class="site-figure">
<figcaption class="site-figure__caption">{{ .title }}</figcaption>
<div class="site-chart-scroll" role="region" tabindex="0" aria-label="{{ .title }}(グラフ)">
<svg class="site-chart" viewBox="0 0 {{ $c.width }} {{ $c.height }}" role="img" aria-labelledby="{{ $id }}-title">
<title id="{{ $id }}-title">{{ .title }}。{{ .desc }}</title>
{{ range $c.yTicks }}<line class="site-chart__grid" x1="{{ $c.left }}" x2="{{ $c.right }}" y1="{{ .pos }}" y2="{{ .pos }}"/>
<text class="site-chart__label" x="{{ sub $c.left 8 }}" y="{{ .pos }}" text-anchor="end" dominant-baseline="central">{{ .label }}</text>
{{ end }}<line class="site-chart__zero" x1="{{ $c.left }}" x2="{{ $c.right }}" y1="{{ $c.zero }}" y2="{{ $c.zero }}"/>
{{ range $c.bars }}<rect class="site-chart__bar" data-sign="{{ .sign }}" x="{{ .x }}" y="{{ .y }}" width="{{ .w }}" height="{{ .h }}"><title>{{ .title }}</title></rect>
{{ end }}{{ with $c.line }}<polyline class="site-chart__line" points="{{ . }}"/>{{ end }}
{{ range $c.dots }}<circle class="site-chart__dot" cx="{{ .x }}" cy="{{ .y }}" r="4"/>
{{ end }}{{ range $c.xTicks }}<text class="site-chart__label" x="{{ .pos }}" y="{{ add $c.bottom 22 }}" text-anchor="{{ if gt .pos (sub $c.right 30) }}end{{ else }}middle{{ end }}">{{ .label }}</text>
{{ end }}
</svg>
</div>
</figure>